From e11e5525db7fdf6f12633ea1041df94d12987649 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 31 Jul 2024 19:58:43 -0400 Subject: [PATCH] gtk: Add gtk_snapshot_append_color2 This is a private snapshot function that uses the new color node constructor to create a color node with a given color state. --- gtk/gtksnapshot.c | 23 ++++++++++++++++++++++- gtk/gtksnapshotprivate.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 8f310a3e3f..2dcf6727e9 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -27,6 +27,7 @@ #include "gsktransformprivate.h" #include "gdk/gdkrgbaprivate.h" +#include "gdk/gdkcolorstateprivate.h" #include "gsk/gskrendernodeprivate.h" #include "gsk/gskroundedrectprivate.h" @@ -2383,6 +2384,26 @@ void gtk_snapshot_append_color (GtkSnapshot *snapshot, const GdkRGBA *color, const graphene_rect_t *bounds) +{ + GdkColor color2; + gdk_color_init_from_rgba (&color2, color); + gtk_snapshot_append_color2 (snapshot, &color2, bounds); +} + +/*< private > + * gtk_snapshot_append_color2: + * @snapshot: a `GtkSnapshot` + * @color: the color to draw + * @bounds: the bounds for the new node + * + * Creates a new render node drawing the @color into the + * given @bounds and appends it to the current render node + * of @snapshot. + */ +void +gtk_snapshot_append_color2 (GtkSnapshot *snapshot, + const GdkColor *color, + const graphene_rect_t *bounds) { GskRenderNode *node; graphene_rect_t real_bounds; @@ -2395,7 +2416,7 @@ gtk_snapshot_append_color (GtkSnapshot *snapshot, gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy); gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds); - node = gsk_color_node_new (color, &real_bounds); + node = gsk_color_node_new2 (color, &real_bounds); gtk_snapshot_append_node_internal (snapshot, node); } diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 0d8a5f5924..77708e9b5e 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -37,5 +37,9 @@ GskRenderNode * gtk_snapshot_pop_collect (GtkSnapshot void gtk_snapshot_push_subsurface (GtkSnapshot *snapshot, GdkSubsurface *subsurface); +void gtk_snapshot_append_color2 (GtkSnapshot *snapshot, + const GdkColor *color, + const graphene_rect_t *bounds); + G_END_DECLS