Blame SOURCES/0138-grub-core-font-font.c-blit_comb-do_blit-Make-static-.patch

f96e0b
From 84f37bce3a842058d6f33839e541d79cec384fab Mon Sep 17 00:00:00 2001
f96e0b
From: Colin Watson <cjwatson@ubuntu.com>
f96e0b
Date: Mon, 21 Jan 2013 21:03:26 +0000
f96e0b
Subject: [PATCH 138/482] * grub-core/font/font.c (blit_comb: do_blit): Make
f96e0b
 static instead of nested. (blit_comb: add_device_width): Likewise.
f96e0b
f96e0b
---
f96e0b
 ChangeLog             |   6 +++
f96e0b
 grub-core/font/font.c | 133 ++++++++++++++++++++++++++++----------------------
f96e0b
 2 files changed, 80 insertions(+), 59 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 08c2c9f..a2edbc5 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,11 @@
f96e0b
 2013-01-21  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
 
f96e0b
+	* grub-core/font/font.c (blit_comb: do_blit): Make static instead of
f96e0b
+	nested.
f96e0b
+	(blit_comb: add_device_width): Likewise.
f96e0b
+
f96e0b
+2013-01-21  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
+
f96e0b
 	Remove nested functions from USB iterators.
f96e0b
 
f96e0b
 	* include/grub/usb.h (grub_usb_iterate_hook_t): New type.
f96e0b
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
f96e0b
index fca8c8d..6b54a84 100644
f96e0b
--- a/grub-core/font/font.c
f96e0b
+++ b/grub-core/font/font.c
f96e0b
@@ -1143,6 +1143,49 @@ grub_font_blit_glyph_mirror (struct grub_font_glyph *target,
f96e0b
     }
f96e0b
 }
f96e0b
 
f96e0b
+/* Context for blit_comb.  */
f96e0b
+struct blit_comb_ctx
f96e0b
+{
f96e0b
+  struct grub_font_glyph *glyph;
f96e0b
+  int *device_width;
f96e0b
+  struct grub_video_signed_rect bounds;
f96e0b
+};
f96e0b
+
f96e0b
+/* Helper for blit_comb.  */
f96e0b
+static void
f96e0b
+do_blit (struct grub_font_glyph *src, signed dx, signed dy,
f96e0b
+	 struct blit_comb_ctx *ctx)
f96e0b
+{
f96e0b
+  if (ctx->glyph)
f96e0b
+    grub_font_blit_glyph (ctx->glyph, src, dx - ctx->glyph->offset_x,
f96e0b
+			  (ctx->glyph->height + ctx->glyph->offset_y) + dy);
f96e0b
+  if (dx < ctx->bounds.x)
f96e0b
+    {
f96e0b
+      ctx->bounds.width += ctx->bounds.x - dx;
f96e0b
+      ctx->bounds.x = dx;
f96e0b
+    }
f96e0b
+  if (ctx->bounds.y > -src->height - dy)
f96e0b
+    {
f96e0b
+      ctx->bounds.height += ctx->bounds.y - (-src->height - dy);
f96e0b
+      ctx->bounds.y = (-src->height - dy);
f96e0b
+    }
f96e0b
+  if (dx + src->width - ctx->bounds.x >= (signed) ctx->bounds.width)
f96e0b
+    ctx->bounds.width = dx + src->width - ctx->bounds.x + 1;
f96e0b
+  if ((signed) ctx->bounds.height < src->height + (-src->height - dy)
f96e0b
+      - ctx->bounds.y)
f96e0b
+    ctx->bounds.height = src->height + (-src->height - dy) - ctx->bounds.y;
f96e0b
+}
f96e0b
+
f96e0b
+/* Helper for blit_comb.  */
f96e0b
+static inline void
f96e0b
+add_device_width (int val, struct blit_comb_ctx *ctx)
f96e0b
+{
f96e0b
+  if (ctx->glyph)
f96e0b
+    ctx->glyph->device_width += val;
f96e0b
+  if (ctx->device_width)
f96e0b
+    *ctx->device_width += val;
f96e0b
+}
f96e0b
+
f96e0b
 static void
f96e0b
 blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 	   struct grub_font_glyph *glyph,
f96e0b
@@ -1150,63 +1193,34 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 	   struct grub_font_glyph *main_glyph,
f96e0b
 	   struct grub_font_glyph **combining_glyphs, int *device_width)
