diff --git a/src/OT/Var/VARC/VARC.cc b/src/OT/Var/VARC/VARC.cc index d55e6227f..1a22f1d81 100644 --- a/src/OT/Var/VARC/VARC.cc +++ b/src/OT/Var/VARC/VARC.cc @@ -134,7 +134,7 @@ VarComponent::get_path_at (const hb_varc_context_t &c, hb_array_t coords, hb_transform_t<> total_transform, hb_ubytes_t total_record, - _hb_scalar_cache_t *cache) const + hb_scalar_cache_t *cache) const { const unsigned char *end = total_record.arrayZ + total_record.length; const unsigned char *record = total_record.arrayZ; @@ -183,7 +183,7 @@ VarComponent::get_path_at (const hb_varc_context_t &c, unsigned conditionIndex; READ_UINT32VAR (conditionIndex); const auto &condition = (&VARC+VARC.conditionList)[conditionIndex]; - auto instancer = MultiItemVarStoreInstancer (&varStore, nullptr, coords, cache); + auto instancer = MultiItemVarStoreInstancer(&varStore, nullptr, coords, cache); show = condition.evaluate (coords.arrayZ, coords.length, &instancer); } @@ -338,7 +338,7 @@ VARC::get_path_at (const hb_varc_context_t &c, hb_array_t coords, hb_transform_t<> transform, hb_codepoint_t parent_glyph, - _hb_scalar_cache_t *parent_cache) const + hb_scalar_cache_t *parent_cache) const { // Don't recurse on the same glyph. unsigned idx = glyph == parent_glyph ? @@ -394,10 +394,10 @@ VARC::get_path_at (const hb_varc_context_t &c, hb_ubytes_t record = (this+glyphRecords)[idx]; - _hb_scalar_cache_t static_cache; - _hb_scalar_cache_t *cache = parent_cache ? - parent_cache : - (this+varStore).create_cache (&static_cache); + hb_scalar_cache_t static_cache; + hb_scalar_cache_t *cache = parent_cache ? + parent_cache : + (this+varStore).create_cache (&static_cache); transform.scale (c.font->x_multf, c.font->y_multf); diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh index 5d9c672a4..719302c93 100644 --- a/src/OT/Var/VARC/VARC.hh +++ b/src/OT/Var/VARC/VARC.hh @@ -67,7 +67,7 @@ struct VarComponent hb_array_t coords, hb_transform_t<> transform, hb_ubytes_t record, - _hb_scalar_cache_t *cache = nullptr) const; + hb_scalar_cache_t *cache = nullptr) const; }; struct VarCompositeGlyph @@ -78,7 +78,7 @@ struct VarCompositeGlyph hb_array_t coords, hb_transform_t<> transform, hb_ubytes_t record, - _hb_scalar_cache_t *cache) + hb_scalar_cache_t *cache) { while (record) { @@ -106,7 +106,7 @@ struct VARC hb_array_t coords, hb_transform_t<> transform = HB_TRANSFORM_IDENTITY, hb_codepoint_t parent_gid = HB_CODEPOINT_INVALID, - _hb_scalar_cache_t *parent_cache = nullptr) const; + hb_scalar_cache_t *parent_cache = nullptr) const; bool get_path (hb_font_t *font, diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 7da14bbc0..5c0533aad 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2540,8 +2540,7 @@ struct SparseVarRegionAxis DEFINE_SIZE_STATIC (8); }; -template -struct _hb_scalar_cache_t +struct hb_scalar_cache_t { private: static constexpr unsigned STATIC_LENGTH = 16; @@ -2550,17 +2549,17 @@ struct _hb_scalar_cache_t static constexpr float DIVISOR = 1.f / MULTIPLIER; public: - _hb_scalar_cache_t () : length (STATIC_LENGTH) { clear (); } + hb_scalar_cache_t () : length (STATIC_LENGTH) { clear (); } - _hb_scalar_cache_t (const _hb_scalar_cache_t&) = delete; - _hb_scalar_cache_t (_hb_scalar_cache_t&&) = delete; - _hb_scalar_cache_t& operator= (const _hb_scalar_cache_t&) = delete; - _hb_scalar_cache_t& operator= (_hb_scalar_cache_t&&) = delete; + hb_scalar_cache_t (const hb_scalar_cache_t&) = delete; + hb_scalar_cache_t (hb_scalar_cache_t&&) = delete; + hb_scalar_cache_t& operator= (const hb_scalar_cache_t&) = delete; + hb_scalar_cache_t& operator= (hb_scalar_cache_t&&) = delete; - static _hb_scalar_cache_t *create (unsigned int count, - _hb_scalar_cache_t *scratch_cache = nullptr) + static hb_scalar_cache_t *create (unsigned int count, + hb_scalar_cache_t *scratch_cache = nullptr) { - if (!count) return (_hb_scalar_cache_t *) &Null(_hb_scalar_cache_t); + if (!count) return (hb_scalar_cache_t *) &Null(hb_scalar_cache_t); if (scratch_cache && count <= scratch_cache->length) { @@ -2568,8 +2567,8 @@ struct _hb_scalar_cache_t return scratch_cache; } - auto *cache = (_hb_scalar_cache_t *) hb_malloc (sizeof (_hb_scalar_cache_t) - sizeof (static_values) + sizeof (static_values[0]) * count); - if (unlikely (!cache)) return (_hb_scalar_cache_t *) &Null(_hb_scalar_cache_t); + auto *cache = (hb_scalar_cache_t *) hb_malloc (sizeof (hb_scalar_cache_t) - sizeof (static_values) + sizeof (static_values[0]) * count); + if (unlikely (!cache)) return (hb_scalar_cache_t *) &Null(hb_scalar_cache_t); cache->length = count; cache->clear (); @@ -2577,10 +2576,10 @@ struct _hb_scalar_cache_t return cache; } - static void destroy (_hb_scalar_cache_t *cache, - _hb_scalar_cache_t *scratch_cache = nullptr) + static void destroy (hb_scalar_cache_t *cache, + hb_scalar_cache_t *scratch_cache = nullptr) { - if (cache != &Null(_hb_scalar_cache_t) && cache != scratch_cache) + if (cache != &Null(hb_scalar_cache_t) && cache != scratch_cache) hb_free (cache); } @@ -2633,15 +2632,11 @@ struct _hb_scalar_cache_t *cached_value = roundf(value * MULTIPLIER); } - using type_t = std::conditional_t, int>; - private: unsigned length; - mutable type_t static_values[STATIC_LENGTH]; + mutable hb_atomic_t static_values[STATIC_LENGTH]; }; -using hb_scalar_cache_t = _hb_scalar_cache_t; - struct VarRegionList { private: @@ -2668,7 +2663,6 @@ struct VarRegionList } public: - template HB_ALWAYS_INLINE float evaluate (unsigned int region_index, const int *coords, unsigned int coord_len, @@ -2827,7 +2821,6 @@ struct SparseVariationRegion : Array16Of struct SparseVarRegionList { - template HB_ALWAYS_INLINE float evaluate (unsigned int region_index, const int *coords, unsigned int coord_len, @@ -2883,7 +2876,6 @@ struct VarData + itemCount * get_row_size (); } - template float _get_delta (unsigned int inner, const int *coords, unsigned int coord_count, const VarRegionList ®ions, @@ -2931,7 +2923,6 @@ struct VarData return delta; } - template HB_ALWAYS_INLINE float get_delta (unsigned int inner, const int *coords, unsigned int coord_count, @@ -3255,7 +3246,6 @@ struct MultiVarData + StructAfter (regionIndices).get_size (); } - template void get_delta (unsigned int inner, const int *coords, unsigned int coord_count, const SparseVarRegionList ®ions, @@ -3298,7 +3288,6 @@ struct ItemVariationStore { friend struct item_variations_t; - template hb_scalar_cache_t *create_cache () const { #ifdef HB_NO_VAR @@ -3307,14 +3296,12 @@ struct ItemVariationStore return hb_scalar_cache_t::create ((this+regions).regionCount); } - template static void destroy_cache (hb_scalar_cache_t *cache) { hb_scalar_cache_t::destroy (cache); } private: - template float get_delta (unsigned int outer, unsigned int inner, const int *coords, unsigned int coord_count, hb_scalar_cache_t *cache = nullptr) const @@ -3333,7 +3320,6 @@ struct ItemVariationStore } public: - template float get_delta (unsigned int index, const int *coords, unsigned int coord_count, hb_scalar_cache_t *cache = nullptr) const @@ -3342,7 +3328,6 @@ struct ItemVariationStore unsigned int inner = index & 0xFFFF; return get_delta (outer, inner, coords, coord_count, cache); } - template float get_delta (unsigned int index, hb_array_t coords, hb_scalar_cache_t *cache = nullptr) const @@ -3553,7 +3538,6 @@ struct ItemVariationStore struct MultiItemVariationStore { - template hb_scalar_cache_t *create_cache (hb_scalar_cache_t *static_cache = nullptr) const { #ifdef HB_NO_VAR @@ -3565,7 +3549,6 @@ struct MultiItemVariationStore return hb_scalar_cache_t::create (count, static_cache); } - template static void destroy_cache (hb_scalar_cache_t *cache, hb_scalar_cache_t *static_cache = nullptr) { @@ -3573,7 +3556,6 @@ struct MultiItemVariationStore } private: - template void get_delta (unsigned int outer, unsigned int inner, const int *coords, unsigned int coord_count, hb_array_t out, @@ -3594,7 +3576,6 @@ struct MultiItemVariationStore } public: - template void get_delta (unsigned int index, const int *coords, unsigned int coord_count, hb_array_t out, @@ -3604,7 +3585,6 @@ struct MultiItemVariationStore unsigned int inner = index & 0xFFFF; get_delta (outer, inner, coords, coord_count, out, cache); } - template void get_delta (unsigned int index, hb_array_t coords, hb_array_t out, @@ -3867,11 +3847,8 @@ struct ItemVarStoreInstancer hb_scalar_cache_t *cache; }; -template struct MultiItemVarStoreInstancer { - using hb_scalar_cache_t = _hb_scalar_cache_t; - MultiItemVarStoreInstancer (const MultiItemVariationStore *varStore, const DeltaSetIndexMap *varIdxMap, hb_array_t coords, @@ -4926,7 +4903,6 @@ struct VariationDevice private: - template float get_delta (hb_font_t *font, const ItemVariationStore &store, hb_scalar_cache_t *store_cache = nullptr) const