[HarfBuzz] harfbuzz: Branch 'master' - 3 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Nov 12 02:54:33 UTC 2018


 src/hb-coretext.cc       |   45 ---------------------
 src/hb-directwrite.cc    |   21 ---------
 src/hb-fallback-shape.cc |   22 ----------
 src/hb-graphite2.cc      |   22 ----------
 src/hb-machinery.hh      |    5 --
 src/hb-ot-shape.cc       |   99 +++++++++++++++++++++--------------------------
 src/hb-ot-shape.hh       |   21 ++++-----
 src/hb-shape-plan.cc     |   23 ++++++----
 src/hb-shape-plan.hh     |    3 -
 src/hb-uniscribe.cc      |   22 ----------
 10 files changed, 71 insertions(+), 212 deletions(-)

New commits:
commit f521a28b4aad1566664cf14d70a911728ee0b962
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Nov 11 21:32:01 2018 -0500

    Embed hb_ot_shape_plan_t into hb_shape_plan_t
    
    No other shaper will need shape_plan_data, by definition.  So, remove
    abstraction layer and always create hb_ot_shape_plan_t as part of
    hb_shape_plan_t.

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 7509b8a3..3cedb5b2 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -372,29 +372,6 @@ hb_coretext_font_get_ct_font (hb_font_t *font)
 }
 
 
