diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-03-12 16:34:00 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-03-12 16:34:00 +0000 |
commit | 5060043a33b32dfdd8ffacc88e8ca05b5e8271a9 (patch) | |
tree | 7323e019847fb6ffd555b4330ef2dbffdeba1dab | |
parent | caf8e7a6c7cfeb245cdb5ac44d310a82ab0155b3 (diff) | |
download | mupdf-5060043a33b32dfdd8ffacc88e8ca05b5e8271a9.tar.xz |
Store AA level used to render a glyph in the glyphcache.
In the existing code, glyphs are stored/retrieved from the glyphcache
with no reference to the antialias level used to create them. This
means that if we are using different aa levels in different threads,
we can retrieve 'non-matching' glyphs and hence get rendering
indeterminisms.
Fixed simply here by storing the aa level in the glyphcache too.
-rw-r--r-- | draw/draw_glyph.c | 4 | ||||
-rw-r--r-- | fitz/fitz.h | 2 | ||||
-rw-r--r-- | fitz/res_font.c | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c index 110a7a25..b8f69ce3 100644 --- a/draw/draw_glyph.c +++ b/draw/draw_glyph.c @@ -20,6 +20,7 @@ struct fz_glyph_key_s int c, d; unsigned short gid; unsigned char e, f; + int aa; }; void @@ -128,6 +129,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_color key.d = ctm.d * 65536; key.e = (ctm.e - floorf(ctm.e)) * 256; key.f = (ctm.f - floorf(ctm.f)) * 256; + key.aa = fz_get_aa_level(ctx); fz_lock(ctx, FZ_LOCK_GLYPHCACHE); val = fz_hash_find(ctx, cache->hash, &key); @@ -145,7 +147,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_color { if (font->ft_face) { - val = fz_render_ft_glyph(ctx, font, gid, ctm); + val = fz_render_ft_glyph(ctx, font, gid, ctm, key.aa); } else if (font->t3procs) { diff --git a/fitz/fitz.h b/fitz/fitz.h index 6427537f..1ec1eb97 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -1747,7 +1747,7 @@ fz_glyph_cache *fz_keep_glyph_cache(fz_context *ctx); void fz_drop_glyph_cache_context(fz_context *ctx); void fz_purge_glyph_cache(fz_context *ctx); -fz_pixmap *fz_render_ft_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm); +fz_pixmap *fz_render_ft_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, int aa); fz_pixmap *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model); fz_pixmap *fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *state); fz_pixmap *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_colorspace *model); diff --git a/fitz/res_font.c b/fitz/res_font.c index e4a4d23a..f6207e80 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -387,7 +387,7 @@ fz_copy_ft_bitmap(fz_context *ctx, int left, int top, FT_Bitmap *bitmap) /* The glyph cache lock is always taken when this is called. */ fz_pixmap * -fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm) +fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, int aa) { FT_Face face = font->ft_face; FT_Matrix m; @@ -421,7 +421,7 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm) fz_warn(ctx, "freetype setting character size: %s", ft_error_string(fterr)); FT_Set_Transform(face, &m, &v); - if (fz_get_aa_level(ctx) == 0) + if (aa == 0) { /* If you really want grid fitting, enable this code. */ float scale = fz_matrix_expansion(trm); |