Bug 1526489 - Make AutoApplyAsyncTestAttributes reentrant. r=kats
authorBotond Ballo <botond@mozilla.com>
Mon, 25 Mar 2019 21:05:51 +0000
changeset 525224 d3071cbcf6780ea9c57fb767cdb43a5b4b00f8b6
parent 525223 cc4ed5c152c0db45084cdf0c692bb2398c9145bd
child 525225 967a5709c6558790426e3903e9f87a612b8b7fe1
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1526489
milestone68.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 1526489 - Make AutoApplyAsyncTestAttributes reentrant. r=kats This gives us more flexibility in where to use it, so we don't have to worry about double application. Differential Revision: https://phabricator.services.mozilla.com/D24611
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -820,16 +820,17 @@ AsyncPanZoomController::AsyncPanZoomCont
       mLastCheckerboardReport(GetFrameTime()),
       mOverscrollEffect(MakeUnique<OverscrollEffect>(*this)),
       mState(NOTHING),
       mNotificationBlockers(0),
       mInputQueue(aInputQueue),
       mPinchPaintTimerSet(false),
       mAPZCId(sAsyncPanZoomControllerCount++),
       mSharedLock(nullptr),
+      mTestAttributeAppliers(0),
       mAsyncTransformAppliedToContent(false),
       mTestHasAsyncKeyScrolled(false),
       mCheckerboardEventLock("APZCBELock") {
   if (aGestures == USE_GESTURE_DETECTOR) {
     mGestureEventListener = new GestureEventListener(this);
   }
 }
 
@@ -4128,34 +4129,39 @@ bool AsyncPanZoomController::SampleCompo
     mCompositedZoom = Metrics().GetZoom();
     return true;
   }
   return false;
 }
 
 void AsyncPanZoomController::ApplyAsyncTestAttributes() {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
-  if (mTestAsyncScrollOffset == CSSPoint() &&
-      mTestAsyncZoom == LayerToParentLayerScale()) {
-    return;
-  }
-  Metrics().ZoomBy(mTestAsyncZoom.scale);
-  ScrollBy(mTestAsyncScrollOffset);
-  SampleCompositedAsyncTransform();
+  if (mTestAttributeAppliers == 0) {
+    if (mTestAsyncScrollOffset != CSSPoint() ||
+        mTestAsyncZoom != LayerToParentLayerScale()) {
+      Metrics().ZoomBy(mTestAsyncZoom.scale);
+      ScrollBy(mTestAsyncScrollOffset);
+      SampleCompositedAsyncTransform();
+    }
+  }
+  ++mTestAttributeAppliers;
 }
 
 void AsyncPanZoomController::UnapplyAsyncTestAttributes(
     const FrameMetrics& aPrevFrameMetrics) {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
-  if (mTestAsyncScrollOffset == CSSPoint() &&
-      mTestAsyncZoom == LayerToParentLayerScale()) {
-    return;
-  }
-  Metrics() = aPrevFrameMetrics;
-  SampleCompositedAsyncTransform();
+  MOZ_ASSERT(mTestAttributeAppliers >= 1);
+  --mTestAttributeAppliers;
+  if (mTestAttributeAppliers == 0) {
+    if (mTestAsyncScrollOffset != CSSPoint() ||
+        mTestAsyncZoom != LayerToParentLayerScale()) {
+      Metrics() = aPrevFrameMetrics;
+      SampleCompositedAsyncTransform();
+    }
+  }
 }
 
 Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() const {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
 
   LayerPoint scrollChange = (mLastContentPaintMetrics.GetScrollOffset() -
                              mExpectedGeckoMetrics.GetScrollOffset()) *
                             mLastContentPaintMetrics.GetDevPixelsPerCSSPixel() *
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -1589,16 +1589,17 @@ class AsyncPanZoomController {
 
   wr::RenderRoot GetRenderRoot() const { return mRenderRoot; }
 
  private:
   // Extra offset to add to the async scroll position for testing
   CSSPoint mTestAsyncScrollOffset;
   // Extra zoom to include in the aync zoom for testing
   LayerToParentLayerScale mTestAsyncZoom;
+  int mTestAttributeAppliers : 8;
   // Flag to track whether or not the APZ transform is not used. This
   // flag is recomputed for every composition frame.
   bool mAsyncTransformAppliedToContent : 1;
   // Flag to track whether or not this APZC has ever async key scrolled.
   bool mTestHasAsyncKeyScrolled : 1;
 
   /* ===================================================================
    * The functions and members in this section are used for checkerboard