mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 00:32:59 +00:00
[GDEF] Use a cache for glyph classes
Shows 5% speedup for Roboto shaping.
This commit is contained in:
parent
323a1fe496
commit
8a8fc37c42
4 changed files with 26 additions and 3 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "../../../hb-ot-layout-common.hh"
|
||||
|
||||
#include "../../../hb-font.hh"
|
||||
#include "../../../hb-cache.hh"
|
||||
|
||||
|
||||
namespace OT {
|
||||
|
@ -861,7 +862,21 @@ struct GDEF
|
|||
}
|
||||
~accelerator_t () { table.destroy (); }
|
||||
|
||||
unsigned int get_glyph_props (hb_codepoint_t glyph) const
|
||||
{
|
||||
unsigned v;
|
||||
if (glyph_props_cache.get (glyph, &v))
|
||||
return v;
|
||||
|
||||
v = table->get_glyph_props (glyph);
|
||||
if (likely (table)) // Don't try setting if we are the null instance!
|
||||
glyph_props_cache.set (glyph, v);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
hb_blob_ptr_t<GDEF> table;
|
||||
mutable hb_cache_t<21, 3, 8> glyph_props_cache;
|
||||
};
|
||||
|
||||
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
/* Global nul-content Null pool. Enlarge as necessary. */
|
||||
|
||||
#define HB_NULL_POOL_SIZE 448
|
||||
#define HB_NULL_POOL_SIZE 520
|
||||
|
||||
template <typename T, typename>
|
||||
struct _hb_has_min_size : hb_false_type {};
|
||||
|
|
|
@ -695,6 +695,7 @@ struct hb_ot_apply_context_t :
|
|||
hb_buffer_t *buffer;
|
||||
recurse_func_t recurse_func = nullptr;
|
||||
const GDEF &gdef;
|
||||
const GDEF::accelerator_t &gdef_accel;
|
||||
const VariationStore &var_store;
|
||||
VariationStore::cache_t *var_store_cache;
|
||||
hb_set_digest_t digest;
|
||||
|
@ -726,6 +727,13 @@ struct hb_ot_apply_context_t :
|
|||
*face->table.GDEF->table
|
||||
#else
|
||||
Null (GDEF)
|
||||
#endif
|
||||
),
|
||||
gdef_accel (
|
||||
#ifndef HB_NO_OT_LAYOUT
|
||||
*face->table.GDEF
|
||||
#else
|
||||
Null (GDEF::accelerator_t)
|
||||
#endif
|
||||
),
|
||||
var_store (gdef.get_var_store ()),
|
||||
|
@ -836,7 +844,7 @@ struct hb_ot_apply_context_t :
|
|||
if (likely (has_glyph_classes))
|
||||
{
|
||||
props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE;
|
||||
_hb_glyph_info_set_glyph_props (&buffer->cur(), props | gdef.get_glyph_props (glyph_index));
|
||||
_hb_glyph_info_set_glyph_props (&buffer->cur(), props | gdef_accel.get_glyph_props (glyph_index));
|
||||
}
|
||||
else if (class_guess)
|
||||
{
|
||||
|
|
|
@ -257,7 +257,7 @@ _hb_ot_layout_set_glyph_props (hb_font_t *font,
|
|||
{
|
||||
_hb_buffer_assert_gsubgpos_vars (buffer);
|
||||
|
||||
const OT::GDEF &gdef = *font->face->table.GDEF->table;
|
||||
const auto &gdef = *font->face->table.GDEF;
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
|
|
Loading…
Add table
Reference in a new issue