Bug 641770. Ensure that the cliprect for a layer is interpreted in the coordinate system of its container in MarkLeafLayersCoveredByOpaque. r=bas

This commit is contained in:
Robert O'Callahan 2011-04-01 10:33:46 +13:00
parent 2030c35c8b
commit 023d0fa5da

View File

@ -1259,6 +1259,7 @@ TransformIntRect(nsIntRect& aRect, const gfxMatrix& aMatrix,
// This implementation assumes that GetEffectiveTransform transforms
// all layers to the same coordinate system. It can't be used as is
// by accelerated layers because of intermediate surfaces.
// aClipRect and aRegion are in that global coordinate system.
static void
MarkLeafLayersCoveredByOpaque(Layer* aLayer, const nsIntRect& aClipRect,
nsIntRegion& aRegion)
@ -1267,7 +1268,6 @@ MarkLeafLayersCoveredByOpaque(Layer* aLayer, const nsIntRect& aClipRect,
BasicImplData* data = ToData(aLayer);
data->SetCoveredByOpaque(PR_FALSE);
const nsIntRect* clipRect = aLayer->GetEffectiveClipRect();
nsIntRect newClipRect(aClipRect);
// Allow aLayer or aLayer's descendants to cover underlying layers
@ -1277,14 +1277,21 @@ MarkLeafLayersCoveredByOpaque(Layer* aLayer, const nsIntRect& aClipRect,
newClipRect.SetRect(0, 0, 0, 0);
}
if (clipRect) {
nsIntRect cr = *clipRect;
gfxMatrix tr;
if (aLayer->GetEffectiveTransform().Is2D(&tr)) {
TransformIntRect(cr, tr, ToInsideIntRect);
{
const nsIntRect* clipRect = aLayer->GetEffectiveClipRect();
if (clipRect) {
nsIntRect cr = *clipRect;
// clipRect is in the container's coordinate system. Get it into the
// global coordinate system.
if (aLayer->GetParent()) {
gfxMatrix tr;
if (aLayer->GetParent()->GetEffectiveTransform().Is2D(&tr)) {
TransformIntRect(cr, tr, ToInsideIntRect);
} else {
cr.SetRect(0, 0, 0, 0);
}
}
newClipRect.IntersectRect(newClipRect, cr);
} else {
newClipRect.SetRect(0, 0, 0, 0);
}
}