[gtk+] Use GskPangoRenderer to render text



commit 82538f935b8c1f41e8e1d5e91b2ade5184020238
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Aug 30 11:14:48 2017 -0400

    Use GskPangoRenderer to render text
    
    This just replaces the wrapper call.

 gtk/gtksnapshot.c |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 77146e4..11e594e 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]