src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc
changeset 48274 51772bf1fb0c
parent 47216 71c04702a3d5
child 54232 7c11a7cc7c1d
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc	Tue Dec 05 11:04:42 2017 -0800
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc	Thu Dec 07 11:55:06 2017 -0800
@@ -24,24 +24,14 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb-private.hh"
+#include "hb-debug.hh"
 #include "hb-shape-plan-private.hh"
 #include "hb-shaper-private.hh"
 #include "hb-font-private.hh"
 #include "hb-buffer-private.hh"
 
 
-#ifndef HB_DEBUG_SHAPE_PLAN
-#define HB_DEBUG_SHAPE_PLAN (HB_DEBUG+0)
-#endif
-
-
-#define HB_SHAPER_IMPLEMENT(shaper) \
-        HB_SHAPER_DATA_ENSURE_DECLARE(shaper, face) \
-        HB_SHAPER_DATA_ENSURE_DECLARE(shaper, font)
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
-
-
 static void
 hb_shape_plan_plan (hb_shape_plan_t    *shape_plan,
                     const hb_feature_t *user_features,
@@ -101,13 +91,13 @@
 
 /**
  * hb_shape_plan_create: (Xconstructor)
- * @face: 
- * @props: 
+ * @face:
+ * @props:
  * @user_features: (array length=num_user_features):
- * @num_user_features: 
+ * @num_user_features:
  * @shaper_list: (array zero-terminated=1):
  *
- * 
+ *
  *
  * Return value: (transfer full):
  *
@@ -122,7 +112,7 @@
 {
   return hb_shape_plan_create2 (face, props,
                                 user_features, num_user_features,
-                                NULL, 0,
+                                nullptr, 0,
                                 shaper_list);
 }
 
@@ -135,7 +125,7 @@
                        unsigned int                   num_coords,
                        const char * const            *shaper_list)
 {
-  DEBUG_MSG_FUNC (SHAPE_PLAN, NULL,
+  DEBUG_MSG_FUNC (SHAPE_PLAN, nullptr,
                   "face=%p num_features=%d num_coords=%d shaper_list=%p",
                   face,
                   num_user_features,
@@ -143,8 +133,8 @@
                   shaper_list);
 
   hb_shape_plan_t *shape_plan;
-  hb_feature_t *features = NULL;
-  int *coords = NULL;
+  hb_feature_t *features = nullptr;
+  int *coords = nullptr;
 
   if (unlikely (!face))
     face = hb_face_get_empty ();
@@ -167,7 +157,7 @@
   assert (props->direction != HB_DIRECTION_INVALID);
 
   hb_face_make_immutable (face);
-  shape_plan->default_shaper_list = shaper_list == NULL;
+  shape_plan->default_shaper_list = !shaper_list;
   shape_plan->face_unsafe = face;
   shape_plan->props = *props;
   shape_plan->num_user_features = num_user_features;
@@ -190,7 +180,7 @@
 /**
  * hb_shape_plan_get_empty:
  *
- * 
+ *
  *
  * Return value: (transfer full):
  *
@@ -203,16 +193,16 @@
     HB_OBJECT_HEADER_STATIC,
 
     true, /* default_shaper_list */
-    NULL, /* face */
+    nullptr, /* face */
     HB_SEGMENT_PROPERTIES_DEFAULT, /* props */
 
-    NULL, /* shaper_func */
-    NULL, /* shaper_name */
+    nullptr, /* shaper_func */
+    nullptr, /* shaper_name */
 
-    NULL, /* user_features */
+    nullptr, /* user_features */
     0,    /* num_user_featurs */
 
-    NULL, /* coords */
+    nullptr, /* coords */
     0,    /* num_coords */
 
     {
@@ -229,7 +219,7 @@
  * hb_shape_plan_reference: (skip)
  * @shape_plan: a shape plan.
  *
- * 
+ *
  *
  * Return value: (transfer full):
  *
@@ -245,7 +235,7 @@
  * hb_shape_plan_destroy: (skip)
  * @shape_plan: a shape plan.
  *
- * 
+ *
  *
  * Since: 0.9.7
  **/
@@ -267,14 +257,14 @@
 /**
  * hb_shape_plan_set_user_data: (skip)
  * @shape_plan: a shape plan.
- * @key: 
- * @data: 
- * @destroy: 
- * @replace: 
+ * @key:
+ * @data:
+ * @destroy:
+ * @replace:
  *
- * 
+ *
  *
- * Return value: 
+ * Return value:
  *
  * Since: 0.9.7
  **/
@@ -291,9 +281,9 @@
 /**
  * hb_shape_plan_get_user_data: (skip)
  * @shape_plan: a shape plan.
- * @key: 
+ * @key:
  *
- * 
+ *
  *
  * Return value: (transfer none):
  *
@@ -313,11 +303,11 @@
  * @font: a font.
  * @buffer: a buffer.
  * @features: (array length=num_features):
- * @num_features: 
+ * @num_features:
+ *
  *
- * 
  *
- * Return value: 
+ * Return value:
  *
  * Since: 0.9.7
  **/
@@ -430,7 +420,7 @@
   return hb_segment_properties_equal (&shape_plan->props, &proposal->props) &&
          hb_shape_plan_user_features_match (shape_plan, proposal) &&
          hb_shape_plan_coords_match (shape_plan, proposal) &&
-         ((shape_plan->default_shaper_list && proposal->shaper_list == NULL) ||
+         ((shape_plan->default_shaper_list && !proposal->shaper_list) ||
           (shape_plan->shaper_func == proposal->shaper_func));
 }
 
@@ -438,11 +428,12 @@
 hb_non_global_user_features_present (const hb_feature_t *user_features,
                                      unsigned int        num_user_features)
 {
-  while (num_user_features)
+  while (num_user_features) {
     if (user_features->start != 0 || user_features->end != (unsigned int) -1)
       return true;
-    else
-      num_user_features--, user_features++;
+    num_user_features--;
+    user_features++;
+  }
   return false;
 }
 
@@ -455,13 +446,13 @@
 
 /**
  * hb_shape_plan_create_cached:
- * @face: 
- * @props: 
+ * @face:
+ * @props:
  * @user_features: (array length=num_user_features):
- * @num_user_features: 
+ * @num_user_features:
  * @shaper_list: (array zero-terminated=1):
  *
- * 
+ *
  *
  * Return value: (transfer full):
  *
@@ -476,7 +467,7 @@
 {
   return hb_shape_plan_create_cached2 (face, props,
                                        user_features, num_user_features,
-                                       NULL, 0,
+                                       nullptr, 0,
                                        shaper_list);
 }
 
@@ -489,7 +480,7 @@
                               unsigned int                   num_coords,
                               const char * const            *shaper_list)
 {
-  DEBUG_MSG_FUNC (SHAPE_PLAN, NULL,
+  DEBUG_MSG_FUNC (SHAPE_PLAN, nullptr,
                   "face=%p num_features=%d shaper_list=%p",
                   face,
                   num_user_features,
@@ -500,7 +491,7 @@
     shaper_list,
     user_features,
     num_user_features,
-    NULL
+    nullptr
   };
 
   if (shaper_list) {
@@ -526,15 +517,17 @@
 
 retry:
   hb_face_t::plan_node_t *cached_plan_nodes = (hb_face_t::plan_node_t *) hb_atomic_ptr_get (&face->shape_plans);
-  for (hb_face_t::plan_node_t *node = cached_plan_nodes; node; node = node->next)
-    if (hb_shape_plan_matches (node->shape_plan, &proposal))
-    {
-      DEBUG_MSG_FUNC (SHAPE_PLAN, node->shape_plan, "fulfilled from cache");
-      return hb_shape_plan_reference (node->shape_plan);
-    }
+
+  /* Don't look for plan in the cache if there were variation coordinates XXX Fix me. */
+  if (!hb_coords_present (coords, num_coords))
+    for (hb_face_t::plan_node_t *node = cached_plan_nodes; node; node = node->next)
+      if (hb_shape_plan_matches (node->shape_plan, &proposal))
+      {
+        DEBUG_MSG_FUNC (SHAPE_PLAN, node->shape_plan, "fulfilled from cache");
+        return hb_shape_plan_reference (node->shape_plan);
+      }
 
   /* Not found. */
-
   hb_shape_plan_t *shape_plan = hb_shape_plan_create2 (face, props,
                                                        user_features, num_user_features,
                                                        coords, num_coords,
@@ -572,7 +565,7 @@
  * hb_shape_plan_get_shaper:
  * @shape_plan: a shape plan.
  *
- * 
+ *
  *
  * Return value: (transfer none):
  *