From c074ebc466dcc9bcc0d8a5dd7e942dea974ff718 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 13 Feb 2013 11:22:42 -0500 Subject: [PATCH] [OTLayout] Minor refactoring --- src/hb-ot-layout-gpos-table.hh | 9 ++++++--- src/hb-ot-layout-gsubgpos-private.hh | 30 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 91bdcc4..71e0aee 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1029,8 +1029,9 @@ struct MarkBasePosFormat1 /* now we search backwards for a non-mark glyph */ hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1); + skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks); do { - if (!skippy_iter.prev (LookupFlag::IgnoreMarks)) return TRACE_RETURN (false); + if (!skippy_iter.prev ()) return TRACE_RETURN (false); /* We only want to attach to the first of a MultipleSubst sequence. Reject others. */ if (0 == get_lig_comp (c->buffer->info[skippy_iter.idx])) break; skippy_iter.reject (); @@ -1132,7 +1133,8 @@ struct MarkLigPosFormat1 /* now we search backwards for a non-mark glyph */ hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1); - if (!skippy_iter.prev (LookupFlag::IgnoreMarks)) return TRACE_RETURN (false); + skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks); + if (!skippy_iter.prev ()) return TRACE_RETURN (false); /* The following assertion is too strong, so we've disabled it. */ if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE)) {/*return TRACE_RETURN (false);*/} @@ -1247,7 +1249,8 @@ struct MarkMarkPosFormat1 /* now we search backwards for a suitable mark glyph until a non-mark glyph */ hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1); - if (!skippy_iter.prev (c->lookup_props & ~LookupFlag::IgnoreFlags)) return TRACE_RETURN (false); + skippy_iter.set_lookup_props (c->lookup_props & ~LookupFlag::IgnoreFlags); + if (!skippy_iter.prev ()) return TRACE_RETURN (false); if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) { return TRACE_RETURN (false); } diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index bbbb9c1..a9824eb 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -281,9 +281,9 @@ struct hb_apply_context_t has_glyph_classes (gdef.has_glyph_classes ()), debug_depth (0) {} - void set_recurse_func (recurse_func_t func) { recurse_func = func; } - void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; } - void set_lookup (const Lookup &l) { lookup_props = l.get_props (); } + inline void set_recurse_func (recurse_func_t func) { recurse_func = func; } + inline void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; } + inline void set_lookup (const Lookup &l) { lookup_props = l.get_props (); } struct skipping_forward_iterator_t { @@ -293,12 +293,17 @@ struct hb_apply_context_t bool context_match = false) { c = c_; + lookup_props = c->lookup_props; idx = start_index_; num_items = num_items_; mask = context_match ? -1 : c->lookup_mask; syllable = context_match ? 0 : c->buffer->cur().syllable (); end = c->buffer->len; } + inline void set_lookup_props (unsigned int lookup_props_) + { + lookup_props = lookup_props_; + } inline bool has_no_chance (void) const { return unlikely (num_items && idx + num_items >= end); @@ -307,7 +312,7 @@ struct hb_apply_context_t { num_items++; } - inline bool next (unsigned int lookup_props) + inline bool next (void) { assert (num_items > 0); do @@ -319,14 +324,11 @@ struct hb_apply_context_t num_items--; return (c->buffer->info[idx].mask & mask) && (!syllable || syllable == c->buffer->info[idx].syllable ()); } - inline bool next (void) - { - return next (c->lookup_props); - } unsigned int idx; protected: hb_apply_context_t *c; + unsigned int lookup_props; unsigned int num_items; hb_mask_t mask; uint8_t syllable; @@ -342,11 +344,16 @@ struct hb_apply_context_t bool match_syllable_ = true) { c = c_; + lookup_props = c->lookup_props; idx = start_index_; num_items = num_items_; mask = mask_ ? mask_ : c->lookup_mask; syllable = match_syllable_ ? c->buffer->cur().syllable () : 0; } + inline void set_lookup_props (unsigned int lookup_props_) + { + lookup_props = lookup_props_; + } inline bool has_no_chance (void) const { return unlikely (idx < num_items); @@ -355,7 +362,7 @@ struct hb_apply_context_t { num_items++; } - inline bool prev (unsigned int lookup_props) + inline bool prev (void) { assert (num_items > 0); do @@ -367,14 +374,11 @@ struct hb_apply_context_t num_items--; return (c->buffer->out_info[idx].mask & mask) && (!syllable || syllable == c->buffer->out_info[idx].syllable ()); } - inline bool prev (void) - { - return prev (c->lookup_props); - } unsigned int idx; protected: hb_apply_context_t *c; + unsigned int lookup_props; unsigned int num_items; hb_mask_t mask; uint8_t syllable; -- 2.7.4