[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue Nov 13 17:04:29 UTC 2018
src/hb-aat-layout-lcar-table.hh | 3 ++-
src/hb-atomic.hh | 10 +++++-----
src/hb-face.cc | 10 +++++-----
src/hb-face.hh | 24 ++++++++++++++----------
src/hb-object.hh | 2 +-
src/hb-ot-color-sbix-table.hh | 2 +-
src/hb-ot-face.hh | 1 +
src/hb-ot-glyf-table.hh | 11 +++--------
src/hb-shape-plan.hh | 12 +-----------
src/hb-static.cc | 16 +++++++++-------
10 files changed, 42 insertions(+), 49 deletions(-)
New commits:
commit fc44dea341f1750fec801faed66656b8a58dcded
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 11:54:33 2018 -0500
Use atomic ints for upem and num_glyphs on face
diff --git a/src/hb-aat-layout-lcar-table.hh b/src/hb-aat-layout-lcar-table.hh
index e57836a0..43ac74f9 100644
--- a/src/hb-aat-layout-lcar-table.hh
+++ b/src/hb-aat-layout-lcar-table.hh
@@ -49,7 +49,8 @@ struct lcar
unsigned int *caret_count /* IN/OUT */,
hb_position_t *caret_array /* OUT */) const
{
- const OffsetTo<LigCaretClassEntry>* entry_offset = lookup.get_value (glyph, font->face->num_glyphs);
+ const OffsetTo<LigCaretClassEntry>* entry_offset = lookup.get_value (glyph,
+ font->face->get_num_glyphs ());
const LigCaretClassEntry& array = entry_offset ? this+*entry_offset : Null (LigCaretClassEntry);
if (caret_count && *caret_count)
{
diff --git a/src/hb-face.cc b/src/hb-face.cc
index da73433c..3294ed4c 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -87,8 +87,8 @@ DEFINE_NULL_INSTANCE (hb_face_t) =
nullptr, /* destroy */
0, /* index */
- 1000, /* upem */
- 0, /* num_glyphs */
+ HB_ATOMIC_INT_INIT (1000), /* upem */
+ HB_ATOMIC_INT_INIT (0), /* num_glyphs */
{
#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID),
@@ -129,7 +129,7 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
face->user_data = user_data;
face->destroy = destroy;
- face->num_glyphs = (unsigned int) -1;
+ face->num_glyphs.set_relaxed (-1);
face->table.init0 (face);
@@ -445,7 +445,7 @@ hb_face_set_upem (hb_face_t *face,
if (hb_object_is_immutable (face))
return;
- face->upem = upem;
+ face->upem.set_relaxed (upem);
}
/**
@@ -480,7 +480,7 @@ hb_face_set_glyph_count (hb_face_t *face,
if (hb_object_is_immutable (face))
return;
- face->num_glyphs = glyph_count;
+ face->num_glyphs.set_relaxed (glyph_count);
}
/**
diff --git a/src/hb-face.hh b/src/hb-face.hh
index 5d22f4ad..002fb2cb 100644
--- a/src/hb-face.hh
+++ b/src/hb-face.hh
@@ -49,8 +49,8 @@ struct hb_face_t
hb_destroy_func_t destroy;
unsigned int index; /* Face index in a collection, zero-based. */
- mutable unsigned int upem; /* Units-per-EM. */
- mutable unsigned int num_glyphs; /* Number of glyphs. */
+ mutable hb_atomic_int_t upem; /* Units-per-EM. */
+ mutable hb_atomic_int_t num_glyphs; /* Number of glyphs. */
struct hb_shaper_data_t shaper_data; /* Various shaper data. */
@@ -80,21 +80,25 @@ struct hb_face_t
inline HB_PURE_FUNC unsigned int get_upem (void) const
{
- if (unlikely (!upem))
- load_upem ();
- return upem;
+ unsigned int ret = upem.get_relaxed ();
+ if (unlikely (!ret))
+ {
+ return load_upem ();
+ }
+ return ret;
}
inline unsigned int get_num_glyphs (void) const
{
- if (unlikely (num_glyphs == (unsigned int) -1))
- load_num_glyphs ();
- return num_glyphs;
+ unsigned int ret = num_glyphs.get_relaxed ();
+ if (unlikely (ret == (unsigned int) -1))
+ return load_num_glyphs ();
+ return ret;
}
private:
- HB_INTERNAL void load_upem (void) const;
- HB_INTERNAL void load_num_glyphs (void) const;
+ HB_INTERNAL unsigned int load_upem (void) const;
+ HB_INTERNAL unsigned int load_num_glyphs (void) const;
};
DECLARE_NULL_INSTANCE (hb_face_t);
diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh
index 80d65022..08dee2a0 100644
--- a/src/hb-ot-color-sbix-table.hh
+++ b/src/hb-ot-color-sbix-table.hh
@@ -249,7 +249,7 @@ struct sbix
/* Convert to font units. */
if (strike_ppem)
{
- double scale = font->face->upem / (double) strike_ppem;
+ double scale = font->face->get_upem () / (double) strike_ppem;
extents->x_bearing = round (extents->x_bearing * scale);
extents->y_bearing = round (extents->y_bearing * scale);
extents->width = round (extents->width * scale);
diff --git a/src/hb-static.cc b/src/hb-static.cc
index 461b08be..73d9528e 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -46,21 +46,26 @@ DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x0
const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF};
-void
+unsigned int
hb_face_t::load_num_glyphs (void) const
{
hb_sanitize_context_t c = hb_sanitize_context_t ();
c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */
hb_blob_t *maxp_blob = c.reference_table<OT::maxp> (this);
const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> ();
- num_glyphs = maxp_table->get_num_glyphs ();
+
+ unsigned int ret = maxp_table->get_num_glyphs ();
+ num_glyphs.set_relaxed (ret);
hb_blob_destroy (maxp_blob);
+ return ret;
}
-void
+unsigned int
hb_face_t::load_upem (void) const
{
- upem = table.head->get_upem ();
+ unsigned int ret = table.head->get_upem ();
+ upem.set_relaxed (ret);
+ return ret;
}
#endif
commit 9579ed9755d7c3e47435c55881c9841a5f60ad7e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 11:45:12 2018 -0500
Make atomic types' internal values non-mutable
This resulted from confusion previously...
diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh
index 49c2809e..3ccaf554 100644
--- a/src/hb-atomic.hh
+++ b/src/hb-atomic.hh
@@ -267,14 +267,14 @@ inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barr
#define HB_ATOMIC_INT_INIT(V) {V}
struct hb_atomic_int_t
{
- inline void set_relaxed (int v_) const { hb_atomic_int_impl_set_relaxed (&v, v_); }
- inline void set (int v_) const { hb_atomic_int_impl_set (&v, v_); }
+ inline void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); }
+ inline void set (int v_) { hb_atomic_int_impl_set (&v, v_); }
inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); }
inline int get (void) const { return hb_atomic_int_impl_get (&v); }
inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); }
inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); }
- mutable int v;
+ int v;
};
@@ -285,7 +285,7 @@ struct hb_atomic_ptr_t
typedef typename hb_remove_pointer<P>::value T;
inline void init (T* v_ = nullptr) { set_relaxed (v_); }
- inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
+ inline void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
inline T *get_relaxed (void) const { return (T *) hb_atomic_ptr_impl_get_relaxed (&v); }
inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); }
inline bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); }
@@ -293,7 +293,7 @@ struct hb_atomic_ptr_t
inline T * operator -> (void) const { return get (); }
template <typename C> inline operator C * (void) const { return get (); }
- mutable T *v;
+ T *v;
};
diff --git a/src/hb-object.hh b/src/hb-object.hh
index 74340c55..cdacf49f 100644
--- a/src/hb-object.hh
+++ b/src/hb-object.hh
@@ -194,7 +194,7 @@ struct hb_user_data_array_t
struct hb_object_header_t
{
hb_reference_count_t ref_count;
- hb_atomic_int_t writable;
+ mutable hb_atomic_int_t writable;
hb_atomic_ptr_t<hb_user_data_array_t> user_data;
};
#define HB_OBJECT_HEADER_STATIC \
commit c52d5bcd9405dbaa9289d720d9f0853aeac6b244
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 11:41:29 2018 -0500
[ot-face] Add 'head' table
diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh
index 4a36a4dc..13c3a96d 100644
--- a/src/hb-ot-face.hh
+++ b/src/hb-ot-face.hh
@@ -40,6 +40,7 @@
#define HB_OT_TABLES \
/* OpenType fundamentals. */ \
+ HB_OT_TABLE(OT, head) \
HB_OT_ACCELERATOR(OT, cmap) \
HB_OT_ACCELERATOR(OT, hmtx) \
HB_OT_ACCELERATOR(OT, vmtx) \
diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh
index 42bb03ff..4fdbced4 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -235,16 +235,11 @@ struct glyf
{
memset (this, 0, sizeof (accelerator_t));
- hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (face);
- const head *head_table = head_blob->as<head> ();
- if (head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0)
- {
+ const OT::head &head = *face->table.head;
+ if (head.indexToLocFormat > 1 || head.glyphDataFormat != 0)
/* Unknown format. Leave num_glyphs=0, that takes care of disabling us. */
- hb_blob_destroy (head_blob);
return;
- }
- short_offset = 0 == head_table->indexToLocFormat;
- hb_blob_destroy (head_blob);
+ short_offset = 0 == head.indexToLocFormat;
loca_table = hb_sanitize_context_t().reference_table<loca> (face);
glyf_table = hb_sanitize_context_t().reference_table<glyf> (face);
diff --git a/src/hb-static.cc b/src/hb-static.cc
index 3669e08b..461b08be 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -60,10 +60,7 @@ hb_face_t::load_num_glyphs (void) const
void
hb_face_t::load_upem (void) const
{
- hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table<OT::head> (this);
- const OT::head *head_table = head_blob->as<OT::head> ();
- upem = head_table->get_upem ();
- hb_blob_destroy (head_blob);
+ upem = table.head->get_upem ();
}
#endif
commit 56f541d0001f6d7e2e35cdd15217bdf52ebf8391
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Nov 12 19:46:37 2018 -0500
[shape-plan] Remove unused code
diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh
index c69d4507..d9aa3ee1 100644
--- a/src/hb-shape-plan.hh
+++ b/src/hb-shape-plan.hh
@@ -1,5 +1,5 @@
/*
- * Copyright © 2012 Google, Inc.
+ * Copyright © 2012,2018 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -71,15 +71,5 @@ struct hb_shape_plan_t
hb_ot_shape_plan_t ot;
};
-#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \
- , const hb_feature_t *user_features \
- , unsigned int num_user_features \
- , const int *coords \
- , unsigned int num_coords
-#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, shape_plan);
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
-#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
-
#endif /* HB_SHAPE_PLAN_HH */
More information about the HarfBuzz
mailing list