diff options
author | Dr.Smile <vabnick@gmail.com> | 2015-09-18 00:33:33 +0300 |
---|---|---|
committer | Dr.Smile <vabnick@gmail.com> | 2016-06-30 23:13:53 +0300 |
commit | f4d6e4b9af4cfe2fe684640f19682e4f954b7549 (patch) | |
tree | e5d817822df0f3448c0708924c7babd553856197 /libass/ass_shaper.c | |
parent | 25d65abce1a0fabe3c3bf81f1ee7ee7f24b91a4e (diff) | |
download | libass-f4d6e4b9af4cfe2fe684640f19682e4f954b7549.tar.bz2 libass-f4d6e4b9af4cfe2fe684640f19682e4f954b7549.tar.xz |
cache: remove ass_cache_cancel(), cache failures instead
Diffstat (limited to 'libass/ass_shaper.c')
-rw-r--r-- | libass/ass_shaper.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index 95ffda3..6f872e3 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -208,26 +208,28 @@ get_cached_metrics(struct ass_shaper_metrics_data *metrics, FT_Face face, { GlyphMetricsHashValue *val; metrics->hash_key.glyph_index = glyph; - if (!ass_cache_get(metrics->metrics_cache, &metrics->hash_key, &val)) { - int load_flags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH - | FT_LOAD_IGNORE_TRANSFORM; - - if (FT_Load_Glyph(face, glyph, load_flags)) { - ass_cache_cancel(val); - return NULL; - } - - memcpy(&val->metrics, &face->glyph->metrics, sizeof(FT_Glyph_Metrics)); + if (ass_cache_get(metrics->metrics_cache, &metrics->hash_key, &val)) + return val->metrics.width < 0 ? NULL : val; + if (!val) + return NULL; - // if @font rendering is enabled and the glyph should be rotated, - // make cached_h_advance pick up the right advance later - if (metrics->vertical && unicode >= VERTICAL_LOWER_BOUND) - val->metrics.horiAdvance = val->metrics.vertAdvance; + int load_flags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH + | FT_LOAD_IGNORE_TRANSFORM; - ass_cache_inc_ref(metrics->hash_key.font); + if (FT_Load_Glyph(face, glyph, load_flags)) { + val->metrics.width = -1; ass_cache_commit(val); + return NULL; } + memcpy(&val->metrics, &face->glyph->metrics, sizeof(FT_Glyph_Metrics)); + + // if @font rendering is enabled and the glyph should be rotated, + // make cached_h_advance pick up the right advance later + if (metrics->vertical && unicode >= VERTICAL_LOWER_BOUND) + val->metrics.horiAdvance = val->metrics.vertAdvance; + + ass_cache_commit(val); return val; } |