Bug 1092543. Intersect bufferRect with visibleRect to ensure that the gralloc buffer offset is taken into account. r=sotaro
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 06 Nov 2014 09:59:10 +1300
changeset 214227 76f74579c68344806b4a78ce4220190ee373f398
parent 214226 75546036a6ededb40fc5140e686d5a83845f8793
child 214228 f786dcb23eca2941a3c2710351c176a97a37efca
push id51438
push userrocallahan@mozilla.com
push dateThu, 06 Nov 2014 00:21:40 +0000
treeherdermozilla-inbound@76f74579c683 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1092543, 1073252
milestone36.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 1092543. Intersect bufferRect with visibleRect to ensure that the gralloc buffer offset is taken into account. r=sotaro The patch in bug 1073252 assumed that the gralloc buffer is always at (0,0,w,h) in layer coordinates, which is incorrect. When intersecting the gralloc buffer bounds with the visible rect, we need to take the gralloc buffer's offset (state.mOffset) into account. Fortunately bufferRect already contains this, so let's just use that.
widget/gonk/HwcComposer2D.cpp
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -390,53 +390,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 (aLayer->AsColorLayer() && mColorFill) {
-            fillColor = true;
-        } else {
-            LOGD("%s Layer doesn't have a gralloc buffer", aLayer->Name());
-            return false;
-        }
+    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 PaintedLayer 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(),