[OTLayout] Add hb_ot_layout_lookup_accelerator_t
This commit is contained in:
parent
76ea563673
commit
45fd9424c7
|
@ -244,6 +244,23 @@ namespace OT {
|
||||||
struct GPOS;
|
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
|
struct hb_ot_layout_t
|
||||||
{
|
{
|
||||||
hb_blob_t *gdef_blob;
|
hb_blob_t *gdef_blob;
|
||||||
|
@ -257,8 +274,8 @@ struct hb_ot_layout_t
|
||||||
unsigned int gsub_lookup_count;
|
unsigned int gsub_lookup_count;
|
||||||
unsigned int gpos_lookup_count;
|
unsigned int gpos_lookup_count;
|
||||||
|
|
||||||
hb_set_digest_t *gsub_digests;
|
hb_ot_layout_lookup_accelerator_t *gsub_accels;
|
||||||
hb_set_digest_t *gpos_digests;
|
hb_ot_layout_lookup_accelerator_t *gpos_accels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,26 +59,20 @@ _hb_ot_layout_create (hb_face_t *face)
|
||||||
layout->gsub_lookup_count = layout->gsub->get_lookup_count ();
|
layout->gsub_lookup_count = layout->gsub->get_lookup_count ();
|
||||||
layout->gpos_lookup_count = layout->gpos->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->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t));
|
||||||
layout->gpos_digests = (hb_set_digest_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_set_digest_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) ||
|
if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) ||
|
||||||
(layout->gpos_lookup_count && !layout->gpos_digests)))
|
(layout->gpos_lookup_count && !layout->gpos_accels)))
|
||||||
{
|
{
|
||||||
_hb_ot_layout_destroy (layout);
|
_hb_ot_layout_destroy (layout);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
|
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
|
||||||
{
|
layout->gsub_accels[i].init (layout->gsub->get_lookup (i));
|
||||||
layout->gsub_digests[i].init ();
|
|
||||||
layout->gsub->get_lookup (i).add_coverage (&layout->gsub_digests[i]);
|
|
||||||
}
|
|
||||||
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
|
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
|
||||||
{
|
layout->gpos_accels[i].init (layout->gpos->get_lookup (i));
|
||||||
layout->gpos_digests[i].init ();
|
|
||||||
layout->gpos->get_lookup (i).add_coverage (&layout->gpos_digests[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +84,13 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout)
|
||||||
hb_blob_destroy (layout->gsub_blob);
|
hb_blob_destroy (layout->gsub_blob);
|
||||||
hb_blob_destroy (layout->gpos_blob);
|
hb_blob_destroy (layout->gpos_blob);
|
||||||
|
|
||||||
free (layout->gsub_digests);
|
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
|
||||||
free (layout->gpos_digests);
|
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);
|
free (layout);
|
||||||
}
|
}
|
||||||
|
@ -659,7 +658,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
|
||||||
|
|
||||||
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index);
|
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
|
void
|
||||||
|
@ -681,7 +680,7 @@ hb_ot_layout_substitute_lookup (hb_font_t *font,
|
||||||
|
|
||||||
const OT::SubstLookup& l = hb_ot_layout_from_face (font->face)->gsub->get_lookup (lookup_index);
|
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
|
void
|
||||||
|
@ -731,7 +730,7 @@ hb_ot_layout_position_lookup (hb_font_t *font,
|
||||||
|
|
||||||
const OT::PosLookup& l = hb_ot_layout_from_face (font->face)->gpos->get_lookup (lookup_index);
|
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
|
void
|
||||||
|
|
|
@ -199,7 +199,7 @@ struct arabic_fallback_plan_t
|
||||||
|
|
||||||
hb_mask_t mask_array[ARABIC_NUM_FALLBACK_FEATURES];
|
hb_mask_t mask_array[ARABIC_NUM_FALLBACK_FEATURES];
|
||||||
OT::SubstLookup *lookup_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 = {};
|
static const arabic_fallback_plan_t arabic_fallback_plan_nil = {};
|
||||||
|
@ -214,12 +214,11 @@ arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan,
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
|
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]);
|
fallback_plan->mask_array[i] = plan->map.get_1_mask (arabic_fallback_features[i]);
|
||||||
if (fallback_plan->mask_array[i]) {
|
if (fallback_plan->mask_array[i]) {
|
||||||
fallback_plan->lookup_array[i] = arabic_fallback_synthesize_lookup (plan, font, i);
|
fallback_plan->lookup_array[i] = arabic_fallback_synthesize_lookup (plan, font, i);
|
||||||
if (fallback_plan->lookup_array[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 @@ arabic_fallback_plan_destroy (arabic_fallback_plan_t *fallback_plan)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
|
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
|
||||||
if (fallback_plan->lookup_array[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->lookup_array[i]);
|
||||||
|
}
|
||||||
|
|
||||||
free (fallback_plan);
|
free (fallback_plan);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +249,7 @@ arabic_fallback_plan_shape (arabic_fallback_plan_t *fallback_plan,
|
||||||
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
|
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
|
||||||
if (fallback_plan->lookup_array[i]) {
|
if (fallback_plan->lookup_array[i]) {
|
||||||
OT::hb_apply_context_t c (0, font, buffer, fallback_plan->mask_array[i], true/*auto_zwj*/);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue