提交 c31fcf4c 编写于 作者: B Behdad Esfahbod

[subset] Replace auto_array with prealloced_array

auto_array has constructor/destructor. Cannot be used in POD object, as the clang
bots all noticed...
上级 931d6790
......@@ -521,8 +521,8 @@ struct cmap
encodingRecord.sanitize (c, this));
}
inline void populate_groups(hb_auto_array_t<hb_codepoint_t> &codepoints,
hb_auto_array_t<CmapSubtableLongGroup> *groups) const
inline void populate_groups(hb_prealloced_array_t<hb_codepoint_t> &codepoints,
hb_prealloced_array_t<CmapSubtableLongGroup> *groups) const
{
CmapSubtableLongGroup *group = nullptr;
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,
void *dest) const
{
......@@ -591,7 +591,7 @@ struct cmap
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);
......
......@@ -31,7 +31,7 @@
HB_INTERNAL bool
_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 */
unsigned int *glyf_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
_write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
const char *glyf_data,
hb_auto_array_t<unsigned int> &glyph_ids,
hb_prealloced_array_t<unsigned int> &glyph_ids,
bool use_short_loca,
int glyf_prime_size,
char *glyf_prime_data /* OUT */,
......@@ -112,7 +112,7 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
HB_INTERNAL bool
_hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
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,
hb_blob_t **glyf_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
_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));
hb_codepoint_t cp = -1;
......@@ -64,14 +64,14 @@ _populate_codepoints (hb_set_t *input_codepoints,
HB_INTERNAL void
_populate_gids_to_retain (hb_face_t *face,
hb_auto_array_t<hb_codepoint_t>& codepoints,
hb_auto_array_t<hb_codepoint_t>& old_gids,
hb_auto_array_t<hb_codepoint_t>& old_gids_sorted)
hb_prealloced_array_t<hb_codepoint_t>& codepoints,
hb_prealloced_array_t<hb_codepoint_t>& old_gids,
hb_prealloced_array_t<hb_codepoint_t>& old_gids_sorted)
{
OT::cmap::accelerator_t cmap;
cmap.init (face);
hb_auto_array_t<unsigned int> bad_indices;
hb_prealloced_array_t<unsigned int> bad_indices;
old_gids.alloc (codepoints.len);
bool has_zero = false;
......@@ -131,6 +131,11 @@ hb_subset_plan_create (hb_face_t *face,
hb_subset_input_t *input)
{
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_gids_to_retain (face,
plan->codepoints,
......@@ -139,13 +144,6 @@ hb_subset_plan_create (hb_face_t *face,
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:
*
......@@ -159,5 +157,6 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan)
plan->codepoints.finish ();
plan->gids_to_retain.finish ();
plan->gids_to_retain_sorted.finish ();
free (plan);
}
......@@ -38,9 +38,9 @@ struct hb_subset_plan_t {
// TODO(Q1) actual map, drop this crap
// Look at me ma, I'm a poor mans map codepoint : new gid
// codepoints is sorted and aligned with gids_to_retain.
hb_auto_array_t<hb_codepoint_t> codepoints;
hb_auto_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> codepoints;
hb_prealloced_array_t<hb_codepoint_t> gids_to_retain;
hb_prealloced_array_t<hb_codepoint_t> gids_to_retain_sorted;
};
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 *new_gid /* OUT */);
HB_INTERNAL hb_subset_plan_t *
hb_subset_plan_get_empty ();
HB_INTERNAL void
hb_subset_plan_destroy (hb_subset_plan_t *plan);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册