From ea278d3895fe0c92801d692cd71d8d9f1de7c048 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 27 Jul 2012 02:12:28 -0400 Subject: [PATCH] Partially switch ot shaper to shape_plan --- src/hb-buffer-private.hh | 1 + src/hb-buffer.cc | 1 - src/hb-font-private.hh | 2 -- src/hb-font.cc | 22 ++++++++++++++-------- src/hb-ot-layout-gpos-table.hh | 2 +- src/hb-ot-layout-gsub-table.hh | 4 ++-- src/hb-ot-layout-private.hh | 1 + src/hb-ot-layout.cc | 9 ++++++--- src/hb-ot-shape.cc | 3 ++- src/hb-shape-plan.cc | 11 +++++++++++ src/hb-shaper-private.hh | 3 ++- 11 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index e06a7fa36..b800aebb8 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -46,6 +46,7 @@ typedef struct hb_segment_properties_t { hb_language_t language; ASSERT_POD (); } hb_segment_properties_t; +#define _HB_BUFFER_PROPS_DEFAULT { HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, HB_LANGUAGE_INVALID } struct hb_buffer_t { diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 2b4acffa1..f8c62ac51 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -38,7 +38,6 @@ #endif #define _HB_BUFFER_UNICODE_FUNCS_DEFAULT (const_cast (&_hb_unicode_funcs_default)) -#define _HB_BUFFER_PROPS_DEFAULT { HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, HB_LANGUAGE_INVALID } /* Here is how the buffer works internally: * diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh index 2540dd67c..f1b43c0ec 100644 --- a/src/hb-font-private.hh +++ b/src/hb-font-private.hh @@ -97,8 +97,6 @@ struct hb_face_t { void *user_data; hb_destroy_func_t destroy; - struct hb_ot_layout_t *ot_layout; - unsigned int index; unsigned int upem; diff --git a/src/hb-font.cc b/src/hb-font.cc index 12610778a..5a3219a1b 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -589,10 +589,14 @@ static const hb_face_t _hb_face_nil = { NULL, /* user_data */ NULL, /* destroy */ - NULL, /* ot_layout */ - 0, /* index */ - 1000 /* upem */ + 1000, /* upem */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } }; @@ -613,8 +617,6 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table, face->user_data = user_data; face->destroy = destroy; - face->ot_layout = _hb_ot_layout_create (face); - face->upem = 0; return face; @@ -707,8 +709,6 @@ hb_face_destroy (hb_face_t *face) { if (!hb_object_destroy (face)) return; - _hb_ot_layout_destroy (face->ot_layout); - #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face); #include "hb-shaper-list.hh" #undef HB_SHAPER_IMPLEMENT @@ -877,7 +877,13 @@ hb_font_get_empty (void) const_cast (&_hb_font_funcs_nil), /* klass */ NULL, /* user_data */ - NULL /* destroy */ + NULL, /* destroy */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } }; return const_cast (&_hb_font_nil); diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 5b714070f..a35f633af 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1553,7 +1553,7 @@ inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c) static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(c->face->ot_layout->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const PosLookup &l = gpos.get_lookup (lookup_index); if (unlikely (c->nesting_level_left == 0)) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 600a92a5e..038cb9321 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1241,7 +1241,7 @@ inline bool ExtensionSubst::is_reverse (void) const static inline void closure_lookup (hb_closure_context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(c->face->ot_layout->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const SubstLookup &l = gsub.get_lookup (lookup_index); if (unlikely (c->nesting_level_left == 0)) @@ -1254,7 +1254,7 @@ static inline void closure_lookup (hb_closure_context_t *c, unsigned int lookup_ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(c->face->ot_layout->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const SubstLookup &l = gsub.get_lookup (lookup_index); if (unlikely (c->nesting_level_left == 0)) diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index ba375aaa7..294c359ad 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -36,6 +36,7 @@ #include "hb-ot-shape-complex-private.hh" +#define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot) /* * GDEF diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index c6de75c89..dff3673f6 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -70,17 +70,20 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) static inline const GDEF& _get_gdef (hb_face_t *face) { - return likely (face->ot_layout && face->ot_layout->gdef) ? *face->ot_layout->gdef : Null(GDEF); + /* XXX ensure ot_layout, and speed up */ + return *hb_ot_layout_from_face (face)->gdef; } static inline const GSUB& _get_gsub (hb_face_t *face) { - return likely (face->ot_layout && face->ot_layout->gsub) ? *face->ot_layout->gsub : Null(GSUB); + /* XXX ensure ot_layout, and speed up */ + return *hb_ot_layout_from_face (face)->gsub; } static inline const GPOS& _get_gpos (hb_face_t *face) { - return likely (face->ot_layout && face->ot_layout->gpos) ? *face->ot_layout->gpos : Null(GPOS); + /* XXX ensure ot_layout, and speed up */ + return *hb_ot_layout_from_face (face)->gpos; } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 639748e10..22dea0750 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -44,12 +44,13 @@ hb_ot_shaper_face_data_t * _hb_ot_shaper_face_data_create (hb_face_t *face) { - return (hb_ot_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return _hb_ot_layout_create (face); } void _hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data) { + _hb_ot_layout_destroy (data); } diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index db21e881d..099d09cb5 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -136,6 +136,17 @@ hb_shape_plan_get_empty (void) { static const hb_shape_plan_t _hb_shape_plan_nil = { HB_OBJECT_HEADER_STATIC, + + NULL, /* face */ + _HB_BUFFER_PROPS_DEFAULT, /* props */ + + {NULL}, /* shapers */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } }; return const_cast (&_hb_shape_plan_nil); diff --git a/src/hb-shaper-private.hh b/src/hb-shaper-private.hh index 1cf7c5b47..e50d86985 100644 --- a/src/hb-shaper-private.hh +++ b/src/hb-shaper-private.hh @@ -68,7 +68,8 @@ struct hb_shaper_data_t { #define HB_SHAPER_DATA_IS_INVALID(data) ((void *) (data) == HB_SHAPER_DATA_INVALID) #define HB_SHAPER_DATA_TYPE(shaper, object) struct hb_##shaper##_shaper_##object##_data_t -#define HB_SHAPER_DATA(shaper, object) (* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(object)->shaper_data.shaper) +#define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(instance)->shaper_data.shaper) +#define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE (shaper, object, object) #define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_create #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_destroy