Fix virtual displays for HWC<=1.1
If we're using a HWC that doesn't support virtual displays, or we have
more virtual displays than HWC supports concurrently, the
VirtualDisplaySurface should simply be a passthrough from source
(GLES) to sink.
This change also tries to distinguish between display types and HWC
display IDs a little better, though there's more to do here. Probably
needs a higher-level rethink; it's too error-prone now.
Bug: 8446838
Change-Id: I708d2cf262ec30177042304f174ca5b8da701df1
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2df279a..0a210f7 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -510,7 +510,8 @@
wp<IBinder> token = mBuiltinDisplays[i];
sp<DisplayDevice> hw = new DisplayDevice(this,
- type, isSecure, token, new FramebufferSurface(*mHwc, i),
+ type, allocateHwcDisplayId(type), isSecure, token,
+ new FramebufferSurface(*mHwc, i),
mEGLConfig);
if (i > DisplayDevice::DISPLAY_PRIMARY) {
// FIXME: currently we don't get blank/unblank requests
@@ -1149,10 +1150,11 @@
const DisplayDeviceState& state(curr[i]);
sp<DisplaySurface> dispSurface;
+ int32_t hwcDisplayId = allocateHwcDisplayId(state.type);
if (state.isVirtualDisplay()) {
if (state.surface != NULL) {
dispSurface = new VirtualDisplaySurface(
- *mHwc, state.type, state.surface,
+ *mHwc, hwcDisplayId, state.surface,
state.displayName);
}
} else {
@@ -1169,8 +1171,8 @@
const wp<IBinder>& display(curr.keyAt(i));
if (dispSurface != NULL) {
sp<DisplayDevice> hw = new DisplayDevice(this,
- state.type, state.isSecure, display,
- dispSurface, mEGLConfig);
+ state.type, hwcDisplayId, state.isSecure,
+ display, dispSurface, mEGLConfig);
hw->setLayerStack(state.layerStack);
hw->setProjection(state.orientation,
state.viewport, state.frame);