summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Nair <vishnun@google.com>2021-05-10 15:01:20 -0700
committerVishnu Nair <vishnun@google.com>2021-05-11 10:55:24 -0700
commit0d7aff7b35de87347a1c9871acf20b9954ba4106 (patch)
tree561d37e545b9136885d3f8824465b8b70f001af0
parentff09af37dd4a88119362ed396f31ace31e95ebf6 (diff)
Remove rotation based scaling
In order to simplify some of the geometry logic in BufferStateLayer, and unify with the rest of the layer in SurfaceFlinger we translate the concept of source and dest frame into crop, scale and position. This is currently done on the client side. But if there is buffer rotation transform, we will generate an additional scale, to scale the buffer size to the new orientation. This causes issues with rounded corners because the additional scale stretches the rounded corner incorrectly. And translating the buffer rotation into a rotation matrix affects child layers. This solution only adjusts the buffer size based on the rotation matrix and the scale is generated based on the rotated buffer. This cannot be done in the client side because we do not have the current display orientation to unflip the buffer if the client sets the transformToDisplayInverse flag. In the future the plan is to drive the transform hint and the display orientation down from WM so this calculation can go back to the client. Also fixes incorrect additional scaling from source frame to dest frame in ASurfaceTransaction_setGeometry. Test: atest SurfaceControlTest ASurfaceControlTest libgui_test SurfaceFlinger_test Test: go/wm-smoke Bug: 185597146 Change-Id: I38adbc72c7567510c953cfd362a94b2b38d7fda7
-rw-r--r--native/android/surface_control.cpp23
1 files changed, 1 insertions, 22 deletions
diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp
index a8c2ea544d38..93a54445a033 100644
--- a/native/android/surface_control.cpp
+++ b/native/android/surface_control.cpp
@@ -454,28 +454,7 @@ void ASurfaceTransaction_setGeometry(ASurfaceTransaction* aSurfaceTransaction,
sourceRect.makeInvalid();
}
transaction->setBufferCrop(surfaceControl, sourceRect);
-
- int destW = destRect.width();
- int destH = destRect.height();
- if (destRect.left < 0) {
- destRect.left = 0;
- destRect.right = destW;
- }
- if (destRect.top < 0) {
- destRect.top = 0;
- destRect.bottom = destH;
- }
-
- if (!sourceRect.isEmpty()) {
- float sx = destW / static_cast<float>(sourceRect.width());
- float sy = destH / static_cast<float>(sourceRect.height());
- transaction->setPosition(surfaceControl, destRect.left - (sourceRect.left * sx),
- destRect.top - (sourceRect.top * sy));
- transaction->setMatrix(surfaceControl, sx, 0, 0, sy);
- } else {
- transaction->setPosition(surfaceControl, destRect.left, destRect.top);
- }
-
+ transaction->setDestinationFrame(surfaceControl, destRect);
transaction->setTransform(surfaceControl, transform);
bool transformToInverseDisplay = (NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY & transform) ==
NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;