Revert^2 "[SF] Introduce VirtualDisplayId"
This change introduces a new class VirtualDisplayId which is
inherited by HwcVirtualDisplayId and GpuVirtualDisplayId.
HwcVirtualDisplayId replaces the current ids assigned to
virtual displays backed by HWC. GpuVirtualDisplayIds are random
generated IDs assigned to non HWC virtual displays, which currently
don't have IDs. This way all compositionengine/Display and
DisplayDevice objects have a DisplayId.
The logic for ID generation is encapsulated in DisplayIdGenerator.h.
Bug: 162916145
Bug: 160679868
Bug: 137375833
Test: scrcpy on device
Test: atest DisplayIdGeneratorTest
Test: atest libsurfaceflinger_unittest
Test: m WITH_TIDY=1 surfaceflinger
Change-Id: I6e7247d18e3521978dfd8af2dc7b1d36ccaa7313
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 35a8b62..fa684c0 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -27,6 +27,7 @@
#include <math/mat4.h>
#include <renderengine/RenderEngine.h>
#include <system/window.h>
+#include <ui/DisplayId.h>
#include <ui/DisplayInfo.h>
#include <ui/DisplayState.h>
#include <ui/GraphicTypes.h>
@@ -104,7 +105,15 @@
bool needsFiltering() const;
ui::LayerStack getLayerStack() const;
- const std::optional<DisplayId>& getId() const;
+ // Returns the physical ID of this display. This function asserts the ID is physical and it
+ // shouldn't be called for other display types, e.g. virtual.
+ PhysicalDisplayId getPhysicalId() const {
+ const auto displayIdOpt = PhysicalDisplayId::tryCast(getId());
+ LOG_FATAL_IF(!displayIdOpt);
+ return *displayIdOpt;
+ }
+
+ DisplayId getId() const;
const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
int32_t getSequenceId() const { return mSequenceId; }