mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 16:50:38 +00:00
[subset/cff] Move lazy cff-accelerator to cff-subset-accelerator
Fixes https://github.com/harfbuzz/harfbuzz/issues/4295
This commit is contained in:
parent
3a827123a1
commit
5f39913918
7 changed files with 31 additions and 22 deletions
|
@ -28,6 +28,7 @@
|
|||
#define HB_OT_CFF1_TABLE_HH
|
||||
|
||||
#include "hb-ot-cff-common.hh"
|
||||
#include "hb-subset-cff-common.hh"
|
||||
#include "hb-draw.hh"
|
||||
#include "hb-paint.hh"
|
||||
|
||||
|
@ -1489,11 +1490,18 @@ struct cff1
|
|||
struct accelerator_subset_t : accelerator_templ_t<cff1_private_dict_opset_subset_t, cff1_private_dict_values_subset_t>
|
||||
{
|
||||
accelerator_subset_t (hb_face_t *face) : SUPER (face) {}
|
||||
~accelerator_subset_t ()
|
||||
{
|
||||
if (cff_accelerator)
|
||||
cff_subset_accelerator_t::destroy (cff_accelerator);
|
||||
}
|
||||
|
||||
HB_INTERNAL bool subset (hb_subset_context_t *c) const;
|
||||
HB_INTERNAL bool serialize (hb_serialize_context_t *c,
|
||||
struct cff1_subset_plan &plan) const;
|
||||
|
||||
mutable CFF::cff_subset_accelerator_t* cff_accelerator = nullptr;
|
||||
|
||||
typedef accelerator_templ_t<cff1_private_dict_opset_subset_t, cff1_private_dict_values_subset_t> SUPER;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define HB_OT_CFF2_TABLE_HH
|
||||
|
||||
#include "hb-ot-cff-common.hh"
|
||||
#include "hb-subset-cff-common.hh"
|
||||
#include "hb-draw.hh"
|
||||
#include "hb-paint.hh"
|
||||
|
||||
|
@ -520,12 +521,19 @@ struct cff2
|
|||
struct accelerator_subset_t : accelerator_templ_t<cff2_private_dict_opset_subset_t, cff2_private_dict_values_subset_t>
|
||||
{
|
||||
accelerator_subset_t (hb_face_t *face) : SUPER (face) {}
|
||||
~accelerator_subset_t ()
|
||||
{
|
||||
if (cff_accelerator)
|
||||
cff_subset_accelerator_t::destroy (cff_accelerator);
|
||||
}
|
||||
|
||||
HB_INTERNAL bool subset (hb_subset_context_t *c) const;
|
||||
HB_INTERNAL bool serialize (hb_serialize_context_t *c,
|
||||
struct cff2_subset_plan &plan,
|
||||
hb_array_t<int> normalized_coords) const;
|
||||
|
||||
mutable CFF::cff_subset_accelerator_t* cff_accelerator = nullptr;
|
||||
|
||||
typedef accelerator_templ_t<cff2_private_dict_opset_subset_t, cff2_private_dict_values_subset_t> SUPER;
|
||||
};
|
||||
|
||||
|
|
|
@ -90,8 +90,6 @@ struct hb_subset_accelerator_t
|
|||
cmap_cache(nullptr),
|
||||
destroy_cmap_cache(nullptr),
|
||||
has_seac(has_seac_),
|
||||
cff_accelerator(nullptr),
|
||||
destroy_cff_accelerator(nullptr),
|
||||
source(hb_face_reference (source))
|
||||
{
|
||||
gid_to_unicodes.resize (unicode_to_gid.get_population ());
|
||||
|
@ -120,8 +118,6 @@ struct hb_subset_accelerator_t
|
|||
|
||||
// CFF
|
||||
bool has_seac;
|
||||
const CFF::cff_subset_accelerator_t* cff_accelerator;
|
||||
hb_destroy_func_t destroy_cff_accelerator;
|
||||
|
||||
// TODO(garretrieger): cumulative glyf checksum map
|
||||
|
||||
|
|
|
@ -678,8 +678,8 @@ struct subr_subsetter_t
|
|||
{
|
||||
unsigned fd_count = acc.fdCount;
|
||||
const cff_subset_accelerator_t* cff_accelerator = nullptr;
|
||||
if (plan->accelerator && plan->accelerator->cff_accelerator) {
|
||||
cff_accelerator = plan->accelerator->cff_accelerator;
|
||||
if (acc.cff_accelerator) {
|
||||
cff_accelerator = acc.cff_accelerator;
|
||||
fd_count = cff_accelerator->parsed_local_subrs.length;
|
||||
}
|
||||
|
||||
|
@ -1126,14 +1126,11 @@ struct subr_subsetter_t
|
|||
|
||||
compact_parsed_subrs ();
|
||||
|
||||
plan->inprogress_accelerator->cff_accelerator =
|
||||
acc.cff_accelerator =
|
||||
cff_subset_accelerator_t::create(acc.blob,
|
||||
parsed_charstrings,
|
||||
parsed_global_subrs_storage,
|
||||
parsed_local_subrs_storage);
|
||||
plan->inprogress_accelerator->destroy_cff_accelerator =
|
||||
cff_subset_accelerator_t::destroy;
|
||||
|
||||
}
|
||||
|
||||
const parsed_cs_str_t& get_parsed_charstring (unsigned i) const
|
||||
|
|
|
@ -492,12 +492,11 @@ struct cff1_subset_plan
|
|||
return;
|
||||
}
|
||||
|
||||
hb_vector_t<uint16_t> *glyph_to_sid_map = (plan->accelerator && plan->accelerator->cff_accelerator) ?
|
||||
plan->accelerator->cff_accelerator->glyph_to_sid_map.get_acquire () :
|
||||
nullptr;
|
||||
hb_vector_t<uint16_t> *glyph_to_sid_map = acc.cff_accelerator ?
|
||||
acc.cff_accelerator->glyph_to_sid_map.get_acquire () :
|
||||
nullptr;
|
||||
bool created_map = false;
|
||||
if (!glyph_to_sid_map &&
|
||||
((plan->accelerator && plan->accelerator->cff_accelerator)))
|
||||
if (!glyph_to_sid_map && acc.cff_accelerator)
|
||||
{
|
||||
created_map = true;
|
||||
glyph_to_sid_map = acc.create_glyph_to_sid_map ();
|
||||
|
@ -541,8 +540,8 @@ struct cff1_subset_plan
|
|||
|
||||
if (created_map)
|
||||
{
|
||||
if (!(plan->accelerator && plan->accelerator->cff_accelerator) ||
|
||||
!plan->accelerator->cff_accelerator->glyph_to_sid_map.cmpexch (nullptr, glyph_to_sid_map))
|
||||
if ((!plan->accelerator && acc.cff_accelerator) ||
|
||||
!acc.cff_accelerator->glyph_to_sid_map.cmpexch (nullptr, glyph_to_sid_map))
|
||||
{
|
||||
glyph_to_sid_map->~hb_vector_t ();
|
||||
hb_free (glyph_to_sid_map);
|
||||
|
|
|
@ -51,9 +51,6 @@ using OT::Layout::GPOS;
|
|||
|
||||
hb_subset_accelerator_t::~hb_subset_accelerator_t ()
|
||||
{
|
||||
if (cff_accelerator && destroy_cff_accelerator)
|
||||
destroy_cff_accelerator ((void*) cff_accelerator);
|
||||
|
||||
if (cmap_cache && destroy_cmap_cache)
|
||||
destroy_cmap_cache ((void*) cmap_cache);
|
||||
|
||||
|
|
|
@ -68,13 +68,17 @@ template<>
|
|||
struct hb_subset_plan_t::source_table_loader<const OT::cff1>
|
||||
{
|
||||
auto operator () (hb_subset_plan_t *plan)
|
||||
HB_AUTO_RETURN (plan->accelerator ? plan->accelerator->cff1_accel : plan->cff1_accel)
|
||||
HB_AUTO_RETURN (plan->accelerator ? plan->accelerator->cff1_accel :
|
||||
plan->inprogress_accelerator ? plan->inprogress_accelerator->cff1_accel :
|
||||
plan->cff1_accel)
|
||||
};
|
||||
template<>
|
||||
struct hb_subset_plan_t::source_table_loader<const OT::cff2>
|
||||
{
|
||||
auto operator () (hb_subset_plan_t *plan)
|
||||
HB_AUTO_RETURN (plan->accelerator ? plan->accelerator->cff2_accel : plan->cff2_accel)
|
||||
HB_AUTO_RETURN (plan->accelerator ? plan->accelerator->cff2_accel :
|
||||
plan->inprogress_accelerator ? plan->inprogress_accelerator->cff2_accel :
|
||||
plan->cff2_accel)
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue