SurfaceFlinger: Peek in current state for transform hint
Imagine a sequence like this:
1. Apply transaction to rotate display
2. Create surface
3. Transaction to rotate display processed
From a client perspective we executed 2 after 1 and would expect it
to observe the new transform hint, but it may not due so
due to the waiting for current->drawing state swap. Since we hold
the lock on the binder thread we can peek in the current state and
return the most recent hint.
Bug: 184584284
Test: Existing tests pass
Change-Id: Ic4927f517757c3c3dcfc1570e66b40ed370496de
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f7c9291..fe9da76 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3267,8 +3267,12 @@
}
}
- if (const auto display = getDefaultDisplayDeviceLocked()) {
- lbc->updateTransformHint(display->getTransformHint());
+ if (const auto token = getInternalDisplayTokenLocked()) {
+ const ssize_t index = mCurrentState.displays.indexOfKey(token);
+ if (index >= 0) {
+ const DisplayDeviceState& state = mCurrentState.displays.valueAt(index);
+ lbc->updateTransformHint(ui::Transform::toRotationFlags(state.orientation));
+ }
}
if (outTransformHint) {
*outTransformHint = lbc->getTransformHint();