[cmap] Simplify caching
This commit is contained in:
parent
a451aa5465
commit
784fe9ac67
|
@ -31,6 +31,7 @@
|
|||
#include "hb-ot-shaper-arabic-pua.hh"
|
||||
#include "hb-open-type.hh"
|
||||
#include "hb-set.hh"
|
||||
#include "hb-cache.hh"
|
||||
|
||||
/*
|
||||
* cmap -- Character to Glyph Index Mapping
|
||||
|
@ -1841,6 +1842,8 @@ struct cmap
|
|||
|
||||
struct accelerator_t
|
||||
{
|
||||
using cache_t = hb_cache_t<21, 16, 8, true>;
|
||||
|
||||
accelerator_t (hb_face_t *face)
|
||||
{
|
||||
this->table = hb_sanitize_context_t ().reference_table<cmap> (face);
|
||||
|
@ -1895,15 +1898,6 @@ struct cmap
|
|||
}
|
||||
~accelerator_t () { this->table.destroy (); }
|
||||
|
||||
bool get_nominal_glyph (hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph) const
|
||||
{
|
||||
if (unlikely (!this->get_glyph_funcZ)) return false;
|
||||
|
||||
return this->get_glyph_funcZ (this->get_glyph_data, unicode, glyph);
|
||||
}
|
||||
|
||||
template <typename cache_t = void>
|
||||
inline bool _cached_get (hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph,
|
||||
cache_t *cache) const
|
||||
|
@ -1914,21 +1908,21 @@ struct cmap
|
|||
*glyph = v;
|
||||
return true;
|
||||
}
|
||||
bool ret = get_nominal_glyph (unicode, glyph);
|
||||
bool ret = this->get_glyph_funcZ (this->get_glyph_data, unicode, glyph);
|
||||
|
||||
if (cache && ret)
|
||||
cache->set (unicode, *glyph);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename cache_t = void>
|
||||
bool get_nominal_glyph (hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph,
|
||||
cache_t *cache = nullptr) const
|
||||
{
|
||||
if (unlikely (!this->get_glyph_funcZ)) return 0;
|
||||
return _cached_get (unicode, glyph, cache);
|
||||
}
|
||||
|
||||
template <typename cache_t = void>
|
||||
unsigned int get_nominal_glyphs (unsigned int count,
|
||||
const hb_codepoint_t *first_unicode,
|
||||
unsigned int unicode_stride,
|
||||
|
@ -1949,7 +1943,6 @@ struct cmap
|
|||
return done;
|
||||
}
|
||||
|
||||
template <typename cache_t = void>
|
||||
bool get_variation_glyph (hb_codepoint_t unicode,
|
||||
hb_codepoint_t variation_selector,
|
||||
hb_codepoint_t *glyph,
|
||||
|
|
Loading…
Reference in New Issue