SF: Extract virtual display allocation from CE
Allocate HAL virtual display and generate HAL/GPU virtual display ID in
SF rather than CE. This centralizes the HAL vs. GPU decision as a first
step in isolating display configuration (e.g. hotplug, modeset) to be a
distinct stage from invalidate/refresh.
Rework SF backend hooks for screen capture. Plumb the PhysicalDisplayId
to be mirrored by the virtual display to Composer::createVirtualDisplay.
This enables the ARC backend to know which display to mirror (instead of
making assumptions about the layer stack) or error out if not mirroring
(previously done through maybeAllocateDisplayIdForVirtualDisplay), such
that SF falls back to creating a GPU virtual display.
Bug: 182939859
Bug: 129481165
Test: Enable overlay display and toggle HAL/GPU
Test: libsurfaceflinger_unittest
Test: libcompositionengine_test
Change-Id: I209b245966e544d5ff55d5d118140cfcfa85db15
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index bf249cd..33c2563 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -103,15 +103,21 @@
bool needsFiltering() const;
ui::LayerStack getLayerStack() 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.
+ DisplayId getId() const;
+
+ // Shorthand to upcast the ID of a display whose type is known as a precondition.
PhysicalDisplayId getPhysicalId() const {
- const auto displayIdOpt = PhysicalDisplayId::tryCast(getId());
- LOG_FATAL_IF(!displayIdOpt);
- return *displayIdOpt;
+ const auto id = PhysicalDisplayId::tryCast(getId());
+ LOG_FATAL_IF(!id);
+ return *id;
}
- DisplayId getId() const;
+ VirtualDisplayId getVirtualId() const {
+ const auto id = VirtualDisplayId::tryCast(getId());
+ LOG_FATAL_IF(!id);
+ return *id;
+ }
+
const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
int32_t getSequenceId() const { return mSequenceId; }