[OTLayout] Add hb_ot_layout_lookup_accelerator_t
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 4866c41..bd01078 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -244,6 +244,23 @@
struct GPOS;
}
+struct hb_ot_layout_lookup_accelerator_t
+{
+ template <typename TLookup>
+ inline void init (const TLookup &lookup)
+ {
+ digest.init ();
+ lookup.add_coverage (&digest);
+ }
+
+ template <typename TLookup>
+ inline void fini (const TLookup &lookup)
+ {
+ }
+
+ hb_set_digest_t digest;
+};
+
struct hb_ot_layout_t
{
hb_blob_t *gdef_blob;
@@ -257,8 +274,8 @@
unsigned int gsub_lookup_count;
unsigned int gpos_lookup_count;
- hb_set_digest_t *gsub_digests;
- hb_set_digest_t *gpos_digests;
+ hb_ot_layout_lookup_accelerator_t *gsub_accels;
+ hb_ot_layout_lookup_accelerator_t *gpos_accels;
};
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index c80ca7d..76a6256 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -59,26 +59,20 @@
layout->gsub_lookup_count = layout->gsub->get_lookup_count ();
layout->gpos_lookup_count = layout->gpos->get_lookup_count ();
- layout->gsub_digests = (hb_set_digest_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_set_digest_t));
- layout->gpos_digests = (hb_set_digest_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_set_digest_t));
+ layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t));
+ layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t));
- if (unlikely ((layout->gsub_lookup_count && !layout->gsub_digests) ||
- (layout->gpos_lookup_count && !layout->gpos_digests)))
+ if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) ||
+ (layout->gpos_lookup_count && !layout->gpos_accels)))
{
_hb_ot_layout_destroy (layout);
return NULL;
}
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
- {
- layout->gsub_digests[i].init ();
- layout->gsub->get_lookup (i).add_coverage (&layout->gsub_digests[i]);
- }
+ layout->gsub_accels[i].init (layout->gsub->get_lookup (i));
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
- {
- layout->gpos_digests[i].init ();
- layout->gpos->get_lookup (i).add_coverage (&layout->gpos_digests[i]);
- }
+ layout->gpos_accels[i].init (layout->gpos->get_lookup (i));
return layout;
}
@@ -90,8 +84,13 @@
hb_blob_destroy (layout->gsub_blob);
hb_blob_destroy (layout->gpos_blob);
- free (layout->gsub_digests);
- free (layout->gpos_digests);
+ for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
+ layout->gsub_accels[i].fini (layout->gsub->get_lookup (i));
+ for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
+ layout->gpos_accels[i].fini (layout->gpos->get_lookup (i));
+
+ free (layout->gsub_accels);
+ free (layout->gpos_accels);
free (layout);
}
@@ -659,7 +658,7 @@
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index);
- return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
+ return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index].digest);
}
void
@@ -681,7 +680,7 @@
const OT::SubstLookup& l = hb_ot_layout_from_face (font->face)->gsub->get_lookup (lookup_index);
- return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gsub_digests[lookup_index]);
+ return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gsub_accels[lookup_index].digest);
}
void
@@ -731,7 +730,7 @@
const OT::PosLookup& l = hb_ot_layout_from_face (font->face)->gpos->get_lookup (lookup_index);
- return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]);
+ return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gpos_accels[lookup_index].digest);
}
void
diff --git a/src/hb-ot-shape-complex-arabic-fallback.hh b/src/hb-ot-shape-complex-arabic-fallback.hh
index 996e40e..91d6e44 100644
--- a/src/hb-ot-shape-complex-arabic-fallback.hh
+++ b/src/hb-ot-shape-complex-arabic-fallback.hh
@@ -199,7 +199,7 @@
hb_mask_t mask_array[ARABIC_NUM_FALLBACK_FEATURES];
OT::SubstLookup *lookup_array[ARABIC_NUM_FALLBACK_FEATURES];
- hb_set_digest_t digest_array[ARABIC_NUM_FALLBACK_FEATURES];
+ hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_NUM_FALLBACK_FEATURES];
};
static const arabic_fallback_plan_t arabic_fallback_plan_nil = {};
@@ -214,12 +214,11 @@
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
{
- fallback_plan->digest_array[i].init ();
fallback_plan->mask_array[i] = plan->map.get_1_mask (arabic_fallback_features[i]);
if (fallback_plan->mask_array[i]) {
fallback_plan->lookup_array[i] = arabic_fallback_synthesize_lookup (plan, font, i);
if (fallback_plan->lookup_array[i])
- fallback_plan->lookup_array[i]->add_coverage (&fallback_plan->digest_array[i]);
+ fallback_plan->accel_array[i].init (*fallback_plan->lookup_array[i]);
}
}
@@ -234,7 +233,10 @@
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
if (fallback_plan->lookup_array[i])
+ {
+ fallback_plan->accel_array[i].fini (fallback_plan->lookup_array[i]);
free (fallback_plan->lookup_array[i]);
+ }
free (fallback_plan);
}
@@ -247,7 +249,7 @@
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
if (fallback_plan->lookup_array[i]) {
OT::hb_apply_context_t c (0, font, buffer, fallback_plan->mask_array[i], true/*auto_zwj*/);
- fallback_plan->lookup_array[i]->apply_string (&c, &fallback_plan->digest_array[i]);
+ fallback_plan->lookup_array[i]->apply_string (&c, &fallback_plan->accel_array[i].digest);
}
}