From 50b8dc79daffc7ef671dd5eedfea47f8d5e946f4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 17 Feb 2015 18:14:17 +0300 Subject: [PATCH] [layout] Add may_dispatch() No functional change right now. --- src/hb-ot-layout-gpos-table.hh | 7 +++++++ src/hb-ot-layout-gsub-table.hh | 6 ++++++ src/hb-ot-layout-gsubgpos-private.hh | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index fb99f4d6..b804bdd8 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -548,6 +548,7 @@ struct SinglePos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); case 2: return TRACE_RETURN (c->dispatch (u.format2)); @@ -853,6 +854,7 @@ struct PairPos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); case 2: return TRACE_RETURN (c->dispatch (u.format2)); @@ -1022,6 +1024,7 @@ struct CursivePos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -1124,6 +1127,7 @@ struct MarkBasePos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -1248,6 +1252,7 @@ struct MarkLigPos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -1370,6 +1375,7 @@ struct MarkMarkPos inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -1430,6 +1436,7 @@ struct PosLookupSubTable inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const { TRACE_DISPATCH (this, lookup_type); + if (unlikely (!c->may_dispatch (this, &u.sub_format))) TRACE_RETURN (c->default_return_value ()); switch (lookup_type) { case Single: return TRACE_RETURN (u.single.dispatch (c)); case Pair: return TRACE_RETURN (u.pair.dispatch (c)); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 556760cb..c1d64b54 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -225,6 +225,7 @@ struct SingleSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); case 2: return TRACE_RETURN (c->dispatch (u.format2)); @@ -428,6 +429,7 @@ struct MultipleSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -581,6 +583,7 @@ struct AlternateSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -901,6 +904,7 @@ struct LigatureSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -1067,6 +1071,7 @@ struct ReverseChainSingleSubst inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); default:return TRACE_RETURN (c->default_return_value ()); @@ -1115,6 +1120,7 @@ struct SubstLookupSubTable inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const { TRACE_DISPATCH (this, lookup_type); + if (unlikely (!c->may_dispatch (this, &u.sub_format))) TRACE_RETURN (c->default_return_value ()); switch (lookup_type) { case Single: return TRACE_RETURN (u.single.dispatch (c)); case Multiple: return TRACE_RETURN (u.multiple.dispatch (c)); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index c06fac8f..2751c824 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -58,6 +58,8 @@ struct hb_closure_context_t static const unsigned int max_debug_depth = HB_DEBUG_CLOSURE; typedef hb_void_t return_t; typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index); + template + inline bool may_dispatch (const T *obj, const F *format) { return true; } template inline return_t dispatch (const T &obj) { obj.closure (this); return HB_VOID; } static return_t default_return_value (void) { return HB_VOID; } @@ -107,6 +109,8 @@ struct hb_would_apply_context_t inline const char *get_name (void) { return "WOULD_APPLY"; } static const unsigned int max_debug_depth = HB_DEBUG_WOULD_APPLY; typedef bool return_t; + template + inline bool may_dispatch (const T *obj, const F *format) { return true; } template inline return_t dispatch (const T &obj) { return obj.would_apply (this); } static return_t default_return_value (void) { return false; } @@ -146,6 +150,8 @@ struct hb_collect_glyphs_context_t static const unsigned int max_debug_depth = HB_DEBUG_COLLECT_GLYPHS; typedef hb_void_t return_t; typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index); + template + inline bool may_dispatch (const T *obj, const F *format) { return true; } template inline return_t dispatch (const T &obj) { obj.collect_glyphs (this); return HB_VOID; } static return_t default_return_value (void) { return HB_VOID; } @@ -237,6 +243,8 @@ struct hb_get_coverage_context_t inline const char *get_name (void) { return "GET_COVERAGE"; } static const unsigned int max_debug_depth = HB_DEBUG_GET_COVERAGE; typedef const Coverage &return_t; + template + inline bool may_dispatch (const T *obj, const F *format) { return true; } template inline return_t dispatch (const T &obj) { return obj.get_coverage (); } static return_t default_return_value (void) { return Null(Coverage); } @@ -442,6 +450,8 @@ struct hb_apply_context_t static const unsigned int max_debug_depth = HB_DEBUG_APPLY; typedef bool return_t; typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup_index); + template + inline bool may_dispatch (const T *obj, const F *format) { return true; } template inline return_t dispatch (const T &obj) { return obj.apply (this); } static return_t default_return_value (void) { return false; } @@ -1503,6 +1513,7 @@ struct Context inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); case 2: return TRACE_RETURN (c->dispatch (u.format2)); @@ -2127,6 +2138,7 @@ struct ChainContext inline typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); + if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_return_value ()); switch (u.format) { case 1: return TRACE_RETURN (c->dispatch (u.format1)); case 2: return TRACE_RETURN (c->dispatch (u.format2)); -- GitLab