Bug 803013 - Update valid region progressively with tiles. r=bgirard
authorChris Lord <chrislord.net@gmail.com>
Wed, 24 Oct 2012 15:49:03 +0100
changeset 111383 5003d92bca8cb7eb8d019c82799ecda0963afef0
parent 111382 791d6f9b8ec81e821dc9af03db0982931047fb73
child 111384 9a4531d2d243c224087d81b032ea9eabbbb6fc17
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersbgirard
bugs803013
milestone19.0a1
Bug 803013 - Update valid region progressively with tiles. r=bgirard When updating tiles progressively, make sure the valid region is also updated progressively to avoid flickering.
gfx/layers/basic/BasicTiledThebesLayer.cpp
--- a/gfx/layers/basic/BasicTiledThebesLayer.cpp
+++ b/gfx/layers/basic/BasicTiledThebesLayer.cpp
@@ -406,17 +406,20 @@ BasicTiledThebesLayer::PaintThebes(gfxCo
     for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
       if (parent->UseIntermediateSurface()) {
         transform.PreMultiply(parent->GetEffectiveTransform());
       }
     }
     transform.Invert();
 
     // Store the old valid region, then clear it before painting.
+    // We clip the old valid region to the visible region, as it only gets
+    // used to decide stale content (currently valid and previously visible)
     nsIntRegion oldValidRegion = mTiledBuffer.GetValidRegion();
+    oldValidRegion.And(oldValidRegion, mVisibleRegion);
     mTiledBuffer.ClearPaintedRegion();
 
     // Make sure that tiles that fall outside of the visible region are
     // discarded on the first update.
     if (!BasicManager()->IsRepeatTransaction()) {
       mValidRegion.And(mValidRegion, mVisibleRegion);
     }
 
@@ -449,18 +452,24 @@ BasicTiledThebesLayer::PaintThebes(gfxCo
         } else {
           return;
         }
       }
 
       // Keep track of what we're about to refresh.
       mValidRegion.Or(mValidRegion, regionToPaint);
 
+      // mValidRegion would have been altered by InvalidateRegion, but we still
+      // want to display stale content until it gets progressively updated.
+      // Create a region that includes stale content.
+      nsIntRegion validOrStale;
+      validOrStale.Or(mValidRegion, oldValidRegion);
+
       // Paint the computed region and subtract it from the invalid region.
-      mTiledBuffer.PaintThebes(this, mValidRegion, regionToPaint, aCallback, aCallbackData);
+      mTiledBuffer.PaintThebes(this, validOrStale, regionToPaint, aCallback, aCallbackData);
       invalidRegion.Sub(invalidRegion, regionToPaint);
     } while (repeat);
   } else {
     mTiledBuffer.ClearPaintedRegion();
     mTiledBuffer.SetResolution(resolution);
     mValidRegion = mVisibleRegion;
     mTiledBuffer.PaintThebes(this, mValidRegion, invalidRegion, aCallback, aCallbackData);
   }