[kern] Switch to dispatch

This commit is contained in:
Behdad Esfahbod 2018-11-07 16:03:09 -05:00
parent bc06e2805a
commit 9af983af24
3 changed files with 22 additions and 19 deletions

View File

@ -881,10 +881,11 @@ struct KerxTable
return v; return v;
} }
inline void apply (AAT::hb_aat_apply_context_t *c) const inline bool apply (AAT::hb_aat_apply_context_t *c) const
{ {
typedef typename T::SubTable SubTable; typedef typename T::SubTable SubTable;
bool ret = false;
bool seenCrossStream = false; bool seenCrossStream = false;
c->set_lookup_index (0); c->set_lookup_index (0);
const SubTable *st = &thiz()->firstSubTable; const SubTable *st = &thiz()->firstSubTable;
@ -927,7 +928,7 @@ struct KerxTable
c->sanitizer.set_object (*st); c->sanitizer.set_object (*st);
st->dispatch (c); ret |= st->dispatch (c);
if (reverse) if (reverse)
c->buffer->reverse (); c->buffer->reverse ();
@ -938,6 +939,8 @@ struct KerxTable
st = &StructAfter<SubTable> (*st); st = &StructAfter<SubTable> (*st);
c->set_lookup_index (c->lookup_index + 1); c->set_lookup_index (c->lookup_index + 1);
} }
return ret;
} }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const

View File

@ -272,10 +272,11 @@ struct kern
static const hb_tag_t tableTag = HB_OT_TAG_kern; static const hb_tag_t tableTag = HB_OT_TAG_kern;
inline bool has_data (void) const { return u.version32; } inline bool has_data (void) const { return u.version32; }
inline unsigned int get_type (void) const { return u.major; }
inline bool has_cross_stream (void) const inline bool has_cross_stream (void) const
{ {
switch (u.major) { switch (get_type ()) {
case 0: return u.ot.has_cross_stream (); case 0: return u.ot.has_cross_stream ();
case 1: return u.aat.has_cross_stream (); case 1: return u.aat.has_cross_stream ();
default:return false; default:return false;
@ -284,20 +285,25 @@ struct kern
inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{ {
switch (u.major) { switch (get_type ()) {
case 0: return u.ot.get_h_kerning (left, right); case 0: return u.ot.get_h_kerning (left, right);
case 1: return u.aat.get_h_kerning (left, right); case 1: return u.aat.get_h_kerning (left, right);
default:return 0; default:return 0;
} }
} }
inline void apply (AAT::hb_aat_apply_context_t *c) const inline bool apply (AAT::hb_aat_apply_context_t *c) const
{ return dispatch (c); }
template <typename context_t>
inline typename context_t::return_t dispatch (context_t *c) const
{ {
/* TODO Switch to dispatch(). */ unsigned int subtable_type = get_type ();
switch (u.major) { TRACE_DISPATCH (this, subtable_type);
case 0: u.ot.apply (c); return; switch (subtable_type) {
case 1: u.aat.apply (c); return; case 0: return_trace (c->dispatch (u.ot));
default: return; case 1: return_trace (c->dispatch (u.aat));
default: return_trace (c->default_return_value ());
} }
} }
@ -305,11 +311,7 @@ struct kern
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (!u.version32.sanitize (c)) return_trace (false); if (!u.version32.sanitize (c)) return_trace (false);
switch (u.major) { return_trace (dispatch (c));
case 0: return_trace (u.ot.sanitize (c));
case 1: return_trace (u.aat.sanitize (c));
default:return_trace (true);
}
} }
protected: protected:

View File

@ -1275,10 +1275,8 @@ apply_backward (OT::hb_ot_apply_context_t *c,
if (accel.may_have (buffer->cur().codepoint) && if (accel.may_have (buffer->cur().codepoint) &&
(buffer->cur().mask & c->lookup_mask) && (buffer->cur().mask & c->lookup_mask) &&
c->check_glyph_property (&buffer->cur(), c->lookup_props)) c->check_glyph_property (&buffer->cur(), c->lookup_props))
{ ret |= accel.apply (c);
if (accel.apply (c))
ret = true;
}
/* The reverse lookup doesn't "advance" cursor (for good reason). */ /* The reverse lookup doesn't "advance" cursor (for good reason). */
buffer->idx--; buffer->idx--;