Bug 602757. Part 6: Don't limit complexity of opaque region when adding opaque chrome display items. r=tnikkel,a=blocking
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 03 Jan 2011 14:48:09 +1300
changeset 59782 836e01a2a6dc041d6d730f1fa3509284990816fd
parent 59781 b804550e79d746172c578ea169f752f36f75abab
child 59783 c20f34eefa5dbe69a12d310b202b47761d6fcb58
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewerstnikkel, blocking
bugs602757
milestone2.0b9pre
Bug 602757. Part 6: Don't limit complexity of opaque region when adding opaque chrome display items. r=tnikkel,a=blocking
layout/base/FrameLayerBuilder.cpp
--- 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);