[ot-face] Unify GSUB/GPOS accelerators in the table accelerator framework
This commit is contained in:
parent
963413fc54
commit
b929100f87
@ -26,9 +26,7 @@
|
||||
|
||||
#include "hb-open-type.hh"
|
||||
|
||||
#include "hb-ot-layout.hh"
|
||||
#include "hb-ot-layout-gsubgpos.hh"
|
||||
|
||||
#include "hb-ot-face.hh"
|
||||
#include "hb-aat-layout.hh"
|
||||
#include "hb-aat-layout-ankr-table.hh"
|
||||
#include "hb-aat-layout-bsln-table.hh" // Just so we compile it; unused otherwise.
|
||||
|
@ -26,10 +26,6 @@
|
||||
|
||||
#include "hb-ot-face.hh"
|
||||
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
#include "hb-ot-layout-gsub-table.hh"
|
||||
#include "hb-ot-layout-gpos-table.hh"
|
||||
|
||||
|
||||
static bool
|
||||
_hb_ot_blacklist_gdef (unsigned int gdef_len,
|
||||
@ -161,50 +157,18 @@ _hb_ot_face_data_create (hb_face_t *face)
|
||||
|
||||
data->table.init0 (face);
|
||||
|
||||
const OT::GSUB &gsub = *data->table.GSUB;
|
||||
const OT::GPOS &gpos = *data->table.GPOS;
|
||||
|
||||
if (unlikely (_hb_ot_blacklist_gdef (data->table.GDEF.get_blob ()->length,
|
||||
data->table.GSUB.get_blob ()->length,
|
||||
data->table.GPOS.get_blob ()->length)))
|
||||
data->table.GSUB->blob->length,
|
||||
data->table.GPOS->blob->length)))
|
||||
data->table.GDEF.set_stored (hb_blob_get_empty ());
|
||||
|
||||
unsigned int gsub_lookup_count = data->gsub_lookup_count = gsub.get_lookup_count ();
|
||||
unsigned int gpos_lookup_count = data->gpos_lookup_count = gpos.get_lookup_count ();
|
||||
|
||||
data->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
|
||||
data->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
|
||||
|
||||
if (unlikely ((gsub_lookup_count && !data->gsub_accels) ||
|
||||
(gpos_lookup_count && !data->gpos_accels)))
|
||||
{
|
||||
_hb_ot_face_data_destroy (data);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < gsub_lookup_count; i++)
|
||||
data->gsub_accels[i].init (gsub.get_lookup (i));
|
||||
for (unsigned int i = 0; i < gpos_lookup_count; i++)
|
||||
data->gpos_accels[i].init (gpos.get_lookup (i));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
_hb_ot_face_data_destroy (hb_ot_face_data_t *data)
|
||||
{
|
||||
if (data->gsub_accels)
|
||||
for (unsigned int i = 0; i < data->gsub_lookup_count; i++)
|
||||
data->gsub_accels[i].fini ();
|
||||
if (data->gpos_accels)
|
||||
for (unsigned int i = 0; i < data->gpos_lookup_count; i++)
|
||||
data->gpos_accels[i].fini ();
|
||||
|
||||
free (data->gsub_accels);
|
||||
free (data->gpos_accels);
|
||||
|
||||
data->table.fini ();
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,19 @@
|
||||
|
||||
#include "hb-machinery.hh"
|
||||
|
||||
|
||||
#define hb_ot_face_data(face) ((hb_ot_face_data_t *) face->shaper_data.ot.get_relaxed ())
|
||||
|
||||
|
||||
#include "hb-ot-cmap-table.hh"
|
||||
#include "hb-ot-glyf-table.hh"
|
||||
#include "hb-ot-hmtx-table.hh"
|
||||
#include "hb-ot-kern-table.hh"
|
||||
#include "hb-ot-post-table.hh"
|
||||
#include "hb-ot-color-cbdt-table.hh"
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
#include "hb-ot-layout-gsub-table.hh"
|
||||
#include "hb-ot-layout-gpos-table.hh"
|
||||
|
||||
|
||||
/*
|
||||
@ -50,8 +57,6 @@
|
||||
#define HB_OT_LAYOUT_TABLES \
|
||||
/* OpenType shaping. */ \
|
||||
HB_OT_LAYOUT_TABLE(OT, GDEF) \
|
||||
HB_OT_LAYOUT_TABLE(OT, GSUB) \
|
||||
HB_OT_LAYOUT_TABLE(OT, GPOS) \
|
||||
HB_OT_LAYOUT_TABLE(OT, JSTF) \
|
||||
HB_OT_LAYOUT_TABLE(OT, BASE) \
|
||||
/* AAT shaping. */ \
|
||||
@ -66,6 +71,8 @@
|
||||
/* OpenType math. */ \
|
||||
HB_OT_LAYOUT_TABLE(OT, MATH) \
|
||||
/* OpenType fundamentals. */ \
|
||||
HB_OT_LAYOUT_ACCELERATOR(OT, GSUB) \
|
||||
HB_OT_LAYOUT_ACCELERATOR(OT, GPOS) \
|
||||
HB_OT_LAYOUT_ACCELERATOR(OT, cmap) \
|
||||
HB_OT_LAYOUT_ACCELERATOR(OT, hmtx) \
|
||||
HB_OT_LAYOUT_ACCELERATOR(OT, vmtx) \
|
||||
@ -104,19 +111,13 @@ struct hb_ot_face_data_t
|
||||
|
||||
hb_face_t *face; /* MUST be JUST before the lazy loaders. */
|
||||
#define HB_OT_LAYOUT_TABLE(Namespace, Type) \
|
||||
hb_table_lazy_loader_t<struct Namespace::Type, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
|
||||
hb_table_lazy_loader_t<Namespace::Type, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
|
||||
#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) \
|
||||
hb_face_lazy_loader_t<struct Namespace::Type::accelerator_t, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
|
||||
hb_face_lazy_loader_t<Namespace::Type::accelerator_t, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
|
||||
HB_OT_LAYOUT_TABLES
|
||||
#undef HB_OT_LAYOUT_ACCELERATOR
|
||||
#undef HB_OT_LAYOUT_TABLE
|
||||
} table;
|
||||
|
||||
/* More accelerators. Merge into previous. */
|
||||
unsigned int gsub_lookup_count;
|
||||
unsigned int gpos_lookup_count;
|
||||
hb_ot_layout_lookup_accelerator_t *gsub_accels;
|
||||
hb_ot_layout_lookup_accelerator_t *gpos_accels;
|
||||
};
|
||||
|
||||
|
||||
@ -127,8 +128,4 @@ HB_INTERNAL void
|
||||
_hb_ot_face_data_destroy (hb_ot_face_data_t *data);
|
||||
|
||||
|
||||
#define hb_ot_face_data(face) ((hb_ot_face_data_t *) face->shaper_data.ot.get_relaxed ())
|
||||
|
||||
|
||||
|
||||
#endif /* HB_OT_FACE_HH */
|
||||
|
@ -1636,7 +1636,7 @@ template <typename context_t>
|
||||
|
||||
/*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
|
||||
{
|
||||
const PosLookup &l = hb_ot_face_data (c->face)->table.GPOS->get_lookup (lookup_index);
|
||||
const PosLookup &l = _get_gpos (c->face).get_lookup (lookup_index);
|
||||
unsigned int saved_lookup_props = c->lookup_props;
|
||||
unsigned int saved_lookup_index = c->lookup_index;
|
||||
c->set_lookup_index (lookup_index);
|
||||
|
@ -1327,7 +1327,7 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
|
||||
{
|
||||
_hb_buffer_assert_gsubgpos_vars (buffer);
|
||||
|
||||
const GDEF &gdef = *hb_ot_face_data (font->face)->table.GDEF;
|
||||
const GDEF &gdef = _get_gdef (font->face);
|
||||
unsigned int count = buffer->len;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
@ -1351,13 +1351,13 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
|
||||
template <typename context_t>
|
||||
/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
|
||||
{
|
||||
const SubstLookup &l = hb_ot_face_data (c->face)->table.GSUB->get_lookup (lookup_index);
|
||||
const SubstLookup &l = _get_gsub (c->face).get_lookup (lookup_index);
|
||||
return l.dispatch (c);
|
||||
}
|
||||
|
||||
/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
|
||||
{
|
||||
const SubstLookup &l = hb_ot_face_data (c->face)->table.GSUB->get_lookup (lookup_index);
|
||||
const SubstLookup &l = _get_gsub (c->face).get_lookup (lookup_index);
|
||||
unsigned int saved_lookup_props = c->lookup_props;
|
||||
unsigned int saved_lookup_index = c->lookup_index;
|
||||
c->set_lookup_index (lookup_index);
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include "hb.hh"
|
||||
#include "hb-buffer.hh"
|
||||
#include "hb-map.hh"
|
||||
#include "hb-ot-face.hh"
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
#include "hb-set.hh"
|
||||
#include "hb-ot-layout-common.hh"
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
|
||||
|
||||
namespace OT {
|
||||
@ -481,7 +481,7 @@ struct hb_ot_apply_context_t :
|
||||
iter_input (), iter_context (),
|
||||
font (font_), face (font->face), buffer (buffer_),
|
||||
recurse_func (nullptr),
|
||||
gdef (*hb_ot_face_data (face)->table.GDEF),
|
||||
gdef (_get_gdef (face)),
|
||||
var_store (gdef.get_var_store ()),
|
||||
direction (buffer_->props.direction),
|
||||
lookup_mask (1),
|
||||
@ -2387,28 +2387,30 @@ struct GSUBGPOS
|
||||
inline void init (hb_face_t *face)
|
||||
{
|
||||
this->blob = hb_sanitize_context_t().reference_table<T> (face);
|
||||
const T &table = *this->blob->as<T> ();
|
||||
table = this->blob->as<T> ();
|
||||
|
||||
this->lookup_count = table.get_lookup_count ();
|
||||
this->lookup_count = table->get_lookup_count ();
|
||||
|
||||
this->accels = (hb_ot_layout_lookup_accelerator_t *) calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
|
||||
if (unlikely (!this->accels))
|
||||
this->lookup_count = 0;
|
||||
|
||||
for (unsigned int i = 0; i < this->lookup_count; i++)
|
||||
this->accels[i].init (table.get_lookup (i));
|
||||
this->accels[i].init (table->get_lookup (i));
|
||||
}
|
||||
|
||||
inline void fini (void)
|
||||
{
|
||||
for (unsigned int i = 0; i < this->lookup_count; i++)
|
||||
this->accels[i].fini ();
|
||||
free (this->accels);
|
||||
hb_blob_destroy (this->blob);
|
||||
free (accels);
|
||||
}
|
||||
|
||||
private:
|
||||
hb_blob_t *blob;
|
||||
unsigned int lookup_count;
|
||||
hb_ot_layout_lookup_accelerator_t *accels;
|
||||
hb_blob_t *blob;
|
||||
const T *table;
|
||||
unsigned int lookup_count;
|
||||
hb_ot_layout_lookup_accelerator_t *accels;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "hb-open-type.hh"
|
||||
#include "hb-ot-layout.hh"
|
||||
#include "hb-ot-face.hh"
|
||||
#include "hb-ot-map.hh"
|
||||
#include "hb-map.hh"
|
||||
|
||||
@ -55,23 +56,23 @@
|
||||
// return *(data->base.get ());
|
||||
// }
|
||||
|
||||
static inline const OT::GDEF&
|
||||
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_face_data (face)->table.GDEF;
|
||||
}
|
||||
static inline const OT::GSUB&
|
||||
inline const OT::GSUB&
|
||||
_get_gsub (hb_face_t *face)
|
||||
{
|
||||
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
|
||||
return *hb_ot_face_data (face)->table.GSUB;
|
||||
return *hb_ot_face_data (face)->table.GSUB->table;
|
||||
}
|
||||
static inline const OT::GPOS&
|
||||
inline const OT::GPOS&
|
||||
_get_gpos (hb_face_t *face)
|
||||
{
|
||||
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
|
||||
return *hb_ot_face_data (face)->table.GPOS;
|
||||
return *hb_ot_face_data (face)->table.GPOS->table;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -461,11 +462,11 @@ hb_ot_layout_table_get_lookup_count (hb_face_t *face,
|
||||
{
|
||||
case HB_OT_TAG_GSUB:
|
||||
{
|
||||
return hb_ot_face_data (face)->gsub_lookup_count;
|
||||
return hb_ot_face_data (face)->table.GSUB->lookup_count;
|
||||
}
|
||||
case HB_OT_TAG_GPOS:
|
||||
{
|
||||
return hb_ot_face_data (face)->gpos_lookup_count;
|
||||
return hb_ot_face_data (face)->table.GPOS->lookup_count;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -679,13 +680,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
|
||||
{
|
||||
case HB_OT_TAG_GSUB:
|
||||
{
|
||||
const OT::SubstLookup& l = hb_ot_face_data (face)->table.GSUB->get_lookup (lookup_index);
|
||||
const OT::SubstLookup& l = hb_ot_face_data (face)->table.GSUB->table->get_lookup (lookup_index);
|
||||
l.collect_glyphs (&c);
|
||||
return;
|
||||
}
|
||||
case HB_OT_TAG_GPOS:
|
||||
{
|
||||
const OT::PosLookup& l = hb_ot_face_data (face)->table.GPOS->get_lookup (lookup_index);
|
||||
const OT::PosLookup& l = hb_ot_face_data (face)->table.GPOS->table->get_lookup (lookup_index);
|
||||
l.collect_glyphs (&c);
|
||||
return;
|
||||
}
|
||||
@ -758,12 +759,12 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
|
||||
unsigned int glyphs_length,
|
||||
hb_bool_t zero_context)
|
||||
{
|
||||
if (unlikely (lookup_index >= hb_ot_face_data (face)->gsub_lookup_count)) return false;
|
||||
if (unlikely (lookup_index >= hb_ot_face_data (face)->table.GSUB->lookup_count)) return false;
|
||||
OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context);
|
||||
|
||||
const OT::SubstLookup& l = hb_ot_face_data (face)->table.GSUB->get_lookup (lookup_index);
|
||||
const OT::SubstLookup& l = hb_ot_face_data (face)->table.GSUB->table->get_lookup (lookup_index);
|
||||
|
||||
return l.would_apply (&c, &hb_ot_face_data (face)->gsub_accels[lookup_index]);
|
||||
return l.would_apply (&c, &hb_ot_face_data (face)->table.GSUB->accels[lookup_index]);
|
||||
}
|
||||
|
||||
void
|
||||
@ -919,8 +920,8 @@ struct GSUBProxy
|
||||
typedef OT::SubstLookup Lookup;
|
||||
|
||||
GSUBProxy (hb_face_t *face) :
|
||||
table (*hb_ot_face_data (face)->table.GSUB),
|
||||
accels (hb_ot_face_data (face)->gsub_accels) {}
|
||||
table (*hb_ot_face_data (face)->table.GSUB->table),
|
||||
accels (hb_ot_face_data (face)->table.GSUB->accels) {}
|
||||
|
||||
const OT::GSUB &table;
|
||||
const hb_ot_layout_lookup_accelerator_t *accels;
|
||||
@ -933,8 +934,8 @@ struct GPOSProxy
|
||||
typedef OT::PosLookup Lookup;
|
||||
|
||||
GPOSProxy (hb_face_t *face) :
|
||||
table (*hb_ot_face_data (face)->table.GPOS),
|
||||
accels (hb_ot_face_data (face)->gpos_accels) {}
|
||||
table (*hb_ot_face_data (face)->table.GPOS->table),
|
||||
accels (hb_ot_face_data (face)->table.GPOS->accels) {}
|
||||
|
||||
const OT::GPOS &table;
|
||||
const hb_ot_layout_lookup_accelerator_t *accels;
|
||||
|
@ -37,6 +37,23 @@
|
||||
#include "hb-set-digest.hh"
|
||||
|
||||
|
||||
namespace OT
|
||||
{
|
||||
struct GDEF;
|
||||
struct GSUB;
|
||||
struct GPOS;
|
||||
}
|
||||
|
||||
HB_INTERNAL const OT::GDEF&
|
||||
_get_gdef (hb_face_t *face);
|
||||
|
||||
HB_INTERNAL const OT::GSUB&
|
||||
_get_gsub (hb_face_t *face);
|
||||
|
||||
HB_INTERNAL const OT::GPOS&
|
||||
_get_gpos (hb_face_t *face);
|
||||
|
||||
|
||||
/* Private API corresponding to hb-ot-layout.h: */
|
||||
|
||||
HB_INTERNAL hb_bool_t
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "hb-ot-shape-fallback.hh"
|
||||
#include "hb-ot-shape-normalize.hh"
|
||||
|
||||
#include "hb-ot-face.hh"
|
||||
#include "hb-ot-layout.hh"
|
||||
#include "hb-unicode.hh"
|
||||
#include "hb-set.hh"
|
||||
|
Loading…
Reference in New Issue
Block a user