Bug 1487001 - Use effective ScrollOffset to calculate visible rect of checkerboard. r=botond
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Fri, 31 Aug 2018 12:44:52 -0400
changeset 482683 a6fc534d433462ff07c2557bc8415f2b8a032dfd
parent 482682 e94ee8be8c140169a92b006d8d59c1a235a3d1d8
child 482684 634d70ead98b364d13111dfc9af1d5818ddc18d1
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersbotond
bugs1487001
milestone63.0a1
Bug 1487001 - Use effective ScrollOffset to calculate visible rect of checkerboard. r=botond
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -3748,27 +3748,30 @@ bool AsyncPanZoomController::AdvanceAnim
   // responsibility to schedule a composite.
   mAsyncTransformAppliedToContent = false;
   bool requestAnimationFrame = false;
   nsTArray<RefPtr<Runnable>> deferredTasks;
 
   {
     RecursiveMutexAutoLock lock(mRecursiveMutex);
 
-    requestAnimationFrame = UpdateAnimation(aSampleTime, &deferredTasks);
-
     { // scope lock
       MutexAutoLock lock(mCheckerboardEventLock);
+      // Update RendertraceProperty before UpdateAnimation() call, since
+      // the UpdateAnimation() updates effective ScrollOffset for next frame
+      // if APZFrameDelay is enabled.
       if (mCheckerboardEvent) {
         mCheckerboardEvent->UpdateRendertraceProperty(
             CheckerboardEvent::UserVisible,
-            CSSRect(Metrics().GetScrollOffset(),
+            CSSRect(GetEffectiveScrollOffset(AsyncPanZoomController::eForCompositing),
                     Metrics().CalculateCompositedSizeInCssPixels()));
       }
     }
+
+    requestAnimationFrame = UpdateAnimation(aSampleTime, &deferredTasks);
   }
 
   // Execute any deferred tasks queued up by mAnimation's Sample() (called by
   // UpdateAnimation()). This needs to be done after the monitor is released
   // since the tasks are allowed to call APZCTreeManager methods which can grab
   // the tree lock.
   for (uint32_t i = 0; i < deferredTasks.Length(); ++i) {
     APZThreadUtils::RunOnControllerThread(deferredTasks[i].forget());
@@ -4023,17 +4026,17 @@ Matrix4x4 AsyncPanZoomController::GetTra
            PostScale(zoomChange.width, zoomChange.height, 1);
 }
 
 uint32_t
 AsyncPanZoomController::GetCheckerboardMagnitude() const
 {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
 
-  CSSPoint currentScrollOffset = Metrics().GetScrollOffset() + mTestAsyncScrollOffset;
+  CSSPoint currentScrollOffset = GetEffectiveScrollOffset(AsyncPanZoomController::eForCompositing) + mTestAsyncScrollOffset;
   CSSRect painted = mLastContentPaintMetrics.GetDisplayPort() + mLastContentPaintMetrics.GetScrollOffset();
   CSSRect visible = CSSRect(currentScrollOffset, Metrics().CalculateCompositedSizeInCssPixels());
 
   CSSIntRegion checkerboard;
   // Round so as to minimize checkerboarding; if we're only showing fractional
   // pixels of checkerboarding it's not really worth counting
   checkerboard.Sub(RoundedIn(visible), RoundedOut(painted));
   return checkerboard.Area();