Bug 1092543. Intersect bufferRect with visibleRect to ensure that the gralloc buffer offset is taken into account. r=sotaro,a=bajaj
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 06 Nov 2014 09:59:10 +1300
changeset 221280 cbe0a91ff5be252b6daad57204d79b10e28f0bf1
parent 221279 ccc2c718b6611f20f0afeb5523fb48f0b35ec3be
child 221295 5d0b1c8cec50e018922577bc2e70d3df35ad2404
push id186
push userrocallahan@mozilla.com
push dateTue, 18 Nov 2014 02:59:45 +0000
treeherdermozilla-b2g34_v2_1@cbe0a91ff5be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro, bajaj
bugs1092543
milestone34.0
Bug 1092543. Intersect bufferRect with visibleRect to ensure that the gralloc buffer offset is taken into account. r=sotaro,a=bajaj
widget/gonk/HwcComposer2D.cpp
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -371,53 +371,51 @@ HwcComposer2D::PrepareLayerList(Layer* a
             if (!PrepareLayerList(children[i], clip, transform)) {
                 return false;
             }
         }
         return true;
     }
 
     LayerRenderState state = aLayer->GetRenderState();
-    nsIntSize surfaceSize;
-    nsIntRect visibleRect = visibleRegion.GetBounds();
 
-    if (state.mSurface.get()) {
-        surfaceSize = state.mSize;
-        // In some cases the visible rect assigned to the layer can be larger
-        // than the layer's surface, e.g., an ImageLayer with a small Image
-        // in it.
-        visibleRect.IntersectRect(visibleRect,
-            nsIntRect(nsIntPoint(0, 0), surfaceSize));
-    } else {
+    if (!state.mSurface.get()) {
         if (aLayer->AsColorLayer() && mColorFill) {
             fillColor = true;
         } else {
             LOGD("%s Layer doesn't have a gralloc buffer", aLayer->Name());
             return false;
         }
     }
-    // Buffer rotation is not to be confused with the angled rotation done by a transform matrix
-    // It's a fancy ThebesLayer feature used for scrolling
-    if (state.BufferRotated()) {
-        LOGD("%s Layer has a rotated buffer", aLayer->Name());
-        return false;
-    }
+
+    nsIntRect visibleRect = visibleRegion.GetBounds();
 
     nsIntRect bufferRect;
     if (fillColor) {
         bufferRect = nsIntRect(visibleRect);
     } else {
-        if(state.mHasOwnOffset) {
+        if (state.mHasOwnOffset) {
             bufferRect = nsIntRect(state.mOffset.x, state.mOffset.y,
                                    state.mSize.width, state.mSize.height);
         } else {
             //Since the buffer doesn't have its own offset, assign the whole
             //surface size as its buffer bounds
             bufferRect = nsIntRect(0, 0, state.mSize.width, state.mSize.height);
         }
+        // In some cases the visible rect assigned to the layer can be larger
+        // than the layer's surface, e.g., an ImageLayer with a small Image
+        // in it.
+        visibleRect.IntersectRect(visibleRect, bufferRect);
+    }
+
+    // Buffer rotation is not to be confused with the angled rotation done by a transform matrix
+    // It's a fancy PaintedLayer feature used for scrolling
+    if (state.BufferRotated()) {
+        LOGD("%s Layer has a rotated buffer", aLayer->Name());
+        return false;
     }
 
     hwc_rect_t sourceCrop, displayFrame;
     if(!HwcUtils::PrepareLayerRects(visibleRect,
                           transform,
                           clip,
                           bufferRect,
                           state.YFlipped(),