From 8c7994c0ac07f8dc03e21789f35d132f2c794724 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 24 Apr 2024 10:03:35 +0530 Subject: [PATCH] Dont call wl_egl_window_resize on every swap --- glfw/wl_platform.h | 2 +- glfw/wl_window.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index d773eb989..fb51392ae 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -186,7 +186,7 @@ typedef struct _GLFWwindowWayland } layer_shell; struct { - int width, height; + int width, height, dirty; } framebuffer_size_at_last_resize; /* information about axis events on current frame */ struct diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 781203ad5..dfe869e65 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -379,12 +379,16 @@ resizeFramebuffer(_GLFWwindow* window) { wait_for_swap_to_commit(window); window->wl.framebuffer_size_at_last_resize.width = scaled_width; window->wl.framebuffer_size_at_last_resize.height = scaled_height; + window->wl.framebuffer_size_at_last_resize.dirty = true; _glfwInputFramebufferSize(window, scaled_width, scaled_height); } void _glfwWaylandBeforeBufferSwap(_GLFWwindow* window) { - wl_egl_window_resize(window->wl.native, window->wl.framebuffer_size_at_last_resize.width, window->wl.framebuffer_size_at_last_resize.height, 0, 0); + if (window->wl.framebuffer_size_at_last_resize.dirty) { + wl_egl_window_resize(window->wl.native, window->wl.framebuffer_size_at_last_resize.width, window->wl.framebuffer_size_at_last_resize.height, 0, 0); + window->wl.framebuffer_size_at_last_resize.dirty = false; + } } void