summaryrefslogtreecommitdiff
path: root/gtk/gtksnapshot.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-08-30 11:14:48 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-09-01 13:30:03 -0400
commit82538f935b8c1f41e8e1d5e91b2ade5184020238 (patch)
treecb89dd24a7a7a8fa23d27ed67ca3abea7d1e116a /gtk/gtksnapshot.c
parent82e8f3a54235df54981c1f6d26c3c497c6565f30 (diff)
downloadgtk+-82538f935b8c1f41e8e1d5e91b2ade5184020238.tar.gz
Use GskPangoRenderer to render text
This just replaces the wrapper call.
Diffstat (limited to 'gtk/gtksnapshot.c')
-rw-r--r--gtk/gtksnapshot.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 77146e4baf..11e594ea84 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -29,6 +29,8 @@
#include "gsk/gskrendernodeprivate.h"
+#include "gtk/gskpango.h"
+
/**
* SECTION:gtksnapshot
@@ -1330,36 +1332,42 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
PangoLayout *layout)
{
const GdkRGBA *fg_color;
- graphene_rect_t bounds;
- GtkBorder shadow_extents;
- PangoRectangle ink_rect;
GtkCssValue *shadow;
- cairo_t *cr;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (PANGO_IS_LAYOUT (layout));
+ gtk_snapshot_offset (snapshot, x, y);
+
fg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
+
shadow = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_SHADOW);
- pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
- _gtk_css_shadows_value_get_extents (shadow, &shadow_extents);
- graphene_rect_init (&bounds,
- ink_rect.x - shadow_extents.left,
- ink_rect.y - shadow_extents.top,
- ink_rect.width + shadow_extents.left + shadow_extents.right,
- ink_rect.height + shadow_extents.top + shadow_extents.bottom);
+ if (!_gtk_css_shadows_value_is_none (shadow))
+ {
+ PangoRectangle ink_rect;
+ graphene_rect_t bounds;
+ GtkBorder shadow_extents = { 0, };
+ cairo_t *cr;
- gtk_snapshot_offset (snapshot, x, y);
+ pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
+ _gtk_css_shadows_value_get_extents (shadow, &shadow_extents);
+ graphene_rect_init (&bounds,
+ ink_rect.x - shadow_extents.left,
+ ink_rect.y - shadow_extents.top,
+ ink_rect.width + shadow_extents.left + shadow_extents.right,
+ ink_rect.height + shadow_extents.top + shadow_extents.bottom);
- cr = gtk_snapshot_append_cairo (snapshot, &bounds, "Text<%dchars>", pango_layout_get_character_count (layout));
+ cr = gtk_snapshot_append_cairo (snapshot, &bounds, "Text<%dchars>", pango_layout_get_character_count (layout));
- _gtk_css_shadows_value_paint_layout (shadow, cr, layout);
+ gdk_cairo_set_source_rgba (cr, fg_color);
+
+ _gtk_css_shadows_value_paint_layout (shadow, cr, layout);
+ cairo_destroy (cr);
+ }
- gdk_cairo_set_source_rgba (cr, fg_color);
- pango_cairo_show_layout (cr, layout);
+ gsk_pango_show_layout (snapshot, fg_color, layout);
- cairo_destroy (cr);
gtk_snapshot_offset (snapshot, -x, -y);
}