blast: fix crop and display frame
BufferStateLayers can have an infinite width and height. Check for
this edge case when calculating the Layer's transform.
Test: atest CtsViewTestCases:android.view.cts.ASurfaceControlTest
Bug: 124128940
Change-Id: I01f53483f154076b24cb3cf588026e410b2f87f9
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 756ca42..39defb8 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -204,8 +204,16 @@
}
const Rect win{getBounds()};
- const float bufferWidth = getBufferSize(s).getWidth();
- const float bufferHeight = getBufferSize(s).getHeight();
+ float bufferWidth = getBufferSize(s).getWidth();
+ float bufferHeight = getBufferSize(s).getHeight();
+
+ // BufferStateLayers can have a "buffer size" of [0, 0, -1, -1] when no display frame has
+ // been set and there is no parent layer bounds. In that case, the scale is meaningless so
+ // ignore them.
+ if (!getBufferSize(s).isValid()) {
+ bufferWidth = float(win.right) - float(win.left);
+ bufferHeight = float(win.bottom) - float(win.top);
+ }
const float scaleHeight = (float(win.bottom) - float(win.top)) / bufferHeight;
const float scaleWidth = (float(win.right) - float(win.left)) / bufferWidth;