SF: Avoid updating clients with stale or incorrect transform hints
When the layer is removed from a display or the display the layer is on
is turned off, the client will continue to receive transform hint
updates via the transaction complete callback using the default/active
displays install orientation. Once the layer is back on the display and
it does not submit a new frame, a buffer with a suboptimal transform
may remain on display.
Fix this by not reporting stale/incorrect values via the callback. Once
the layer is reparent back to the display and the display state is not
OFF, it will continue to get hints via the callback.
For special cases where we want the app to draw its first frame before
the display is available, we rely on WMS and DMS to provide the right
information so the client can calculate the hint.
Bug: 251360251
Test: move app between displays, rotate, check final buffer transforms
Change-Id: I0a9abac7e9cf4ade1c49ec400e73b634c8269b4b
diff --git a/services/surfaceflinger/TransactionCallbackInvoker.h b/services/surfaceflinger/TransactionCallbackInvoker.h
index 23ea7a5..61ff9bc 100644
--- a/services/surfaceflinger/TransactionCallbackInvoker.h
+++ b/services/surfaceflinger/TransactionCallbackInvoker.h
@@ -19,6 +19,7 @@
#include <condition_variable>
#include <deque>
#include <mutex>
+#include <optional>
#include <queue>
#include <thread>
#include <unordered_map>
@@ -48,7 +49,7 @@
std::vector<ftl::SharedFuture<FenceResult>> previousReleaseFences;
std::variant<nsecs_t, sp<Fence>> acquireTimeOrFence = -1;
nsecs_t latchTime = -1;
- uint32_t transformHint = 0;
+ std::optional<uint32_t> transformHint = std::nullopt;
uint32_t currentMaxAcquiredBufferCount = 0;
std::shared_ptr<FenceTime> gpuCompositionDoneFence{FenceTime::NO_FENCE};
CompositorTiming compositorTiming;