Skip to content

Commit

Permalink
Bug 923512 - Transition the TransformTo<>() functions from gfx3DMatri…
Browse files Browse the repository at this point in the history
…x to Matrix4x4. r=kats
theres-waldo committed Aug 6, 2014
1 parent 96cc219 commit d02122b
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gfx/layers/apz/src/AsyncPanZoomController.cpp
Original file line number Diff line number Diff line change
@@ -2906,7 +2906,7 @@ void AsyncPanZoomController::ShareCompositorFrameMetrics() {

ParentLayerPoint AsyncPanZoomController::ToParentLayerCoords(const ScreenPoint& aPoint)
{
return TransformTo<ParentLayerPixel>(To3DMatrix(GetNontransientAsyncTransform() * GetCSSTransform()), aPoint);
return TransformTo<ParentLayerPixel>(GetNontransientAsyncTransform() * GetCSSTransform(), aPoint);
}

void AsyncPanZoomController::UpdateTransformScale()
2 changes: 1 addition & 1 deletion gfx/layers/client/ClientTiledThebesLayer.cpp
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ ClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
static LayerRect
ApplyParentLayerToLayerTransform(const gfx::Matrix4x4& aTransform, const ParentLayerRect& aParentLayerRect)
{
return TransformTo<LayerPixel>(gfx::To3DMatrix(aTransform), aParentLayerRect);
return TransformTo<LayerPixel>(aTransform, aParentLayerRect);
}

static gfx::Matrix4x4
3 changes: 2 additions & 1 deletion gfx/layers/client/TiledContentClient.cpp
Original file line number Diff line number Diff line change
@@ -1236,7 +1236,8 @@ GetCompositorSideCompositionBounds(ContainerLayer* aScrollAncestor,

// Finally, put back the scroll ancestor's local transform.
transform = transform * layerTransform;
return TransformTo<LayerPixel>(To3DMatrix(transform).Inverse(),
transform.Invert();
return TransformTo<LayerPixel>(transform,
aScrollAncestor->GetFrameMetrics().mCompositionBounds);
}

33 changes: 16 additions & 17 deletions layout/base/UnitTransforms.h
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
#define MOZ_UNIT_TRANSFORMS_H_

#include "Units.h"
#include "mozilla/gfx/Matrix.h"

namespace mozilla {

@@ -42,7 +43,11 @@ gfx::PointTyped<TargetUnits> ViewAs(const gfxPoint& aPoint) {
return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits>
gfx::RectTyped<TargetUnits> ViewAs(const gfxRect& aRect) {
gfx::PointTyped<TargetUnits> ViewAs(const gfx::Point& aPoint) {
return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits>
gfx::RectTyped<TargetUnits> ViewAs(const gfx::Rect& aRect) {
return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class TargetUnits>
@@ -58,31 +63,25 @@ gfx::IntRectTyped<TargetUnits> ViewAs(const nsIntRect& aRect) {
return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}

// Convenience functions for casting typed entities to untyped entities.
// Using these functions does not require a justification, but once we convert
// all code to use strongly typed units they should not be needed any longer.
template <class SourceUnits>
gfxPoint ViewAsUntyped(const gfx::PointTyped<SourceUnits>& aPoint) {
return gfxPoint(aPoint.x, aPoint.y);
}
template <class SourceUnits>
gfxRect ViewAsUntyped(const gfx::RectTyped<SourceUnits>& aRect) {
return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
}

// Convenience functions for transforming an entity from one strongly-typed
// coordinate system to another using the provided transformation matrix.
template <typename TargetUnits, typename SourceUnits>
static gfx::PointTyped<TargetUnits> TransformTo(const gfx3DMatrix& aTransform,
static gfx::PointTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
const gfx::PointTyped<SourceUnits>& aPoint)
{
return ViewAs<TargetUnits>(aTransform.Transform(ViewAsUntyped(aPoint)));
return ViewAs<TargetUnits>(aTransform * aPoint.ToUnknownPoint());
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntPointTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
const gfx::IntPointTyped<SourceUnits>& aPoint)
{
return RoundedToInt(TransformTo<TargetUnits>(aTransform, gfx::PointTyped<SourceUnits>(aPoint)));
}
template <typename TargetUnits, typename SourceUnits>
static gfx::RectTyped<TargetUnits> TransformTo(const gfx3DMatrix& aTransform,
static gfx::RectTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
const gfx::RectTyped<SourceUnits>& aRect)
{
return ViewAs<TargetUnits>(aTransform.TransformBounds(ViewAsUntyped(aRect)));
return ViewAs<TargetUnits>(aTransform.TransformBounds(aRect.ToUnknownRect()));
}


0 comments on commit d02122b

Please sign in to comment.