Bug 363861. Part 4: Track rectangles of opaque content in RGBA surfaces and use them to make PushGroupAndCopyBackground work in more situations. r=jrmuizel,sr=vlad,a=blocking

This commit is contained in:
Robert O'Callahan
2011-01-03 14:48:08 +13:00
parent dc5c974f6b
commit a8e399a872
3 changed files with 54 additions and 5 deletions

View File

@@ -1314,6 +1314,22 @@ BasicLayerManager::PaintLayer(Layer* aLayer,
effectiveTransform.Is2D(&transform);
mTarget->SetMatrix(transform);
PRBool pushedTargetOpaqueRect = PR_FALSE;
const nsIntRegion& visibleRegion = aLayer->GetEffectiveVisibleRegion();
nsRefPtr<gfxASurface> currentSurface = mTarget->CurrentSurface();
const gfxRect& targetOpaqueRect = currentSurface->GetOpaqueRect();
// Try to annotate currentSurface with a region of pixels that have been
// (or will be) painted opaque, if no such region is currently set.
if (targetOpaqueRect.IsEmpty() && visibleRegion.GetNumRects() == 1 &&
(aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
!transform.HasNonAxisAlignedTransform()) {
const nsIntRect& bounds = visibleRegion.GetBounds();
currentSurface->SetOpaqueRect(
mTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
pushedTargetOpaqueRect = PR_TRUE;
}
if (needsGroup) {
// If we need to call PushGroup, we should clip to the smallest possible
// area first to minimize the size of the temporary surface.
@@ -1352,6 +1368,10 @@ BasicLayerManager::PaintLayer(Layer* aLayer,
mTarget->Paint(aLayer->GetEffectiveOpacity());
}
if (pushedTargetOpaqueRect) {
currentSurface->SetOpaqueRect(gfxRect(0, 0, 0, 0));
}
if (needsSaveRestore) {
mTarget->Restore();
} else {