Bug 1471437 - Part 1: Store the previous paint rect before occlusion culling. r=mattwoodrow draft
authorBas Schouten <bschouten@mozilla.com>
Wed, 27 Jun 2018 03:41:31 +0200
changeset 811156 a23427916397d1adf10ceca4ee56d128d78c58e2
parent 810151 0ed1a6d400dc59baf24e92de4cb554400fc6b872
child 811158 619afb2eec650572c13e48ff094e34fd856391bb
push id114209
push userbschouten@mozilla.com
push dateWed, 27 Jun 2018 01:43:13 +0000
reviewersmattwoodrow
bugs1471437
milestone62.0a1
Bug 1471437 - Part 1: Store the previous paint rect before occlusion culling. r=mattwoodrow MozReview-Commit-ID: 8Bw9hsPcipZ
layout/painting/FrameLayerBuilder.cpp
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -6165,25 +6165,31 @@ FrameLayerBuilder::RecomputeVisibilityFo
   uint32_t i;
   // Update visible regions. We perform visibility analysis to take account
   // of occlusion culling.
   nsRegion visible = aRegionToDraw.ToAppUnits(aAppUnitsPerDevPixel);
   visible.MoveBy(NSIntPixelsToAppUnits(aOffset.x, aAppUnitsPerDevPixel),
                  NSIntPixelsToAppUnits(aOffset.y, aAppUnitsPerDevPixel));
   visible.ScaleInverseRoundOut(aXScale, aYScale);
 
+  // We're going to read from previousRectToDraw for every iteration, let's do
+  // that on the stack, and just update the heap allocated one now. By the end
+  // of this function {visible} will have been modified by occlusion culling.
+  nsRect previousRectToDraw = aPreviousRectToDraw;
+  aPreviousRectToDraw = visible.GetBounds();
+
   for (i = aItems.Length(); i > 0; --i) {
     AssignedDisplayItem* cdi = &aItems[i - 1];
     if (!cdi->mItem) {
       continue;
     }
 
     if (cdi->mHasPaintRect &&
         !cdi->mContentRect.Intersects(visible.GetBounds()) &&
-        !cdi->mContentRect.Intersects(aPreviousRectToDraw)) {
+        !cdi->mContentRect.Intersects(previousRectToDraw)) {
       continue;
     }
 
     if (cdi->mType == DisplayItemEntryType::POP_OPACITY ||
         (cdi->mType == DisplayItemEntryType::ITEM && cdi->mHasOpacity)) {
       // The visibility calculations are skipped when the item is an effect end
       // marker, or when the display item is within a flattened opacity group.
       // This is because RecomputeVisibility has already been called for the
@@ -6218,18 +6224,16 @@ FrameLayerBuilder::RecomputeVisibilityFo
       nsRegion newVisible;
       newVisible.Sub(visible, removed);
       // Don't let the visible region get too complex.
       if (newVisible.GetNumRects() <= 15) {
         visible = std::move(newVisible);
       }
     }
   }
-
-  aPreviousRectToDraw = visible.GetBounds();
 }
 
 /**
  * Sets the clip chain and starts a new opacity group.
  */
 static void
 PushOpacity(gfxContext* aContext,
             const nsRect& aPaintRect,