From 01ab69659d664b78bb03336a0d55bd173cdd3c59 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 13 Sep 2023 16:50:08 +0200 Subject: [PATCH] macOS: Clamp damage region to surface size ...in _gdk_macos_cairo_context_begin_frame () GdkMacosCairoContext needs regions that are clamped to the actual surface size. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5812 --- gdk/macos/gdkmacoscairocontext.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdk/macos/gdkmacoscairocontext.c b/gdk/macos/gdkmacoscairocontext.c index 17c2b32811..31a9091b75 100644 --- a/gdk/macos/gdkmacoscairocontext.c +++ b/gdk/macos/gdkmacoscairocontext.c @@ -188,6 +188,14 @@ copy_surface_data (GdkMacosBuffer *from, } } +static void +clamp_region_to_surface (cairo_region_t *region, + GdkSurface *surface) +{ + cairo_rectangle_int_t rectangle = {0, 0, surface->width, surface->height}; + cairo_region_intersect_rectangle (region, &rectangle); +} + static void _gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context, GdkMemoryDepth depth, @@ -205,6 +213,8 @@ _gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context, surface = GDK_MACOS_SURFACE (gdk_draw_context_get_surface (draw_context)); buffer = _gdk_macos_surface_get_buffer (surface); + clamp_region_to_surface (region, GDK_SURFACE (surface)); + _gdk_macos_buffer_set_damage (buffer, region); _gdk_macos_buffer_set_flipped (buffer, FALSE); -- 2.30.2