Bug 1023882 - Part 7 - Move down the calculation of the low-precision invalid region so it happens later. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 11 Jun 2014 12:42:46 -0400
changeset 208287 5c082ed1469bc89163a56462bb20a0d71292fe5f
parent 208286 71229cd93bd6520900cd93ae40652d3915cfc37e
child 208288 b5411d889c2d71ef49dcb9910afb4f039e6ee37f
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs1023882
milestone32.0a2
Bug 1023882 - Part 7 - Move down the calculation of the low-precision invalid region so it happens later. r=Cwiiis
gfx/layers/client/ClientTiledThebesLayer.cpp
--- a/gfx/layers/client/ClientTiledThebesLayer.cpp
+++ b/gfx/layers/client/ClientTiledThebesLayer.cpp
@@ -237,20 +237,19 @@ ClientTiledThebesLayer::RenderHighPrecis
   return true;
 }
 
 bool
 ClientTiledThebesLayer::RenderLowPrecision(nsIntRegion& aInvalidRegion,
                                            LayerManager::DrawThebesLayerCallback aCallback,
                                            void* aCallbackData)
 {
-  // Render the low precision buffer, if there's area to invalidate and the
-  // visible region is larger than the critical display port.
-  if (!aInvalidRegion.IsEmpty() &&
-      !nsIntRegion(LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)).Contains(mVisibleRegion)) {
+  // Render the low precision buffer, if the visible region is larger than the
+  // critical display port.
+  if (!nsIntRegion(LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)).Contains(mVisibleRegion)) {
     nsIntRegion oldValidRegion = mContentClient->mLowPrecisionTiledBuffer.GetValidRegion();
     oldValidRegion.And(oldValidRegion, mVisibleRegion);
 
     bool updatedBuffer = false;
 
     // If the frame resolution or format have changed, invalidate the buffer
     if (mContentClient->mLowPrecisionTiledBuffer.GetFrameResolution() != mPaintData.mResolution ||
         mContentClient->mLowPrecisionTiledBuffer.HasFormatChanged()) {
@@ -329,16 +328,17 @@ ClientTiledThebesLayer::RenderLayer()
   }
 
   if (mContentClient->mTiledBuffer.HasFormatChanged()) {
     mValidRegion = nsIntRegion();
   }
 
   TILING_PRLOG_OBJ(("TILING 0x%p: Initial visible region %s\n", this, tmpstr.get()), mVisibleRegion);
   TILING_PRLOG_OBJ(("TILING 0x%p: Initial valid region %s\n", this, tmpstr.get()), mValidRegion);
+  TILING_PRLOG_OBJ(("TILING 0x%p: Initial low-precision valid region %s\n", this, tmpstr.get()), mLowPrecisionValidRegion);
 
   nsIntRegion invalidRegion;
   invalidRegion.Sub(mVisibleRegion, mValidRegion);
   if (invalidRegion.IsEmpty()) {
     EndPaint(true);
     return;
   }
 
@@ -379,63 +379,56 @@ ClientTiledThebesLayer::RenderLayer()
   } else {
     if (!mPaintData.mCriticalDisplayPort.IsEmpty()) {
       invalidRegion.And(invalidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort));
     }
     TILING_PRLOG_OBJ(("TILING 0x%p: Repeat-transaction invalid region %s\n", this, tmpstr.get()), invalidRegion);
   }
 
   nsIntRegion lowPrecisionInvalidRegion;
-  if (!mPaintData.mCriticalDisplayPort.IsEmpty()) {
-    if (gfxPrefs::UseLowPrecisionBuffer()) {
-      // Calculate the invalid region for the low precision buffer
-      lowPrecisionInvalidRegion.Sub(mVisibleRegion, mLowPrecisionValidRegion);
-
-      // Remove the valid region from the low precision valid region (we don't
-      // validate this part of the low precision buffer).
-      lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion);
-    }
-
-    if (invalidRegion.IsEmpty() && lowPrecisionInvalidRegion.IsEmpty()) {
-      EndPaint(true);
-      return;
-    }
+  if (gfxPrefs::UseLowPrecisionBuffer()) {
+    // Calculate the invalid region for the low precision buffer. Make sure
+    // to remove the valid high-precision area so we don't double-paint it.
+    lowPrecisionInvalidRegion.Sub(mVisibleRegion, mLowPrecisionValidRegion);
+    lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion);
   }
-
-  TILING_PRLOG_OBJ(("TILING 0x%p: Invalid region %s\n", this, tmpstr.get()), invalidRegion);
+  TILING_PRLOG_OBJ(("TILING 0x%p: Low-precision invalid region %s\n", this, tmpstr.get()), lowPrecisionInvalidRegion);
 
   bool updatedHighPrecision = RenderHighPrecision(invalidRegion, callback, data);
   if (updatedHighPrecision) {
     ClientManager()->Hold(this);
     mContentClient->UseTiledLayerBuffer(TiledContentClient::TILED_BUFFER);
 
     if (!mPaintData.mPaintFinished) {
       // There is still more high-res stuff to paint, so we're not
       // done yet. A subsequent transaction will take care of this.
       ClientManager()->SetRepeatTransaction();
       return;
     }
+  }
 
-    // If there are low precision updates, mark the paint as unfinished and
-    // request a repeat transaction.
-    if (!lowPrecisionInvalidRegion.IsEmpty()) {
-      ClientManager()->SetRepeatTransaction();
-      mPaintData.mLowPrecisionPaintCount = 1;
-      mPaintData.mPaintFinished = false;
-    }
+  // If there is nothing to draw in low-precision, then we're done.
+  if (lowPrecisionInvalidRegion.IsEmpty()) {
+    EndPaint(true);
+    return;
+  }
 
-    // Return so that low precision updates aren't performed in the same
-    // transaction as high-precision updates.
+  if (updatedHighPrecision) {
+    // If there are low precision updates, but we just did some high-precision
+    // updates, then mark the paint as unfinished and request a repeat transaction.
+    // This is so that we don't perform low-precision updates in the same transaction
+    // as high-precision updates.
+    TILING_PRLOG(("TILING 0x%p: Scheduling repeat transaction for low-precision painting\n", this));
+    ClientManager()->SetRepeatTransaction();
+    mPaintData.mLowPrecisionPaintCount = 1;
+    mPaintData.mPaintFinished = false;
     EndPaint(false);
     return;
   }
 
-  TILING_PRLOG_OBJ(("TILING 0x%p: Low-precision valid region is %s\n", this, tmpstr.get()), mLowPrecisionValidRegion);
-  TILING_PRLOG_OBJ(("TILING 0x%p: Low-precision invalid region is %s\n", this, tmpstr.get()), lowPrecisionInvalidRegion);
-
   bool updatedLowPrecision = RenderLowPrecision(lowPrecisionInvalidRegion, callback, data);
   if (updatedLowPrecision) {
     ClientManager()->Hold(this);
     mContentClient->UseTiledLayerBuffer(TiledContentClient::LOW_PRECISION_TILED_BUFFER);
 
     if (!mPaintData.mPaintFinished) {
       // There is still more low-res stuff to paint, so we're not
       // done yet. A subsequent transaction will take care of this.