diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-02 23:50:39 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-04 14:28:16 -0400 |
commit | d6be42203ba341a6973e424987f9a331e57cd448 (patch) | |
tree | 04da7e153f8f0cf6a3c0c5bbdd68555e33adcde0 | |
parent | e2869853dc0690cb4f466b9662f6e7afd472d96a (diff) | |
download | gtk+-d6be42203ba341a6973e424987f9a331e57cd448.tar.gz |
Add gtk_snapshot_push_blur()
This function is similar to the other push functions.
This one uses the newly created blur node.
-rw-r--r-- | gtk/gtksnapshot.c | 51 | ||||
-rw-r--r-- | gtk/gtksnapshot.h | 5 | ||||
-rw-r--r-- | gtk/gtksnapshotprivate.h | 3 |
3 files changed, 59 insertions, 0 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 0408a70fc8..7f5a1f1db2 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -322,6 +322,57 @@ gtk_snapshot_push_opacity (GtkSnapshot *snapshot, } static GskRenderNode * +gtk_snapshot_collect_blur (GtkSnapshotState *state, + GskRenderNode **nodes, + guint n_nodes, + const char *name) +{ + GskRenderNode *node, *blur_node; + + node = gtk_snapshot_collect_default (state, nodes, n_nodes, name); + if (node == NULL) + return NULL; + + blur_node = gsk_blur_node_new (node, state->data.blur.radius); + if (name) + gsk_render_node_set_name (blur_node, name); + + gsk_render_node_unref (node); + + return blur_node; +} + +void +gtk_snapshot_push_blur (GtkSnapshot *snapshot, + double radius, + const char *name, + ...) +{ + GtkSnapshotState *state; + char *str; + + if (name && snapshot->record_names) + { + va_list args; + + va_start (args, name); + str = g_strdup_vprintf (name, args); + va_end (args); + } + else + str = NULL; + + state = gtk_snapshot_state_new (snapshot->state, + str, + snapshot->state->clip_region, + snapshot->state->translate_x, + snapshot->state->translate_y, + gtk_snapshot_collect_blur); + state->data.blur.radius = radius; + snapshot->state = state; +} + +static GskRenderNode * gtk_snapshot_collect_color_matrix (GtkSnapshotState *state, GskRenderNode **nodes, guint n_nodes, diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h index 39ebd25aa0..b5e21ae6ed 100644 --- a/gtk/gtksnapshot.h +++ b/gtk/gtksnapshot.h @@ -51,6 +51,11 @@ void gtk_snapshot_push_opacity (GtkSnapshot double opacity, const char *name, ...) G_GNUC_PRINTF (3, 4); +GDK_AVAILABLE_IN_3_92 +void gtk_snapshot_push_blur (GtkSnapshot *snapshot, + double radius, + 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, diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 3676a10859..deffbc1aaf 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -49,6 +49,9 @@ struct _GtkSnapshotState { double opacity; } opacity; struct { + double radius; + } blur; + struct { graphene_matrix_t matrix; graphene_vec4_t offset; } color_matrix; |