/** * Returns a rectangle of content painted opaquely by aLayer. Very consertative; * bails by returning an empty rect in any tricky situations. */ static nsIntRect GetOpaqueRect(Layer* aLayer) { nsIntRect result; // Just bail if there's anything difficult to handle. if (!aLayer->GetEffectiveTransform().IsIdentity() || aLayer->GetEffectiveOpacity() != 1.0f || aLayer->GetMaskLayer()) { return result; } if (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) { result = aLayer->GetEffectiveVisibleRegion().GetLargestRectangle(); } else { // Drill down into RefLayers because that's what we particularly care about; // layer construction for aLayer will not have known about the opaqueness // of any RefLayer subtrees. RefLayer* refLayer = aLayer->AsRefLayer(); if (refLayer && refLayer->GetFirstChild()) { result = GetOpaqueRect(refLayer->GetFirstChild()); } } const nsIntRect* clipRect = aLayer->GetEffectiveClipRect(); if (clipRect) { result.IntersectRect(result, *clipRect); } return result; }
/** * Returns a rectangle of content painted opaquely by aLayer. Very consertative; * bails by returning an empty rect in any tricky situations. */ static nsIntRect GetOpaqueRect(Layer* aLayer) { nsIntRect result; gfx::Matrix matrix; bool is2D = aLayer->GetBaseTransform().Is2D(&matrix); // Just bail if there's anything difficult to handle. if (!is2D || aLayer->GetMaskLayer() || aLayer->GetEffectiveOpacity() != 1.0f || matrix.HasNonIntegerTranslation()) { return result; } if (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) { result = aLayer->GetEffectiveVisibleRegion().GetLargestRectangle(); } else { // Drill down into RefLayers because that's what we particularly care about; // layer construction for aLayer will not have known about the opaqueness // of any RefLayer subtrees. RefLayer* refLayer = aLayer->AsRefLayer(); if (refLayer && refLayer->GetFirstChild()) { result = GetOpaqueRect(refLayer->GetFirstChild()); } } // Translate our opaque region to cover the child gfx::Point point = matrix.GetTranslation(); result.MoveBy(static_cast<int>(point.x), static_cast<int>(point.y)); const nsIntRect* clipRect = aLayer->GetEffectiveClipRect(); if (clipRect) { result.IntersectRect(result, *clipRect); } return result; }