Bug 923512 - Transition the TransformTo<>() functions from gfx3DMatrix to Matrix4x4. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 06 Aug 2014 12:52:04 -0400
changeset 200459 4df5daa7ca34757a3107acc8a6d8239842ab535f
parent 200458 26519c9f0c1eca942a2c6d50dc4fb0b954045ba6
child 200460 6a9f66a511d2ecb8edb56c8759ef1c04a97a2287
push id27345
push useremorley@mozilla.com
push dateWed, 20 Aug 2014 13:28:47 +0000
treeherdermozilla-central@1ddfd9afba40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs923512
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 923512 - Transition the TransformTo<>() functions from gfx3DMatrix to Matrix4x4. r=kats
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/client/ClientTiledThebesLayer.cpp
gfx/layers/client/TiledContentClient.cpp
layout/base/UnitTransforms.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -2901,17 +2901,17 @@ void AsyncPanZoomController::ShareCompos
         APZC_LOG("%p failed to share FrameMetrics with content process.", this);
       }
     }
   }
 }
 
 ParentLayerPoint AsyncPanZoomController::ToParentLayerCoords(const ScreenPoint& aPoint)
 {
-  return TransformTo<ParentLayerPixel>(To3DMatrix(GetNontransientAsyncTransform() * GetCSSTransform()), aPoint);
+  return TransformTo<ParentLayerPixel>(GetNontransientAsyncTransform() * GetCSSTransform(), aPoint);
 }
 
 void AsyncPanZoomController::UpdateTransformScale()
 {
   Matrix4x4 nontransientTransforms = GetNontransientAsyncTransform() * GetCSSTransform();
   if (!FuzzyEqualsMultiplicative(nontransientTransforms._11, nontransientTransforms._22)) {
     NS_WARNING("The x- and y-scales of the nontransient transforms should be equal");
   }
--- a/gfx/layers/client/ClientTiledThebesLayer.cpp
+++ b/gfx/layers/client/ClientTiledThebesLayer.cpp
@@ -54,17 +54,17 @@ void
 ClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
 {
   aAttrs = ThebesLayerAttributes(GetValidRegion());
 }
 
 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
 GetTransformToAncestorsParentLayer(Layer* aStart, Layer* aAncestor)
 {
   gfx::Matrix4x4 transform;
   Layer* ancestorParent = aAncestor->GetParent();
   for (Layer* iter = aStart; iter != ancestorParent; iter = iter->GetParent()) {
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -1348,17 +1348,18 @@ GetCompositorSideCompositionBounds(Layer
   Matrix4x4 transform = aTransformToCompBounds * layerUntransform * nonTransientAPZUntransform;
 
   // Next, apply the APZ's async transform (this includes the nontransient component
   // as well).
   transform = transform * Matrix4x4(aAPZTransform);
 
   // 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);
 }
 
 bool
 ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInvalidRegion,
                                                        const nsIntRegion& aOldValidRegion,
                                                        nsIntRegion& aRegionToPaint,
                                                        BasicTiledLayerPaintData* aPaintData,
--- a/layout/base/UnitTransforms.h
+++ b/layout/base/UnitTransforms.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZ_UNIT_TRANSFORMS_H_
 #define MOZ_UNIT_TRANSFORMS_H_
 
 #include "Units.h"
+#include "mozilla/gfx/Matrix.h"
 
 namespace mozilla {
 
 // Convenience functions for converting an entity from one strongly-typed
 // coordinate system to another without changing the values it stores (this
 // can be thought of as a cast).
 // To use these functions, you must provide a justification for each use!
 // Feel free to add more justifications to PixelCastJustification, along with
@@ -37,55 +38,53 @@ gfx::IntSizeTyped<TargetUnits> ViewAs(co
 // Convenience functions for casting untyped entities to typed 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 TargetUnits>
 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>
 gfx::IntSizeTyped<TargetUnits> ViewAs(const nsIntSize& aSize) {
   return gfx::IntSizeTyped<TargetUnits>(aSize.width, aSize.height);
 }
 template <class TargetUnits>
 gfx::IntPointTyped<TargetUnits> ViewAs(const nsIntPoint& aPoint) {
   return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y);
 }
 template <class TargetUnits>
 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::RectTyped<TargetUnits> TransformTo(const gfx3DMatrix& aTransform,
+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 gfx::Matrix4x4& aTransform,
                                                const gfx::RectTyped<SourceUnits>& aRect)
 {
-  return ViewAs<TargetUnits>(aTransform.TransformBounds(ViewAsUntyped(aRect)));
+  return ViewAs<TargetUnits>(aTransform.TransformBounds(aRect.ToUnknownRect()));
 }
 
 
 }
 
 #endif