Partially switch ot shaper to shape_plan

This commit is contained in:
Behdad Esfahbod 2012-07-27 02:12:28 -04:00
parent b6b7ba1313
commit ea278d3895
11 changed files with 40 additions and 19 deletions

View File

@ -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 {

View File

@ -38,7 +38,6 @@
#endif
#define _HB_BUFFER_UNICODE_FUNCS_DEFAULT (const_cast<hb_unicode_funcs_t *> (&_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:
*

View File

@ -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;

View File

@ -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_t *> (&_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_t *> (&_hb_font_nil);

View File

@ -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))

View File

@ -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))

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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_t *> (&_hb_shape_plan_nil);

View File

@ -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