Received: from list by lists.gnu.org with archive (Exim 4.71) id 1TxHKS-0002Xg-Ef for mharc-grub-devel@gnu.org; Mon, 21 Jan 2013 08:22:24 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxHKO-0002Mg-Fm for grub-devel@gnu.org; Mon, 21 Jan 2013 08:22:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxHKM-0003gT-Ep for grub-devel@gnu.org; Mon, 21 Jan 2013 08:22:20 -0500 Received: from v6.chiark.greenend.org.uk ([2001:ba8:1e3::]:49447 helo=chiark.greenend.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxHKM-0003gE-6Q for grub-devel@gnu.org; Mon, 21 Jan 2013 08:22:18 -0500 Received: from [172.20.153.9] (helo=riva.pelham.vpn.ucam.org) by chiark.greenend.org.uk (Debian Exim 4.72 #1) with esmtps (return-path cjwatson@ubuntu.com) id 1TxHKL-0001Xn-6U for grub-devel@gnu.org; Mon, 21 Jan 2013 13:22:17 +0000 Received: from localhost ([127.0.0.1] helo=sarantium.pelham.vpn.ucam.org) by riva.pelham.vpn.ucam.org with esmtp (Exim 4.72) (envelope-from ) id 1TxHKK-0001ij-7U for grub-devel@gnu.org; Mon, 21 Jan 2013 13:22:16 +0000 Received: from riva.dynamic.greenend.org.uk (localhost [127.0.0.1]) by sarantium.pelham.vpn.ucam.org (Postfix) with ESMTPS id 8240B3E417A for ; Mon, 21 Jan 2013 13:22:13 +0000 (GMT) Date: Mon, 21 Jan 2013 13:22:12 +0000 From: Colin Watson To: grub-devel@gnu.org Subject: [PATCH 9/n] Remove nested functions from font module Message-ID: <20130121132212.GD4066@riva.dynamic.greenend.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:ba8:1e3:: X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2013 13:22:22 -0000 This increases the size of font.mod by 36 bytes on i386-pc, but it's not typically in core so I'm not too worried. === modified file 'ChangeLog' --- ChangeLog 2013-01-21 11:10:25 +0000 +++ ChangeLog 2013-01-21 13:21:09 +0000 @@ -1,5 +1,11 @@ 2013-01-21 Colin Watson + * grub-core/font/font.c (blit_comb: do_blit): Make static instead of + nested. + (blit_comb: add_device_width): Likewise. + +2013-01-21 Colin Watson + * grub-core/partmap/msdos.c (embed_signatures): Add the signature of an Acer registration utility with several sightings in the wild. Reported by: Rickard Westman. Fixes Ubuntu bug #987022. === modified file 'grub-core/font/font.c' --- grub-core/font/font.c 2012-06-10 22:20:55 +0000 +++ grub-core/font/font.c 2013-01-21 13:18:50 +0000 @@ -1143,6 +1143,49 @@ grub_font_blit_glyph_mirror (struct grub } } +/* Context for blit_comb. */ +struct blit_comb_ctx +{ + struct grub_font_glyph *glyph; + int *device_width; + struct grub_video_signed_rect bounds; +}; + +/* Helper for blit_comb. */ +static void +do_blit (struct grub_font_glyph *src, signed dx, signed dy, + struct blit_comb_ctx *ctx) +{ + if (ctx->glyph) + grub_font_blit_glyph (ctx->glyph, src, dx - ctx->glyph->offset_x, + (ctx->glyph->height + ctx->glyph->offset_y) + dy); + if (dx < ctx->bounds.x) + { + ctx->bounds.width += ctx->bounds.x - dx; + ctx->bounds.x = dx; + } + if (ctx->bounds.y > -src->height - dy) + { + ctx->bounds.height += ctx->bounds.y - (-src->height - dy); + ctx->bounds.y = (-src->height - dy); + } + if (dx + src->width - ctx->bounds.x >= (signed) ctx->bounds.width) + ctx->bounds.width = dx + src->width - ctx->bounds.x + 1; + if ((signed) ctx->bounds.height < src->height + (-src->height - dy) + - ctx->bounds.y) + ctx->bounds.height = src->height + (-src->height - dy) - ctx->bounds.y; +} + +/* Helper for blit_comb. */ +static inline void +add_device_width (int val, struct blit_comb_ctx *ctx) +{ + if (ctx->glyph) + ctx->glyph->device_width += val; + if (ctx->device_width) + *ctx->device_width += val; +} + static void blit_comb (const struct grub_unicode_glyph *glyph_id, struct grub_font_glyph *glyph, @@ -1150,63 +1193,34 @@ blit_comb (const struct grub_unicode_gly struct grub_font_glyph *main_glyph, struct grub_font_glyph **combining_glyphs, int *device_width) { - struct grub_video_signed_rect bounds; + struct blit_comb_ctx ctx = { + .glyph = glyph, + .device_width = device_width + }; unsigned i; signed above_rightx, above_righty; signed above_leftx, above_lefty; signed below_rightx, below_righty; signed min_devwidth = 0; - auto void NESTED_FUNC_ATTR do_blit (struct grub_font_glyph *src, - signed dx, signed dy); - void NESTED_FUNC_ATTR do_blit (struct grub_font_glyph *src, - signed dx, signed dy) - { - if (glyph) - grub_font_blit_glyph (glyph, src, dx - glyph->offset_x, - (glyph->height + glyph->offset_y) + dy); - if (dx < bounds.x) - { - bounds.width += bounds.x - dx; - bounds.x = dx; - } - if (bounds.y > -src->height - dy) - { - bounds.height += bounds.y - (-src->height - dy); - bounds.y = (-src->height - dy); - } - if (dx + src->width - bounds.x >= (signed) bounds.width) - bounds.width = dx + src->width - bounds.x + 1; - if ((signed) bounds.height < src->height + (-src->height - dy) - bounds.y) - bounds.height = src->height + (-src->height - dy) - bounds.y; - } - - auto void add_device_width (int val); - void add_device_width (int val) - { - if (glyph) - glyph->device_width += val; - if (device_width) - *device_width += val; - } if (glyph) glyph->device_width = main_glyph->device_width; if (device_width) *device_width = main_glyph->device_width; - bounds.x = main_glyph->offset_x; - bounds.y = main_glyph->offset_y; - bounds.width = main_glyph->width; - bounds.height = main_glyph->height; + ctx.bounds.x = main_glyph->offset_x; + ctx.bounds.y = main_glyph->offset_y; + ctx.bounds.width = main_glyph->width; + ctx.bounds.height = main_glyph->height; above_rightx = main_glyph->offset_x + main_glyph->width; - above_righty = bounds.y + bounds.height; + above_righty = ctx.bounds.y + ctx.bounds.height; above_leftx = main_glyph->offset_x; - above_lefty = bounds.y + bounds.height; + above_lefty = ctx.bounds.y + ctx.bounds.height; - below_rightx = bounds.x + bounds.width; - below_righty = bounds.y; + below_rightx = ctx.bounds.x + ctx.bounds.width; + below_righty = ctx.bounds.y; for (i = 0; i < glyph_id->ncomb; i++) { @@ -1216,7 +1230,7 @@ blit_comb (const struct grub_unicode_gly if (!combining_glyphs[i]) continue; - targetx = (bounds.width - combining_glyphs[i]->width) / 2 + bounds.x; + targetx = (ctx.bounds.width - combining_glyphs[i]->width) / 2 + ctx.bounds.x; /* CGJ is to avoid diacritics reordering. */ if (glyph_id->combining[i].code == GRUB_UNICODE_COMBINING_GRAPHEME_JOINER) @@ -1226,31 +1240,31 @@ blit_comb (const struct grub_unicode_gly case GRUB_UNICODE_COMB_OVERLAY: do_blit (combining_glyphs[i], targetx, - (bounds.height - combining_glyphs[i]->height) / 2 - - (bounds.height + bounds.y)); + (ctx.bounds.height - combining_glyphs[i]->height) / 2 + - (ctx.bounds.height + ctx.bounds.y), &ctx); if (min_devwidth < combining_glyphs[i]->width) min_devwidth = combining_glyphs[i]->width; break; case GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT: - do_blit (combining_glyphs[i], above_rightx, -above_righty); + do_blit (combining_glyphs[i], above_rightx, -above_righty, &ctx); above_rightx += combining_glyphs[i]->width; break; case GRUB_UNICODE_COMB_ABOVE_RIGHT: do_blit (combining_glyphs[i], above_rightx, - -(above_righty + combining_glyphs[i]->height)); + -(above_righty + combining_glyphs[i]->height), &ctx); above_rightx += combining_glyphs[i]->width; break; case GRUB_UNICODE_COMB_ABOVE_LEFT: above_leftx -= combining_glyphs[i]->width; do_blit (combining_glyphs[i], above_leftx, - -(above_lefty + combining_glyphs[i]->height)); + -(above_lefty + combining_glyphs[i]->height), &ctx); break; case GRUB_UNICODE_COMB_BELOW_RIGHT: - do_blit (combining_glyphs[i], below_rightx, below_righty); + do_blit (combining_glyphs[i], below_rightx, below_righty, &ctx); below_rightx += combining_glyphs[i]->width; break; @@ -1276,7 +1290,7 @@ blit_comb (const struct grub_unicode_gly space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; do_blit (combining_glyphs[i], targetx, -(main_glyph->height + main_glyph->offset_y + space - + combining_glyphs[i]->height)); + + combining_glyphs[i]->height), &ctx); if (min_devwidth < combining_glyphs[i]->width) min_devwidth = combining_glyphs[i]->width; break; @@ -1300,16 +1314,16 @@ blit_comb (const struct grub_unicode_gly case GRUB_UNICODE_STACK_ATTACHED_ABOVE: do_blit (combining_glyphs[i], targetx, - -(bounds.height + bounds.y + space - + combining_glyphs[i]->height)); + -(ctx.bounds.height + ctx.bounds.y + space + + combining_glyphs[i]->height), &ctx); if (min_devwidth < combining_glyphs[i]->width) min_devwidth = combining_glyphs[i]->width; break; case GRUB_UNICODE_COMB_HEBREW_DAGESH: do_blit (combining_glyphs[i], targetx, - -(bounds.height / 2 + bounds.y - + combining_glyphs[i]->height / 2)); + -(ctx.bounds.height / 2 + ctx.bounds.y + + combining_glyphs[i]->height / 2), &ctx); if (min_devwidth < combining_glyphs[i]->width) min_devwidth = combining_glyphs[i]->width; break; @@ -1340,7 +1354,8 @@ blit_comb (const struct grub_unicode_gly space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; case GRUB_UNICODE_STACK_ATTACHED_BELOW: - do_blit (combining_glyphs[i], targetx, -(bounds.y - space)); + do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space), + &ctx); if (min_devwidth < combining_glyphs[i]->width) min_devwidth = combining_glyphs[i]->width; break; @@ -1373,22 +1388,22 @@ blit_comb (const struct grub_unicode_gly main_glyph->device_width + combining_glyphs[i]->offset_x, -(combining_glyphs[i]->height - + combining_glyphs[i]->offset_y)); - add_device_width (combining_glyphs[i]->device_width); + + combining_glyphs[i]->offset_y), &ctx); + add_device_width (combining_glyphs[i]->device_width, &ctx); } } } add_device_width ((above_rightx > below_rightx ? above_rightx : below_rightx) - - (main_glyph->offset_x + main_glyph->width)); - add_device_width (above_leftx - main_glyph->offset_x); + (main_glyph->offset_x + main_glyph->width), &ctx); + add_device_width (above_leftx - main_glyph->offset_x, &ctx); if (glyph && glyph->device_width < min_devwidth) glyph->device_width = min_devwidth; if (device_width && *device_width < min_devwidth) *device_width = min_devwidth; if (bounds_out) - *bounds_out = bounds; + *bounds_out = ctx.bounds; } static struct grub_font_glyph * Thanks, -- Colin Watson [cjwatson@ubuntu.com]