summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-04-29 11:45:42 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-04-29 11:45:42 -0400
commitfc2b5abd7eb04dd1ceb6fb49b038e3767b872982 (patch)
tree1b1bbe77772ded11d8b3f14271cb7fb3f47cbfe1
parent192f9cd72b20b1e0410ef75ae413ab66ae061d0e (diff)
Only look up when the glyph is not in pixman's cacheglyphs
This requires deciding on the mask format up front based on the font options. I'm not 100% certain this is correct.
-rw-r--r--src/cairo-image-surface.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index f290756b..133b09cb 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -3818,7 +3818,6 @@ _composite_glyphs (void *closure,
const cairo_rectangle_int_t *extents,
cairo_region_t *clip_region)
{
- cairo_scaled_glyph_t *local_cache[64];
composite_glyphs_info_t *info = closure;
cairo_scaled_font_t *font = info->font;
cairo_glyph_t *glyphs = info->glyphs;
@@ -3850,24 +3849,35 @@ _composite_glyphs (void *closure,
goto OOM;
}
- memset (local_cache, 0, sizeof (local_cache));
_cairo_scaled_font_freeze_cache (font);
pixman_glyph_cache_freeze (glyph_cache);
- mask_format = PIXMAN_a8;
+ switch (font->options.antialias)
+ {
+ case CAIRO_ANTIALIAS_DEFAULT:
+ case CAIRO_ANTIALIAS_GRAY:
+ mask_format = PIXMAN_a8;
+ break;
+ case CAIRO_ANTIALIAS_NONE:
+ mask_format = PIXMAN_a1;
+ break;
+ case CAIRO_ANTIALIAS_SUBPIXEL:
+ mask_format = PIXMAN_a8r8g8b8;
+ break;
+ }
+
pg = pglyphs;
for (i = 0; i < num_glyphs; i++)
{
- cairo_image_surface_t *glyph_surface;
- cairo_scaled_glyph_t *scaled_glyph;
- size_t index = glyphs[i].index;
- int cache_index = index % ARRAY_LENGTH (local_cache);
const void *glyph;
+ size_t index = glyphs[i].index;
- scaled_glyph = local_cache[cache_index];
- if (scaled_glyph == NULL ||
- _cairo_scaled_glyph_index (scaled_glyph) != index)
+ glyph = pixman_glyph_cache_contains (glyph_cache, font, (void *)index);
+ if (!glyph)
{
+ cairo_scaled_glyph_t *scaled_glyph;
+ cairo_image_surface_t *glyph_surface;
+
status = _cairo_scaled_glyph_lookup (info->font, index,
CAIRO_SCALED_GLYPH_INFO_SURFACE,
&scaled_glyph);
@@ -3875,36 +3885,27 @@ _composite_glyphs (void *closure,
if (unlikely (status))
goto CLEANUP;
- local_cache[cache_index] = scaled_glyph;
- }
-
- glyph_surface = scaled_glyph->surface;
-
- if (glyph_surface->width == 0 || glyph_surface->height == 0)
- continue;
+ glyph_surface = scaled_glyph->surface;
- if (PIXMAN_FORMAT_BPP (mask_format) <
- PIXMAN_FORMAT_BPP (glyph_surface->pixman_format))
- {
- mask_format = glyph_surface->pixman_format;
- }
+#if 0
+ /* FIXME: How common is this? */
+ if (glyph_surface->width == 0 || glyph_surface->height == 0)
+ continue;
+#endif
- glyph = pixman_glyph_cache_contains (glyph_cache, font, (void *)index);
- if (!glyph)
- {
+ /* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug?
+ * Also, we are assuming that the origin is an integer.
+ */
glyph = pixman_glyph_cache_insert (glyph_cache, font, (void *)index,
glyph_surface->base.device_transform.x0,
glyph_surface->base.device_transform.y0,
glyph_surface->pixman_image);
- if (!glyph)
- {
- /* FIXME: OOM fail */;
- }
+ if (unlikely (!glyph))
+ goto CLEANUP;
}
/* round glyph locations to the nearest pixel */
- /* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug? */
pg->x = _cairo_lround (glyphs[i].x);
pg->y = _cairo_lround (glyphs[i].y);
pg->glyph = (void *)glyph;