Android native code: Assigning a Surface to a specific display

﹥>﹥吖頭↗ 提交于 2021-01-26 18:21:43

问题


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

来源:https://stackoverflow.com/questions/26660882/android-native-code-assigning-a-surface-to-a-specific-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!