SF: Define DisplayId as struct type
This prevents accidental mix-up with HWC display IDs, which have the
same backing type, as well as other implicitly convertible integers,
e.g. EDID manufacturer IDs. This CL also fixes misuses detected by
type checking:
1) Recycling of virtual display IDs.
2) Skipping composition for non-HWC virtual displays.
3) Unit tests for fallback/virtual display IDs.
Bug: 74619554
Bug: 119412688
Test: libsurfaceflinger_unittest
Test: vrflinger_test on walleye_xr
Change-Id: I0be41cc93c82860e859f1adf427430436c926595
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index 2e90a59..9d17ef4 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -249,8 +249,8 @@
template <typename PhysicalDisplay>
struct PhysicalDisplayId {};
-template <DisplayId displayId>
-using VirtualDisplayId = std::integral_constant<DisplayId, displayId>;
+template <DisplayId::Type displayId>
+using VirtualDisplayId = std::integral_constant<DisplayId::Type, displayId>;
struct NoDisplayId {};
@@ -279,9 +279,9 @@
}
};
-template <DisplayId displayId>
+template <DisplayId::Type displayId>
struct DisplayIdGetter<VirtualDisplayId<displayId>> {
- static std::optional<DisplayId> get() { return displayId; }
+ static std::optional<DisplayId> get() { return DisplayId{displayId}; }
};
template <>
@@ -1090,7 +1090,7 @@
*/
class GetBestColorModeTest : public DisplayTransactionTest {
public:
- static constexpr DisplayId DEFAULT_DISPLAY_ID = 777;
+ static constexpr DisplayId DEFAULT_DISPLAY_ID = DisplayId{777};
GetBestColorModeTest()
: DisplayTransactionTest(),