tareksander / termux-gfx-wrapper

Mozilla Public License 2.0
19 stars 1 forks source link

EGL Wayland support #2

Open tareksander opened 1 year ago

tareksander commented 1 year ago
twaik commented 1 year ago

Write to a wl_shm wl_buffer like to an X11 pixmap

You can use simple wl_shm buffer just like any other app... No need to implement something new.

Try to create wl_shm buffers from HardwareBuffer DMABUF fd

You should not do that. You can create wl_buffer with line of code like that:

wl_resource_create(client, &wl_buffer_interface, 1, id);

You can assign it any data you want (with wl_resource_set_user_data). But it should be done from some other interface, with passing this wl_buffer as a parameter.

Make a custom protocol for sharing AHardwareBuffers with the compositor as wl_buffer objects

Also no need to implement something new. Wayland passes xkbmaps in a file descriptor. I mean compositor must create shared memory fragment, mmap it, fill with needed data (pre-compiled or built from scratch with libxkbcommon), unmap it and pass to client with wl_keyboard_send_keymap call...

You can create socketpair, pass one of sockets to client (or server, depends on the place where you want to create buffers) and pass buffer with AHardwareBuffer_sendHandleToUnixSocket.

tareksander commented 1 year ago

You can create socketpair, pass one of sockets to client (or server, depends on the place where you want to create buffers) and pass buffer with AHardwareBuffer_sendHandleToUnixSocket.

I want to do that, but that should be specified in a protocol, too.

Write to a wl_shm wl_buffer like to an X11 pixmap

You can use simple wl_shm buffer just like any other app... No need to implement something new.

This is a general to-do list. Apps can write to it, but we need GLES, so we need to copy it with the needed format changes.

Try to create wl_shm buffers from HardwareBuffer DMABUF fd

You should not do that. You can create wl_buffer with line of code like that:

wl_resource_create(client, &wl_buffer_interface, 1, id);

You can assign it any data you want (with wl_resource_set_user_data). But it should be done from some other interface, with passing this wl_buffer as a parameter.

That is for the case where the compositor doesn't support the dedicated HardwareBuffer protocol, like X11. You can pass the DMABUF fd to create a wl_shm_pool in the server and then allocate a single full-size wl_buffer from it.

Make a custom protocol for sharing AHardwareBuffers with the compositor as wl_buffer objects

Also no need to implement something new. Wayland passes xkbmaps in a file descriptor. I mean compositor must create shared memory fragment, mmap it, fill with needed data (pre-compiled or built from scratch with libxkbcommon), unmap it and pass to client with wl_keyboard_send_keymap call...

That has nothing to do with keymaps, no?

twaik commented 1 year ago

I want to do that, but that should be specified in a protocol, too.

But you writing protocol for that stuff is up to you...

That is for the case where the compositor doesn't support the dedicated HardwareBuffer protocol, like X11

Do you mean a fallback? I think it anyway will not work in proot-distro or in chroot so anyway software will be patched to handle this. Libhybris can not work with android's libEGL.so because of TLS restricitons... But maybe it will work with libvulkan.

That has nothing to do with keymaps, no?

I meant that we can use the same principle