[ot] Move GSUB/GPOS into tables_t

This commit is contained in:
Behdad Esfahbod 2018-08-03 16:45:57 -07:00
parent f73d2775cf
commit 0271c7ab3b
5 changed files with 30 additions and 40 deletions

View File

@ -613,10 +613,8 @@ struct hb_base_lazy_loader_t
thiz ()->destroy (instance); thiz ()->destroy (instance);
} }
inline const Returned * operator-> (void) const inline const Returned * operator -> (void) const { return thiz ()->get (); }
{ inline const Returned & operator * (void) const { return *thiz ()->get (); }
return thiz ()->get ();
}
inline Stored * get_stored (void) const inline Stored * get_stored (void) const
{ {

View File

@ -1628,14 +1628,14 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
template <typename context_t> template <typename context_t>
/*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) /*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{ {
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS);
const PosLookup &l = gpos.get_lookup (lookup_index); const PosLookup &l = gpos.get_lookup (lookup_index);
return l.dispatch (c); return l.dispatch (c);
} }
/*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) /*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{ {
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS);
const PosLookup &l = gpos.get_lookup (lookup_index); const PosLookup &l = gpos.get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index; unsigned int saved_lookup_index = c->lookup_index;

View File

@ -1359,14 +1359,14 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
template <typename context_t> template <typename context_t>
/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{ {
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB);
const SubstLookup &l = gsub.get_lookup (lookup_index); const SubstLookup &l = gsub.get_lookup (lookup_index);
return l.dispatch (c); return l.dispatch (c);
} }
/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) /*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{ {
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB);
const SubstLookup &l = gsub.get_lookup (lookup_index); const SubstLookup &l = gsub.get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index; unsigned int saved_lookup_index = c->lookup_index;

View File

@ -158,6 +158,8 @@ namespace AAT {
} }
#define HB_OT_LAYOUT_TABLES \ #define HB_OT_LAYOUT_TABLES \
HB_OT_LAYOUT_TABLE(OT, GSUB) \
HB_OT_LAYOUT_TABLE(OT, GPOS) \
HB_OT_LAYOUT_TABLE(OT, MATH) \ HB_OT_LAYOUT_TABLE(OT, MATH) \
HB_OT_LAYOUT_TABLE(OT, fvar) \ HB_OT_LAYOUT_TABLE(OT, fvar) \
HB_OT_LAYOUT_TABLE(OT, avar) \ HB_OT_LAYOUT_TABLE(OT, avar) \
@ -171,12 +173,7 @@ HB_OT_LAYOUT_TABLES
struct hb_ot_layout_t struct hb_ot_layout_t
{ {
hb_blob_t *gdef_blob; hb_blob_t *gdef_blob;
hb_blob_t *gsub_blob;
hb_blob_t *gpos_blob;
const struct OT::GDEF *gdef; const struct OT::GDEF *gdef;
const struct OT::GSUB *gsub;
const struct OT::GPOS *gpos;
unsigned int gsub_lookup_count; unsigned int gsub_lookup_count;
unsigned int gpos_lookup_count; unsigned int gpos_lookup_count;

View File

@ -173,36 +173,33 @@ _hb_ot_layout_create (hb_face_t *face)
layout->gdef_blob = hb_sanitize_context_t ().reference_table<OT::GDEF> (face); layout->gdef_blob = hb_sanitize_context_t ().reference_table<OT::GDEF> (face);
layout->gdef = layout->gdef_blob->as<OT::GDEF> (); layout->gdef = layout->gdef_blob->as<OT::GDEF> ();
layout->gsub_blob = hb_sanitize_context_t ().reference_table<OT::GSUB> (face);
layout->gsub = layout->gsub_blob->as<OT::GSUB> ();
layout->gpos_blob = hb_sanitize_context_t ().reference_table<OT::GPOS> (face);
layout->gpos = layout->gpos_blob->as<OT::GPOS> ();
layout->table.init0 (face); layout->table.init0 (face);
const OT::GSUB &gsub = *layout->table.GSUB;
const OT::GPOS &gpos = *layout->table.GPOS;
if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, if (_hb_ot_blacklist_gdef (layout->gdef_blob->length,
layout->gsub_blob->length, layout->table.GSUB.get_blob()->length,
layout->gpos_blob->length)) layout->table.GPOS.get_blob()->length))
layout->gdef = &Null(OT::GDEF); layout->gdef = &Null(OT::GDEF);
layout->gsub_lookup_count = layout->gsub->get_lookup_count (); unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count ();
layout->gpos_lookup_count = layout->gpos->get_lookup_count (); unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count ();
layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_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)); layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) || if (unlikely ((gsub_lookup_count && !layout->gsub_accels) ||
(layout->gpos_lookup_count && !layout->gpos_accels))) (gpos_lookup_count && !layout->gpos_accels)))
{ {
_hb_ot_layout_destroy (layout); _hb_ot_layout_destroy (layout);
return nullptr; return nullptr;
} }
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++) for (unsigned int i = 0; i < gsub_lookup_count; i++)
layout->gsub_accels[i].init (layout->gsub->get_lookup (i)); layout->gsub_accels[i].init (gsub.get_lookup (i));
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++) for (unsigned int i = 0; i < gpos_lookup_count; i++)
layout->gpos_accels[i].init (layout->gpos->get_lookup (i)); layout->gpos_accels[i].init (gpos.get_lookup (i));
return layout; return layout;
} }
@ -221,8 +218,6 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout)
free (layout->gpos_accels); free (layout->gpos_accels);
hb_blob_destroy (layout->gdef_blob); hb_blob_destroy (layout->gdef_blob);
hb_blob_destroy (layout->gsub_blob);
hb_blob_destroy (layout->gpos_blob);
layout->table.fini (); layout->table.fini ();
@ -247,13 +242,13 @@ static inline const OT::GSUB&
_get_gsub (hb_face_t *face) _get_gsub (hb_face_t *face)
{ {
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB); if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
return *hb_ot_layout_from_face (face)->gsub; return *hb_ot_layout_from_face (face)->table.GSUB;
} }
static inline const OT::GPOS& static inline const OT::GPOS&
_get_gpos (hb_face_t *face) _get_gpos (hb_face_t *face)
{ {
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS); if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
return *hb_ot_layout_from_face (face)->gpos; return *hb_ot_layout_from_face (face)->table.GPOS;
} }
/* /*
@ -861,13 +856,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
{ {
case HB_OT_TAG_GSUB: case HB_OT_TAG_GSUB:
{ {
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)->table.GSUB->get_lookup (lookup_index);
l.collect_glyphs (&c); l.collect_glyphs (&c);
return; return;
} }
case HB_OT_TAG_GPOS: case HB_OT_TAG_GPOS:
{ {
const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index); const OT::PosLookup& l = hb_ot_layout_from_face (face)->table.GPOS->get_lookup (lookup_index);
l.collect_glyphs (&c); l.collect_glyphs (&c);
return; return;
} }
@ -943,7 +938,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false; if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context); OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context);
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)->table.GSUB->get_lookup (lookup_index);
return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]); return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]);
} }
@ -1101,7 +1096,7 @@ struct GSUBProxy
typedef OT::SubstLookup Lookup; typedef OT::SubstLookup Lookup;
GSUBProxy (hb_face_t *face) : GSUBProxy (hb_face_t *face) :
table (*hb_ot_layout_from_face (face)->gsub), table (*hb_ot_layout_from_face (face)->table.GSUB),
accels (hb_ot_layout_from_face (face)->gsub_accels) {} accels (hb_ot_layout_from_face (face)->gsub_accels) {}
const OT::GSUB &table; const OT::GSUB &table;
@ -1115,7 +1110,7 @@ struct GPOSProxy
typedef OT::PosLookup Lookup; typedef OT::PosLookup Lookup;
GPOSProxy (hb_face_t *face) : GPOSProxy (hb_face_t *face) :
table (*hb_ot_layout_from_face (face)->gpos), table (*hb_ot_layout_from_face (face)->table.GPOS),
accels (hb_ot_layout_from_face (face)->gpos_accels) {} accels (hb_ot_layout_from_face (face)->gpos_accels) {}
const OT::GPOS &table; const OT::GPOS &table;