提交 365576d2 编写于 作者: B Behdad Esfahbod

[layout] Allocate iters in the context

Can be further optimized, but I think I didn't break anything.

Saves another 3% off Roboto shaping.
上级 514564f5
......@@ -684,8 +684,7 @@ struct PairPosFormat1
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
......@@ -755,8 +754,7 @@ struct PairPosFormat2
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
......@@ -906,8 +904,7 @@ struct CursivePosFormat1
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
if (!this_record.exitAnchor) return TRACE_RETURN (false);
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
......@@ -1051,8 +1048,7 @@ struct MarkBasePosFormat1
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
do {
......@@ -1157,8 +1153,7 @@ struct MarkLigPosFormat1
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
......@@ -1275,8 +1270,7 @@ struct MarkMarkPosFormat1
if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
skippy_iter.set_lookup_props (c->lookup_props & ~LookupFlag::IgnoreFlags);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
......
......@@ -469,6 +469,7 @@ struct hb_apply_context_t
unsigned int lookup_props;
const GDEF &gdef;
bool has_glyph_classes;
skipping_iterator_t iter_input, iter_context;
unsigned int debug_depth;
......@@ -485,13 +486,20 @@ struct hb_apply_context_t
lookup_props (0),
gdef (*hb_ot_layout_from_face (face)->gdef),
has_glyph_classes (gdef.has_glyph_classes ()),
iter_input (),
iter_context (),
debug_depth (0) {}
inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; }
inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; }
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 (); }
inline void set_lookup (const Lookup &l) { set_lookup_props (l.get_props ()); }
inline void set_lookup_props (unsigned int lookup_props_)
{
lookup_props = lookup_props_;
iter_input.init (this, false);
iter_context.init (this, true);
}
inline bool
match_properties_mark (hb_codepoint_t glyph,
......@@ -704,8 +712,7 @@ static inline bool match_input (hb_apply_context_t *c,
hb_buffer_t *buffer = c->buffer;
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, count - 1);
skippy_iter.set_match_func (match_func, match_data, input);
......@@ -874,8 +881,7 @@ static inline bool match_backtrack (hb_apply_context_t *c,
{
TRACE_APPLY (NULL);
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c, true);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context;
skippy_iter.reset (c->buffer->backtrack_len (), count);
skippy_iter.set_match_func (match_func, match_data, backtrack);
......@@ -895,8 +901,7 @@ static inline bool match_lookahead (hb_apply_context_t *c,
{
TRACE_APPLY (NULL);
hb_apply_context_t::skipping_iterator_t skippy_iter;
skippy_iter.init (c, true);
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context;
skippy_iter.reset (c->buffer->idx + offset - 1, count);
skippy_iter.set_match_func (match_func, match_data, lookahead);
......
......@@ -441,7 +441,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
OT::hb_apply_context_t c (1, font, buffer);
c.set_lookup_mask (plan->kern_mask);
c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
OT::hb_apply_context_t::skipping_iterator_t skippy_iter;
OT::hb_apply_context_t::skipping_iterator_t &skippy_iter = c.iter_input;
skippy_iter.init (&c);
unsigned int count = buffer->len;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册