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.
Test: atest SurfaceControlTest ASurfaceControlTest libgui_test SurfaceFlinger_test
Test: go/wm-smoke
Bug: 185597146, 186191378
Change-Id: Ia566f952f5efe765382434dbc460b4815165f4f5
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index beda834..3edbe1d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2816,16 +2816,19 @@
}
void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) {
- /*
- * Traversal of the children
- * (perform the transaction for each of them if needed)
- */
+ // Commit display transactions
+ const bool displayTransactionNeeded = transactionFlags & eDisplayTransactionNeeded;
+ if (displayTransactionNeeded) {
+ processDisplayChangesLocked();
+ processDisplayHotplugEventsLocked();
+ }
- if ((transactionFlags & eTraversalNeeded) || mForceTraversal) {
- mForceTraversal = false;
+ // Commit layer transactions. This needs to happen after display transactions are
+ // committed because some geometry logic relies on display orientation.
+ if ((transactionFlags & eTraversalNeeded) || mForceTraversal || displayTransactionNeeded) {
mCurrentState.traverse([&](Layer* layer) {
uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded);
- if (!trFlags) return;
+ if (!trFlags && !displayTransactionNeeded) return;
const uint32_t flags = layer->doTransaction(0);
if (flags & Layer::eVisibleRegion)
@@ -2837,15 +2840,7 @@
});
}
- /*
- * Perform display own transactions if needed
- */
-
- if (transactionFlags & eDisplayTransactionNeeded) {
- processDisplayChangesLocked();
- processDisplayHotplugEventsLocked();
- }
-
+ // Update transform hint
if (transactionFlags & (eTransformHintUpdateNeeded | eDisplayTransactionNeeded)) {
// The transform hint might have changed for some layers
// (either because a display has changed, or because a layer
@@ -4039,6 +4034,11 @@
flags |= eTraversalNeeded;
}
}
+ if (what & layer_state_t::eDestinationFrameChanged) {
+ if (layer->setDestinationFrame(s.destinationFrame)) {
+ flags |= eTraversalNeeded;
+ }
+ }
// This has to happen after we reparent children because when we reparent to null we remove
// child layers from current state and remove its relative z. If the children are reparented in
// the same transaction, then we have to make sure we reparent the children first so we do not