-
-/*
- * shaper shape_plan data
- */
-
-struct hb_coretext_shape_plan_data_t {};
-
-hb_coretext_shape_plan_data_t *
-_hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
-					     const hb_feature_t *user_features HB_UNUSED,
-					     unsigned int        num_user_features HB_UNUSED,
-					     const int          *coords HB_UNUSED,
-					     unsigned int        num_coords HB_UNUSED)
-{
-  return (hb_coretext_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
 /*
  * shaper
  */
@@ -1205,28 +1182,6 @@ _hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_font_data_t *data HB_
 
 
 /*
- * shaper shape_plan data
- */
-
-struct hb_coretext_aat_shape_plan_data_t {};
-
-hb_coretext_aat_shape_plan_data_t *
-_hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
-					     const hb_feature_t *user_features HB_UNUSED,
-					     unsigned int        num_user_features HB_UNUSED,
-					     const int          *coords HB_UNUSED,
-					     unsigned int        num_coords HB_UNUSED)
-{
-  return (hb_coretext_aat_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
  * shaper
  */
 
diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc
index cc8f6cc0..b34ae601 100644
--- a/src/hb-directwrite.cc
+++ b/src/hb-directwrite.cc
@@ -256,27 +256,6 @@ _hb_directwrite_shaper_font_data_destroy (hb_directwrite_font_data_t *data)
 }
 
 
-/*
- * shaper shape_plan data
- */
-
-struct hb_directwrite_shape_plan_data_t {};
-
-hb_directwrite_shape_plan_data_t *
-_hb_directwrite_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
-					       const hb_feature_t *user_features HB_UNUSED,
-					       unsigned int        num_user_features HB_UNUSED,
-					       const int          *coords HB_UNUSED,
-					       unsigned int        num_coords HB_UNUSED)
-{
-  return (hb_directwrite_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_directwrite_shaper_shape_plan_data_destroy (hb_directwrite_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
 // Most of TextAnalysis is originally written by Bas Schouten for Mozilla project
 // but now is relicensed to MIT for HarfBuzz use
 class TextAnalysis
diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc
index ccfeba4b..40f8dad2 100644
--- a/src/hb-fallback-shape.cc
+++ b/src/hb-fallback-shape.cc
@@ -69,28 +69,6 @@ _hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED)
 
 
 /*
- * shaper shape_plan data
- */
-
-struct hb_fallback_shape_plan_data_t {};
-
-hb_fallback_shape_plan_data_t *
-_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
-					    const hb_feature_t *user_features HB_UNUSED,
-					    unsigned int        num_user_features HB_UNUSED,
-					    const int          *coords HB_UNUSED,
-					    unsigned int        num_coords HB_UNUSED)
-{
-  return (hb_fallback_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
  * shaper
  */
 
diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index 38c2cd81..8dce8170 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -221,28 +221,6 @@ hb_graphite2_font_get_gr_font (hb_font_t *font HB_UNUSED)
 
 
 /*
- * shaper shape_plan data
- */
-
-struct hb_graphite2_shape_plan_data_t {};
-
-hb_graphite2_shape_plan_data_t *
-_hb_graphite2_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
-					     const hb_feature_t *user_features HB_UNUSED,
-					     unsigned int        num_user_features HB_UNUSED,
-					     const int          *coords HB_UNUSED,
-					     unsigned int        num_coords HB_UNUSED)
-{
-  return (hb_graphite2_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
  * shaper
  */
 
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 92a4b53a..44cf3907 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -27,7 +27,6 @@
  */
 
 #define HB_SHAPER ot
-#define hb_ot_shape_plan_data_t hb_ot_shape_plan_t
 #include "hb-shaper-impl.hh"
 
 #include "hb-ot-shape.hh"
@@ -52,6 +51,12 @@
  **/
 
 
+static void
+hb_ot_shape_collect_features (hb_ot_shape_planner_t          *planner,
+			      const hb_segment_properties_t  *props,
+			      const hb_feature_t             *user_features,
+			      unsigned int                    num_user_features);
+
 static bool
 _hb_apply_morx (hb_face_t *face)
 {
@@ -89,7 +94,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m'));
   plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask);
   plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
-  hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
+  hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (props.direction) ?
 		      HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
   plan.kern_mask = plan.map.get_mask (kern_tag);
   plan.trak_mask = plan.map.get_mask (HB_TAG ('t','r','a','k'));
@@ -142,6 +147,43 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
 }
 
+bool
+hb_ot_shape_plan_t::init0 (hb_shape_plan_t    *shape_plan,
+			   const hb_feature_t *user_features,
+			   unsigned int        num_user_features,
+			   const int          *coords,
+			   unsigned int        num_coords)
+{
+  map.init ();
+  aat_map.init ();
+
+  hb_ot_shape_planner_t planner (shape_plan);
+
+  hb_ot_shape_collect_features (&planner, &shape_plan->props,
+				user_features, num_user_features);
+
+  planner.compile (*this, coords, num_coords);
+
+  if (shaper->data_create)
+  {
+    data = shaper->data_create (this);
+    if (unlikely (!data))
+      return false;
+  }
+
+  return true;
+}
+
+void
+hb_ot_shape_plan_t::fini (void)
+{
+  if (shaper->data_destroy)
+    shaper->data_destroy (const_cast<void *> (data));
+
+  map.fini ();
+  aat_map.fini ();
+}
+
 
 static const hb_ot_map_feature_t
 common_features[] =
@@ -292,54 +334,6 @@ _hb_ot_shaper_font_data_destroy (hb_ot_font_data_t *data HB_UNUSED)
 
 
 /*
- * shaper shape_plan data
- */
-
-hb_ot_shape_plan_data_t *
-_hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan,
-				      const hb_feature_t *user_features,
-				      unsigned int        num_user_features,
-				      const int          *coords,
-				      unsigned int        num_coords)
-{
-  hb_ot_shape_plan_t *plan = (hb_ot_shape_plan_t *) calloc (1, sizeof (hb_ot_shape_plan_t));
-  if (unlikely (!plan))
-    return nullptr;
-
-  plan->init ();
-
-  hb_ot_shape_planner_t planner (shape_plan);
-
-  hb_ot_shape_collect_features (&planner, &shape_plan->props,
-				user_features, num_user_features);
-
-  planner.compile (*plan, coords, num_coords);
-
-  if (plan->shaper->data_create) {
-    plan->data = plan->shaper->data_create (plan);
-    if (unlikely (!plan->data))
-    {
-      free (plan);
-      return nullptr;
-    }
-  }
-
-  return plan;
-}
-
-void
-_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shape_plan_data_t *plan)
-{
-  if (plan->shaper->data_destroy)
-    plan->shaper->data_destroy (const_cast<void *> (plan->data));
-
-  plan->fini ();
-
-  free (plan);
-}
-
-
-/*
  * shaper
  */
 
@@ -978,7 +972,7 @@ _hb_ot_shape (hb_shape_plan_t    *shape_plan,
 	      const hb_feature_t *features,
 	      unsigned int        num_features)
 {
-  hb_ot_shape_context_t c = {HB_SHAPER_DATA_GET (shape_plan), font, font->face, buffer, features, num_features};
+  hb_ot_shape_context_t c = {&shape_plan->ot, font, font->face, buffer, features, num_features};
   hb_ot_shape_internal (&c);
 
   return true;
@@ -995,8 +989,7 @@ hb_ot_shape_plan_collect_lookups (hb_shape_plan_t *shape_plan,
 				  hb_tag_t         table_tag,
 				  hb_set_t        *lookup_indexes /* OUT */)
 {
-  /* XXX Does the first part always succeed? */
-  HB_SHAPER_DATA_GET (shape_plan)->collect_lookups (table_tag, lookup_indexes);
+  shape_plan->ot.collect_lookups (table_tag, lookup_indexes);
 }
 
 
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index 655e28d6..049830a6 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -31,8 +31,6 @@
 
 #include "hb-ot-map.hh"
 #include "hb-aat-map.hh"
-#include "hb-shape-plan.hh"
-
 
 
 struct hb_ot_shape_plan_t
@@ -75,18 +73,17 @@ 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 init (void)
-  {
-    memset (this, 0, sizeof (*this));
-    map.init ();
-    aat_map.init ();
-  }
-  void fini (void) {
-    map.fini ();
-    aat_map.fini ();
-  }
+  HB_INTERNAL bool init0 (hb_shape_plan_t    *shape_plan,
+			  const hb_feature_t *user_features,
+			  unsigned int        num_user_features,
+			  const int          *coords,
+			  unsigned int        num_coords);
+
+  HB_INTERNAL void fini (void);
 };
 
+struct hb_shape_plan_t;
+
 struct hb_ot_shape_planner_t
 {
   /* In the order that they are filled in. */
diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index ebf0e9f5..5579ded7 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -64,10 +64,6 @@ hb_shape_plan_plan (hb_shape_plan_t    *shape_plan,
 	HB_STMT_START { \
 	  if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) \
 	  { \
-	    HB_SHAPER_DATA (shaper, shape_plan).set_relaxed ( \
-	      HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, \
-							       user_features, num_user_features, \
-							       coords, num_coords)); \
 	    shape_plan->shaper_func = _hb_##shaper##_shape; \
 	    shape_plan->shaper_name = #shaper; \
 	    return; \
@@ -188,6 +184,17 @@ hb_shape_plan_create2 (hb_face_t                     *face,
 		      coords, num_coords,
 		      shaper_list);
 
+  if (unlikely (!shape_plan->ot.init0 (shape_plan,
+				       user_features,
+				       num_user_features,
+				       coords,
+				       num_coords)))
+  {
+    free (coords);
+    free (features);
+    return hb_shape_plan_get_empty ();
+  }
+
   return shape_plan;
 }
 
@@ -235,9 +242,7 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan)
 {
   if (!hb_object_destroy (shape_plan)) return;
 
-#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, shape_plan);
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
+  shape_plan->ot.fini ();
 
   free (shape_plan->user_features);
   free (shape_plan->coords);
@@ -329,8 +334,7 @@ hb_shape_plan_execute (hb_shape_plan_t    *shape_plan,
 
 #define HB_SHAPER_EXECUTE(shaper) \
 	HB_STMT_START { \
-	  return HB_SHAPER_DATA (shaper, shape_plan).get () && \
-		 hb_##shaper##_shaper_font_data_ensure (font) && \
+	  return hb_##shaper##_shaper_font_data_ensure (font) && \
 		 _hb_##shaper##_shape (shape_plan, font, buffer, features, num_features); \
 	} HB_STMT_END
 
diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh
index 891b9957..eaa84fd4 100644
--- a/src/hb-shape-plan.hh
+++ b/src/hb-shape-plan.hh
@@ -29,6 +29,7 @@
 
 #include "hb.hh"
 #include "hb-shaper.hh"
+#include "hb-ot-shape.hh"
 
 
 struct hb_shape_plan_t
@@ -48,7 +49,7 @@ struct hb_shape_plan_t
   int *coords;
   unsigned int num_coords;
 
-  struct hb_shaper_data_t shaper_data;
+  hb_ot_shape_plan_t ot;
 };
 
 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 76da20df..dc82d6b7 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -601,28 +601,6 @@ hb_uniscribe_font_get_hfont (hb_font_t *font)
 
 
 /*
- * shaper shape_plan data
- */
-
-struct hb_uniscribe_shape_plan_data_t {};
-
-hb_uniscribe_shape_plan_data_t *
-_hb_uniscribe_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
-					     const hb_feature_t *user_features HB_UNUSED,
-					     unsigned int        num_user_features HB_UNUSED,
-					     const int          *coords HB_UNUSED,
-					     unsigned int        num_coords HB_UNUSED)
-{
-  return (hb_uniscribe_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
  * shaper
  */
 
commit fabb01210433ce1c6d5f630bc270f82a8a4a4014
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Nov 11 17:10:23 2018 -0500

    Remove wrong comment

diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index 8fcc038f..ebf0e9f5 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -64,7 +64,6 @@ hb_shape_plan_plan (hb_shape_plan_t    *shape_plan,
 	HB_STMT_START { \
 	  if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) \
 	  { \
-	    /* XXX-MT-bug What happened to *ensure*ing this?!!!! */ \
 	    HB_SHAPER_DATA (shaper, shape_plan).set_relaxed ( \
 	      HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, \
 							       user_features, num_user_features, \
commit 1fd183ee1c40e2eedf86b5e82d1b547c5650ebf5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Nov 11 16:47:52 2018 -0500

    Finish off eecccc919ce15f60ae7ef9da5cfb311b4aa05c63

diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 160e99a5..9e4c16d8 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -780,12 +780,9 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
     do_destroy (p);
   }
 
-  inline Stored * do_create (void) const
-  {
-  }
   static inline void do_destroy (Stored *p)
   {
-    if (p && p != Funcs::get_null ())
+    if (p)
       Funcs::destroy (p);
   }
 


More information about the HarfBuzz mailing list