From 90df8be3fa7ceeba02bb55cd0706c5732c9062ed Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Fri, 16 Oct 2026 22:42:50 +0200 Subject: [PATCH] gdkcairo: add gdk_cairo_create_in_area_libgtk_only() Gives theme engines a cairo context clipped only to the window clip rectangles that touch the area being drawn. --- gdk/gdk.symbols | 1 + gdk/gdkcairo.c | 27 +++++++++++++++++++++++++++ gdk/gdkcairo.h | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 98300282a..0fd330da0 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -325,6 +325,7 @@ gdk_fontset_load_for_display #if IN_HEADER(__GDK_CAIRO_H__) #if IN_FILE(__GDK_CAIRO_C__) gdk_cairo_create +gdk_cairo_create_in_area_libgtk_only gdk_cairo_reset_clip gdk_cairo_set_source_color gdk_cairo_set_source_pixbuf diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index 046bc5de7..145c674ed 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -98,6 +98,33 @@ _gdk_cairo_create_in_area (GdkDrawable *drawable, return cr; } +/** + * gdk_cairo_create_in_area_libgtk_only: + * @drawable: a #GdkDrawable + * @area: the area that will be drawn + * + * Like gdk_cairo_create(), for drawing that stays inside @area: of the + * clip of a window only the rectangles meeting @area are given to cairo, + * which within @area is the same clip. Theme engines that clip to the + * area they are given anyway spare cairo the whole clip of the window, + * which during an expose can be many rectangles, for each part they + * draw. Private to GTK+ and its modules. + * + * Return value: A newly created Cairo context. Free with + * cairo_destroy() when you are done drawing. + **/ +cairo_t * +gdk_cairo_create_in_area_libgtk_only (GdkDrawable *drawable, + const GdkRectangle *area) +{ + g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); + + if (!area) + return gdk_cairo_create (drawable); + + return _gdk_cairo_create_in_area (drawable, area); +} + /** * gdk_cairo_reset_clip: * @cr: a #cairo_t diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h index 5bc952636..3d9822aef 100644 --- a/gdk/gdkcairo.h +++ b/gdk/gdkcairo.h @@ -31,6 +31,10 @@ G_BEGIN_DECLS cairo_t *gdk_cairo_create (GdkDrawable *drawable); + +/* private, for the theme engines of GTK+ */ +cairo_t *gdk_cairo_create_in_area_libgtk_only (GdkDrawable *drawable, + const GdkRectangle *area); void gdk_cairo_reset_clip (cairo_t *cr, GdkDrawable *drawable);