Bug 1067748. When a solid-color display item covers everything else in its layer, make it a ColorLayer. r=tn
☠☠ backed out by 5ab71e736ba4 ☠ ☠
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 16 Sep 2014 16:27:14 +1200
changeset 205579 ec335dbccfbdf490769fa7e8e45f4f8f36e55a13
parent 205443 3b7921328fc126999fa908e6379cbd555d028c50
child 205580 66bad3def0255c3a692a6f1fed1781a9c1856292
push id27498
push userkwierso@gmail.com
push dateWed, 17 Sep 2014 00:06:56 +0000
treeherdermozilla-central@8252eae8278c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1067748
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1067748. When a solid-color display item covers everything else in its layer, make it a ColorLayer. r=tn
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -2344,33 +2344,34 @@ ThebesLayerData::Accumulate(ContainerSta
     FLB_LOG_THEBES_DECISION(this, "  Tracking image\n");
   } else if (mImage) {
     FLB_LOG_THEBES_DECISION(this, "  No longer tracking image\n");
     mImage = nullptr;
   }
   bool clipMatches = mItemClip == aClip;
   mItemClip = aClip;
 
-  if (!mIsSolidColorInVisibleRegion && mOpaqueRegion.Contains(aDrawRect) &&
+  nscolor uniformColor;
+  bool isUniform = aItem->IsUniform(aState->mBuilder, &uniformColor);
+
+  if (!mIsSolidColorInVisibleRegion && !isUniform &&
+      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
     // and mDrawRegion don't need updating. mVisibleRegion contains aVisibleRect
     // already, mOpaqueRegion contains aDrawRect and therefore whatever
     // the opaque region of the item is. mDrawRegion must contain mOpaqueRegion
     // and therefore aDrawRect.
     NS_ASSERTION(mDrawRegion.Contains(aDrawRect), "Draw region not covered");
     return;
   }
 
-  nscolor uniformColor;
-  bool isUniform = aItem->IsUniform(aState->mBuilder, &uniformColor);
-
   // Some display items have to exist (so they can set forceTransparentSurface
   // below) but don't draw anything. They'll return true for isUniform but
   // a color with opacity 0.
   if (!isUniform || NS_GET_A(uniformColor) > 0) {
     // Make sure that the visible area is covered by uniform pixels. In
     // particular this excludes cases where the edges of the item are not
     // pixel-aligned (thus the item will not be truly uniform).
     if (isUniform) {
@@ -2381,16 +2382,21 @@ ThebesLayerData::Accumulate(ContainerSta
         FLB_LOG_THEBES_DECISION(this, "  Display item does not cover the visible rect\n");
       }
     }
     if (isUniform) {
       if (mVisibleRegion.IsEmpty()) {
         // This color is all we have
         mSolidColor = uniformColor;
         mIsSolidColorInVisibleRegion = true;
+      } else if (NS_GET_A(uniformColor) == 255 &&
+                 aVisibleRect.Contains(mVisibleRegion.GetBounds())) {
+        // This color covers everything else in the layer
+        mSolidColor = uniformColor;
+        mIsSolidColorInVisibleRegion = true;
       } else if (mIsSolidColorInVisibleRegion &&
                  mVisibleRegion.IsEqual(nsIntRegion(aVisibleRect)) &&
                  clipMatches) {
         // we can just blend the colors together
         mSolidColor = NS_ComposeColors(mSolidColor, uniformColor);
       } else {
         FLB_LOG_THEBES_DECISION(this, "  Layer not a solid color: Can't blend colors togethers\n");
         mIsSolidColorInVisibleRegion = false;