Back out bug 1021248 for causing bug 1028271. r=backout
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 23 Jun 2014 14:38:02 -0400
changeset 190260 0f07aa386616c6d01064d0eb003c365bed7348d4
parent 190259 f62815d96448e62d20d2821ceae2dc84b6f6d8ad
child 190261 2c62d4b7b0554e09efe43a7e543fc6e976d6aac0
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbackout
bugs1021248, 1028271
milestone33.0a1
Back out bug 1021248 for causing bug 1028271. r=backout
gfx/layers/client/TiledContentClient.cpp
gfx/layers/client/TiledContentClient.h
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -122,16 +122,18 @@ TiledContentClient::UseTiledLayerBuffer(
   // TiledLayerBufferComposite.
   buffer->ReadLock();
 
   mForwarder->UseTiledLayerBuffer(this, buffer->GetSurfaceDescriptorTiles());
   buffer->ClearPaintedRegion();
 }
 
 SharedFrameMetricsHelper::SharedFrameMetricsHelper()
+  : mLastProgressiveUpdateWasLowPrecision(false)
+  , mProgressiveUpdateWasInDanger(false)
 {
   MOZ_COUNT_CTOR(SharedFrameMetricsHelper);
 }
 
 SharedFrameMetricsHelper::~SharedFrameMetricsHelper()
 {
   MOZ_COUNT_DTOR(SharedFrameMetricsHelper);
 }
@@ -180,16 +182,27 @@ SharedFrameMetricsHelper::UpdateFromComp
 
   if (!compositor->LookupCompositorFrameMetrics(contentMetrics.GetScrollId(),
                                                 compositorMetrics)) {
     return false;
   }
 
   aViewTransform = ComputeViewTransform(contentMetrics, compositorMetrics);
 
+  // Reset the checkerboard risk flag when switching to low precision
+  // rendering.
+  if (aLowPrecision && !mLastProgressiveUpdateWasLowPrecision) {
+    // Skip low precision rendering until we're at risk of checkerboarding.
+    if (!mProgressiveUpdateWasInDanger) {
+      return true;
+    }
+    mProgressiveUpdateWasInDanger = false;
+  }
+  mLastProgressiveUpdateWasLowPrecision = aLowPrecision;
+
   // Always abort updates if the resolution has changed. There's no use
   // in drawing at the incorrect resolution.
   if (!FuzzyEquals(compositorMetrics.GetZoom().scale, contentMetrics.GetZoom().scale)) {
     return true;
   }
 
   // Never abort drawing if we can't be sure we've sent a more recent
   // display-port. If we abort updating when we shouldn't, we can end up
@@ -199,30 +212,33 @@ SharedFrameMetricsHelper::UpdateFromComp
       fabsf(contentMetrics.GetScrollOffset().y - compositorMetrics.GetScrollOffset().y) <= 2 &&
       fabsf(contentMetrics.mDisplayPort.x - compositorMetrics.mDisplayPort.x) <= 2 &&
       fabsf(contentMetrics.mDisplayPort.y - compositorMetrics.mDisplayPort.y) <= 2 &&
       fabsf(contentMetrics.mDisplayPort.width - compositorMetrics.mDisplayPort.width) <= 2 &&
       fabsf(contentMetrics.mDisplayPort.height - compositorMetrics.mDisplayPort.height)) {
     return false;
   }
 
-  bool scrollUpdatePending = contentMetrics.GetScrollOffsetUpdated() &&
-      contentMetrics.GetScrollGeneration() != compositorMetrics.GetScrollGeneration();
-  // If scrollUpdatePending is true, then that means the content-side
-  // metrics has a new scroll offset that is going to be forced into the
-  // compositor but it hasn't gotten there yet.
-  // Even though right now comparing the metrics might indicate we're
-  // about to checkerboard (and that's true), the checkerboarding will
-  // disappear as soon as the new scroll offset update is processed
-  // on the compositor side. To avoid leaving things in a low-precision
-  // paint, we need to detect and handle this case (bug 1026756).
-  if (!aLowPrecision && !scrollUpdatePending && AboutToCheckerboard(contentMetrics, compositorMetrics)) {
-    TILING_PRLOG_OBJ(("TILING: Checkerboard abort content %s\n", tmpstr.get()), contentMetrics);
-    TILING_PRLOG_OBJ(("TILING: Checkerboard abort compositor %s\n", tmpstr.get()), compositorMetrics);
-    return true;
+  // When not a low precision pass and the page is in danger of checker boarding
+  // abort update.
+  if (!aLowPrecision && !mProgressiveUpdateWasInDanger) {
+    bool scrollUpdatePending = contentMetrics.GetScrollOffsetUpdated() &&
+        contentMetrics.GetScrollGeneration() != compositorMetrics.GetScrollGeneration();
+    // If scrollUpdatePending is true, then that means the content-side
+    // metrics has a new scroll offset that is going to be forced into the
+    // compositor but it hasn't gotten there yet.
+    // Even though right now comparing the metrics might indicate we're
+    // about to checkerboard (and that's true), the checkerboarding will
+    // disappear as soon as the new scroll offset update is processed
+    // on the compositor side. To avoid leaving things in a low-precision
+    // paint, we need to detect and handle this case (bug 1026756).
+    if (!scrollUpdatePending && AboutToCheckerboard(contentMetrics, compositorMetrics)) {
+      mProgressiveUpdateWasInDanger = true;
+      return true;
+    }
   }
 
   // Abort drawing stale low-precision content if there's a more recent
   // display-port in the pipeline.
   if (aLowPrecision && !aHasPendingNewThebesContent) {
     return true;
   }
 
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -330,16 +330,19 @@ public:
    * Determines if the compositor's upcoming composition bounds has fallen
    * outside of the contents display port. If it has then the compositor
    * will start to checker board. Checker boarding is when the compositor
    * tries to composite a tile and it is not available. Historically
    * a tile with a checker board pattern was used. Now a blank tile is used.
    */
   bool AboutToCheckerboard(const FrameMetrics& aContentMetrics,
                            const FrameMetrics& aCompositorMetrics);
+private:
+  bool mLastProgressiveUpdateWasLowPrecision;
+  bool mProgressiveUpdateWasInDanger;
 };
 
 /**
  * Provide an instance of TiledLayerBuffer backed by drawable TextureClients.
  * This buffer provides an implementation of ValidateTile using a
  * thebes callback and can support painting using a single paint buffer.
  * Whether a single paint buffer is used is controlled by
  * gfxPrefs::PerTileDrawing().