mirror of
https://github.com/labwc/labwc.git
synced 2026-04-06 07:15:40 -04:00
server: allow external renderer and allocator on Android
On Android, the standard wlr_renderer_autocreate() and wlr_allocator_autocreate() paths fail because there is no DRM subsystem. Android apps create EGL contexts via eglGetDisplay() and provide GPU buffers via AHardwareBuffer. Add hooks guarded by #ifdef __ANDROID__ that check for externally provided renderer/allocator globals before falling back to autocreate. This allows the JNI bridge to: 1. Create an EGL context via Android's native EGL 2. Wrap it in wlr_egl_create_with_context() 3. Create a GLES2 renderer via wlr_gles2_renderer_create() 4. Provide a custom allocator (e.g. AHardwareBuffer-based) The globals (android_renderer, android_allocator) are declared extern and only referenced when __ANDROID__ is defined, so there is no impact on non-Android builds. Ref: https://github.com/GlassOnTin/Haven/issues/47
This commit is contained in:
parent
9a8154836c
commit
c902d6d6a8
1 changed files with 21 additions and 3 deletions
24
src/server.c
24
src/server.c
|
|
@ -502,7 +502,17 @@ server_init(void)
|
|||
* The renderer is responsible for defining the various pixel formats it
|
||||
* supports for shared memory, this configures that for clients.
|
||||
*/
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
#ifdef __ANDROID__
|
||||
/* Android: accept externally created renderer (e.g. GLES2 via
|
||||
* eglGetDisplay + wlr_egl_create_with_context) */
|
||||
extern struct wlr_renderer *android_renderer;
|
||||
if (android_renderer) {
|
||||
server.renderer = android_renderer;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
}
|
||||
if (!server.renderer) {
|
||||
wlr_log(WLR_ERROR, "unable to create renderer");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -541,8 +551,16 @@ server_init(void)
|
|||
* the renderer and the backend. It handles the buffer creation,
|
||||
* allowing wlroots to render onto the screen
|
||||
*/
|
||||
server.allocator = wlr_allocator_autocreate(
|
||||
server.backend, server.renderer);
|
||||
#ifdef __ANDROID__
|
||||
extern struct wlr_allocator *android_allocator;
|
||||
if (android_allocator) {
|
||||
server.allocator = android_allocator;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
server.allocator = wlr_allocator_autocreate(
|
||||
server.backend, server.renderer);
|
||||
}
|
||||
if (!server.allocator) {
|
||||
wlr_log(WLR_ERROR, "unable to create allocator");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue