diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index 2cbf2b651054..a71dadee88d7 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -6170,6 +6170,12 @@ FrameLayerBuilder::RecomputeVisibilityForItems(nsTArray& aI 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) { @@ -6178,7 +6184,7 @@ FrameLayerBuilder::RecomputeVisibilityForItems(nsTArray& aI if (cdi->mHasPaintRect && !cdi->mContentRect.Intersects(visible.GetBounds()) && - !cdi->mContentRect.Intersects(aPreviousRectToDraw)) { + !cdi->mContentRect.Intersects(previousRectToDraw)) { continue; } @@ -6223,8 +6229,6 @@ FrameLayerBuilder::RecomputeVisibilityForItems(nsTArray& aI } } } - - aPreviousRectToDraw = visible.GetBounds(); } /**