Allow creating child surfaces from BlastBufferQueue

App such as Chrome create child surfaces and parent them to
surfaces provided by SurfaceView. When we enable the blast
adapter for SurfaceView, the IGBP returned to the app is
created in the client and SurfaceFlinger does not know about it.
When the app creates a child surface and provides the IGBP as the
parent surface identifier, SF fails to validate the IGBP and the
surface is not created. This can be avoid if the client creates the
child surface from the SV SurfaceControl but we still need to
support existing APIs.

To fix this, when we create a Surface from the adapter, pass in
the handle of the Blast SurfaceControl. When calling
ASurfaceControl_createFromWindow, use this handle to identify
the parent.

Bug: 168917217
Test: adb shell settings put global use_blast_adapter_sv 1 & launch chrome
Change-Id: I879b411c47e8558397516bd7b7278813e79e005f
This commit is contained in:
Vishnu Nair
2020-10-22 17:41:30 -07:00
parent d544d34cd2
commit ce1a648484
7 changed files with 46 additions and 16 deletions

View File

@@ -137,12 +137,24 @@ ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* window, const c
return nullptr;
}
Surface* surface = static_cast<Surface*>(window);
sp<IBinder> parentHandle = surface->getSurfaceControlHandle();
uint32_t flags = ISurfaceComposerClient::eFXSurfaceBufferState;
sp<SurfaceControl> surfaceControl =
client->createWithSurfaceParent(String8(debug_name), 0 /* width */, 0 /* height */,
// Format is only relevant for buffer queue layers.
PIXEL_FORMAT_UNKNOWN /* format */, flags,
static_cast<Surface*>(window));
sp<SurfaceControl> surfaceControl;
if (parentHandle) {
surfaceControl =
client->createSurface(String8(debug_name), 0 /* width */, 0 /* height */,
// Format is only relevant for buffer queue layers.
PIXEL_FORMAT_UNKNOWN /* format */, flags, parentHandle);
} else {
surfaceControl =
client->createWithSurfaceParent(String8(debug_name), 0 /* width */, 0 /* height */,
// Format is only relevant for buffer queue layers.
PIXEL_FORMAT_UNKNOWN /* format */, flags,
static_cast<Surface*>(window));
}
if (!surfaceControl) {
return nullptr;
}
@@ -164,7 +176,7 @@ ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* deb
client->createSurface(String8(debug_name), 0 /* width */, 0 /* height */,
// Format is only relevant for buffer queue layers.
PIXEL_FORMAT_UNKNOWN /* format */, flags,
surfaceControlParent);
surfaceControlParent->getHandle());
if (!surfaceControl) {
return nullptr;
}