summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-09-01 15:33:27 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-09-01 15:34:13 -0400
commit7da4d8af2fde8db384398011b4c35e37299d940a (patch)
tree22499bfb5226e6b99d3deddb07806b2e74d2b794
parent6bdebd157048678a0b067e1492cff3ac0717e35d (diff)
downloadgtk+-7da4d8af2fde8db384398011b4c35e37299d940a.tar.gz
Use gsk for text shadows
We don't need to render these manually using cairo anymore.
-rw-r--r--gtk/gtksnapshot.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 11e594ea84..0408a70fc8 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -1332,7 +1332,9 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
PangoLayout *layout)
{
const GdkRGBA *fg_color;
- GtkCssValue *shadow;
+ GtkCssValue *shadows_value;
+ GskShadow *shadows;
+ gsize n_shadows;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
@@ -1342,32 +1344,19 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
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);
- if (!_gtk_css_shadows_value_is_none (shadow))
- {
- PangoRectangle ink_rect;
- graphene_rect_t bounds;
- GtkBorder shadow_extents = { 0, };
- cairo_t *cr;
-
- 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);
+ shadows_value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_SHADOW);
+ shadows = gtk_css_shadows_value_get_shadows (shadows_value, &n_shadows);
+ if (shadows)
+ gtk_snapshot_push_shadow (snapshot, shadows, n_shadows, "TextShadow<%zu>", n_shadows);
- cr = gtk_snapshot_append_cairo (snapshot, &bounds, "Text<%dchars>", pango_layout_get_character_count (layout));
-
- gdk_cairo_set_source_rgba (cr, fg_color);
+ gsk_pango_show_layout (snapshot, fg_color, layout);
- _gtk_css_shadows_value_paint_layout (shadow, cr, layout);
- cairo_destroy (cr);
+ if (shadows)
+ {
+ gtk_snapshot_pop (snapshot);
+ g_free (shadows);
}
- gsk_pango_show_layout (snapshot, fg_color, layout);
-
gtk_snapshot_offset (snapshot, -x, -y);
}