From 74b4df2cdef68b74536d9c29426b242199a63a6f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Aug 2018 16:57:40 -0700 Subject: [PATCH] [ot] Move GDEF into tables_t --- src/hb-machinery-private.hh | 6 ++++++ src/hb-ot-layout-gsub-table.hh | 2 +- src/hb-ot-layout-gsubgpos-private.hh | 2 +- src/hb-ot-layout-private.hh | 7 +------ src/hb-ot-layout.cc | 15 +++++---------- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index cd608cfb..ce90fabd 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -633,6 +633,12 @@ struct hb_base_lazy_loader_t return p; } + inline void set_stored (Stored *instance_) + { + assert (instance == nullptr); + instance = instance_; + } + inline const Returned * get (void) const { return thiz ()->convert (get_stored ()); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index b967bf6f..1d5a02a0 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1335,7 +1335,7 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) { _hb_buffer_assert_gsubgpos_vars (buffer); - const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef; + const GDEF &gdef = *hb_ot_layout_from_face (font->face)->table.GDEF; unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) { diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 747811e6..f3566ab1 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -480,7 +480,7 @@ struct hb_ot_apply_context_t : iter_input (), iter_context (), font (font_), face (font->face), buffer (buffer_), recurse_func (nullptr), - gdef (*hb_ot_layout_from_face (face)->gdef), + gdef (*hb_ot_layout_from_face (face)->table.GDEF), var_store (gdef.get_var_store ()), direction (buffer_->props.direction), lookup_mask (1), diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 3c957f1e..a579b037 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -146,9 +146,6 @@ namespace OT { struct BASE; struct COLR; struct CPAL; - struct GDEF; - struct GSUB; - struct GPOS; } namespace AAT { @@ -158,6 +155,7 @@ namespace AAT { } #define HB_OT_LAYOUT_TABLES \ + HB_OT_LAYOUT_TABLE(OT, GDEF) \ HB_OT_LAYOUT_TABLE(OT, GSUB) \ HB_OT_LAYOUT_TABLE(OT, GPOS) \ HB_OT_LAYOUT_TABLE(OT, MATH) \ @@ -172,9 +170,6 @@ HB_OT_LAYOUT_TABLES struct hb_ot_layout_t { - hb_blob_t *gdef_blob; - const struct OT::GDEF *gdef; - unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 557800a6..bfde063d 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -170,18 +170,15 @@ _hb_ot_layout_create (hb_face_t *face) if (unlikely (!layout)) return nullptr; - layout->gdef_blob = hb_sanitize_context_t ().reference_table (face); - layout->gdef = layout->gdef_blob->as (); - 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, - layout->table.GSUB.get_blob()->length, - layout->table.GPOS.get_blob()->length)) - layout->gdef = &Null(OT::GDEF); + if (unlikely (_hb_ot_blacklist_gdef (layout->table.GDEF.get_blob ()->length, + layout->table.GSUB.get_blob ()->length, + layout->table.GPOS.get_blob ()->length))) + layout->table.GDEF.set_stored (hb_blob_get_empty ()); unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count (); unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count (); @@ -217,8 +214,6 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) free (layout->gsub_accels); free (layout->gpos_accels); - hb_blob_destroy (layout->gdef_blob); - layout->table.fini (); free (layout); @@ -236,7 +231,7 @@ static inline const OT::GDEF& _get_gdef (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF); - return *hb_ot_layout_from_face (face)->gdef; + return *hb_ot_layout_from_face (face)->table.GDEF; } static inline const OT::GSUB& _get_gsub (hb_face_t *face) -- GitLab