Iām looking for a way to assign a Surface (native window) object to a display so that the buffers submitted to that native window would be rendered to that specific display rather than to the main display. I would like to do that in native code.
In Java, it can be done by using the Presentation API.
In native code I tried to call SurfaceComposerClient::setDisplaySurface(), passing to it the display's IBinder object (returned by SurfaceComposerClient::getBuiltInDisplay()), and the IGraphicBufferProducer object (returned by Surface::getIGraphicBufferProducer()).
The problem is that the display goes blank, and even though I'm submitting buffers to the native window nothing is displayed.
If I don't call SurfaceComposerClient::setDisplaySurface(), then the native window renders to the main display.
Sample code:
sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(1));
SurfaceComposerClient::getDisplayInfo(display, &displayInfo);
surfaceControl = surfaceComposerClient->createSurface(String8(""), displayInfo.w, displayInfo.h, HAL_PIXEL_FORMAT_RGB_565);
sp<Surface> surface = surfaceControl->getSurface();
sp<IGraphicBufferProducer> iGraphicBufferProducer = surface->getIGraphicBufferProducer();
SurfaceComposerClient::setDisplaySurface(display, iGraphicBufferProducer);
Does anyone know if this can be accomplished in native code, and if so how ?
Thanks