[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Nov 11 04:53:00 UTC 2018
src/hb-blob.hh | 23 +++++++++++++++++++++++
src/hb-ot-layout-gdef-table.hh | 5 ++---
src/hb-ot-layout-gsubgpos.hh | 8 +++-----
src/hb-ot-layout.cc | 19 ++++++++-----------
src/hb-ot-name-table.hh | 12 +++++-------
5 files changed, 41 insertions(+), 26 deletions(-)
New commits:
commit 5d0078a48b246e713817e5bb6b4efada9618bea3
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Nov 10 23:52:15 2018 -0500
Add hb_blob_ptr_t
Use in a couple of places. Push to bots to see how many unhappy before
I convert the rest.
diff --git a/src/hb-blob.hh b/src/hb-blob.hh
index 1f7499fb..08afd562 100644
--- a/src/hb-blob.hh
+++ b/src/hb-blob.hh
@@ -80,4 +80,27 @@ struct hb_blob_t
DECLARE_NULL_INSTANCE (hb_blob_t);
+/*
+ * hb_blob_ptr_t
+ */
+
+template <typename P>
+struct hb_blob_ptr_t
+{
+ typedef typename hb_remove_pointer<P>::value T;
+
+ inline hb_blob_ptr_t (hb_blob_t *b_ = nullptr) : b (b_) {}
+ inline hb_blob_t * operator = (hb_blob_t *b_) { return b = b_; }
+ inline const T * operator -> (void) const { return get (); }
+ inline const T & operator * (void) const { return *get (); }
+ template <typename C> inline operator const C * (void) const { return get (); }
+ inline operator const char * (void) const { return (const char *) get (); }
+ inline const T * get (void) const { return b->as<T> (); }
+ inline hb_blob_t * get_blob (void) const { return b.get_raw (); }
+ inline unsigned int get_length (void) const { return get_blob ()->length; }
+
+ hb_nonnull_ptr_t<hb_blob_t> b;
+};
+
+
#endif /* HB_BLOB_HH */
diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index af7e5a83..aa6ffc88 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -412,11 +412,10 @@ struct GDEF
inline void fini (void)
{
- hb_blob_destroy (this->blob);
+ hb_blob_destroy (this->table.get_blob ());
}
- hb_blob_t *blob;
- hb_nonnull_ptr_t<const GDEF> table;
+ hb_blob_ptr_t<GDEF> table;
};
inline unsigned int get_size (void) const
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index eccbcf42..2a89d495 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2752,8 +2752,7 @@ struct GSUBGPOS
{
inline void init (hb_face_t *face)
{
- this->blob = hb_sanitize_context_t().reference_table<T> (face);
- table = this->blob->template as<T> ();
+ this->table = hb_sanitize_context_t().reference_table<T> (face);
this->lookup_count = table->get_lookup_count ();
@@ -2770,11 +2769,10 @@ struct GSUBGPOS
for (unsigned int i = 0; i < this->lookup_count; i++)
this->accels[i].fini ();
free (this->accels);
- hb_blob_destroy (this->blob);
+ hb_blob_destroy (this->table.get_blob ());
}
- hb_blob_t *blob;
- hb_nonnull_ptr_t<const T> table;
+ hb_blob_ptr_t<T> table;
unsigned int lookup_count;
hb_ot_layout_lookup_accelerator_t *accels;
};
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 0353c1c5..ec2421e3 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -194,17 +194,15 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len,
void
OT::GDEF::accelerator_t::init (hb_face_t *face)
{
- this->blob = hb_sanitize_context_t().reference_table<GDEF> (face);
+ this->table = hb_sanitize_context_t().reference_table<GDEF> (face);
- if (unlikely (_hb_ot_blacklist_gdef (this->blob->length,
- face->table.GSUB->blob->length,
- face->table.GPOS->blob->length)))
+ if (unlikely (_hb_ot_blacklist_gdef (this->table.get_length (),
+ face->table.GSUB->table.get_length (),
+ face->table.GPOS->table.get_length ())))
{
- hb_blob_destroy (this->blob);
- this->blob = hb_blob_get_empty ();
+ hb_blob_destroy (this->table.get_blob ());
+ this->table = hb_blob_get_empty ();
}
-
- table = this->blob->as<GDEF> ();
}
static void
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh
index f1e785f1..5aa06813 100644
--- a/src/hb-ot-name-table.hh
+++ b/src/hb-ot-name-table.hh
@@ -179,11 +179,10 @@ struct name
{
inline void init (hb_face_t *face)
{
- this->blob = hb_sanitize_context_t().reference_table<name> (face);
- this->table = this->blob->as<name> ();
- assert (this->blob->length >= this->table->stringOffset);
+ this->table = hb_sanitize_context_t().reference_table<name> (face);
+ assert (this->table.get_length () >= this->table->stringOffset);
this->pool = (this->table+this->table->stringOffset).arrayZ;
- this->pool_len = this->blob->length - this->table->stringOffset;
+ this->pool_len = this->table.get_length () - this->table->stringOffset;
const hb_array_t<const NameRecord> all_names (this->table->nameRecordZ.arrayZ,
this->table->count);
@@ -221,7 +220,7 @@ struct name
inline void fini (void)
{
this->names.fini ();
- hb_blob_destroy (this->blob);
+ hb_blob_destroy (this->table.get_blob ());
}
inline int get_index (hb_ot_name_id_t name_id,
@@ -253,11 +252,10 @@ struct name
}
private:
- hb_blob_t *blob;
const void *pool;
unsigned int pool_len;
public:
- hb_nonnull_ptr_t<const name> table;
+ hb_blob_ptr_t<name> table;
hb_vector_t<hb_ot_name_entry_t> names;
};
commit e44046ec499949884b9b77c4c9937ad381386850
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Nov 10 22:41:35 2018 -0500
Minor
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 33bf03c1..0353c1c5 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1060,9 +1060,8 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
for (unsigned int i = 0; i < gsub.get_lookup_count (); i++)
gsub.get_lookup (i).closure (&c, i);
}
- iteration_count++;
- } while (iteration_count <= HB_CLOSURE_MAX_STAGES
- && glyphs_length != glyphs->get_population ());
+ } while (iteration_count++ <= HB_CLOSURE_MAX_STAGES &&
+ glyphs_length != glyphs->get_population ());
}
/*
More information about the HarfBuzz
mailing list