pango r2814 - in trunk: . pango



Author: behdad
Date: Wed Jan 28 23:41:59 2009
New Revision: 2814
URL: http://svn.gnome.org/viewvc/pango?rev=2814&view=rev

Log:
2009-01-28  Behdad Esfahbod  <behdad gnome org>

        Bug 560792 â Make PangoLayoutLine with line->layout==NULL renderable

        * pango/pango-renderer.c (pango_renderer_draw_layout_line),
        (pango_renderer_draw_glyph_item), (pango_renderer_set_matrix):
        Handle line->layout == NULL.

Modified:
   trunk/ChangeLog
   trunk/pango/pango-renderer.c

Modified: trunk/pango/pango-renderer.c
==============================================================================
--- trunk/pango/pango-renderer.c	(original)
+++ trunk/pango/pango-renderer.c	Wed Jan 28 23:41:59 2009
@@ -475,11 +475,11 @@
    * active.
    */
   if (!renderer->active_count)
-    {
-      PangoContext *context = pango_layout_get_context (line->layout);
-      pango_renderer_set_matrix (renderer,
-				 pango_context_get_matrix (context));
-    }
+    pango_renderer_set_matrix (renderer,
+			       G_LIKELY (line->layout) ?
+			       pango_context_get_matrix
+			       (pango_layout_get_context (line->layout)) :
+			       NULL);
 
   pango_renderer_activate (renderer);
 
@@ -489,7 +489,7 @@
   state.underline = PANGO_UNDERLINE_NONE;
   state.strikethrough = FALSE;
 
-  text = pango_layout_get_text (line->layout);
+  text = G_LIKELY (line->layout) ? pango_layout_get_text (line->layout) : NULL;
 
   for (l = line->runs; l; l = l->next)
     {
@@ -676,7 +676,7 @@
 /**
  * pango_renderer_draw_glyph_item:
  * @renderer: a #PangoRenderer
- * @text: the UTF-8 text that @glyph_item refers to
+ * @text: the UTF-8 text that @glyph_item refers to, or %NULL
  * @glyph_item: a #PangoGlyphItem
  * @x: X position of left edge of baseline, in user space coordinates
  *   in Pango units.
@@ -690,6 +690,8 @@
  * Note that @text is the start of the text for layout, which is then
  * indexed by <literal>@glyph_item->item->offset</literal>.
  *
+ * If @text is %NULL, this simply calls pango_renderer_draw_glyphs().
+ *
  * The default implementation of this method simply falls back to
  * pango_renderer_draw_glyphs().
  *
@@ -702,6 +704,15 @@
 				int               x,
 				int               y)
 {
+  if (G_UNLIKELY (text))
+    {
+      pango_renderer_draw_glyphs (renderer,
+				  glyph_item->item->analysis.font,
+				  glyph_item->glyphs,
+				  x, y);
+      return;
+    }
+
   g_return_if_fail (PANGO_IS_RENDERER_FAST (renderer));
 
   pango_renderer_activate (renderer);
@@ -1323,13 +1334,8 @@
 {
   g_return_if_fail (PANGO_IS_RENDERER_FAST (renderer));
 
-  if (renderer->matrix)
-    pango_matrix_free (renderer->matrix);
-  if (matrix)
-    renderer->matrix = pango_matrix_copy (matrix);
-  else
-    renderer->matrix = NULL;
-
+  pango_matrix_free (renderer->matrix);
+  renderer->matrix = pango_matrix_copy (matrix);
 }
 
 /**
@@ -1371,7 +1377,7 @@
  * Since: 1.20
  **/
 PangoLayout *
-pango_renderer_get_layout      (PangoRenderer     *renderer)
+pango_renderer_get_layout (PangoRenderer *renderer)
 {
   if (G_UNLIKELY (renderer->priv->line == NULL))
     return NULL;



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