f96e0b
 {
f96e0b
-  struct grub_video_signed_rect bounds;
f96e0b
+  struct blit_comb_ctx ctx = {
f96e0b
+    .glyph = glyph,
f96e0b
+    .device_width = device_width
f96e0b
+  };
f96e0b
   unsigned i;
f96e0b
   signed above_rightx, above_righty;
f96e0b
   signed above_leftx, above_lefty;
f96e0b
   signed below_rightx, below_righty;
f96e0b
   signed min_devwidth = 0;
f96e0b
-  auto void NESTED_FUNC_ATTR do_blit (struct grub_font_glyph *src,
f96e0b
-				      signed dx, signed dy);
f96e0b
-  void NESTED_FUNC_ATTR do_blit (struct grub_font_glyph *src,
f96e0b
-				 signed dx, signed dy)
f96e0b
-  {
f96e0b
-    if (glyph)
f96e0b
-      grub_font_blit_glyph (glyph, src, dx - glyph->offset_x,
f96e0b
-			    (glyph->height + glyph->offset_y) + dy);
f96e0b
-    if (dx < bounds.x)
f96e0b
-      {
f96e0b
-	bounds.width += bounds.x - dx;
f96e0b
-	bounds.x = dx;
f96e0b
-      }
f96e0b
-    if (bounds.y > -src->height - dy)
f96e0b
-      {
f96e0b
-	bounds.height += bounds.y - (-src->height - dy);
f96e0b
-	bounds.y = (-src->height - dy);
f96e0b
-      }
f96e0b
-    if (dx + src->width - bounds.x >= (signed) bounds.width)
f96e0b
-      bounds.width = dx + src->width - bounds.x + 1;
f96e0b
-    if ((signed) bounds.height < src->height + (-src->height - dy) - bounds.y)
f96e0b
-      bounds.height = src->height + (-src->height - dy) - bounds.y;
f96e0b
-  }
f96e0b
-
f96e0b
-  auto void add_device_width (int val);
f96e0b
-  void add_device_width (int val)
f96e0b
-  {
f96e0b
-    if (glyph)
f96e0b
-      glyph->device_width += val;
f96e0b
-    if (device_width)
f96e0b
-      *device_width += val;
f96e0b
-  }
f96e0b
 
f96e0b
   if (glyph)
f96e0b
     glyph->device_width = main_glyph->device_width;
f96e0b
   if (device_width)
f96e0b
     *device_width = main_glyph->device_width;
f96e0b
 
f96e0b
-  bounds.x = main_glyph->offset_x;
f96e0b
-  bounds.y = main_glyph->offset_y;
f96e0b
-  bounds.width = main_glyph->width;
f96e0b
-  bounds.height = main_glyph->height;
f96e0b
+  ctx.bounds.x = main_glyph->offset_x;
f96e0b
+  ctx.bounds.y = main_glyph->offset_y;
f96e0b
+  ctx.bounds.width = main_glyph->width;
f96e0b
+  ctx.bounds.height = main_glyph->height;
f96e0b
 
f96e0b
   above_rightx = main_glyph->offset_x + main_glyph->width;
f96e0b
-  above_righty = bounds.y + bounds.height;
f96e0b
+  above_righty = ctx.bounds.y + ctx.bounds.height;
f96e0b
 
f96e0b
   above_leftx = main_glyph->offset_x;
f96e0b
-  above_lefty = bounds.y + bounds.height;
f96e0b
+  above_lefty = ctx.bounds.y + ctx.bounds.height;
f96e0b
 
f96e0b
-  below_rightx = bounds.x + bounds.width;
f96e0b
-  below_righty = bounds.y;
f96e0b
+  below_rightx = ctx.bounds.x + ctx.bounds.width;
f96e0b
+  below_righty = ctx.bounds.y;
f96e0b
 
f96e0b
   for (i = 0; i < glyph_id->ncomb; i++)
f96e0b
     {
f96e0b
@@ -1216,7 +1230,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 
f96e0b
       if (!combining_glyphs[i])
f96e0b
 	continue;
f96e0b
-      targetx = (bounds.width - combining_glyphs[i]->width) / 2 + bounds.x;
f96e0b
+      targetx = (ctx.bounds.width - combining_glyphs[i]->width) / 2 + ctx.bounds.x;
f96e0b
       /* CGJ is to avoid diacritics reordering. */
f96e0b
       if (glyph_id->combining[i].code
f96e0b
 	  == GRUB_UNICODE_COMBINING_GRAPHEME_JOINER)
f96e0b
@@ -1226,31 +1240,31 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 	case GRUB_UNICODE_COMB_OVERLAY:
f96e0b
 	  do_blit (combining_glyphs[i],
f96e0b
 		   targetx,
f96e0b
-		   (bounds.height - combining_glyphs[i]->height) / 2
f96e0b
-		   - (bounds.height + bounds.y));
f96e0b
+		   (ctx.bounds.height - combining_glyphs[i]->height) / 2
f96e0b
+		   - (ctx.bounds.height + ctx.bounds.y), &ctx;;
f96e0b
 	  if (min_devwidth < combining_glyphs[i]->width)
f96e0b
 	    min_devwidth = combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
 
f96e0b
 	case GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT:
f96e0b
-	  do_blit (combining_glyphs[i], above_rightx, -above_righty);
f96e0b
+	  do_blit (combining_glyphs[i], above_rightx, -above_righty, &ctx;;
f96e0b
 	  above_rightx += combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
 
f96e0b
 	case GRUB_UNICODE_COMB_ABOVE_RIGHT:
f96e0b
 	  do_blit (combining_glyphs[i], above_rightx,
f96e0b
-		   -(above_righty + combining_glyphs[i]->height));
f96e0b
+		   -(above_righty + combining_glyphs[i]->height), &ctx;;
f96e0b
 	  above_rightx += combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
 
f96e0b
 	case GRUB_UNICODE_COMB_ABOVE_LEFT:
f96e0b
 	  above_leftx -= combining_glyphs[i]->width;
f96e0b
 	  do_blit (combining_glyphs[i], above_leftx,
f96e0b
-		   -(above_lefty + combining_glyphs[i]->height));
f96e0b
+		   -(above_lefty + combining_glyphs[i]->height), &ctx;;
f96e0b
 	  break;
f96e0b
 
f96e0b
 	case GRUB_UNICODE_COMB_BELOW_RIGHT:
f96e0b
-	  do_blit (combining_glyphs[i], below_rightx, below_righty);
f96e0b
+	  do_blit (combining_glyphs[i], below_rightx, below_righty, &ctx;;
f96e0b
 	  below_rightx += combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
 
f96e0b
@@ -1276,7 +1290,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 	    space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
f96e0b
 	  do_blit (combining_glyphs[i], targetx,
f96e0b
 		   -(main_glyph->height + main_glyph->offset_y + space
f96e0b
-		     + combining_glyphs[i]->height));
f96e0b
+		     + combining_glyphs[i]->height), &ctx;;
f96e0b
 	  if (min_devwidth < combining_glyphs[i]->width)
f96e0b
 	    min_devwidth = combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
@@ -1300,16 +1314,16 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 
f96e0b
 	case GRUB_UNICODE_STACK_ATTACHED_ABOVE:
f96e0b
 	  do_blit (combining_glyphs[i], targetx,
f96e0b
-		   -(bounds.height + bounds.y + space
f96e0b
-		     + combining_glyphs[i]->height));
f96e0b
+		   -(ctx.bounds.height + ctx.bounds.y + space
f96e0b
+		     + combining_glyphs[i]->height), &ctx;;
f96e0b
 	  if (min_devwidth < combining_glyphs[i]->width)
f96e0b
 	    min_devwidth = combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
 
f96e0b
 	case GRUB_UNICODE_COMB_HEBREW_DAGESH:
f96e0b
 	  do_blit (combining_glyphs[i], targetx,
f96e0b
-		   -(bounds.height / 2 + bounds.y
f96e0b
-		     + combining_glyphs[i]->height / 2));
f96e0b
+		   -(ctx.bounds.height / 2 + ctx.bounds.y
f96e0b
+		     + combining_glyphs[i]->height / 2), &ctx;;
f96e0b
 	  if (min_devwidth < combining_glyphs[i]->width)
f96e0b
 	    min_devwidth = combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
@@ -1340,7 +1354,8 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 	    space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
f96e0b
 
f96e0b
 	case GRUB_UNICODE_STACK_ATTACHED_BELOW:
f96e0b
-	  do_blit (combining_glyphs[i], targetx, -(bounds.y - space));
f96e0b
+	  do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space),
f96e0b
+		   &ctx;;
f96e0b
 	  if (min_devwidth < combining_glyphs[i]->width)
f96e0b
 	    min_devwidth = combining_glyphs[i]->width;
f96e0b
 	  break;
f96e0b
@@ -1373,22 +1388,22 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
f96e0b
 		     main_glyph->device_width
f96e0b
 		     + combining_glyphs[i]->offset_x,
f96e0b
 		     -(combining_glyphs[i]->height
f96e0b
-		       + combining_glyphs[i]->offset_y));
f96e0b
-	    add_device_width (combining_glyphs[i]->device_width);
f96e0b
+		       + combining_glyphs[i]->offset_y), &ctx;;
f96e0b
+	    add_device_width (combining_glyphs[i]->device_width, &ctx;;
f96e0b
 	  }
f96e0b
 	}
f96e0b
     }
f96e0b
   add_device_width ((above_rightx >
f96e0b
 		     below_rightx ? above_rightx : below_rightx) -
f96e0b
-		    (main_glyph->offset_x + main_glyph->width));
f96e0b
-  add_device_width (above_leftx - main_glyph->offset_x);
f96e0b
+		    (main_glyph->offset_x + main_glyph->width), &ctx;;
f96e0b
+  add_device_width (above_leftx - main_glyph->offset_x, &ctx;;
f96e0b
   if (glyph && glyph->device_width < min_devwidth)
f96e0b
     glyph->device_width = min_devwidth;
f96e0b
   if (device_width && *device_width < min_devwidth)
f96e0b
     *device_width = min_devwidth;
f96e0b
 
f96e0b
   if (bounds_out)
f96e0b
-    *bounds_out = bounds;
f96e0b
+    *bounds_out = ctx.bounds;
f96e0b
 }
f96e0b
 
f96e0b
 static struct grub_font_glyph *
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b