Make onVsync return a display id
The caller of this method then turns around and asks HWComposer for the
display id, so we might as well return the id in the first place. Use an
optional so it can return the equivalent of false in the old version.
Use ftl::Concat to save memory allocations.
Factored out from If60218e85292c786b9fa70ecb33ee374d3a385e0 after it was
reverted.
Bug: 255601557
Bug: 256196556
Test: atest libsurfaceflinger_unittest:HWComposerTest
Change-Id: I21be76e20776d8a3f49e5bd295a0042de9e2dde9
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 169e101..0b8d362 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2031,13 +2031,9 @@
Mutex::Autolock lock(mStateLock);
- if (!getHwComposer().onVsync(hwcDisplayId, timestamp)) {
- return;
- }
-
- if (const auto displayId = getHwComposer().toPhysicalDisplayId(hwcDisplayId);
- displayId != mActiveDisplayId) {
- // For now, we don't do anything with non active display vsyncs.
+ if (const auto displayIdOpt = getHwComposer().onVsync(hwcDisplayId, timestamp);
+ displayIdOpt != mActiveDisplayId) {
+ // Ignore VSYNC for invalid/inactive displays.
return;
}