diff options
author | Benjamin Otte <otte@redhat.com> | 2018-07-14 20:21:15 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-07-24 20:55:45 +0200 |
commit | 51d40ca02372bcf242ed62f84a59d3b9152c4d8d (patch) | |
tree | 373192507b213e1bc26b039dafdfd71916f9cadd /gtk/gtkrender.c | |
parent | 5d9d73b0907cbffe53fdbb343d7f1702f28e4739 (diff) | |
download | gtk+-51d40ca02372bcf242ed62f84a59d3b9152c4d8d.tar.gz |
render: Make gtk_render_layout() use the snapshot API
This removes a lot of duplicated code.
Diffstat (limited to 'gtk/gtkrender.c')
-rw-r--r-- | gtk/gtkrender.c | 63 |
1 files changed, 14 insertions, 49 deletions
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c index 3c90bb03d2..ae772a7f91 100644 --- a/gtk/gtkrender.c +++ b/gtk/gtkrender.c @@ -427,54 +427,6 @@ gtk_render_focus (GtkStyleContext *context, x, y, width, height); } -static void -prepare_context_for_layout (cairo_t *cr, - gdouble x, - gdouble y, - PangoLayout *layout) -{ - const PangoMatrix *matrix; - - matrix = pango_context_get_matrix (pango_layout_get_context (layout)); - - cairo_move_to (cr, x, y); - - if (matrix) - { - cairo_matrix_t cairo_matrix; - - cairo_matrix_init (&cairo_matrix, - matrix->xx, matrix->yx, - matrix->xy, matrix->yy, - matrix->x0, matrix->y0); - - cairo_transform (cr, &cairo_matrix); - } -} - -static void -gtk_do_render_layout (GtkStyleContext *context, - cairo_t *cr, - gdouble x, - gdouble y, - PangoLayout *layout) -{ - const GdkRGBA *fg_color; - - cairo_save (cr); - fg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)); - - prepare_context_for_layout (cr, x, y, layout); - - _gtk_css_shadows_value_paint_layout (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_SHADOW), - cr, layout); - - gdk_cairo_set_source_rgba (cr, fg_color); - pango_cairo_show_layout (cr, layout); - - cairo_restore (cr); -} - /** * gtk_render_layout: * @context: a #GtkStyleContext @@ -492,11 +444,24 @@ gtk_render_layout (GtkStyleContext *context, gdouble y, PangoLayout *layout) { + GtkSnapshot *snapshot; + GskRenderNode *node; + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (PANGO_IS_LAYOUT (layout)); g_return_if_fail (cr != NULL); - gtk_do_render_layout (context, cr, x, y, layout); + snapshot = gtk_snapshot_new (); + gtk_snapshot_render_layout (snapshot, context, x, y, layout); + node = gtk_snapshot_free_to_node (snapshot); + if (node == NULL) + return; + + cairo_save (cr); + gsk_render_node_draw (node, cr); + cairo_restore (cr); + + gsk_render_node_unref (node); } static void |