Bug 1471437 - Part 1: Store the previous paint rect before occlusion culling. r=mattwoodrow
MozReview-Commit-ID: 8Bw9hsPcipZ
--- 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,