diff --git a/gfx/2d/Matrix.h b/gfx/2d/Matrix.h index 2ddbf0e75d57..67665c05f5e0 100644 --- a/gfx/2d/Matrix.h +++ b/gfx/2d/Matrix.h @@ -556,6 +556,25 @@ public: bool Invert(); + void ScalePost(Float aX, Float aY, Float aZ) + { + _11 *= aX; + _21 *= aX; + _31 *= aX; + _41 *= aX; + + _12 *= aY; + _22 *= aY; + _32 *= aY; + _42 *= aY; + + _13 *= aZ; + _23 *= aZ; + _33 *= aZ; + _43 *= aZ; + } + + // Set all the members of the matrix to NaN void SetNAN(); }; diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 6e931668d3d8..8ed4b577d157 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1199,7 +1199,7 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc, // and RC.Inverse() * QC.Inverse() * PC.Inverse() * PA.Inverse() at P. gfx3DMatrix childUntransform = ancestorUntransform * aApzc->GetCSSTransform().Inverse() - * gfx3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse(); + * gfx::To3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse(); gfxPointH3D hitTestPointForChildLayers = childUntransform.ProjectPoint(aHitTestPoint); APZCTM_LOG("Untransformed %f %f to layer coordinates %f %f for APZC %p\n", aHitTestPoint.x, aHitTestPoint.y, @@ -1347,7 +1347,7 @@ APZCTreeManager::GetInputTransforms(AsyncPanZoomController *aApzc, gfx3DMatrix& // ancestorUntransform is OC.Inverse() * NC.Inverse() * MC.Inverse() gfx3DMatrix ancestorUntransform = aApzc->GetAncestorTransform().Inverse(); // asyncUntransform is LA.Inverse() - gfx3DMatrix asyncUntransform = gfx3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse(); + gfx3DMatrix asyncUntransform = gfx::To3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse(); // nontransientAsyncTransform is LN gfx3DMatrix nontransientAsyncTransform = aApzc->GetNontransientAsyncTransform(); // transientAsyncUntransform is LT.Inverse() @@ -1362,7 +1362,7 @@ APZCTreeManager::GetInputTransforms(AsyncPanZoomController *aApzc, gfx3DMatrix& // ancestorUntransform is updated to RC.Inverse() * QC.Inverse() when parent == P ancestorUntransform = parent->GetAncestorTransform().Inverse(); // asyncUntransform is updated to PA.Inverse() when parent == P - asyncUntransform = gfx3DMatrix(parent->GetCurrentAsyncTransform()).Inverse(); + asyncUntransform = gfx::To3DMatrix(parent->GetCurrentAsyncTransform()).Inverse(); // untransformSinceLastApzc is RC.Inverse() * QC.Inverse() * PC.Inverse() * PA.Inverse() gfx3DMatrix untransformSinceLastApzc = ancestorUntransform * parent->GetCSSTransform().Inverse() * asyncUntransform; diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 4e8f7e445a31..b3f80c3734ae 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -1145,7 +1145,7 @@ GetCompositorSideCompositionBounds(ContainerLayer* aScrollAncestor, // Next, apply the APZ's async transform (this includes the nontransient component // as well). - transform = transform * gfx3DMatrix(aAPZTransform); + transform = transform * To3DMatrix(aAPZTransform); // Finally, put back the scroll ancestor's local transform. transform = transform * layerTransform; diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index c6f4885047c6..576eb7432dbd 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -509,9 +509,9 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint) } Matrix4x4 -AdjustAndCombineWithCSSTransform(const gfx3DMatrix& asyncTransform, Layer* aLayer) +AdjustAndCombineWithCSSTransform(const Matrix4x4& asyncTransform, Layer* aLayer) { - Matrix4x4 result = ToMatrix4x4(asyncTransform); + Matrix4x4 result = asyncTransform; // Container layers start at the origin, but they are clipped to where they // actually have content on the screen. The tree transform is meant to apply @@ -675,7 +675,7 @@ ApplyAsyncTransformToScrollbarForContent(TimeStamp aCurrentFrame, ContainerLayer apzc->SampleContentTransformForFrame(aCurrentFrame, &asyncTransform, scrollOffset); } - gfx3DMatrix asyncTransform = gfx3DMatrix(apzc->GetCurrentAsyncTransform()); + gfx3DMatrix asyncTransform = To3DMatrix(apzc->GetCurrentAsyncTransform()); gfx3DMatrix nontransientTransform = apzc->GetNontransientAsyncTransform(); gfx3DMatrix transientTransform = asyncTransform * nontransientTransform.Inverse(); @@ -780,11 +780,8 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) const FrameMetrics& metrics = container->GetFrameMetrics(); // We must apply the resolution scale before a pan/zoom transform, so we call // GetTransform here. - gfx3DMatrix currentTransform = To3DMatrix(aLayer->GetTransform()); Matrix4x4 oldTransform = aLayer->GetTransform(); - gfx3DMatrix treeTransform; - CSSToLayerScale geckoZoom = metrics.LayersPixelsPerCSSPixel(); LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.GetScrollOffset() * geckoZoom); @@ -842,22 +839,22 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) } LayerPoint translation = (userScroll / zoomAdjust) - geckoScroll; - treeTransform = gfx3DMatrix(ViewTransform(-translation, + Matrix4x4 treeTransform = ViewTransform(-translation, userZoom / metrics.mDevPixelsPerCSSPixel - / metrics.GetParentResolution())); + / metrics.GetParentResolution()); // The transform already takes the resolution scale into account. Since we // will apply the resolution scale again when computing the effective // transform, we must apply the inverse resolution scale here. - gfx3DMatrix computedTransform = treeTransform * currentTransform; + Matrix4x4 computedTransform = treeTransform * oldTransform; computedTransform.Scale(1.0f/container->GetPreXScale(), 1.0f/container->GetPreYScale(), 1); computedTransform.ScalePost(1.0f/container->GetPostXScale(), 1.0f/container->GetPostYScale(), 1); - layerComposite->SetShadowTransform(ToMatrix4x4(computedTransform)); + layerComposite->SetShadowTransform(computedTransform); NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(), "overwriting animated transform!"); diff --git a/gfx/layers/composite/AsyncCompositionManager.h b/gfx/layers/composite/AsyncCompositionManager.h index e1c90cfffb0d..becfe0188147 100644 --- a/gfx/layers/composite/AsyncCompositionManager.h +++ b/gfx/layers/composite/AsyncCompositionManager.h @@ -8,12 +8,12 @@ #include "Units.h" // for LayerPoint, etc #include "mozilla/layers/LayerManagerComposite.h" // for LayerManagerComposite -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "mozilla/Attributes.h" // for MOZ_DELETE, MOZ_FINAL, etc #include "mozilla/RefPtr.h" // for RefCounted #include "mozilla/TimeStamp.h" // for TimeStamp #include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation #include "mozilla/gfx/BasePoint.h" // for BasePoint +#include "mozilla/gfx/Matrix.h" // for Matrix4x4 #include "mozilla/layers/LayersMessages.h" // for TargetConfig #include "nsAutoPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for LayerManager::AddRef, etc @@ -34,17 +34,17 @@ struct ViewTransform { , mScale(aScale) {} - operator gfx3DMatrix() const + operator gfx::Matrix4x4() const { return - gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0) * - gfx3DMatrix::ScalingMatrix(mScale.scale, mScale.scale, 1); + gfx::Matrix4x4().Translate(mTranslation.x, mTranslation.y, 0) * + gfx::Matrix4x4().Scale(mScale.scale, mScale.scale, 1); } // For convenience, to avoid writing the cumbersome - // "gfx3dMatrix(a) * gfx3DMatrix(b)". - friend gfx3DMatrix operator*(const ViewTransform& a, const ViewTransform& b) { - return gfx3DMatrix(a) * gfx3DMatrix(b); + // "gfx::Matrix4x4(a) * gfx::Matrix4x4(b)". + friend gfx::Matrix4x4 operator*(const ViewTransform& a, const ViewTransform& b) { + return gfx::Matrix4x4(a) * gfx::Matrix4x4(b); } bool operator==(const ViewTransform& rhs) const {