From 7bbe707700b9804cbe70f7e7083cac6970f63b47 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Mon, 3 May 2021 23:51:28 +0000 Subject: [PATCH] Bug 1708855 - Give Axis a few more accessor methods. r=tnikkel Depends on D114160 Differential Revision: https://phabricator.services.mozilla.com/D114161 --- gfx/layers/apz/src/Axis.cpp | 48 +++++++++++++++++++++++++++++++++++++ gfx/layers/apz/src/Axis.h | 27 +++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/gfx/layers/apz/src/Axis.cpp b/gfx/layers/apz/src/Axis.cpp index 4a6147d04b38..41e2a7fd4ca6 100644 --- a/gfx/layers/apz/src/Axis.cpp +++ b/gfx/layers/apz/src/Axis.cpp @@ -452,6 +452,10 @@ bool Axis::OverscrollBehaviorAllowsOverscrollEffect() const { AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController) : Axis(aAsyncPanZoomController) {} +CSSCoord AxisX::GetPointOffset(const CSSPoint& aPoint) const { + return aPoint.x; +} + ParentLayerCoord AxisX::GetPointOffset(const ParentLayerPoint& aPoint) const { return aPoint.x; } @@ -474,6 +478,26 @@ CSSToParentLayerScale AxisX::GetScaleForAxis( return CSSToParentLayerScale(aScale.xScale); } +float AxisX::GetTransformScale( + const AsyncTransformComponentMatrix& aMatrix) const { + return aMatrix._11; +} + +ParentLayerCoord AxisX::GetTransformTranslation( + const AsyncTransformComponentMatrix& aMatrix) const { + return aMatrix._41; +} + +void AxisX::PostScale(AsyncTransformComponentMatrix& aMatrix, + float aScale) const { + aMatrix.PostScale(aScale, 1.f, 1.f); +} + +void AxisX::PostTranslate(AsyncTransformComponentMatrix& aMatrix, + ParentLayerCoord aTranslation) const { + aMatrix.PostTranslate(aTranslation, 0, 0); +} + ScreenPoint AxisX::MakePoint(ScreenCoord aCoord) const { return ScreenPoint(aCoord, 0); } @@ -512,6 +536,10 @@ OverscrollBehavior AxisX::GetOverscrollBehavior() const { AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController) : Axis(aAsyncPanZoomController) {} +CSSCoord AxisY::GetPointOffset(const CSSPoint& aPoint) const { + return aPoint.y; +} + ParentLayerCoord AxisY::GetPointOffset(const ParentLayerPoint& aPoint) const { return aPoint.y; } @@ -534,6 +562,26 @@ CSSToParentLayerScale AxisY::GetScaleForAxis( return CSSToParentLayerScale(aScale.yScale); } +float AxisY::GetTransformScale( + const AsyncTransformComponentMatrix& aMatrix) const { + return aMatrix._22; +} + +ParentLayerCoord AxisY::GetTransformTranslation( + const AsyncTransformComponentMatrix& aMatrix) const { + return aMatrix._42; +} + +void AxisY::PostScale(AsyncTransformComponentMatrix& aMatrix, + float aScale) const { + aMatrix.PostScale(1.f, aScale, 1.f); +} + +void AxisY::PostTranslate(AsyncTransformComponentMatrix& aMatrix, + ParentLayerCoord aTranslation) const { + aMatrix.PostTranslate(0, aTranslation, 0); +} + ScreenPoint AxisY::MakePoint(ScreenCoord aCoord) const { return ScreenPoint(0, aCoord); } diff --git a/gfx/layers/apz/src/Axis.h b/gfx/layers/apz/src/Axis.h index aba356a00a9e..428496ce3f7f 100644 --- a/gfx/layers/apz/src/Axis.h +++ b/gfx/layers/apz/src/Axis.h @@ -287,6 +287,7 @@ class Axis { virtual CSSToParentLayerScale GetAxisScale( const CSSToParentLayerScale2D& aScale) const = 0; + virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const = 0; virtual ParentLayerCoord GetPointOffset( const ParentLayerPoint& aPoint) const = 0; virtual ParentLayerCoord GetRectLength( @@ -295,6 +296,14 @@ class Axis { const ParentLayerRect& aRect) const = 0; virtual CSSToParentLayerScale GetScaleForAxis( const CSSToParentLayerScale2D& aScale) const = 0; + virtual float GetTransformScale( + const AsyncTransformComponentMatrix& aMatrix) const = 0; + virtual ParentLayerCoord GetTransformTranslation( + const AsyncTransformComponentMatrix& aMatrix) const = 0; + virtual void PostScale(AsyncTransformComponentMatrix& aMatrix, + float aScale) const = 0; + virtual void PostTranslate(AsyncTransformComponentMatrix& aMatrix, + ParentLayerCoord aTranslation) const = 0; virtual ScreenPoint MakePoint(ScreenCoord aCoord) const = 0; @@ -356,12 +365,21 @@ class AxisX : public Axis { explicit AxisX(AsyncPanZoomController* mAsyncPanZoomController); CSSToParentLayerScale GetAxisScale( const CSSToParentLayerScale2D& aScale) const override; + CSSCoord GetPointOffset(const CSSPoint& aPoint) const override; ParentLayerCoord GetPointOffset( const ParentLayerPoint& aPoint) const override; ParentLayerCoord GetRectLength(const ParentLayerRect& aRect) const override; ParentLayerCoord GetRectOffset(const ParentLayerRect& aRect) const override; CSSToParentLayerScale GetScaleForAxis( const CSSToParentLayerScale2D& aScale) const override; + float GetTransformScale( + const AsyncTransformComponentMatrix& aMatrix) const override; + ParentLayerCoord GetTransformTranslation( + const AsyncTransformComponentMatrix& aMatrix) const override; + void PostScale(AsyncTransformComponentMatrix& aMatrix, + float aScale) const override; + void PostTranslate(AsyncTransformComponentMatrix& aMatrix, + ParentLayerCoord aTranslation) const override; ScreenPoint MakePoint(ScreenCoord aCoord) const override; const char* Name() const override; bool CanScrollTo(Side aSide) const; @@ -374,6 +392,7 @@ class AxisX : public Axis { class AxisY : public Axis { public: explicit AxisY(AsyncPanZoomController* mAsyncPanZoomController); + CSSCoord GetPointOffset(const CSSPoint& aPoint) const override; ParentLayerCoord GetPointOffset( const ParentLayerPoint& aPoint) const override; CSSToParentLayerScale GetAxisScale( @@ -382,6 +401,14 @@ class AxisY : public Axis { ParentLayerCoord GetRectOffset(const ParentLayerRect& aRect) const override; CSSToParentLayerScale GetScaleForAxis( const CSSToParentLayerScale2D& aScale) const override; + float GetTransformScale( + const AsyncTransformComponentMatrix& aMatrix) const override; + ParentLayerCoord GetTransformTranslation( + const AsyncTransformComponentMatrix& aMatrix) const override; + void PostScale(AsyncTransformComponentMatrix& aMatrix, + float aScale) const override; + void PostTranslate(AsyncTransformComponentMatrix& aMatrix, + ParentLayerCoord aTranslation) const override; ScreenPoint MakePoint(ScreenCoord aCoord) const override; const char* Name() const override; bool CanScrollTo(Side aSide) const;