[OT] Minor refactoring
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 2 Aug 2012 13:24:35 +0000 (09:24 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 2 Aug 2012 13:24:35 +0000 (09:24 -0400)
src/hb-ot-map.cc
src/hb-ot-shape-private.hh
src/hb-ot-shape.cc
src/hb-shape-plan.cc
src/hb-shape.cc

index 03c9ba1..7192c2b 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "hb-ot-map-private.hh"
 
-#include "hb-ot-shape-private.hh"
-
 
 void
 hb_ot_map_t::add_lookups (hb_face_t    *face,
@@ -303,5 +301,3 @@ hb_ot_map_builder_t::compile (hb_face_t *face,
     }
   }
 }
-
-
index fd45e2d..89f15be 100644 (file)
 
 struct hb_ot_shape_plan_t
 {
+  const hb_ot_complex_shaper_t *shaper;
   hb_ot_map_t map;
+};
+
+struct hb_ot_shape_planner_t
+{
+  /* In the order that they are filled in. */
+  hb_face_t *face;
+  hb_segment_properties_t props;
   const hb_ot_complex_shaper_t *shaper;
+  hb_ot_map_builder_t map;
+
+  hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) :
+                        face (master_plan->face),
+                        props (master_plan->props),
+                        shaper (NULL),
+                        map () {}
+  ~hb_ot_shape_planner_t (void) { map.finish (); }
+
+  inline void compile (hb_ot_shape_plan_t &plan)
+  {
+    plan.shaper = shaper;
+    map.compile (face, &props, plan.map);
+  }
+
+  private:
+  NO_COPY (hb_ot_shape_planner_t);
 };
 
 
+
 inline void
 _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
 {
index 66664c5..f6d7a83 100644 (file)
@@ -70,26 +70,6 @@ hb_tag_t vertical_features[] = {
 
 
 
-struct hb_ot_shape_planner_t
-{
-  hb_ot_map_builder_t map;
-  const hb_ot_complex_shaper_t *shaper;
-
-  hb_ot_shape_planner_t (void) : map () {}
-  ~hb_ot_shape_planner_t (void) { map.finish (); }
-
-  inline void compile (hb_face_t *face,
-                      const hb_segment_properties_t *props,
-                      hb_ot_shape_plan_t &plan)
-  {
-    plan.shaper = shaper;
-    map.compile (face, props, plan.map);
-  }
-
-  private:
-  NO_COPY (hb_ot_shape_planner_t);
-};
-
 static void
 hb_ot_shape_collect_features (hb_ot_shape_planner_t          *planner,
                              const hb_segment_properties_t  *props,
@@ -188,15 +168,13 @@ _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan,
   if (unlikely (!data))
     return NULL;
 
-  hb_ot_shape_planner_t planner;
-
-  assert (HB_DIRECTION_IS_VALID (shape_plan->props.direction));
+  hb_ot_shape_planner_t planner (shape_plan);
 
   planner.shaper = hb_ot_shape_complex_categorize (&shape_plan->props);
 
   hb_ot_shape_collect_features (&planner, &shape_plan->props, user_features, num_user_features);
 
-  planner.compile (shape_plan->face, &shape_plan->props, *data);
+  planner.compile (*data);
 
   return data;
 }
index a478ba5..974c370 100644 (file)
@@ -90,6 +90,8 @@ hb_shape_plan_create (hb_face_t                     *face,
                      unsigned int                   num_user_features,
                      const char * const            *shaper_list)
 {
+  assert (props->direction != HB_DIRECTION_INVALID);
+
   hb_shape_plan_t *shape_plan;
 
   if (unlikely (!face))
index b3d373b..5aa587b 100644 (file)
@@ -87,8 +87,6 @@ hb_shape_full (hb_font_t          *font,
 
   buffer->guess_properties ();
 
-  assert (buffer->props.direction != HB_DIRECTION_INVALID);
-
   hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, shaper_list);
   hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features);
   hb_shape_plan_destroy (shape_plan);