pango r2767 - in trunk: . pango pango-view pango/opentype



Author: behdad
Date: Fri Dec 26 02:31:47 2008
New Revision: 2767
URL: http://svn.gnome.org/viewvc/pango?rev=2767&view=rev

Log:
2008-12-25  Behdad Esfahbod  <behdad gnome org>

        Bug 469049 â Fix all compiler warnings

        * pango-view/viewer-pangocairo.c (render_callback):
        * pango/fonts.c (append_field), (pango_font_description_to_string):
        * pango/opentype/harfbuzz-dump.c:
        * pango/pango-bidi-type.c (pango_log2vis_get_embedding_levels):
        * pango/pango-coverage.c (pango_coverage_set):
        * pango/pango-markup.c (span_parse_func):
        * pango/pango-renderer.c
        (pango_renderer_default_draw_error_underline):
        * pango/pango-utils.c (pango_scan_string):
        * pango/pangocairo-render.c (pango_cairo_renderer_draw_trapezoid),
        (draw_error_underline), (pango_cairo_renderer_class_init):
        Fix all the remaining warnings.

Modified:
   trunk/ChangeLog
   trunk/pango-view/viewer-pangocairo.c
   trunk/pango/fonts.c
   trunk/pango/opentype/harfbuzz-dump.c
   trunk/pango/pango-bidi-type.c
   trunk/pango/pango-coverage.c
   trunk/pango/pango-markup.c
   trunk/pango/pango-renderer.c
   trunk/pango/pango-utils.c
   trunk/pango/pangocairo-render.c

Modified: trunk/pango-view/viewer-pangocairo.c
==============================================================================
--- trunk/pango-view/viewer-pangocairo.c	(original)
+++ trunk/pango-view/viewer-pangocairo.c	Fri Dec 26 02:31:47 2008
@@ -269,6 +269,7 @@
       cairo_restore (cr);
     }
 
+  cairo_move_to (cr, 0, 0);
   pango_cairo_show_layout (cr, layout);
 
   cairo_restore (cr);

Modified: trunk/pango/fonts.c
==============================================================================
--- trunk/pango/fonts.c	(original)
+++ trunk/pango/fonts.c	Fri Dec 26 02:31:47 2008
@@ -1120,19 +1120,19 @@
   int i;
   for (i=0; i<n_elements; i++)
     {
-      if (map[i].value == val)
+      if (map[i].value != val)
+        continue;
+
+      if (G_LIKELY (map[i].str && map[i].str[0]))
 	{
-	  if (map[i].str && map[i].str[0])
-	    {
-	      if (str->len > 0 && str->str[str->len -1] != ' ')
-		g_string_append_c (str, ' ');
-	      g_string_append (str, map[i].str);
-	    }
-	  return;
+	  if (G_LIKELY (str->len > 0 && str->str[str->len -1] != ' '))
+	    g_string_append_c (str, ' ');
+	  g_string_append (str, map[i].str);
 	}
+      return;
     }
 
-  if (str->len > 0 || str->str[str->len -1] != ' ')
+  if (G_LIKELY (str->len > 0 || str->str[str->len -1] != ' '))
     g_string_append_c (str, ' ');
   g_string_append_printf (str, "%d", val);
 }
@@ -1158,7 +1158,7 @@
 
   result = g_string_new (NULL);
 
-  if (desc->family_name && desc->mask & PANGO_FONT_MASK_FAMILY)
+  if (G_LIKELY (desc->family_name && desc->mask & PANGO_FONT_MASK_FAMILY))
     {
       const char *p;
       size_t wordlen;

Modified: trunk/pango/opentype/harfbuzz-dump.c
==============================================================================
--- trunk/pango/opentype/harfbuzz-dump.c	(original)
+++ trunk/pango/opentype/harfbuzz-dump.c	Fri Dec 26 02:31:47 2008
@@ -54,6 +54,9 @@
   fprintf (stream, "%*s", indent * 3, "");
 }
 
