diff options
author | LaserEyess <lasereyess@users.noreply.github.com> | 2022-11-15 20:52:56 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2022-11-20 19:13:59 +0000 |
commit | a62f71bfbeb8f35bf5f09f12e48b63505c475750 (patch) | |
tree | 019ec5e071e6ca90214f6f3623037eb2b540a696 /video/out/vo_dmabuf_wayland.c | |
parent | 303178e6451da7072aa71ce5e3cbffc233d6dbd1 (diff) | |
download | mpv-a62f71bfbeb8f35bf5f09f12e48b63505c475750.tar.bz2 mpv-a62f71bfbeb8f35bf5f09f12e48b63505c475750.tar.xz |
vo_dmabuf_wayland: use single-pixel-buffer-v1
The new single-pixel-buffer protocol is designed to optimize the case
for using a solid color as an underlay wl_surface. It works the same as
the wl_shm 1x1 pixel trick currently used, but it allows the compositor
to make optimizations with more certainty than the wl_shm trick.
Diffstat (limited to 'video/out/vo_dmabuf_wayland.c')
-rw-r--r-- | video/out/vo_dmabuf_wayland.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 24ced832ab..e6ce97f643 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -41,9 +41,15 @@ #include "present_sync.h" #include "wayland_common.h" #include "wlbuf_pool.h" + +// Generated from wayland-protocols #include "generated/wayland/linux-dmabuf-unstable-v1.h" #include "generated/wayland/viewporter.h" +#if HAVE_WAYLAND_PROTOCOLS_1_27 +#include "generated/wayland/single-pixel-buffer-v1.h" +#endif + struct priv { struct mp_log *log; struct ra_ctx *ctx; @@ -238,24 +244,6 @@ static int query_format(struct vo *vo, int format) static int reconfig(struct vo *vo, struct mp_image_params *params) { - struct priv *p = vo->priv; - struct vo_wayland_state *wl = vo->wl; - - if (!p->solid_buffer_pool) { - int width = 1; - int height = 1; - int stride = MP_ALIGN_UP(width * 4, 16); - int fd = vo_wayland_allocate_memfd(vo, stride); - if (fd < 0) - return VO_ERROR; - p->solid_buffer_pool = wl_shm_create_pool(wl->shm, fd, height * stride); - if (!p->solid_buffer_pool) - return VO_ERROR; - p->solid_buffer = wl_shm_pool_create_buffer(p->solid_buffer_pool, 0, width, height, stride, WL_SHM_FORMAT_XRGB8888); - if (!p->solid_buffer) - return VO_ERROR; - wl_surface_attach(wl->surface, p->solid_buffer, 0, 0); - } if (!vo_wayland_reconfig(vo)) return VO_ERROR; @@ -354,6 +342,30 @@ static int preinit(struct vo *vo) return VO_ERROR; } + + if (vo->wl->single_pixel_manager) { +#if HAVE_WAYLAND_PROTOCOLS_1_27 + p->solid_buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer( + vo->wl->single_pixel_manager, 0, 0, 0, UINT32_MAX); /* R, G, B, A */ +#endif + } else { + int width = 1; + int height = 1; + int stride = MP_ALIGN_UP(width * 4, 16); + int fd = vo_wayland_allocate_memfd(vo, stride); + if (fd < 0) + return VO_ERROR; + p->solid_buffer_pool = wl_shm_create_pool(vo->wl->shm, fd, height * stride); + if (!p->solid_buffer_pool) + return VO_ERROR; + p->solid_buffer = wl_shm_pool_create_buffer( + p->solid_buffer_pool, 0, width, height, stride, WL_SHM_FORMAT_XRGB8888); + } + if (!p->solid_buffer) + return VO_ERROR; + + wl_surface_attach(vo->wl->surface, p->solid_buffer, 0, 0); + vo->hwdec_devs = hwdec_devices_create(); hwdec_devices_set_loader(vo->hwdec_devs, call_request_hwdec_api, vo); assert(!p->hwdec_ctx.ra); |