Bug 971720 - Allow ThebesLayers to be optimized to ColorLayers even if they have rounded rect clipping. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Sat, 01 Mar 2014 08:52:03 +1300
changeset 171606 253efc28d705366a486972686c6457c2d5dc0d62
parent 171605 9a491cb7be311581a31b70605b347026320a405d
child 171607 4895aa1f1ee50b434c3f3d6ff86bc64d164511c5
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersroc
bugs971720
milestone30.0a1
Bug 971720 - Allow ThebesLayers to be optimized to ColorLayers even if they have rounded rect clipping. r=roc
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -2060,16 +2060,17 @@ ThebesLayerData::Accumulate(ContainerSta
    * we are the first visible item in the ThebesLayerData object.
    */
   if (mVisibleRegion.IsEmpty() &&
       aItem->SupportsOptimizingToImage()) {
     mImage = static_cast<nsDisplayImageContainer*>(aItem);
   } else {
     mImage = nullptr;
   }
+  bool clipMatches = mItemClip == aClip;
   mItemClip = aClip;
 
   if (!mIsSolidColorInVisibleRegion && mOpaqueRegion.Contains(aDrawRect) &&
       mVisibleRegion.Contains(aVisibleRect)) {
     // A very common case! Most pages have a ThebesLayer with the page
     // background (opaque) visible and most or all of the page content over the
     // top of that background.
     // The rest of this method won't do anything. mVisibleRegion, mOpaqueRegion
@@ -2093,23 +2094,24 @@ ThebesLayerData::Accumulate(ContainerSta
     // pixel-aligned (thus the item will not be truly uniform).
     if (isUniform) {
       bool snap;
       nsRect bounds = aItem->GetBounds(aState->mBuilder, &snap);
       if (!aState->ScaleToInsidePixels(bounds, snap).Contains(aVisibleRect)) {
         isUniform = false;
       }
     }
-    if (isUniform && aClip.GetRoundedRectCount() == 0) {
+    if (isUniform) {
       if (mVisibleRegion.IsEmpty()) {
         // This color is all we have
         mSolidColor = uniformColor;
         mIsSolidColorInVisibleRegion = true;
       } else if (mIsSolidColorInVisibleRegion &&
-                 mVisibleRegion.IsEqual(nsIntRegion(aVisibleRect))) {
+                 mVisibleRegion.IsEqual(nsIntRegion(aVisibleRect)) &&
+                 clipMatches) {
         // we can just blend the colors together
         mSolidColor = NS_ComposeColors(mSolidColor, uniformColor);
       } else {
         mIsSolidColorInVisibleRegion = false;
       }
     } else {
       mIsSolidColorInVisibleRegion = false;
     }