diff options
author | Benjamin Otte <otte@redhat.com> | 2016-12-31 01:14:59 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-31 02:49:47 +0100 |
commit | 8973191278c191728b7f71239871c1cd55bfbc80 (patch) | |
tree | f58cb90c34b6dc9b79070c25d4b2c7367d98eac3 | |
parent | 7540702cf0196cf4890de87f4225165a5f2f53f2 (diff) | |
download | gtk+-8973191278c191728b7f71239871c1cd55bfbc80.tar.gz |
snapshot: Add gtk_snapshot_push_color_matrix()
So far, this is unused.
-rw-r--r-- | docs/reference/gtk/gtk4-sections.txt | 2 | ||||
-rw-r--r-- | gtk/gtksnapshot.c | 64 | ||||
-rw-r--r-- | gtk/gtksnapshot.h | 6 |
3 files changed, 72 insertions, 0 deletions
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index d2faa2c8b7..e3d3bd24db 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4457,6 +4457,8 @@ GtkSnapshot gtk_snapshot_push gtk_snapshot_push_node gtk_snapshot_push_transform +gtk_snapshot_push_opacity +gtk_snapshot_push_color_matrix gtk_snapshot_push_clip gtk_snapshot_push_rounded_clip gtk_snapshot_pop diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index d85a43d21f..f604872cf4 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -295,6 +295,12 @@ gtk_snapshot_collect_opacity (GskRenderNode **nodes, return opacity_node; } +typedef struct _ColorMatrix ColorMatrix; +struct _ColorMatrix { + graphene_matrix_t matrix; + graphene_vec4_t offset; +}; + void gtk_snapshot_push_opacity (GtkSnapshot *snapshot, double opacity, @@ -326,6 +332,64 @@ gtk_snapshot_push_opacity (GtkSnapshot *snapshot, real_opacity); } +static GskRenderNode * +gtk_snapshot_collect_color_matrix (GskRenderNode **nodes, + guint n_nodes, + const char *name, + gpointer data) +{ + ColorMatrix *color_matrix = data; + GskRenderNode *node, *color_matrix_node; + + node = gtk_snapshot_collect_default (nodes, n_nodes, name, NULL); + if (node == NULL) + return NULL; + + color_matrix_node = gsk_color_matrix_node_new (node, + &color_matrix->matrix, + &color_matrix->offset); + gsk_render_node_set_name (color_matrix_node, name); + + gsk_render_node_unref (node); + g_free (color_matrix); + + return color_matrix_node; +} + +void +gtk_snapshot_push_color_matrix (GtkSnapshot *snapshot, + const graphene_matrix_t *color_matrix, + const graphene_vec4_t *color_offset, + const char *name, + ...) +{ + ColorMatrix *color_matrix_data; + char *str; + + if (name) + { + va_list args; + + va_start (args, name); + str = g_strdup_vprintf (name, args); + va_end (args); + } + else + str = NULL; + + color_matrix_data = g_new (ColorMatrix, 1); + graphene_matrix_init_from_matrix (&color_matrix_data->matrix, color_matrix); + graphene_vec4_init_from_vec4 (&color_matrix_data->offset, color_offset); + + snapshot->state = gtk_snapshot_state_new (snapshot->state, + str, + snapshot->state->clip_region, + snapshot->state->translate_x, + snapshot->state->translate_y, + gtk_snapshot_collect_color_matrix, + color_matrix_data); +} + static void rectangle_init_from_graphene (cairo_rectangle_int_t *cairo, const graphene_rect_t *graphene) diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h index 22a12a3527..e7b35b87a3 100644 --- a/gtk/gtksnapshot.h +++ b/gtk/gtksnapshot.h @@ -52,6 +52,12 @@ void gtk_snapshot_push_opacity (GtkSnapshot const char *name, ...) G_GNUC_PRINTF (3, 4); GDK_AVAILABLE_IN_3_90 +void gtk_snapshot_push_color_matrix (GtkSnapshot *snapshot, + const graphene_matrix_t*color_matrix, + const graphene_vec4_t *color_offset, + const char *name, + ...) G_GNUC_PRINTF (4, 5); +GDK_AVAILABLE_IN_3_90 void gtk_snapshot_push_clip (GtkSnapshot *snapshot, const graphene_rect_t *bounds, const char *name, |