Bug 602757. Part 6: Don't limit complexity of opaque region when adding opaque chrome display items. r=tnikkel,a=blocking
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -916,16 +916,23 @@ SuppressComponentAlpha(nsDisplayListBuil
for (nsIFrame* t = f; t; t = t->GetParent()) {
if (t->IsTransformed())
return PR_FALSE;
}
return windowTransparentRegion->Intersects(aComponentAlphaBounds);
}
+static PRBool
+WindowHasTransparency(nsDisplayListBuilder* aBuilder)
+{
+ const nsRegion* windowTransparentRegion = aBuilder->GetFinalTransparentRegion();
+ return windowTransparentRegion && !windowTransparentRegion->IsEmpty();
+}
+
void
ContainerState::ThebesLayerData::Accumulate(nsDisplayListBuilder* aBuilder,
nsDisplayItem* aItem,
const nsIntRect& aVisibleRect,
const nsIntRect& aDrawRect,
const FrameLayerBuilder::Clip& aClip)
{
nscolor uniformColor;
@@ -959,17 +966,22 @@ ContainerState::ThebesLayerData::Accumul
// We don't use SimplifyInward here since it's not defined exactly
// what it will discard. For our purposes the most important case
// is a large opaque background at the bottom of z-order (e.g.,
// a canvas background), so we need to make sure that the first rect
// we see doesn't get discarded.
nsIntRect rect = aClip.ApproximateIntersect(*r).ToNearestPixels(appUnitsPerDevPixel);
nsIntRegion tmp;
tmp.Or(mOpaqueRegion, rect);
- if (tmp.GetNumRects() <= 4) {
+ // Opaque display items in chrome documents whose window is partially
+ // transparent are always added to the opaque region. This helps ensure
+ // that we get as much subpixel-AA as possible in the chrome.
+ if (tmp.GetNumRects() <= 4 ||
+ (WindowHasTransparency(aBuilder) &&
+ aItem->GetUnderlyingFrame()->PresContext()->IsChrome())) {
mOpaqueRegion = tmp;
}
}
}
nsRect componentAlpha = aItem->GetComponentAlphaBounds(aBuilder);
componentAlpha.IntersectRect(componentAlpha, aItem->GetVisibleRect());
if (!componentAlpha.IsEmpty()) {
nscoord appUnitsPerDevPixel = AppUnitsPerDevPixel(aItem);