diff options
Diffstat (limited to 'video/out/vo_wlshm.c')
-rw-r--r-- | video/out/vo_wlshm.c | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/video/out/vo_wlshm.c b/video/out/vo_wlshm.c index fc9fc705fc..0b63426a23 100644 --- a/video/out/vo_wlshm.c +++ b/video/out/vo_wlshm.c @@ -21,8 +21,6 @@ #include <time.h> #include <unistd.h> -#include <libswscale/swscale.h> - #include "osdep/endian.h" #include "present_sync.h" #include "sub/osd.h" @@ -32,6 +30,8 @@ #include "vo.h" #include "wayland_common.h" +#define IMGFMT_WL_RGB MP_SELECT_LE_BE(IMGFMT_BGR0, IMGFMT_0RGB) + struct buffer { struct vo *vo; size_t size; @@ -128,27 +128,44 @@ error0: return NULL; } +static void uninit(struct vo *vo) +{ + struct priv *p = vo->priv; + struct buffer *buf; + + while (p->free_buffers) { + buf = p->free_buffers; + p->free_buffers = buf->next; + talloc_free(buf); + } + vo_wayland_uninit(vo); +} + static int preinit(struct vo *vo) { struct priv *p = vo->priv; if (!vo_wayland_init(vo)) - return -1; + goto err; if (!vo->wl->shm) { MP_FATAL(vo->wl, "Compositor doesn't support the %s protocol!\n", wl_shm_interface.name); - return -1; + goto err; } p->sws = mp_sws_alloc(vo); p->sws->log = vo->log; mp_sws_enable_cmdline_opts(p->sws, vo->global); return 0; +err: + uninit(vo); + return -1; } static int query_format(struct vo *vo, int format) { - return sws_isSupportedInput(imgfmt2pixfmt(format)); + struct priv *p = vo->priv; + return mp_sws_supports_formats(p->sws, IMGFMT_WL_RGB, format) ? 1 : 0; } static int reconfig(struct vo *vo, struct mp_image_params *params) @@ -166,33 +183,51 @@ static int resize(struct vo *vo) { struct priv *p = vo->priv; struct vo_wayland_state *wl = vo->wl; - const int32_t width = wl->scaling * mp_rect_w(wl->geometry); - const int32_t height = wl->scaling * mp_rect_h(wl->geometry); + const int32_t width = mp_rect_w(wl->geometry); + const int32_t height = mp_rect_h(wl->geometry); + + if (width == 0 || height == 0) + return 1; + struct buffer *buf; - vo_wayland_set_opaque_region(wl, 0); + vo_wayland_set_opaque_region(wl, false); vo->want_redraw = true; vo->dwidth = width; vo->dheight = height; vo_get_src_dst_rects(vo, &p->src, &p->dst, &p->osd); + p->sws->dst = (struct mp_image_params) { - .imgfmt = MP_SELECT_LE_BE(IMGFMT_BGR0, IMGFMT_0RGB), + .imgfmt = IMGFMT_WL_RGB, .w = width, .h = height, .p_w = 1, .p_h = 1, }; mp_image_params_guess_csp(&p->sws->dst); + mp_mutex_lock(&vo->params_mutex); + vo->target_params = &p->sws->dst; + mp_mutex_unlock(&vo->params_mutex); + while (p->free_buffers) { buf = p->free_buffers; p->free_buffers = buf->next; talloc_free(buf); } + + vo_wayland_handle_scale(wl); + return mp_sws_reinit(p->sws); } static int control(struct vo *vo, uint32_t request, void *data) { + switch (request) { + case VOCTRL_SET_PANSCAN: + resize(vo); + return VO_TRUE; + } + int events = 0; int ret = vo_wayland_control(vo, &events, request, data); @@ -278,19 +313,6 @@ static void get_vsync(struct vo *vo, struct vo_vsync_info *info) present_sync_get_info(wl->present, info); } -static void uninit(struct vo *vo) -{ - struct priv *p = vo->priv; - struct buffer *buf; - - while (p->free_buffers) { - buf = p->free_buffers; - p->free_buffers = buf->next; - talloc_free(buf); - } - vo_wayland_uninit(vo); -} - const struct vo_driver video_out_wlshm = { .description = "Wayland SHM video output (software scaling)", .name = "wlshm", |