From: Luca Bacci Date: Wed, 13 Sep 2023 14:50:08 +0000 (+0200) Subject: macOS: Clamp damage region to surface size X-Git-Tag: archive/raspbian/4.12.4+ds-3+rpi1^2~21^2~2^2~45^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=01ab69659d664b78bb03336a0d55bd173cdd3c59;p=gtk4.git 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 --- 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);