From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/wayland_surface.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index a2699d66e51..3b4ced893b6 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -477,9 +477,15 @@ static void wayland_surface_reconfigure_size(struct wayland_surface *surface, if (surface->wp_viewport) { if (width != 0 && height != 0) + { + wp_viewport_set_source(surface->wp_viewport, 0, 0, width << 8, height << 8); wp_viewport_set_destination(surface->wp_viewport, width, height); + } else + { + wp_viewport_set_source(surface->wp_viewport, -1, -1, -1, -1); wp_viewport_set_destination(surface->wp_viewport, -1, -1); + } } }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/window_surface.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 570c186861b..ddd4fb45976 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -329,10 +329,9 @@ static BOOL wayland_window_surface_flush(struct window_surface *window_surface, HRGN surface_damage_region = NULL; HRGN copy_from_window_region;
- if (!wws->wayland_surface || !wws->wayland_buffer_queue) + if (!wws->wayland_surface) { - ERR("missing wayland surface=%p or buffer_queue=%p, returning\n", - wws->wayland_surface, wws->wayland_buffer_queue); + ERR("missing wayland surface=%p, returning\n", wws->wayland_surface); goto done; }
@@ -423,8 +422,7 @@ static void wayland_window_surface_destroy(struct window_surface *window_surface
TRACE("surface=%p\n", wws);
- if (wws->wayland_buffer_queue) - wayland_buffer_queue_destroy(wws->wayland_buffer_queue); + wayland_buffer_queue_destroy(wws->wayland_buffer_queue); }
static const struct window_surface_funcs wayland_window_surface_funcs = @@ -444,6 +442,7 @@ static struct window_surface *wayland_window_surface_create(HWND hwnd, const REC struct wayland_window_surface *wws; int width = rect->right - rect->left; int height = rect->bottom - rect->top; + struct window_surface *window_surface;
TRACE("hwnd %p rect %s\n", hwnd, wine_dbgstr_rect(rect));
@@ -456,7 +455,13 @@ static struct window_surface *wayland_window_surface_create(HWND hwnd, const REC info->bmiHeader.biSizeImage = width * height * 4; info->bmiHeader.biCompression = BI_RGB;
- return window_surface_create(sizeof(*wws), &wayland_window_surface_funcs, hwnd, rect, info, 0); + if ((window_surface = window_surface_create(sizeof(*wws), &wayland_window_surface_funcs, hwnd, rect, info, 0))) + { + struct wayland_window_surface *wws = wayland_window_surface_cast(window_surface); + wws->wayland_buffer_queue = wayland_buffer_queue_create(width, height); + } + + return window_surface; }
/***********************************************************************
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/window_surface.c | 15 --------------- 1 file changed, 15 deletions(-)
diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index ddd4fb45976..7e4ea202e89 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -482,21 +482,6 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *window wine_dbgstr_rect(visible_rect), wayland_surface);
wws->wayland_surface = wayland_surface; - - if (wws->wayland_buffer_queue) - { - wayland_buffer_queue_destroy(wws->wayland_buffer_queue); - wws->wayland_buffer_queue = NULL; - } - - /* We only need a buffer queue if we have a surface to commit to. */ - if (wws->wayland_surface) - { - wws->wayland_buffer_queue = - wayland_buffer_queue_create(visible_rect->right - visible_rect->left, - visible_rect->bottom - visible_rect->top); - } - window_surface_unlock(window_surface); }
`wp_viewport_set_source` makes it a compositor error to have (quoting from the spec) "a source rectangle that is partially or completely outside of the non-NULL wl_buffer". This makes it tricky to use at the moment since the code is not designed to respect this requirement. For example, here is a (partial) log of a protocol error I am seeing with this branch: [set_source_error.txt](/uploads/406f1cc729960c30defcae2871262324/set_source_error.txt), and there are probably other error scenarios involving multiple threads, GL/VK rendering threads etc. In any case, pursuing this path this needs some care.
Note that not all compositors enforce this error strictly, so this branch may work with some compositors but not others.
Also, I am seeing some strange (and somewhat inconsistent between compositors) results with this change when the output is scaled (i.e., dpi > 96), but I am not sure yet what's the problem.
On Wed Aug 28 15:52:45 2024 +0000, Alexandros Frantzis wrote:
`wp_viewport_set_source` makes it a compositor error to have (quoting from the spec) "a source rectangle that is partially or completely outside of the non-NULL wl_buffer". This makes it tricky to use at the moment since the code is not designed to respect this requirement. For example, here is a (partial) log of a protocol error I am seeing with this branch: [set_source_error.txt](/uploads/406f1cc729960c30defcae2871262324/set_source_error.txt), and there are probably other error scenarios involving multiple threads, GL/VK rendering threads etc. In any case, pursuing this path this needs some care. Note that I have tried using `wp_viewport_set_source` myself in the past, but abandoned it because I found it to be too fragile for the benefit it brought. Note that not all compositors enforce this error strictly, so this branch may work with some compositors but not others. Also, I am seeing some strange (and somewhat inconsistent between compositors) results with this change when the output is scaled (i.e., dpi > 96), but I am not sure yet what's the problem.
Thanks for the details it looks a bit sensitive... but hopefully we could make it work. The advantages of it are IMO worth the try, and reallocating a shared memory file on every window resize operation, even one pixel, looks like a waste of resources.