summaryrefslogtreecommitdiff
path: root/pango/pangoft2.c
diff options
context:
space:
mode:
authorSven Neumann <sven@gimp.org>2003-07-24 22:13:48 +0000
committerSven Neumann <neo@src.gnome.org>2003-07-24 22:13:48 +0000
commita730bbb4e4e9ff89a0129aa90f857612d888ff69 (patch)
treef9388ba3c8368b3343fe5470484065a470ec959d /pango/pangoft2.c
parentf3a4b12140a862bf716f8e3513a20e5729e13cc9 (diff)
downloadpango-a730bbb4e4e9ff89a0129aa90f857612d888ff69.tar.gz
removed redundant call to pango_layout_line_get_extents() (#116822).
2003-07-25 Sven Neumann <sven@gimp.org> * pango/pangoft2.c (pango_ft2_render_layout_line): removed redundant call to pango_layout_line_get_extents() (#116822). * pango/pangoft2.c (pango_ft2_render): fixed source bitmap offset for the monochrome case; some code cleanup (#116837).
Diffstat (limited to 'pango/pangoft2.c')
-rw-r--r--pango/pangoft2.c130
1 files changed, 74 insertions, 56 deletions
diff --git a/pango/pangoft2.c b/pango/pangoft2.c
index 1e7f391b..7213da02 100644
--- a/pango/pangoft2.c
+++ b/pango/pangoft2.c
@@ -418,7 +418,8 @@ pango_ft2_render (FT_Bitmap *bitmap,
PangoFT2RenderedGlyph *rendered_glyph;
glyph_index = gi->glyph;
- rendered_glyph = pango_ft2_font_get_cache_glyph_data (font, glyph_index);
+ rendered_glyph = pango_ft2_font_get_cache_glyph_data (font,
+ glyph_index);
add_glyph_to_cache = FALSE;
if (rendered_glyph == NULL)
{
@@ -430,10 +431,12 @@ pango_ft2_render (FT_Bitmap *bitmap,
iyoff = y + PANGO_PIXELS (gi->geometry.y_offset);
x_start = MAX (0, - (ixoff + rendered_glyph->bitmap_left));
- x_limit = MIN (rendered_glyph->bitmap.width, bitmap->width - (ixoff + rendered_glyph->bitmap_left));
+ x_limit = MIN (rendered_glyph->bitmap.width,
+ bitmap->width - (ixoff + rendered_glyph->bitmap_left));
y_start = MAX (0, - (iyoff - rendered_glyph->bitmap_top));
- y_limit = MIN (rendered_glyph->bitmap.rows, bitmap->rows - (iyoff - rendered_glyph->bitmap_top));
+ y_limit = MIN (rendered_glyph->bitmap.rows,
+ bitmap->rows - (iyoff - rendered_glyph->bitmap_top));
PING (("glyph %d:%d: bitmap: %dx%d, left:%d top:%d",
i, glyph_index,
@@ -442,61 +445,79 @@ pango_ft2_render (FT_Bitmap *bitmap,
PING (("xstart:%d xlim:%d ystart:%d ylim:%d",
x_start, x_limit, y_start, y_limit));
- if (rendered_glyph->bitmap.pixel_mode == ft_pixel_mode_grays)
- for (iy = y_start; iy < y_limit; iy++)
- {
- dest = bitmap->buffer +
- (iyoff - rendered_glyph->bitmap_top + iy) * bitmap->pitch +
- ixoff + rendered_glyph->bitmap_left + x_start;
-
- src = rendered_glyph->bitmap.buffer +
- iy * rendered_glyph->bitmap.pitch + x_start;
-
- for (ix = x_start; ix < x_limit; ix++)
- {
- switch (*src)
- {
- case 0:
- break;
- case 0xff:
- *dest = 0xff;
- default:
- *dest = MIN ((gushort) *dest + (gushort) *src, 0xff);
- break;
- }
- dest++;
- src++;
- }
- }
- else if (rendered_glyph->bitmap.pixel_mode == ft_pixel_mode_mono)
- for (iy = y_start; iy < y_limit; iy++)
- {
- dest = bitmap->buffer +
- (iyoff - rendered_glyph->bitmap_top + iy) * bitmap->pitch +
- ixoff + rendered_glyph->bitmap_left +
- x_start;
-
- src = rendered_glyph->bitmap.buffer +
- iy*rendered_glyph->bitmap.pitch;
-
- for (ix = x_start; ix < x_limit; ix++)
- {
- if ((*src) & (1 << (7 - (ix % 8))))
- *dest |= 0xff;
- if ((ix % 8) == 7)
- src++;
- dest++;
- }
- }
- else
- g_warning ("pango_ft2_render: Unrecognized glyph bitmap pixel mode %d\n",
- rendered_glyph->bitmap.pixel_mode);
+ src = rendered_glyph->bitmap.buffer +
+ y_start * rendered_glyph->bitmap.pitch;
+
+ dest = bitmap->buffer +
+ (y_start + iyoff - rendered_glyph->bitmap_top) * bitmap->pitch +
+ x_start + ixoff + rendered_glyph->bitmap_left;
+
+ switch (rendered_glyph->bitmap.pixel_mode)
+ {
+ case ft_pixel_mode_grays:
+ src += x_start;
+ for (iy = y_start; iy < y_limit; iy++)
+ {
+ guchar *s = src;
+ guchar *d = dest;
+
+ for (ix = x_start; ix < x_limit; ix++)
+ {
+ switch (*s)
+ {
+ case 0:
+ break;
+ case 0xff:
+ *d = 0xff;
+ default:
+ *d = MIN ((gushort) *d + (gushort) *s, 0xff);
+ break;
+ }
+
+ s++;
+ d++;
+ }
+
+ dest += bitmap->pitch;
+ src += rendered_glyph->bitmap.pitch;
+ }
+ break;
+
+ case ft_pixel_mode_mono:
+ src += x_start / 8;
+ for (iy = y_start; iy < y_limit; iy++)
+ {
+ guchar *s = src;
+ guchar *d = dest;
+
+ for (ix = x_start; ix < x_limit; ix++)
+ {
+ if ((*s) & (1 << (7 - (ix % 8))))
+ *d |= 0xff;
+
+ if ((ix % 8) == 7)
+ s++;
+ d++;
+ }
+
+ dest += bitmap->pitch;
+ src += rendered_glyph->bitmap.pitch;
+ }
+ break;
+
+ default:
+ g_warning ("pango_ft2_render: "
+ "Unrecognized glyph bitmap pixel mode %d\n",
+ rendered_glyph->bitmap.pixel_mode);
+ break;
+ }
if (add_glyph_to_cache)
{
pango_ft2_font_set_glyph_cache_destroy (font,
(GDestroyNotify) pango_ft2_free_rendered_glyph);
- pango_ft2_font_set_cache_glyph_data (font, glyph_index, rendered_glyph);
+ pango_ft2_font_set_cache_glyph_data (font,
+ glyph_index, rendered_glyph);
}
}
@@ -849,13 +870,10 @@ pango_ft2_render_layout_line (FT_Bitmap *bitmap,
int y)
{
GSList *tmp_list = line->runs;
- PangoRectangle overall_rect;
PangoRectangle logical_rect;
PangoRectangle ink_rect;
int x_off = 0;
- pango_layout_line_get_extents (line, NULL, &overall_rect);
-
while (tmp_list)
{
PangoUnderline uline = PANGO_UNDERLINE_NONE;