[subset] Replace auto_array with prealloced_array
auto_array has constructor/destructor. Cannot be used in POD object, as the clang bots all noticed...
This commit is contained in:
parent
931d67900e
commit
c31fcf4c58
|
@ -521,8 +521,8 @@ struct cmap
|
||||||
encodingRecord.sanitize (c, this));
|
encodingRecord.sanitize (c, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void populate_groups(hb_auto_array_t<hb_codepoint_t> &codepoints,
|
inline void populate_groups(hb_prealloced_array_t<hb_codepoint_t> &codepoints,
|
||||||
hb_auto_array_t<CmapSubtableLongGroup> *groups) const
|
hb_prealloced_array_t<CmapSubtableLongGroup> *groups) const
|
||||||
{
|
{
|
||||||
CmapSubtableLongGroup *group = nullptr;
|
CmapSubtableLongGroup *group = nullptr;
|
||||||
for (unsigned int i = 0; i < codepoints.len; i++) {
|
for (unsigned int i = 0; i < codepoints.len; i++) {
|
||||||
|
@ -549,7 +549,7 @@ struct cmap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_bool_t _subset (hb_auto_array_t<CmapSubtableLongGroup> &groups,
|
hb_bool_t _subset (hb_prealloced_array_t<CmapSubtableLongGroup> &groups,
|
||||||
size_t dest_sz,
|
size_t dest_sz,
|
||||||
void *dest) const
|
void *dest) const
|
||||||
{
|
{
|
||||||
|
@ -591,7 +591,7 @@ struct cmap
|
||||||
|
|
||||||
hb_blob_t * subset (hb_subset_plan_t *plan, hb_face_t *source) const
|
hb_blob_t * subset (hb_subset_plan_t *plan, hb_face_t *source) const
|
||||||
{
|
{
|
||||||
hb_auto_array_t<CmapSubtableLongGroup> groups;
|
hb_prealloced_array_t<CmapSubtableLongGroup> groups;
|
||||||
|
|
||||||
populate_groups(plan->codepoints, &groups);
|
populate_groups(plan->codepoints, &groups);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
HB_INTERNAL bool
|
HB_INTERNAL bool
|
||||||
_calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
|
_calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
|
||||||
hb_auto_array_t<unsigned int> &glyph_ids,
|
hb_prealloced_array_t<unsigned int> &glyph_ids,
|
||||||
bool *use_short_loca, /* OUT */
|
bool *use_short_loca, /* OUT */
|
||||||
unsigned int *glyf_size, /* OUT */
|
unsigned int *glyf_size, /* OUT */
|
||||||
unsigned int *loca_size /* OUT */)
|
unsigned int *loca_size /* OUT */)
|
||||||
|
@ -75,7 +75,7 @@ _write_loca_entry (unsigned int id, unsigned int offset, bool is_short, void *lo
|
||||||
HB_INTERNAL bool
|
HB_INTERNAL bool
|
||||||
_write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
|
_write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
|
||||||
const char *glyf_data,
|
const char *glyf_data,
|
||||||
hb_auto_array_t<unsigned int> &glyph_ids,
|
hb_prealloced_array_t<unsigned int> &glyph_ids,
|
||||||
bool use_short_loca,
|
bool use_short_loca,
|
||||||
int glyf_prime_size,
|
int glyf_prime_size,
|
||||||
char *glyf_prime_data /* OUT */,
|
char *glyf_prime_data /* OUT */,
|
||||||
|
@ -112,7 +112,7 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
|
||||||
HB_INTERNAL bool
|
HB_INTERNAL bool
|
||||||
_hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
|
_hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
|
||||||
const char *glyf_data,
|
const char *glyf_data,
|
||||||
hb_auto_array_t<hb_codepoint_t>&glyphs_to_retain,
|
hb_prealloced_array_t<hb_codepoint_t>&glyphs_to_retain,
|
||||||
bool *use_short_loca,
|
bool *use_short_loca,
|
||||||
hb_blob_t **glyf_prime /* OUT */,
|
hb_blob_t **glyf_prime /* OUT */,
|
||||||
hb_blob_t **loca_prime /* OUT */)
|
hb_blob_t **loca_prime /* OUT */)
|
||||||
|
|
|
@ -51,7 +51,7 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan,
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_populate_codepoints (hb_set_t *input_codepoints,
|
_populate_codepoints (hb_set_t *input_codepoints,
|
||||||
hb_auto_array_t<hb_codepoint_t>& plan_codepoints)
|
hb_prealloced_array_t<hb_codepoint_t>& plan_codepoints)
|
||||||
{
|
{
|
||||||
plan_codepoints.alloc (hb_set_get_population (input_codepoints));
|
plan_codepoints.alloc (hb_set_get_population (input_codepoints));
|
||||||
hb_codepoint_t cp = -1;
|
hb_codepoint_t cp = -1;
|
||||||
|
@ -64,14 +64,14 @@ _populate_codepoints (hb_set_t *input_codepoints,
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_populate_gids_to_retain (hb_face_t *face,
|
_populate_gids_to_retain (hb_face_t *face,
|
||||||
hb_auto_array_t<hb_codepoint_t>& codepoints,
|
hb_prealloced_array_t<hb_codepoint_t>& codepoints,
|
||||||
hb_auto_array_t<hb_codepoint_t>& old_gids,
|
hb_prealloced_array_t<hb_codepoint_t>& old_gids,
|
||||||
hb_auto_array_t<hb_codepoint_t>& old_gids_sorted)
|
hb_prealloced_array_t<hb_codepoint_t>& old_gids_sorted)
|
||||||
{
|
{
|
||||||
OT::cmap::accelerator_t cmap;
|
OT::cmap::accelerator_t cmap;
|
||||||
cmap.init (face);
|
cmap.init (face);
|
||||||
|
|
||||||
hb_auto_array_t<unsigned int> bad_indices;
|
hb_prealloced_array_t<unsigned int> bad_indices;
|
||||||
|
|
||||||
old_gids.alloc (codepoints.len);
|
old_gids.alloc (codepoints.len);
|
||||||
bool has_zero = false;
|
bool has_zero = false;
|
||||||
|
@ -131,6 +131,11 @@ hb_subset_plan_create (hb_face_t *face,
|
||||||
hb_subset_input_t *input)
|
hb_subset_input_t *input)
|
||||||
{
|
{
|
||||||
hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> ();
|
hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> ();
|
||||||
|
|
||||||
|
plan->codepoints.init();
|
||||||
|
plan->gids_to_retain.init();
|
||||||
|
plan->gids_to_retain_sorted.init();
|
||||||
|
|
||||||
_populate_codepoints (input->codepoints, plan->codepoints);
|
_populate_codepoints (input->codepoints, plan->codepoints);
|
||||||
_populate_gids_to_retain (face,
|
_populate_gids_to_retain (face,
|
||||||
plan->codepoints,
|
plan->codepoints,
|
||||||
|
@ -139,13 +144,6 @@ hb_subset_plan_create (hb_face_t *face,
|
||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_subset_plan_t *
|
|
||||||
hb_subset_plan_get_empty ()
|
|
||||||
{
|
|
||||||
hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> ();
|
|
||||||
return plan;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_subset_plan_destroy:
|
* hb_subset_plan_destroy:
|
||||||
*
|
*
|
||||||
|
@ -159,5 +157,6 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan)
|
||||||
plan->codepoints.finish ();
|
plan->codepoints.finish ();
|
||||||
plan->gids_to_retain.finish ();
|
plan->gids_to_retain.finish ();
|
||||||
plan->gids_to_retain_sorted.finish ();
|
plan->gids_to_retain_sorted.finish ();
|
||||||
|
|
||||||
free (plan);
|
free (plan);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ struct hb_subset_plan_t {
|
||||||
// TODO(Q1) actual map, drop this crap
|
// TODO(Q1) actual map, drop this crap
|
||||||
// Look at me ma, I'm a poor mans map codepoint : new gid
|
// Look at me ma, I'm a poor mans map codepoint : new gid
|
||||||
// codepoints is sorted and aligned with gids_to_retain.
|
// codepoints is sorted and aligned with gids_to_retain.
|
||||||
hb_auto_array_t<hb_codepoint_t> codepoints;
|
hb_prealloced_array_t<hb_codepoint_t> codepoints;
|
||||||
hb_auto_array_t<hb_codepoint_t> gids_to_retain;
|
hb_prealloced_array_t<hb_codepoint_t> gids_to_retain;
|
||||||
hb_auto_array_t<hb_codepoint_t> gids_to_retain_sorted;
|
hb_prealloced_array_t<hb_codepoint_t> gids_to_retain_sorted;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct hb_subset_plan_t hb_subset_plan_t;
|
typedef struct hb_subset_plan_t hb_subset_plan_t;
|
||||||
|
@ -55,9 +55,6 @@ hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
|
||||||
hb_codepoint_t old_gid,
|
hb_codepoint_t old_gid,
|
||||||
hb_codepoint_t *new_gid /* OUT */);
|
hb_codepoint_t *new_gid /* OUT */);
|
||||||
|
|
||||||
HB_INTERNAL hb_subset_plan_t *
|
|
||||||
hb_subset_plan_get_empty ();
|
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
hb_subset_plan_destroy (hb_subset_plan_t *plan);
|
hb_subset_plan_destroy (hb_subset_plan_t *plan);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue