Index: third_party/harfbuzz-ng/src/hb-shape-plan.cc |
diff --git a/third_party/harfbuzz-ng/src/hb-shape-plan.cc b/third_party/harfbuzz-ng/src/hb-shape-plan.cc |
index 5ffc6b1362e4794b602241d0cb036273ea8203ef..2166173f9e5e3acf0675e22ba398081c9dcd7dda 100644 |
--- a/third_party/harfbuzz-ng/src/hb-shape-plan.cc |
+++ b/third_party/harfbuzz-ng/src/hb-shape-plan.cc |
@@ -29,6 +29,12 @@ |
#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) |
@@ -42,6 +48,11 @@ hb_shape_plan_plan (hb_shape_plan_t *shape_plan, |
unsigned int num_user_features, |
const char * const *shaper_list) |
{ |
+ DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, |
+ "num_features=%d shaper_list=%p", |
+ num_user_features, |
+ shaper_list); |
+ |
const hb_shaper_pair_t *shapers = _hb_shapers_get (); |
#define HB_SHAPER_PLAN(shaper) \ |
@@ -104,6 +115,12 @@ hb_shape_plan_create (hb_face_t *face, |
unsigned int num_user_features, |
const char * const *shaper_list) |
{ |
+ DEBUG_MSG_FUNC (SHAPE_PLAN, NULL, |
+ "face=%p num_features=%d shaper_list=%p", |
+ face, |
+ num_user_features, |
+ shaper_list); |
+ |
hb_shape_plan_t *shape_plan; |
hb_feature_t *features = NULL; |
@@ -271,6 +288,11 @@ hb_shape_plan_execute (hb_shape_plan_t *shape_plan, |
const hb_feature_t *features, |
unsigned int num_features) |
{ |
+ DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, |
+ "num_features=%d shaper_func=%p", |
+ num_features, |
+ shape_plan->shaper_func); |
+ |
if (unlikely (hb_object_is_inert (shape_plan) || |
hb_object_is_inert (font) || |
hb_object_is_inert (buffer))) |
@@ -383,6 +405,12 @@ hb_shape_plan_create_cached (hb_face_t *face, |
unsigned int num_user_features, |
const char * const *shaper_list) |
{ |
+ DEBUG_MSG_FUNC (SHAPE_PLAN, NULL, |
+ "face=%p num_features=%d shaper_list=%p", |
+ face, |
+ num_user_features, |
+ shaper_list); |
+ |
hb_shape_plan_proposal_t proposal = { |
*props, |
shaper_list, |
@@ -392,25 +420,22 @@ hb_shape_plan_create_cached (hb_face_t *face, |
}; |
if (shaper_list) { |
- /* Choose shaper. Adapted from hb_shape_plan_plan(). */ |
-#define HB_SHAPER_PLAN(shaper) \ |
- HB_STMT_START { \ |
- if (hb_##shaper##_shaper_face_data_ensure (face)) \ |
- proposal.shaper_func = _hb_##shaper##_shape; \ |
- } HB_STMT_END |
- |
+ /* Choose shaper. Adapted from hb_shape_plan_plan(). |
+ * Must choose shaper exactly the same way as that function. */ |
for (const char * const *shaper_item = shaper_list; *shaper_item; shaper_item++) |
if (0) |
; |
#define HB_SHAPER_IMPLEMENT(shaper) \ |
- else if (0 == strcmp (*shaper_item, #shaper)) \ |
- HB_SHAPER_PLAN (shaper); |
+ else if (0 == strcmp (*shaper_item, #shaper) && \ |
+ hb_##shaper##_shaper_face_data_ensure (face)) \ |
+ { \ |
+ proposal.shaper_func = _hb_##shaper##_shape; \ |
+ break; \ |
+ } |
#include "hb-shaper-list.hh" |
#undef HB_SHAPER_IMPLEMENT |
-#undef HB_SHAPER_PLAN |
- |
- if (unlikely (!proposal.shaper_list)) |
+ if (unlikely (!proposal.shaper_func)) |
return hb_shape_plan_get_empty (); |
} |
@@ -419,7 +444,10 @@ 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); |
+ } |
/* Not found. */ |
@@ -442,6 +470,7 @@ retry: |
free (node); |
goto retry; |
} |
+ DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, "inserted into cache"); |
return hb_shape_plan_reference (shape_plan); |
} |