Bug 1059023 - Do not compose layer hidden under the opaque layer. r=mattwoodrow
authorSushil Chauhan <sushilchauhan@codeaurora.org>
Thu, 28 Aug 2014 10:44:03 -0700
changeset 223954 0849d066f121d01720597584b511b8e9178909fb
parent 223953 9ef1298abf22cd46e74dbb6723195da51fa663c6
child 223955 103cf4c29d7f82f8e005eeb3ffd9781ec604a16a
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1059023
milestone34.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 1059023 - Do not compose layer hidden under the opaque layer. r=mattwoodrow
widget/gonk/HwcComposer2D.cpp
widget/gonk/HwcUtils.cpp
widget/gonk/HwcUtils.h
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -392,27 +392,31 @@ HwcComposer2D::PrepareLayerList(Layer* a
                           &(displayFrame)))
     {
         return true;
     }
 
     // OK!  We can compose this layer with hwc.
     int current = mList ? mList->numHwLayers : 0;
 
-    // Do not compose any layer below full-screen Opaque layer
-    // Note: It can be generalized to non-fullscreen Opaque layers.
     bool isOpaque = (opacity == 0xFF) && (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
     if (current && isOpaque) {
-        nsIntRect displayRect = nsIntRect(displayFrame.left, displayFrame.top,
-            displayFrame.right - displayFrame.left, displayFrame.bottom - displayFrame.top);
+        nsIntRect displayRect = HwcUtils::HwcToIntRect(displayFrame);
         if (displayRect.Contains(mScreenRect)) {
-            // In z-order, all previous layers are below
-            // the current layer. We can ignore them now.
+            // In z-order, all previous layers are below current layer
+            // Do not compose any layer below full-screen opaque layer
             mList->numHwLayers = current = 0;
             mHwcLayerMap.Clear();
+        } else {
+            nsIntRect rect = HwcUtils::HwcToIntRect(mList->hwLayers[current-1].displayFrame);
+            if (displayRect.Contains(rect)) {
+                // Do not compose layer hidden under the opaque layer
+                mHwcLayerMap.RemoveElementAt(current-1);
+                current = --mList->numHwLayers;
+            }
         }
     }
 
     if (!mList || current >= mMaxLayerCount) {
         if (!ReallocLayerList() || current >= mMaxLayerCount) {
             LOGE("PrepareLayerList failed! Could not increase the maximum layer count");
             return false;
         }
--- a/widget/gonk/HwcUtils.cpp
+++ b/widget/gonk/HwcUtils.cpp
@@ -141,9 +141,15 @@ HwcUtils::CalculateClipRect(const gfx::M
     gfxRect trClip = aTransform.TransformBounds(r);
     trClip.Round();
     gfxUtils::GfxRectToIntRect(trClip, &clip);
 
     aRenderClip->IntersectRect(*aRenderClip, clip);
     return true;
 }
 
+nsIntRect
+HwcUtils::HwcToIntRect(hwc_rect_t aRect) {
+    return nsIntRect(aRect.left, aRect.top, aRect.right - aRect.left,
+                aRect.bottom - aRect.top);
+}
+
 } // namespace mozilla
--- a/widget/gonk/HwcUtils.h
+++ b/widget/gonk/HwcUtils.h
@@ -113,13 +113,16 @@ static bool PrepareVisibleRegion(const n
  *         false if the layer can be skipped
  */
 static bool PrepareLayerRects(nsIntRect aVisible, const gfx::Matrix& aTransform,
                               nsIntRect aClip, nsIntRect aBufferRect,
                               bool aYFlipped,
                               hwc_rect_t* aSourceCrop,
                               hwc_rect_t* aVisibleRegionScreen);
 
+/* Converts hwc_rect_t to nsIntRect */
+static nsIntRect HwcToIntRect(hwc_rect_t aRect);
+
 };
 
 } // namespace mozilla
 
 #endif // mozilla_HwcUtils