[HarfBuzz] harfbuzz: Branch 'master' - 6 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue May 1 23:17:02 UTC 2018
src/hb-common.cc | 8 ++++----
src/hb-coretext.cc | 8 ++++----
src/hb-mutex-private.hh | 2 +-
src/hb-object-private.hh | 15 ++++++++++-----
src/hb-ot-cmap-table.hh | 8 ++++----
src/hb-ot-hmtx-table.hh | 2 +-
src/hb-ot-layout-private.hh | 4 ++--
src/hb-ot-layout.cc | 2 +-
src/hb-ot-map-private.hh | 24 ++++++++++++------------
src/hb-ot-os2-table.hh | 4 ++--
src/hb-ot-post-table.hh | 4 ++--
src/hb-ot-shape-private.hh | 4 ++--
src/hb-ot-shape.cc | 2 +-
src/hb-private.hh | 29 +++++++++++++++++------------
src/hb-set-private.hh | 34 ++++++++++++++++++++++++++++------
src/hb-set.cc | 3 ++-
src/hb-subset-glyf.cc | 18 +++++++++---------
src/hb-subset-plan.cc | 16 ++++++++--------
src/hb-subset-plan.hh | 6 +++---
src/hb-subset.cc | 4 ++--
src/hb-uniscribe.cc | 12 ++++++------
21 files changed, 121 insertions(+), 88 deletions(-)
New commits:
commit 37b95612d4ae8a9d75a1a5a5165bc073c709cf30
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 1 19:09:00 2018 -0400
Remove hb_auto_array_t
Part of https://github.com/harfbuzz/harfbuzz/issues/1017
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index bb9b5ca2..837b3fb7 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -641,8 +641,8 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
buffer->merge_clusters (i - 1, i + 1);
}
- hb_auto_array_t<feature_record_t> feature_records;
- hb_auto_array_t<range_record_t> range_records;
+ hb_auto_t<hb_vector_t<feature_record_t> > feature_records;
+ hb_auto_t<hb_vector_t<range_record_t> > range_records;
/*
* Set up features.
@@ -651,7 +651,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
if (num_features)
{
/* Sort features by start/end events. */
- hb_auto_array_t<feature_event_t> feature_events;
+ hb_auto_t<hb_vector_t<feature_event_t> > feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag,
@@ -700,7 +700,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
/* Scan events and save features for each range. */
- hb_auto_array_t<active_feature_t> active_features;
+ hb_auto_t<hb_vector_t<active_feature_t> > active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 0c313a7c..9155b7c0 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -623,7 +623,7 @@ struct cmap
inline bool subset (hb_subset_plan_t *plan) const
{
- hb_auto_array_t<CmapSubtableLongGroup> groups;
+ hb_auto_t<hb_vector_t<CmapSubtableLongGroup> > groups;
if (unlikely (!populate_groups (plan, &groups))) return false;
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 9e6f858c..42d29aa1 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1109,7 +1109,7 @@ struct hb_get_subtables_context_t :
hb_apply_func_t apply_func;
};
- typedef hb_auto_array_t<hb_applicable_t> array_t;
+ typedef hb_auto_t<hb_vector_t<hb_applicable_t> > array_t;
/* Dispatch interface. */
inline const char *get_name (void) { return "GET_SUBTABLES"; }
diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc
index c28e6085..0c11765c 100644
--- a/src/hb-subset-plan.cc
+++ b/src/hb-subset-plan.cc
@@ -130,7 +130,7 @@ _populate_gids_to_retain (hb_face_t *face,
cmap.init (face);
glyf.init (face);
- hb_auto_array_t<unsigned int> bad_indices;
+ hb_auto_t<hb_vector_t<unsigned int> > bad_indices;
old_gids.alloc (codepoints.len);
for (unsigned int i = 0; i < codepoints.len; i++)
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index b4717a3d..bc6667c3 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -630,12 +630,12 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
/*
* Set up features.
*/
- hb_auto_array_t<OPENTYPE_FEATURE_RECORD> feature_records;
- hb_auto_array_t<range_record_t> range_records;
+ hb_auto_t<hb_vector_t<OPENTYPE_FEATURE_RECORD> > feature_records;
+ hb_auto_t<hb_vector_t<range_record_t> > range_records;
if (num_features)
{
/* Sort features by start/end events. */
- hb_auto_array_t<feature_event_t> feature_events;
+ hb_auto_t<hb_vector_t<feature_event_t> > feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
active_feature_t feature;
@@ -676,7 +676,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
}
/* Scan events and save features for each range. */
- hb_auto_array_t<active_feature_t> active_features;
+ hb_auto_t<hb_vector_t<active_feature_t> > active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
@@ -858,8 +858,8 @@ retry:
#undef MAX_ITEMS
OPENTYPE_TAG language_tag = hb_uint32_swap (hb_ot_tag_from_language (buffer->props.language));
- hb_auto_array_t<TEXTRANGE_PROPERTIES*> range_properties;
- hb_auto_array_t<int> range_char_counts;
+ hb_auto_t<hb_vector_t<TEXTRANGE_PROPERTIES*> > range_properties;
+ hb_auto_t<hb_vector_t<int> > range_char_counts;
unsigned int glyphs_offset = 0;
unsigned int glyphs_len;
commit 5c3112aec8b77d0fe39164f0f700e2a1aa810022
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 1 19:07:04 2018 -0400
s/hb_prealloced_array_t/hb_vector_t/g
Part of https://github.com/harfbuzz/harfbuzz/issues/1017
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 7eb706af..0c313a7c 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -294,7 +294,7 @@ struct CmapSubtableLongSegmented
}
inline bool serialize (hb_serialize_context_t *c,
- hb_prealloced_array_t<CmapSubtableLongGroup> &group_data)
+ hb_vector_t<CmapSubtableLongGroup> &group_data)
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
@@ -548,7 +548,7 @@ struct cmap
}
inline bool populate_groups (hb_subset_plan_t *plan,
- hb_prealloced_array_t<CmapSubtableLongGroup> *groups) const
+ hb_vector_t<CmapSubtableLongGroup> *groups) const
{
CmapSubtableLongGroup *group = nullptr;
for (unsigned int i = 0; i < plan->codepoints.len; i++) {
@@ -582,7 +582,7 @@ struct cmap
return true;
}
- inline bool _subset (hb_prealloced_array_t<CmapSubtableLongGroup> &groups,
+ inline bool _subset (hb_vector_t<CmapSubtableLongGroup> &groups,
size_t dest_sz,
void *dest) const
{
diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh
index b209a4ec..5944688a 100644
--- a/src/hb-ot-hmtx-table.hh
+++ b/src/hb-ot-hmtx-table.hh
@@ -94,7 +94,7 @@ struct hmtxvmtx
/* All the trailing glyphs with the same advance can use one LongMetric
* and just keep LSB */
- hb_prealloced_array_t<hb_codepoint_t> &gids = plan->gids_to_retain_sorted;
+ hb_vector_t<hb_codepoint_t> &gids = plan->gids_to_retain_sorted;
unsigned int num_advances = gids.len;
unsigned int last_advance = _mtx.get_advance (gids[num_advances - 1]);
while (num_advances > 1
diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh
index 9cfe3668..f34c2bfc 100644
--- a/src/hb-ot-map-private.hh
+++ b/src/hb-ot-map-private.hh
@@ -147,9 +147,9 @@ struct hb_ot_map_t
hb_mask_t global_mask;
- hb_prealloced_array_t<feature_map_t, 8> features;
- hb_prealloced_array_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */
- hb_prealloced_array_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */
+ hb_vector_t<feature_map_t, 8> features;
+ hb_vector_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */
+ hb_vector_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */
};
enum hb_ot_map_feature_flags_t {
@@ -241,8 +241,8 @@ struct hb_ot_map_builder_t
private:
unsigned int current_stage[2]; /* GSUB/GPOS */
- hb_prealloced_array_t<feature_info_t, 32> feature_infos;
- hb_prealloced_array_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */
+ hb_vector_t<feature_info_t, 32> feature_infos;
+ hb_vector_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */
};
diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh
index dfb87dc0..7d26a207 100644
--- a/src/hb-ot-os2-table.hh
+++ b/src/hb-ot-os2-table.hh
@@ -74,7 +74,7 @@ struct os2
return result;
}
- inline void _update_unicode_ranges (const hb_prealloced_array_t<hb_codepoint_t> &codepoints,
+ inline void _update_unicode_ranges (const hb_vector_t<hb_codepoint_t> &codepoints,
HBUINT32 ulUnicodeRange[4]) const
{
for (unsigned int i = 0; i < 4; i++)
@@ -101,7 +101,7 @@ struct os2
}
}
- static inline void find_min_and_max_codepoint (const hb_prealloced_array_t<hb_codepoint_t> &codepoints,
+ static inline void find_min_and_max_codepoint (const hb_vector_t<hb_codepoint_t> &codepoints,
uint16_t *min_cp, /* OUT */
uint16_t *max_cp /* OUT */)
{
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index f3605242..0cd97fa2 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -258,7 +258,7 @@ struct post
hb_blob_t *blob;
uint32_t version;
const ArrayOf<HBUINT16> *glyphNameIndex;
- hb_prealloced_array_t<uint32_t, 1> index_to_offset;
+ hb_vector_t<uint32_t, 1> index_to_offset;
const uint8_t *pool;
mutable uint16_t *gids_sorted_by_name;
};
diff --git a/src/hb-private.hh b/src/hb-private.hh
index a9a6bda4..d7c8fef8 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -527,7 +527,7 @@ _hb_ceil_to_4 (unsigned int v)
#define HB_PREALLOCED_ARRAY_INIT {0, 0, nullptr}
template <typename Type, unsigned int StaticSize=16>
-struct hb_prealloced_array_t
+struct hb_vector_t
{
unsigned int len;
unsigned int allocated;
@@ -710,14 +710,14 @@ struct hb_auto_t : Type
void fini (void) {}
};
template <typename Type>
-struct hb_auto_array_t : hb_auto_t <hb_prealloced_array_t <Type> > {};
+struct hb_auto_array_t : hb_auto_t <hb_vector_t <Type> > {};
#define HB_LOCKABLE_SET_INIT {HB_PREALLOCED_ARRAY_INIT}
template <typename item_t, typename lock_t>
struct hb_lockable_set_t
{
- hb_prealloced_array_t <item_t, 1> items;
+ hb_vector_t <item_t, 1> items;
inline void init (void) { items.init (); }
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index df3326b3..4288b15b 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -190,8 +190,8 @@ struct hb_set_t
ASSERT_POD ();
bool in_error;
mutable unsigned int population;
- hb_prealloced_array_t<page_map_t, 8> page_map;
- hb_prealloced_array_t<page_t, 1> pages;
+ hb_vector_t<page_map_t, 8> page_map;
+ hb_vector_t<page_t, 1> pages;
inline void init (void)
{
diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc
index 372832f1..2daa63ed 100644
--- a/src/hb-subset-glyf.cc
+++ b/src/hb-subset-glyf.cc
@@ -32,12 +32,12 @@
static bool
_calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
- hb_prealloced_array_t<hb_codepoint_t> &glyph_ids,
+ hb_vector_t<hb_codepoint_t> &glyph_ids,
hb_bool_t drop_hints,
bool *use_short_loca /* OUT */,
unsigned int *glyf_size /* OUT */,
unsigned int *loca_size /* OUT */,
- hb_prealloced_array_t<unsigned int> *instruction_ranges /* OUT */)
+ hb_vector_t<unsigned int> *instruction_ranges /* OUT */)
{
unsigned int total = 0;
for (unsigned int i = 0; i < glyph_ids.len; i++)
@@ -159,13 +159,13 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan,
const OT::glyf::accelerator_t &glyf,
const char *glyf_data,
bool use_short_loca,
- hb_prealloced_array_t<unsigned int> &instruction_ranges,
+ hb_vector_t<unsigned int> &instruction_ranges,
unsigned int glyf_prime_size,
char *glyf_prime_data /* OUT */,
unsigned int loca_prime_size,
char *loca_prime_data /* OUT */)
{
- hb_prealloced_array_t<hb_codepoint_t> &glyph_ids = plan->gids_to_retain_sorted;
+ hb_vector_t<hb_codepoint_t> &glyph_ids = plan->gids_to_retain_sorted;
char *glyf_prime_data_next = glyf_prime_data;
bool success = true;
@@ -234,11 +234,11 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
hb_blob_t **loca_prime /* OUT */)
{
// TODO(grieger): Sanity check allocation size for the new table.
- hb_prealloced_array_t<hb_codepoint_t> &glyphs_to_retain = plan->gids_to_retain_sorted;
+ hb_vector_t<hb_codepoint_t> &glyphs_to_retain = plan->gids_to_retain_sorted;
unsigned int glyf_prime_size;
unsigned int loca_prime_size;
- hb_prealloced_array_t<unsigned int> instruction_ranges;
+ hb_vector_t<unsigned int> instruction_ranges;
instruction_ranges.init();
if (unlikely (!_calculate_glyf_and_loca_prime_size (glyf,
diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc
index 1784aefb..c28e6085 100644
--- a/src/hb-subset-plan.cc
+++ b/src/hb-subset-plan.cc
@@ -87,7 +87,7 @@ hb_subset_plan_add_table (hb_subset_plan_t *plan,
static void
_populate_codepoints (hb_set_t *input_codepoints,
- hb_prealloced_array_t<hb_codepoint_t>& plan_codepoints)
+ hb_vector_t<hb_codepoint_t>& plan_codepoints)
{
plan_codepoints.alloc (hb_set_get_population (input_codepoints));
hb_codepoint_t cp = -1;
@@ -121,9 +121,9 @@ _add_gid_and_children (const OT::glyf::accelerator_t &glyf,
static void
_populate_gids_to_retain (hb_face_t *face,
- 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)
+ hb_vector_t<hb_codepoint_t>& codepoints,
+ hb_vector_t<hb_codepoint_t>& old_gids,
+ hb_vector_t<hb_codepoint_t>& old_gids_sorted)
{
OT::cmap::accelerator_t cmap;
OT::glyf::accelerator_t glyf;
diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh
index d1b66b44..3b9db03f 100644
--- a/src/hb-subset-plan.hh
+++ b/src/hb-subset-plan.hh
@@ -45,12 +45,12 @@ struct hb_subset_plan_t {
// These first two lists provide a mapping from cp -> gid
// As a result it does not list the full set of glyphs to retain.
- hb_prealloced_array_t<hb_codepoint_t> codepoints;
- hb_prealloced_array_t<hb_codepoint_t> gids_to_retain;
+ hb_vector_t<hb_codepoint_t> codepoints;
+ hb_vector_t<hb_codepoint_t> gids_to_retain;
// This list contains the complete set of glyphs to retain and may contain
// more glyphs then the lists above.
- hb_prealloced_array_t<hb_codepoint_t> gids_to_retain_sorted;
+ hb_vector_t<hb_codepoint_t> gids_to_retain_sorted;
// Plan is only good for a specific source/dest so keep them with it
hb_face_t *source;
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 41f44533..35fe0ef8 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -123,7 +123,7 @@ struct hb_subset_face_data_t
hb_blob_t *blob;
};
- hb_prealloced_array_t<table_entry_t, 32> tables;
+ hb_vector_t<table_entry_t, 32> tables;
};
static hb_subset_face_data_t *
commit 4a01eb1234a72e6a91ed66d3ed60b5db378fe340
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 1 19:05:58 2018 -0400
Add hb_auto_t
Part of https://github.com/harfbuzz/harfbuzz/issues/1017
diff --git a/src/hb-private.hh b/src/hb-private.hh
index d27d5805..a9a6bda4 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -701,11 +701,16 @@ struct hb_prealloced_array_t
};
template <typename Type>
-struct hb_auto_array_t : hb_prealloced_array_t <Type>
+struct hb_auto_t : Type
{
- hb_auto_array_t (void) { hb_prealloced_array_t<Type>::init (); }
- ~hb_auto_array_t (void) { hb_prealloced_array_t<Type>::fini (); }
+ hb_auto_t (void) { Type::init (); }
+ ~hb_auto_t (void) { Type::fini (); }
+ private: /* Hide */
+ void init (void) {}
+ void fini (void) {}
};
+template <typename Type>
+struct hb_auto_array_t : hb_auto_t <hb_prealloced_array_t <Type> > {};
#define HB_LOCKABLE_SET_INIT {HB_PREALLOCED_ARRAY_INIT}
commit a60ba7964ea196a3a02c48e813f2d9505d0cded2
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 1 19:01:25 2018 -0400
s/finish/fini
For consistency.
diff --git a/src/hb-common.cc b/src/hb-common.cc
index bc54db67..f38ebb04 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -225,7 +225,7 @@ struct hb_language_item_t {
inline hb_language_item_t & operator = (const char *s) {
/* If a custom allocated is used calling strdup() pairs
- badly with a call to the custom free() in finish() below.
+ badly with a call to the custom free() in fini() below.
Therefore don't call strdup(), implement its behavior.
*/
size_t len = strlen(s) + 1;
@@ -240,7 +240,7 @@ struct hb_language_item_t {
return *this;
}
- void finish (void) { free ((void *) lang); }
+ void fini (void) { free ((void *) lang); }
};
@@ -259,7 +259,7 @@ retry:
while (first_lang) {
hb_language_item_t *next = first_lang->next;
- first_lang->finish ();
+ first_lang->fini ();
free (first_lang);
first_lang = next;
}
@@ -289,7 +289,7 @@ retry:
}
if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) {
- lang->finish ();
+ lang->fini ();
free (lang);
goto retry;
}
diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh
index 49ed10e0..14bde310 100644
--- a/src/hb-mutex-private.hh
+++ b/src/hb-mutex-private.hh
@@ -134,7 +134,7 @@ struct hb_mutex_t
inline void init (void) { hb_mutex_impl_init (&m); }
inline void lock (void) { hb_mutex_impl_lock (&m); }
inline void unlock (void) { hb_mutex_impl_unlock (&m); }
- inline void finish (void) { hb_mutex_impl_finish (&m); }
+ inline void fini (void) { hb_mutex_impl_finish (&m); }
};
diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh
index f23f90ac..75a72f4b 100644
--- a/src/hb-object-private.hh
+++ b/src/hb-object-private.hh
@@ -53,7 +53,7 @@ struct hb_reference_count_t
inline int get_unsafe (void) const { return ref_count.get_unsafe (); }
inline int inc (void) { return ref_count.inc (); }
inline int dec (void) { return ref_count.dec (); }
- inline void finish (void) { ref_count.set_unsafe (HB_REFERENCE_COUNT_POISON_VALUE); }
+ inline void fini (void) { ref_count.set_unsafe (HB_REFERENCE_COUNT_POISON_VALUE); }
inline bool is_inert (void) const { return ref_count.get_unsafe () == HB_REFERENCE_COUNT_INERT_VALUE; }
inline bool is_valid (void) const { return ref_count.get_unsafe () > 0; }
@@ -73,7 +73,7 @@ struct hb_user_data_array_t
inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; }
inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; }
- void finish (void) { if (destroy) destroy (data); }
+ void fini (void) { if (destroy) destroy (data); }
};
hb_mutex_t lock;
@@ -88,7 +88,7 @@ struct hb_user_data_array_t
HB_INTERNAL void *get (hb_user_data_key_t *key);
- inline void finish (void) { items.finish (lock); lock.finish (); }
+ inline void fini (void) { items.fini (lock); lock.fini (); }
};
@@ -171,8 +171,8 @@ static inline bool hb_object_destroy (Type *obj)
template <typename Type>
static inline void hb_object_fini (Type *obj)
{
- obj->header.ref_count.finish (); /* Do this before user_data */
- obj->header.user_data.finish ();
+ obj->header.ref_count.fini (); /* Do this before user_data */
+ obj->header.user_data.fini ();
}
template <typename Type>
static inline bool hb_object_set_user_data (Type *obj,
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 9bcbf1cb..2454920c 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -105,12 +105,12 @@ HB_INTERNAL void
hb_ot_layout_position_start (hb_font_t *font,
hb_buffer_t *buffer);
-/* Should be called after all the position_lookup's are done, to finish advances. */
+/* Should be called after all the position_lookup's are done, to fini advances. */
HB_INTERNAL void
hb_ot_layout_position_finish_advances (hb_font_t *font,
hb_buffer_t *buffer);
-/* Should be called after hb_ot_layout_position_finish_advances, to finish offsets. */
+/* Should be called after hb_ot_layout_position_finish_advances, to fini offsets. */
HB_INTERNAL void
hb_ot_layout_position_finish_offsets (hb_font_t *font,
hb_buffer_t *buffer);
diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh
index e6bd8ea5..9cfe3668 100644
--- a/src/hb-ot-map-private.hh
+++ b/src/hb-ot-map-private.hh
@@ -130,12 +130,12 @@ struct hb_ot_map_t
HB_INTERNAL void substitute (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
HB_INTERNAL void position (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
- inline void finish (void) {
- features.finish ();
+ inline void fini (void) {
+ features.fini ();
for (unsigned int table_index = 0; table_index < 2; table_index++)
{
- lookups[table_index].finish ();
- stages[table_index].finish ();
+ lookups[table_index].fini ();
+ stages[table_index].fini ();
}
}
@@ -187,11 +187,11 @@ struct hb_ot_map_builder_t
const int *coords,
unsigned int num_coords);
- inline void finish (void) {
- feature_infos.finish ();
+ inline void fini (void) {
+ feature_infos.fini ();
for (unsigned int table_index = 0; table_index < 2; table_index++)
{
- stages[table_index].finish ();
+ stages[table_index].fini ();
}
}
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 1441e2cb..f3605242 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -134,7 +134,7 @@ struct post
}
inline void fini (void)
{
- index_to_offset.finish ();
+ index_to_offset.fini ();
free (gids_sorted_by_name);
}
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index fe5d2b7f..fddb757c 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -59,7 +59,7 @@ struct hb_ot_shape_plan_t
inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); }
inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); }
- void finish (void) { map.finish (); }
+ void fini (void) { map.fini (); }
};
struct hb_ot_shape_planner_t
@@ -75,7 +75,7 @@ struct hb_ot_shape_planner_t
props (master_plan->props),
shaper (nullptr),
map (face, &props) {}
- ~hb_ot_shape_planner_t (void) { map.finish (); }
+ ~hb_ot_shape_planner_t (void) { map.fini (); }
inline void compile (hb_ot_shape_plan_t &plan,
const int *coords,
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 263d65c0..dd10e346 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -204,7 +204,7 @@ _hb_ot_shaper_shape_plan_data_destroy (hb_ot_shaper_shape_plan_data_t *plan)
if (plan->shaper->data_destroy)
plan->shaper->data_destroy (const_cast<void *> (plan->data));
- plan->finish ();
+ plan->fini ();
free (plan);
}
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 7e6d8e51..d27d5805 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -691,7 +691,7 @@ struct hb_prealloced_array_t
return false;
}
- inline void finish (void)
+ inline void fini (void)
{
if (array != static_array)
free (array);
@@ -704,7 +704,7 @@ template <typename Type>
struct hb_auto_array_t : hb_prealloced_array_t <Type>
{
hb_auto_array_t (void) { hb_prealloced_array_t<Type>::init (); }
- ~hb_auto_array_t (void) { hb_prealloced_array_t<Type>::finish (); }
+ ~hb_auto_array_t (void) { hb_prealloced_array_t<Type>::fini (); }
};
@@ -726,7 +726,7 @@ struct hb_lockable_set_t
item_t old = *item;
*item = v;
l.unlock ();
- old.finish ();
+ old.fini ();
}
else {
item = nullptr;
@@ -751,7 +751,7 @@ struct hb_lockable_set_t
*item = items[items.len - 1];
items.pop ();
l.unlock ();
- old.finish ();
+ old.fini ();
} else {
l.unlock ();
}
@@ -782,11 +782,11 @@ struct hb_lockable_set_t
return item;
}
- inline void finish (lock_t &l)
+ inline void fini (lock_t &l)
{
if (!items.len) {
/* No need for locking. */
- items.finish ();
+ items.fini ();
return;
}
l.lock ();
@@ -794,10 +794,10 @@ struct hb_lockable_set_t
item_t old = items[items.len - 1];
items.pop ();
l.unlock ();
- old.finish ();
+ old.fini ();
l.lock ();
}
- items.finish ();
+ items.fini ();
l.unlock ();
}
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 5ccefc89..df3326b3 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -200,10 +200,10 @@ struct hb_set_t
page_map.init ();
pages.init ();
}
- inline void finish (void)
+ inline void fini (void)
{
- page_map.finish ();
- pages.finish ();
+ page_map.fini ();
+ pages.fini ();
}
inline bool resize (unsigned int count)
diff --git a/src/hb-set.cc b/src/hb-set.cc
index deb8d29a..d5163c78 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -96,7 +96,7 @@ hb_set_destroy (hb_set_t *set)
{
if (!hb_object_destroy (set)) return;
- set->finish ();
+ set->fini ();
free (set);
}
diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc
index b9e6355c..372832f1 100644
--- a/src/hb-subset-glyf.cc
+++ b/src/hb-subset-glyf.cc
@@ -248,7 +248,7 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
&glyf_prime_size,
&loca_prime_size,
&instruction_ranges))) {
- instruction_ranges.finish();
+ instruction_ranges.fini();
return false;
}
@@ -261,10 +261,10 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
loca_prime_size, loca_prime_data))) {
free (glyf_prime_data);
free (loca_prime_data);
- instruction_ranges.finish();
+ instruction_ranges.fini();
return false;
}
- instruction_ranges.finish();
+ instruction_ranges.fini();
*glyf_prime = hb_blob_create (glyf_prime_data,
glyf_prime_size,
diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc
index f8a09efe..1784aefb 100644
--- a/src/hb-subset-plan.cc
+++ b/src/hb-subset-plan.cc
@@ -216,9 +216,9 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan)
{
if (!hb_object_destroy (plan)) return;
- plan->codepoints.finish ();
- plan->gids_to_retain.finish ();
- plan->gids_to_retain_sorted.finish ();
+ plan->codepoints.fini ();
+ plan->gids_to_retain.fini ();
+ plan->gids_to_retain_sorted.fini ();
hb_face_destroy (plan->source);
hb_face_destroy (plan->dest);
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 5da46c79..41f44533 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -144,7 +144,7 @@ _hb_subset_face_data_destroy (void *user_data)
for (unsigned int i = 0; i < data->tables.len; i++)
hb_blob_destroy (data->tables[i].blob);
- data->tables.finish ();
+ data->tables.fini ();
free (data);
}
commit 17618ee2ecd02cb100ca911bd1907d108e9df475
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 1 18:39:25 2018 -0400
Add hb_object_fini()
diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh
index baa1f8f0..f23f90ac 100644
--- a/src/hb-object-private.hh
+++ b/src/hb-object-private.hh
@@ -165,9 +165,14 @@ static inline bool hb_object_destroy (Type *obj)
if (obj->header.ref_count.dec () != 1)
return false;
+ hb_object_fini (obj);
+ return true;
+}
+template <typename Type>
+static inline void hb_object_fini (Type *obj)
+{
obj->header.ref_count.finish (); /* Do this before user_data */
obj->header.user_data.finish ();
- return true;
}
template <typename Type>
static inline bool hb_object_set_user_data (Type *obj,
commit bd5f918e2f86241d3e2cb706bf558de21c198860
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 1 18:27:41 2018 -0400
[set] Cache population
Part of https://github.com/harfbuzz/harfbuzz/issues/1017
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 3615c50e..5ccefc89 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -189,12 +189,14 @@ struct hb_set_t
hb_object_header_t header;
ASSERT_POD ();
bool in_error;
+ mutable unsigned int population;
hb_prealloced_array_t<page_map_t, 8> page_map;
hb_prealloced_array_t<page_t, 1> pages;
inline void init (void)
{
in_error = false;
+ population = 0;
page_map.init ();
pages.init ();
}
@@ -220,6 +222,7 @@ struct hb_set_t
if (unlikely (hb_object_is_inert (this)))
return;
in_error = false;
+ population = 0;
page_map.resize (0);
pages.resize (0);
}
@@ -231,10 +234,13 @@ struct hb_set_t
return true;
}
+ inline void dirty (void) { population = (unsigned int) -1; }
+
inline void add (hb_codepoint_t g)
{
if (unlikely (in_error)) return;
if (unlikely (g == INVALID)) return;
+ dirty ();
page_t *page = page_for_insert (g); if (unlikely (!page)) return;
page->add (g);
}
@@ -242,6 +248,7 @@ struct hb_set_t
{
if (unlikely (in_error)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */
if (unlikely (a > b || a == INVALID || b == INVALID)) return false;
+ dirty ();
unsigned int ma = get_major (a);
unsigned int mb = get_major (b);
if (ma == mb)
@@ -271,6 +278,7 @@ struct hb_set_t
{
if (unlikely (in_error)) return;
if (!count) return;
+ dirty ();
hb_codepoint_t g = *array;
while (count)
{
@@ -296,6 +304,7 @@ struct hb_set_t
{
if (unlikely (in_error)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */
if (!count) return true;
+ dirty ();
hb_codepoint_t g = *array;
hb_codepoint_t last_g = g;
while (count)
@@ -325,6 +334,7 @@ struct hb_set_t
page_t *p = page_for (g);
if (!p)
return;
+ dirty ();
p->del (g);
}
inline void del_range (hb_codepoint_t a, hb_codepoint_t b)
@@ -353,13 +363,18 @@ struct hb_set_t
unsigned int count = other->pages.len;
if (!resize (count))
return;
-
+ population = other->population;
memcpy (pages.array, other->pages.array, count * sizeof (pages.array[0]));
memcpy (page_map.array, other->page_map.array, count * sizeof (page_map.array[0]));
}
inline bool is_equal (const hb_set_t *other) const
{
+ if (population != (unsigned int) -1 &&
+ other->population != (unsigned int) -1 &&
+ population != other->population)
+ return false;
+
unsigned int na = pages.len;
unsigned int nb = other->pages.len;
@@ -387,6 +402,8 @@ struct hb_set_t
{
if (unlikely (in_error)) return;
+ dirty ();
+
unsigned int na = pages.len;
unsigned int nb = other->pages.len;
unsigned int next_page = na;
@@ -592,10 +609,15 @@ struct hb_set_t
inline unsigned int get_population (void) const
{
+ if (population != (unsigned int) -1)
+ return population;
+
unsigned int pop = 0;
unsigned int count = pages.len;
for (unsigned int i = 0; i < count; i++)
pop += pages[i].get_population ();
+
+ population = pop;
return pop;
}
inline hb_codepoint_t get_min (void) const
diff --git a/src/hb-set.cc b/src/hb-set.cc
index af590ef3..deb8d29a 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -53,6 +53,7 @@ hb_set_create (void)
static const hb_set_t _hb_set_nil = {
HB_OBJECT_HEADER_STATIC,
true, /* in_error */
+ 0, /* population */
{0} /* elts */
};
More information about the HarfBuzz
mailing list