Bug 1246290 - Refactoring to get rid of SampleContentTransformForFrame from AsyncPanZoomController. r=botond
MozReview-Commit-ID: HLfXsvEPwpe
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -3123,23 +3123,23 @@ bool AsyncPanZoomController::AdvanceAnim
// One of the deferred tasks may have started a new animation. In this case,
// we want to ask the compositor to schedule a new composite.
requestAnimationFrame |= (mAnimation != nullptr);
return requestAnimationFrame;
}
-void AsyncPanZoomController::SampleContentTransformForFrame(AsyncTransform* aOutTransform,
- ParentLayerPoint& aScrollOffset)
+ParentLayerPoint
+AsyncPanZoomController::GetCurrentAsyncScrollOffset() const
{
ReentrantMonitorAutoEnter lock(mMonitor);
- aScrollOffset = mFrameMetrics.GetScrollOffset() * mFrameMetrics.GetZoom();
- *aOutTransform = GetCurrentAsyncTransform();
+ return (mFrameMetrics.GetScrollOffset() + mTestAsyncScrollOffset)
+ * mFrameMetrics.GetZoom() * mTestAsyncZoom.scale;
}
AsyncTransform AsyncPanZoomController::GetCurrentAsyncTransform() const {
ReentrantMonitorAutoEnter lock(mMonitor);
CSSPoint lastPaintScrollOffset;
if (mLastContentPaintMetrics.IsScrollable()) {
lastPaintScrollOffset = mLastContentPaintMetrics.GetScrollOffset();
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -158,31 +158,16 @@ public:
* should continue. If true, the compositor should schedule another composite.
*/
bool AdvanceAnimations(const TimeStamp& aSampleTime);
bool UpdateAnimation(const TimeStamp& aSampleTime,
Vector<Task*>* aOutDeferredTasks);
/**
- * Query the transforms that should be applied to the layer corresponding
- * to this APZC due to asynchronous panning and zooming.
- * This function returns the async transform via the |aOutTransform|
- * out parameter.
- */
- void SampleContentTransformForFrame(AsyncTransform* aOutTransform,
- ParentLayerPoint& aScrollOffset);
-
- /**
- * Return a visual effect that reflects this apzc's
- * overscrolled state, if any.
- */
- AsyncTransformComponentMatrix GetOverscrollTransform() const;
-
- /**
* A shadow layer update has arrived. |aLayerMetrics| is the new FrameMetrics
* for the container layer corresponding to this APZC.
* |aIsFirstPaint| is a flag passed from the shadow
* layers code indicating that the frame metrics being sent with this call are
* the initial metrics and the initial paint of the frame has just happened.
*/
void NotifyLayersUpdated(const FrameMetrics& aLayerMetrics, bool aIsFirstPaint,
bool aThisLayerTreeUpdated);
@@ -218,30 +203,16 @@ public:
void Destroy();
/**
* Returns true if Destroy() has already been called on this APZC instance.
*/
bool IsDestroyed() const;
/**
- * Returns the incremental transformation corresponding to the async pan/zoom
- * in progress. That is, when this transform is multiplied with the layer's
- * existing transform, it will make the layer appear with the desired pan/zoom
- * amount.
- */
- AsyncTransform GetCurrentAsyncTransform() const;
-
- /**
- * Returns the same transform as GetCurrentAsyncTransform(), but includes
- * any transform due to axis over-scroll.
- */
- AsyncTransformComponentMatrix GetCurrentAsyncTransformWithOverscroll() const;
-
- /**
* Returns the transform to take something from the coordinate space of the
* last thing we know gecko painted, to the coordinate space of the last thing
* we asked gecko to paint. In cases where that last request has not yet been
* processed, this is needed to transform input events properly into a space
* gecko will understand.
*/
Matrix4x4 GetTransformToLastDispatchedPaint() const;
@@ -730,16 +701,50 @@ private:
// to allow panning by moving multiple fingers (thus moving the focus point).
ParentLayerPoint mLastZoomFocus;
RefPtr<AsyncPanZoomAnimation> mAnimation;
friend class Axis;
+ /* ===================================================================
+ * The functions and members in this section are used to expose
+ * the current async transform state to callers.
+ */
+public:
+ /**
+ * Query the transforms that should be applied to the layer corresponding
+ * to this APZC due to asynchronous panning and zooming.
+ * This function returns the async transform via the |aOutTransform|
+ * out parameter.
+ */
+ ParentLayerPoint GetCurrentAsyncScrollOffset() const;
+
+ /**
+ * Return a visual effect that reflects this apzc's
+ * overscrolled state, if any.
+ */
+ AsyncTransformComponentMatrix GetOverscrollTransform() const;
+
+ /**
+ * Returns the incremental transformation corresponding to the async pan/zoom
+ * in progress. That is, when this transform is multiplied with the layer's
+ * existing transform, it will make the layer appear with the desired pan/zoom
+ * amount.
+ */
+ AsyncTransform GetCurrentAsyncTransform() const;
+
+ /**
+ * Returns the same transform as GetCurrentAsyncTransform(), but includes
+ * any transform due to axis over-scroll.
+ */
+ AsyncTransformComponentMatrix GetCurrentAsyncTransformWithOverscroll() const;
+
+
/* ===================================================================
* The functions and members in this section are used to manage
* the state that tracks what this APZC is doing with the input events.
*/
protected:
enum PanZoomState {
NOTHING, /* no touch-start events received */
@@ -1099,19 +1104,19 @@ public:
}
uint64_t GetLayersId() const
{
return mLayersId;
}
private:
- // Extra offset to add in SampleContentTransformForFrame for testing
+ // Extra offset to add to the async scroll position for testing
CSSPoint mTestAsyncScrollOffset;
- // Extra zoom to include in SampleContentTransformForFrame for testing
+ // Extra zoom to include in the aync zoom for testing
LayerToParentLayerScale mTestAsyncZoom;
// Flag to track whether or not the APZ transform is not used. This
// flag is recomputed for every composition frame.
bool mAsyncTransformAppliedToContent;
/* ===================================================================
* The functions and members in this section are used for checkerboard
--- a/gfx/layers/apz/test/gtest/APZTestCommon.h
+++ b/gfx/layers/apz/test/gtest/APZTestCommon.h
@@ -247,18 +247,20 @@ public:
}
}
bool SampleContentTransformForFrame(AsyncTransform* aOutTransform,
ParentLayerPoint& aScrollOffset,
const TimeDuration& aIncrement = TimeDuration::FromMilliseconds(0)) {
mcc->AdvanceBy(aIncrement);
bool ret = AdvanceAnimations(mcc->Time());
- AsyncPanZoomController::SampleContentTransformForFrame(
- aOutTransform, aScrollOffset);
+ if (aOutTransform) {
+ *aOutTransform = GetCurrentAsyncTransform();
+ }
+ aScrollOffset = GetCurrentAsyncScrollOffset();
return ret;
}
void SetWaitForMainThread() {
mWaitForMainThread = true;
}
private:
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -839,20 +839,17 @@ AsyncCompositionManager::ApplyAsyncConte
for (uint32_t i = 0; i < aLayer->GetFrameMetricsCount(); i++) {
AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController(i);
if (!controller) {
continue;
}
hasAsyncTransform = true;
- AsyncTransform asyncTransformWithoutOverscroll;
- ParentLayerPoint scrollOffset;
- controller->SampleContentTransformForFrame(&asyncTransformWithoutOverscroll,
- scrollOffset);
+ AsyncTransform asyncTransformWithoutOverscroll = controller->GetCurrentAsyncTransform();
AsyncTransformComponentMatrix overscrollTransform = controller->GetOverscrollTransform();
AsyncTransformComponentMatrix asyncTransform =
AsyncTransformComponentMatrix(asyncTransformWithoutOverscroll)
* overscrollTransform;
if (!aLayer->IsScrollInfoLayer()) {
controller->MarkAsyncTransformAppliedToContent();
}
@@ -875,16 +872,17 @@ AsyncCompositionManager::ApplyAsyncConte
CSSToLayerScale geckoZoom = metrics.LayersPixelsPerCSSPixel().ToScaleFactor();
if (mIsFirstPaint) {
LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.GetScrollOffset() * geckoZoom);
mContentRect = metrics.GetScrollableRect();
SetFirstPaintViewport(scrollOffsetLayerPixels,
geckoZoom,
mContentRect);
} else {
+ ParentLayerPoint scrollOffset = controller->GetCurrentAsyncScrollOffset();
// Compute the painted displayport in document-relative CSS pixels.
CSSRect displayPort(metrics.GetCriticalDisplayPort().IsEmpty() ?
metrics.GetDisplayPort() :
metrics.GetCriticalDisplayPort());
displayPort += metrics.GetScrollOffset();
SyncFrameMetrics(scrollOffset,
geckoZoom * asyncTransformWithoutOverscroll.mScale,
metrics.GetScrollableRect(), displayPort, geckoZoom, mLayersUpdated,
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -482,20 +482,17 @@ RenderMinimap(ContainerT* aContainer, La
return;
}
AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController(0);
if (!controller) {
return;
}
- AsyncTransform asyncTransformWithoutOverscroll;
- ParentLayerPoint scrollOffset;
- controller->SampleContentTransformForFrame(&asyncTransformWithoutOverscroll,
- scrollOffset);
+ ParentLayerPoint scrollOffset = controller->GetCurrentAsyncScrollOffset();
// Options
const int verticalPadding = 10;
const int horizontalPadding = 5;
gfx::Color backgroundColor(0.3f, 0.3f, 0.3f, 0.3f);
gfx::Color tileActiveColor(1, 1, 1, 0.4f);
gfx::Color tileBorderColor(0, 0, 0, 0.1f);
gfx::Color pageBorderColor(0, 0, 0);