+#if __GNUC__ >= 3
+__attribute__((__format__(__printf__, 3, 4)))
+#endif
 static void
 dump (FILE *stream, int indent, const char *format, ...)
 {

Modified: trunk/pango/pango-bidi-type.c
==============================================================================
--- trunk/pango/pango-bidi-type.c	(original)
+++ trunk/pango/pango-bidi-type.c	Fri Dec 26 02:31:47 2008
@@ -131,7 +131,7 @@
   {
     if (length < 0)
       length = strlen (text);
-    embedding_levels_list = fribidi_log2vis_get_embedding_levels_new_utf8 (text, length, &fribidi_base_dir);
+    embedding_levels_list = (guint8 *) fribidi_log2vis_get_embedding_levels_new_utf8 (text, length, &fribidi_base_dir);
   }
 #else
   {

Modified: trunk/pango/pango-coverage.c
==============================================================================
--- trunk/pango/pango-coverage.c	(original)
+++ trunk/pango/pango-coverage.c	Fri Dec 26 02:31:47 2008
@@ -212,7 +212,7 @@
 
   g_return_if_fail (coverage != NULL);
   g_return_if_fail (index >= 0);
-  g_return_if_fail (level >= 0 && level <= 3);
+  g_return_if_fail ((guint) level <= 3);
 
   block_index = index / 256;
 

Modified: trunk/pango/pango-markup.c
==============================================================================
--- trunk/pango/pango-markup.c	(original)
+++ trunk/pango/pango-markup.c	Fri Dec 26 02:31:47 2008
@@ -1244,7 +1244,7 @@
     {
       PangoUnderline ul = PANGO_UNDERLINE_NONE;
 
-      if (!span_parse_enum ("underline", underline, PANGO_TYPE_UNDERLINE, (int *) &ul, line_number, error))
+      if (!span_parse_enum ("underline", underline, PANGO_TYPE_UNDERLINE, (int*)(void*)&ul, line_number, error))
 	goto error;
 
       add_attribute (tag, pango_attr_underline_new (ul));
@@ -1264,7 +1264,7 @@
     {
       PangoGravity gr = PANGO_GRAVITY_SOUTH;
 
-      if (!span_parse_enum ("gravity", gravity, PANGO_TYPE_GRAVITY, (int *) &gr, line_number, error))
+      if (!span_parse_enum ("gravity", gravity, PANGO_TYPE_GRAVITY, (int*)(void*)&gr, line_number, error))
 	goto error;
 
       add_attribute (tag, pango_attr_gravity_new (gr));
@@ -1274,7 +1274,7 @@
     {
       PangoGravityHint hint = PANGO_GRAVITY_HINT_NATURAL;
 
-      if (!span_parse_enum ("gravity_hint", gravity_hint, PANGO_TYPE_GRAVITY_HINT, (int *) &hint, line_number, error))
+      if (!span_parse_enum ("gravity_hint", gravity_hint, PANGO_TYPE_GRAVITY_HINT, (int*)(void*)&hint, line_number, error))
 	goto error;
 
       add_attribute (tag, pango_attr_gravity_hint_new (hint));

Modified: trunk/pango/pango-renderer.c
==============================================================================
--- trunk/pango/pango-renderer.c	(original)
+++ trunk/pango/pango-renderer.c	Fri Dec 26 02:31:47 2008
@@ -975,6 +975,7 @@
   const PangoMatrix *matrix;
   double dx, dx0, dy0;
   PangoMatrix total;
+  int i;
 
   x += (width - width_units * unit_width) / 2;
   width = width_units * unit_width;
@@ -989,27 +990,25 @@
   dx0 = (matrix->xx * dx) / PANGO_SCALE;
   dy0 = (matrix->yx * dx) / PANGO_SCALE;
 
+  i = (width_units - 1) / 2;
   while (TRUE)
     {
-
       draw_rectangle (renderer, &total, PANGO_RENDER_PART_UNDERLINE, /* A */
 		      0,                      0,
 		      HEIGHT_SQUARES * 2 - 1, 1);
 
-      if (width_units > 2)
-	{
-	  draw_rectangle (renderer, &total, PANGO_RENDER_PART_UNDERLINE, /* B */
-			  HEIGHT_SQUARES * 2 - 2, - (HEIGHT_SQUARES * 2 - 3),
-			  1,                      HEIGHT_SQUARES * 2 - 3);
-	  width_units -= 2;
+      if (i <= 0)
+        break;
+      i--;
+
+      draw_rectangle (renderer, &total, PANGO_RENDER_PART_UNDERLINE, /* B */
+		      HEIGHT_SQUARES * 2 - 2, - (HEIGHT_SQUARES * 2 - 3),
+		      1,                      HEIGHT_SQUARES * 2 - 3);
 
-	  total.x0 += dx0;
-	  total.y0 += dy0;
-	}
-      else
-	break;
+      total.x0 += dx0;
+      total.y0 += dy0;
     }
-  if (width_units == 2)
+  if (width_units % 2 == 0)
     {
       draw_rectangle (renderer, &total, PANGO_RENDER_PART_UNDERLINE, /* C */
 		      HEIGHT_SQUARES * 2 - 2, - (HEIGHT_SQUARES * 2 - 2),

Modified: trunk/pango/pango-utils.c
==============================================================================
--- trunk/pango/pango-utils.c	(original)
+++ trunk/pango/pango-utils.c	Fri Dec 26 02:31:47 2008
@@ -425,7 +425,7 @@
   while (g_ascii_isspace (*p))
     p++;
 
-  if (!*p)
+  if (G_UNLIKELY (!*p))
     return FALSE;
   else if (*p == '"')
     {

Modified: trunk/pango/pangocairo-render.c
==============================================================================
--- trunk/pango/pangocairo-render.c	(original)
+++ trunk/pango/pangocairo-render.c	Fri Dec 26 02:31:47 2008
@@ -498,6 +498,45 @@
     }
 }
 
+static void
+pango_cairo_renderer_draw_trapezoid (PangoRenderer     *renderer,
+				     PangoRenderPart    part,
+				     double             y1_,
+				     double             x11,
+				     double             x21,
+				     double             y2,
+				     double             x12,
+				     double             x22)
+{
+  PangoCairoRenderer *crenderer = (PangoCairoRenderer *) (renderer);
+  cairo_t *cr;
+  double x, y;
+
+  cr = crenderer->cr;
+
+  cairo_save (cr);
+
+  if (!crenderer->do_path)
+    set_color (crenderer, part);
+
+  x = crenderer->x_offset,
+  y = crenderer->y_offset;
+  cairo_user_to_device_distance (cr, &x, &y);
+  cairo_identity_matrix (cr);
+  cairo_translate (cr, x, y);
+
+  cairo_move_to (cr, x11, y1_);
+  cairo_line_to (cr, x21, y1_);
+  cairo_line_to (cr, x22, y2);
+  cairo_line_to (cr, x12, y2);
+  cairo_close_path (cr);
+
+  if (!crenderer->do_path)
+    cairo_fill (cr);
+
+  cairo_restore (cr);
+}
+
 /* Draws an error underline that looks like one of:
  *              H       E                H
  *     /\      /\      /\        /\      /\               -
@@ -527,8 +566,10 @@
 {
   double square = height / HEIGHT_SQUARES;
   double unit_width = (HEIGHT_SQUARES - 1) * square;
+  double double_width = 2 * unit_width;
   int width_units = (width + unit_width / 2) / unit_width;
   double y_top, y_bottom;
+  double x_left, x_middle, x_right;
   int i;
 
   x += (width - width_units * unit_width) / 2;
@@ -538,38 +579,35 @@
   y_bottom = y + height;
 
   /* Bottom of squiggle */
+  x_middle = x + unit_width;
+  x_right  = x + double_width;
   cairo_move_to (cr, x - square / 2, y_top + square / 2); /* A */
-  for (i = 0; i < width_units; i += 2)
+  for (i = 0; i < width_units-2; i += 2)
     {
-      double x_middle = x + (i + 1) * unit_width;
-      double x_right = x + (i + 2) * unit_width;
-
       cairo_line_to (cr, x_middle, y_bottom); /* B */
+      cairo_line_to (cr, x_right, y_top + square); /* C */
 
-      if (i + 1 == width_units)
-	/* Nothing */;
-      else if (i + 2 == width_units)
-	cairo_line_to (cr, x_right + square / 2, y_top + square / 2); /* D */
-      else
-	cairo_line_to (cr, x_right, y_top + square); /* C */
+      x_middle += double_width;
+      x_right  += double_width;
     }
+  cairo_line_to (cr, x_middle, y_bottom); /* B */
+
+  if (i + 1 == width_units)
+    cairo_line_to (cr, x_middle + square / 2, y_bottom - square / 2); /* G */
+  else if (i + 2 == width_units) {
+    cairo_line_to (cr, x_right + square / 2, y_top + square / 2); /* D */
+    cairo_line_to (cr, x_right, y_top); /* E */
+  }
 
   /* Top of squiggle */
-  for (i -= 2; i >= 0; i -= 2)
+  x_left = x_middle - unit_width;
+  for (; i >= 0; i -= 2)
     {
-      double x_left = x + i * unit_width;
-      double x_middle = x + (i + 1) * unit_width;
-      double x_right = x + (i + 2) * unit_width;
-
-      if (i + 1 == width_units)
-	cairo_line_to (cr, x_middle + square / 2, y_bottom - square / 2); /* G */
-      else {
-	if (i + 2 == width_units)
-	  cairo_line_to (cr, x_right, y_top); /* E */
-	cairo_line_to (cr, x_middle, y_bottom - square); /* F */
-      }
-
+      cairo_line_to (cr, x_middle, y_bottom - square); /* F */
       cairo_line_to (cr, x_left, y_top);   /* H */
+
+      x_left   -= double_width;
+      x_middle -= double_width;
     }
 }
 
@@ -656,6 +694,7 @@
   renderer_class->draw_glyphs = pango_cairo_renderer_draw_glyphs;
   renderer_class->draw_glyph_item = pango_cairo_renderer_draw_glyph_item;
   renderer_class->draw_rectangle = pango_cairo_renderer_draw_rectangle;
+  renderer_class->draw_trapezoid = pango_cairo_renderer_draw_trapezoid;
   renderer_class->draw_error_underline = pango_cairo_renderer_draw_error_underline;
   renderer_class->draw_shape = pango_cairo_renderer_draw_shape;
 }



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