summaryrefslogtreecommitdiff
path: root/pkg/mpv/patch/0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/mpv/patch/0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch')
-rw-r--r--pkg/mpv/patch/0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch173
1 files changed, 173 insertions, 0 deletions
diff --git a/pkg/mpv/patch/0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch b/pkg/mpv/patch/0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch
new file mode 100644
index 00000000..fda8f358
--- /dev/null
+++ b/pkg/mpv/patch/0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch
@@ -0,0 +1,173 @@
+From 9c07bab33a0bd57fb74a0368a3d5483cc2820d77 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Wed, 14 Aug 2024 23:01:11 -0700
+Subject: [PATCH] Revert "wayland: drop buffer_scale use for viewporter"
+
+This reverts commit e32554cd570d984efb712a7214a40237233a3cea.
+---
+ video/out/opengl/context_wayland.c | 4 ++--
+ video/out/vo_dmabuf_wayland.c | 6 ++++++
+ video/out/vo_wlshm.c | 2 +-
+ video/out/vulkan/context_wayland.c | 2 +-
+ video/out/wayland_common.c | 34 ++++++++++++++----------------
+ video/out/wayland_common.h | 2 +-
+ 6 files changed, 27 insertions(+), 23 deletions(-)
+
+diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
+index 2c5611b2e6..26c52688d3 100644
+--- a/video/out/opengl/context_wayland.c
++++ b/video/out/opengl/context_wayland.c
+@@ -47,14 +47,14 @@ static void resize(struct ra_ctx *ctx)
+ const int32_t width = mp_rect_w(wl->geometry);
+ const int32_t height = mp_rect_h(wl->geometry);
+
+- vo_wayland_handle_scale(wl);
+-
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
+ if (p->egl_window)
+ wl_egl_window_resize(p->egl_window, width, height, 0, 0);
+
+ wl->vo->dwidth = width;
+ wl->vo->dheight = height;
++
++ vo_wayland_handle_fractional_scale(wl);
+ }
+
+ static bool wayland_egl_check_visible(struct ra_ctx *ctx)
+diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c
+index 35a4dac464..040c73e8a1 100644
+--- a/video/out/vo_dmabuf_wayland.c
++++ b/video/out/vo_dmabuf_wayland.c
+@@ -781,6 +781,12 @@ static int preinit(struct vo *vo)
+ goto err;
+ }
+
++ if (!vo->wl->viewport) {
++ MP_FATAL(vo->wl, "Compositor doesn't support the %s protocol!\n",
++ wp_viewporter_interface.name);
++ goto err;
++ }
++
+ 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(
+diff --git a/video/out/vo_wlshm.c b/video/out/vo_wlshm.c
+index 0b63426a23..0dd22ae940 100644
+--- a/video/out/vo_wlshm.c
++++ b/video/out/vo_wlshm.c
+@@ -215,7 +215,7 @@ static int resize(struct vo *vo)
+ talloc_free(buf);
+ }
+
+- vo_wayland_handle_scale(wl);
++ vo_wayland_handle_fractional_scale(wl);
+
+ return mp_sws_reinit(p->sws);
+ }
+diff --git a/video/out/vulkan/context_wayland.c b/video/out/vulkan/context_wayland.c
+index cdf1ba60b8..761ff5b12c 100644
+--- a/video/out/vulkan/context_wayland.c
++++ b/video/out/vulkan/context_wayland.c
+@@ -118,7 +118,7 @@ static bool resize(struct ra_ctx *ctx)
+ const int32_t height = mp_rect_h(wl->geometry);
+
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
+- vo_wayland_handle_scale(wl);
++ vo_wayland_handle_fractional_scale(wl);
+ return ra_vk_ctx_resize(ctx, width, height);
+ }
+
+diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
+index 4ccd4bda9c..7da864b59f 100644
+--- a/video/out/wayland_common.c
++++ b/video/out/wayland_common.c
+@@ -1185,13 +1185,13 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
+ apply_keepaspect(wl, &width, &height);
+ wl->window_size.x0 = 0;
+ wl->window_size.y0 = 0;
+- wl->window_size.x1 = lround(width * wl->scaling);
+- wl->window_size.y1 = lround(height * wl->scaling);
++ wl->window_size.x1 = round(width * wl->scaling);
++ wl->window_size.y1 = round(height * wl->scaling);
+ }
+ wl->geometry.x0 = 0;
+ wl->geometry.y0 = 0;
+- wl->geometry.x1 = lround(width * wl->scaling);
+- wl->geometry.y1 = lround(height * wl->scaling);
++ wl->geometry.x1 = round(width * wl->scaling);
++ wl->geometry.y1 = round(height * wl->scaling);
+
+ if (mp_rect_equals(&old_geometry, &wl->geometry))
+ return;
+@@ -1713,11 +1713,13 @@ static bool create_input(struct vo_wayland_state *wl)
+
+ static int create_viewports(struct vo_wayland_state *wl)
+ {
+- wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
+- wl->osd_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->osd_surface);
+- wl->video_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->video_surface);
++ if (wl->viewporter) {
++ wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
++ wl->osd_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->osd_surface);
++ wl->video_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->video_surface);
++ }
+
+- if (!wl->viewport || !wl->osd_viewport || !wl->video_viewport) {
++ if (wl->viewporter && (!wl->viewport || !wl->osd_viewport || !wl->video_viewport)) {
+ MP_ERR(wl, "failed to create viewport interfaces!\n");
+ return 1;
+ }
+@@ -2125,6 +2127,7 @@ static void set_surface_scaling(struct vo_wayland_state *wl)
+ wl->scaling = wl->current_output->scale;
+ rescale_geometry(wl, old_scale);
+ wl->pending_vo_events |= VO_EVENT_DPI;
++ wl_surface_set_buffer_scale(wl->surface, wl->scaling);
+ }
+
+ static void set_window_bounds(struct vo_wayland_state *wl)
+@@ -2510,11 +2513,12 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
+ return VO_NOTIMPL;
+ }
+
+-void vo_wayland_handle_scale(struct vo_wayland_state *wl)
++void vo_wayland_handle_fractional_scale(struct vo_wayland_state *wl)
+ {
+- wp_viewport_set_destination(wl->viewport,
+- lround(mp_rect_w(wl->geometry) / wl->scaling),
+- lround(mp_rect_h(wl->geometry) / wl->scaling));
++ if (wl->fractional_scale_manager && wl->viewport)
++ wp_viewport_set_destination(wl->viewport,
++ round(mp_rect_w(wl->geometry) / wl->scaling),
++ round(mp_rect_h(wl->geometry) / wl->scaling));
+ }
+
+ bool vo_wayland_init(struct vo *vo)
+@@ -2575,12 +2579,6 @@ bool vo_wayland_init(struct vo *vo)
+ goto err;
+ }
+
+- if (!wl->viewporter) {
+- MP_FATAL(wl, "Compositor doesn't support the required %s protocol!\n",
+- wp_viewporter_interface.name);
+- goto err;
+- }
+-
+ /* Can't be initialized during registry due to multi-protocol dependence */
+ if (create_viewports(wl))
+ goto err;
+diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
+index f5fcb80445..c489c5db98 100644
+--- a/video/out/wayland_common.h
++++ b/video/out/wayland_common.h
+@@ -170,7 +170,7 @@ bool vo_wayland_reconfig(struct vo *vo);
+ int vo_wayland_allocate_memfd(struct vo *vo, size_t size);
+ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg);
+
+-void vo_wayland_handle_scale(struct vo_wayland_state *wl);
++void vo_wayland_handle_fractional_scale(struct vo_wayland_state *wl);
+ void vo_wayland_set_opaque_region(struct vo_wayland_state *wl, bool alpha);
+ void vo_wayland_sync_swap(struct vo_wayland_state *wl);
+ void vo_wayland_uninit(struct vo *vo);
+--
+2.44.0
+