logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0008-Revert-wayland-drop-buffer_scale-use-for-viewporter.patch (6962B)


  1. From 9c07bab33a0bd57fb74a0368a3d5483cc2820d77 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Wed, 14 Aug 2024 23:01:11 -0700
  4. Subject: [PATCH] Revert "wayland: drop buffer_scale use for viewporter"
  5. This reverts commit e32554cd570d984efb712a7214a40237233a3cea.
  6. ---
  7. video/out/opengl/context_wayland.c | 4 ++--
  8. video/out/vo_dmabuf_wayland.c | 6 ++++++
  9. video/out/vo_wlshm.c | 2 +-
  10. video/out/vulkan/context_wayland.c | 2 +-
  11. video/out/wayland_common.c | 34 ++++++++++++++----------------
  12. video/out/wayland_common.h | 2 +-
  13. 6 files changed, 27 insertions(+), 23 deletions(-)
  14. diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
  15. index 2c5611b2e6..26c52688d3 100644
  16. --- a/video/out/opengl/context_wayland.c
  17. +++ b/video/out/opengl/context_wayland.c
  18. @@ -47,14 +47,14 @@ static void resize(struct ra_ctx *ctx)
  19. const int32_t width = mp_rect_w(wl->geometry);
  20. const int32_t height = mp_rect_h(wl->geometry);
  21. - vo_wayland_handle_scale(wl);
  22. -
  23. vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
  24. if (p->egl_window)
  25. wl_egl_window_resize(p->egl_window, width, height, 0, 0);
  26. wl->vo->dwidth = width;
  27. wl->vo->dheight = height;
  28. +
  29. + vo_wayland_handle_fractional_scale(wl);
  30. }
  31. static bool wayland_egl_check_visible(struct ra_ctx *ctx)
  32. diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c
  33. index 35a4dac464..040c73e8a1 100644
  34. --- a/video/out/vo_dmabuf_wayland.c
  35. +++ b/video/out/vo_dmabuf_wayland.c
  36. @@ -781,6 +781,12 @@ static int preinit(struct vo *vo)
  37. goto err;
  38. }
  39. + if (!vo->wl->viewport) {
  40. + MP_FATAL(vo->wl, "Compositor doesn't support the %s protocol!\n",
  41. + wp_viewporter_interface.name);
  42. + goto err;
  43. + }
  44. +
  45. if (vo->wl->single_pixel_manager) {
  46. #if HAVE_WAYLAND_PROTOCOLS_1_27
  47. p->solid_buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer(
  48. diff --git a/video/out/vo_wlshm.c b/video/out/vo_wlshm.c
  49. index 0b63426a23..0dd22ae940 100644
  50. --- a/video/out/vo_wlshm.c
  51. +++ b/video/out/vo_wlshm.c
  52. @@ -215,7 +215,7 @@ static int resize(struct vo *vo)
  53. talloc_free(buf);
  54. }
  55. - vo_wayland_handle_scale(wl);
  56. + vo_wayland_handle_fractional_scale(wl);
  57. return mp_sws_reinit(p->sws);
  58. }
  59. diff --git a/video/out/vulkan/context_wayland.c b/video/out/vulkan/context_wayland.c
  60. index cdf1ba60b8..761ff5b12c 100644
  61. --- a/video/out/vulkan/context_wayland.c
  62. +++ b/video/out/vulkan/context_wayland.c
  63. @@ -118,7 +118,7 @@ static bool resize(struct ra_ctx *ctx)
  64. const int32_t height = mp_rect_h(wl->geometry);
  65. vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
  66. - vo_wayland_handle_scale(wl);
  67. + vo_wayland_handle_fractional_scale(wl);
  68. return ra_vk_ctx_resize(ctx, width, height);
  69. }
  70. diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
  71. index 4ccd4bda9c..7da864b59f 100644
  72. --- a/video/out/wayland_common.c
  73. +++ b/video/out/wayland_common.c
  74. @@ -1185,13 +1185,13 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
  75. apply_keepaspect(wl, &width, &height);
  76. wl->window_size.x0 = 0;
  77. wl->window_size.y0 = 0;
  78. - wl->window_size.x1 = lround(width * wl->scaling);
  79. - wl->window_size.y1 = lround(height * wl->scaling);
  80. + wl->window_size.x1 = round(width * wl->scaling);
  81. + wl->window_size.y1 = round(height * wl->scaling);
  82. }
  83. wl->geometry.x0 = 0;
  84. wl->geometry.y0 = 0;
  85. - wl->geometry.x1 = lround(width * wl->scaling);
  86. - wl->geometry.y1 = lround(height * wl->scaling);
  87. + wl->geometry.x1 = round(width * wl->scaling);
  88. + wl->geometry.y1 = round(height * wl->scaling);
  89. if (mp_rect_equals(&old_geometry, &wl->geometry))
  90. return;
  91. @@ -1713,11 +1713,13 @@ static bool create_input(struct vo_wayland_state *wl)
  92. static int create_viewports(struct vo_wayland_state *wl)
  93. {
  94. - wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
  95. - wl->osd_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->osd_surface);
  96. - wl->video_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->video_surface);
  97. + if (wl->viewporter) {
  98. + wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
  99. + wl->osd_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->osd_surface);
  100. + wl->video_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->video_surface);
  101. + }
  102. - if (!wl->viewport || !wl->osd_viewport || !wl->video_viewport) {
  103. + if (wl->viewporter && (!wl->viewport || !wl->osd_viewport || !wl->video_viewport)) {
  104. MP_ERR(wl, "failed to create viewport interfaces!\n");
  105. return 1;
  106. }
  107. @@ -2125,6 +2127,7 @@ static void set_surface_scaling(struct vo_wayland_state *wl)
  108. wl->scaling = wl->current_output->scale;
  109. rescale_geometry(wl, old_scale);
  110. wl->pending_vo_events |= VO_EVENT_DPI;
  111. + wl_surface_set_buffer_scale(wl->surface, wl->scaling);
  112. }
  113. static void set_window_bounds(struct vo_wayland_state *wl)
  114. @@ -2510,11 +2513,12 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
  115. return VO_NOTIMPL;
  116. }
  117. -void vo_wayland_handle_scale(struct vo_wayland_state *wl)
  118. +void vo_wayland_handle_fractional_scale(struct vo_wayland_state *wl)
  119. {
  120. - wp_viewport_set_destination(wl->viewport,
  121. - lround(mp_rect_w(wl->geometry) / wl->scaling),
  122. - lround(mp_rect_h(wl->geometry) / wl->scaling));
  123. + if (wl->fractional_scale_manager && wl->viewport)
  124. + wp_viewport_set_destination(wl->viewport,
  125. + round(mp_rect_w(wl->geometry) / wl->scaling),
  126. + round(mp_rect_h(wl->geometry) / wl->scaling));
  127. }
  128. bool vo_wayland_init(struct vo *vo)
  129. @@ -2575,12 +2579,6 @@ bool vo_wayland_init(struct vo *vo)
  130. goto err;
  131. }
  132. - if (!wl->viewporter) {
  133. - MP_FATAL(wl, "Compositor doesn't support the required %s protocol!\n",
  134. - wp_viewporter_interface.name);
  135. - goto err;
  136. - }
  137. -
  138. /* Can't be initialized during registry due to multi-protocol dependence */
  139. if (create_viewports(wl))
  140. goto err;
  141. diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
  142. index f5fcb80445..c489c5db98 100644
  143. --- a/video/out/wayland_common.h
  144. +++ b/video/out/wayland_common.h
  145. @@ -170,7 +170,7 @@ bool vo_wayland_reconfig(struct vo *vo);
  146. int vo_wayland_allocate_memfd(struct vo *vo, size_t size);
  147. int vo_wayland_control(struct vo *vo, int *events, int request, void *arg);
  148. -void vo_wayland_handle_scale(struct vo_wayland_state *wl);
  149. +void vo_wayland_handle_fractional_scale(struct vo_wayland_state *wl);
  150. void vo_wayland_set_opaque_region(struct vo_wayland_state *wl, bool alpha);
  151. void vo_wayland_sync_swap(struct vo_wayland_state *wl);
  152. void vo_wayland_uninit(struct vo *vo);
  153. --
  154. 2.44.0