[OTLayout] Remove bogus caching of glyph property

This commit is contained in:
Behdad Esfahbod 2013-02-13 11:13:06 -05:00
parent 6b1e3502e2
commit 407fc12466
3 changed files with 26 additions and 42 deletions

View File

@ -878,7 +878,7 @@ struct CursivePosFormat1
TRACE_APPLY (this); TRACE_APPLY (this);
/* We don't handle mark glyphs here. */ /* We don't handle mark glyphs here. */
if (c->property & HB_OT_LAYOUT_GLYPH_PROPS_MARK) return TRACE_RETURN (false); if (c->buffer->cur().glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK) return TRACE_RETURN (false);
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1); hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false); if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
@ -1028,17 +1028,16 @@ struct MarkBasePosFormat1
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false); if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */ /* now we search backwards for a non-mark glyph */
unsigned int property;
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1); hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
do { do {
if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks)) return TRACE_RETURN (false); if (!skippy_iter.prev (LookupFlag::IgnoreMarks)) return TRACE_RETURN (false);
/* We only want to attach to the first of a MultipleSubst sequence. Reject others. */ /* 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; if (0 == get_lig_comp (c->buffer->info[skippy_iter.idx])) break;
skippy_iter.reject (); skippy_iter.reject ();
} while (1); } while (1);
/* The following assertion is too strong, so we've disabled it. */ /* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/} if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/}
unsigned int base_index = (this+baseCoverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint); unsigned int base_index = (this+baseCoverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint);
if (base_index == NOT_COVERED) return TRACE_RETURN (false); if (base_index == NOT_COVERED) return TRACE_RETURN (false);
@ -1132,12 +1131,11 @@ struct MarkLigPosFormat1
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false); if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */ /* now we search backwards for a non-mark glyph */
unsigned int property;
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1); hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks)) return TRACE_RETURN (false); if (!skippy_iter.prev (LookupFlag::IgnoreMarks)) return TRACE_RETURN (false);
/* The following assertion is too strong, so we've disabled it. */ /* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE)) {/*return TRACE_RETURN (false);*/} if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE)) {/*return TRACE_RETURN (false);*/}
unsigned int j = skippy_iter.idx; unsigned int j = skippy_iter.idx;
unsigned int lig_index = (this+ligatureCoverage).get_coverage (c->buffer->info[j].codepoint); unsigned int lig_index = (this+ligatureCoverage).get_coverage (c->buffer->info[j].codepoint);
@ -1248,11 +1246,10 @@ struct MarkMarkPosFormat1
if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false); if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a suitable mark glyph until a non-mark glyph */ /* now we search backwards for a suitable mark glyph until a non-mark glyph */
unsigned int property;
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1); hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (!skippy_iter.prev (&property, c->lookup_props & ~LookupFlag::IgnoreFlags)) return TRACE_RETURN (false); if (!skippy_iter.prev (c->lookup_props & ~LookupFlag::IgnoreFlags)) return TRACE_RETURN (false);
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) return TRACE_RETURN (false); if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) { return TRACE_RETURN (false); }
unsigned int j = skippy_iter.idx; unsigned int j = skippy_iter.idx;
@ -1474,7 +1471,7 @@ struct PosLookup : Lookup
inline bool apply_once (hb_apply_context_t *c) const inline bool apply_once (hb_apply_context_t *c) const
{ {
TRACE_APPLY (this); TRACE_APPLY (this);
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->property)) if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props))
return TRACE_RETURN (false); return TRACE_RETURN (false);
return TRACE_RETURN (process (c)); return TRACE_RETURN (process (c));
} }
@ -1629,11 +1626,9 @@ inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int l
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
const PosLookup &l = gpos.get_lookup (lookup_index); const PosLookup &l = gpos.get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_property = c->property;
c->set_lookup (l); c->set_lookup (l);
bool ret = l.apply_once (c); bool ret = l.apply_once (c);
c->lookup_props = saved_lookup_props; c->lookup_props = saved_lookup_props;
c->property = saved_property;
return ret; return ret;
} }

View File

@ -272,7 +272,8 @@ struct Sequence
TRACE_APPLY (this); TRACE_APPLY (this);
if (unlikely (!substitute.len)) return TRACE_RETURN (false); if (unlikely (!substitute.len)) return TRACE_RETURN (false);
unsigned int klass = c->property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0; unsigned int klass = c->buffer->cur().glyph_props() &
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0;
unsigned int count = substitute.len; unsigned int count = substitute.len;
for (unsigned int i = 0; i < count; i++) { for (unsigned int i = 0; i < count; i++) {
set_lig_props_for_component (c->buffer->cur(), i); set_lig_props_for_component (c->buffer->cur(), i);
@ -1193,7 +1194,7 @@ struct SubstLookup : Lookup
inline bool apply_once (hb_apply_context_t *c) const inline bool apply_once (hb_apply_context_t *c) const
{ {
TRACE_APPLY (this); TRACE_APPLY (this);
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->property)) if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props))
return TRACE_RETURN (false); return TRACE_RETURN (false);
return TRACE_RETURN (process (c)); return TRACE_RETURN (process (c));
} }
@ -1399,11 +1400,9 @@ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index); const SubstLookup &l = gsub.get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_property = c->property;
c->set_lookup (l); c->set_lookup (l);
bool ret = l.apply_once (c); bool ret = l.apply_once (c);
c->lookup_props = saved_lookup_props; c->lookup_props = saved_lookup_props;
c->property = saved_property;
return ret; return ret;
} }

View File

@ -263,7 +263,6 @@ struct hb_apply_context_t
recurse_func_t recurse_func; recurse_func_t recurse_func;
unsigned int nesting_level_left; unsigned int nesting_level_left;
unsigned int lookup_props; unsigned int lookup_props;
unsigned int property; /* propety of first glyph */
const GDEF &gdef; const GDEF &gdef;
bool has_glyph_classes; bool has_glyph_classes;
unsigned int debug_depth; unsigned int debug_depth;
@ -277,7 +276,7 @@ struct hb_apply_context_t
lookup_mask (lookup_mask_), lookup_mask (lookup_mask_),
recurse_func (NULL), recurse_func (NULL),
nesting_level_left (MAX_NESTING_LEVEL), nesting_level_left (MAX_NESTING_LEVEL),
lookup_props (0), property (0), lookup_props (0),
gdef (*hb_ot_layout_from_face (face)->gdef), gdef (*hb_ot_layout_from_face (face)->gdef),
has_glyph_classes (gdef.has_glyph_classes ()), has_glyph_classes (gdef.has_glyph_classes ()),
debug_depth (0) {} debug_depth (0) {}
@ -308,8 +307,7 @@ struct hb_apply_context_t
{ {
num_items++; num_items++;
} }
inline bool next (unsigned int *property_out, inline bool next (unsigned int lookup_props)
unsigned int lookup_props)
{ {
assert (num_items > 0); assert (num_items > 0);
do do
@ -317,13 +315,13 @@ struct hb_apply_context_t
if (has_no_chance ()) if (has_no_chance ())
return false; return false;
idx++; idx++;
} while (c->should_skip (&c->buffer->info[idx], lookup_props, property_out)); } while (c->should_skip (&c->buffer->info[idx], lookup_props));
num_items--; num_items--;
return (c->buffer->info[idx].mask & mask) && (!syllable || syllable == c->buffer->info[idx].syllable ()); return (c->buffer->info[idx].mask & mask) && (!syllable || syllable == c->buffer->info[idx].syllable ());
} }
inline bool next (unsigned int *property_out = NULL) inline bool next (void)
{ {
return next (property_out, c->lookup_props); return next (c->lookup_props);
} }
unsigned int idx; unsigned int idx;
@ -357,8 +355,7 @@ struct hb_apply_context_t
{ {
num_items++; num_items++;
} }
inline bool prev (unsigned int *property_out, inline bool prev (unsigned int lookup_props)
unsigned int lookup_props)
{ {
assert (num_items > 0); assert (num_items > 0);
do do
@ -366,13 +363,13 @@ struct hb_apply_context_t
if (has_no_chance ()) if (has_no_chance ())
return false; return false;
idx--; idx--;
} while (c->should_skip (&c->buffer->out_info[idx], lookup_props, property_out)); } while (c->should_skip (&c->buffer->out_info[idx], lookup_props));
num_items--; num_items--;
return (c->buffer->out_info[idx].mask & mask) && (!syllable || syllable == c->buffer->out_info[idx].syllable ()); return (c->buffer->out_info[idx].mask & mask) && (!syllable || syllable == c->buffer->out_info[idx].syllable ());
} }
inline bool prev (unsigned int *property_out = NULL) inline bool prev (void)
{ {
return prev (property_out, c->lookup_props); return prev (c->lookup_props);
} }
unsigned int idx; unsigned int idx;
@ -423,27 +420,22 @@ struct hb_apply_context_t
inline bool inline bool
check_glyph_property (hb_glyph_info_t *info, check_glyph_property (hb_glyph_info_t *info,
unsigned int lookup_props, unsigned int lookup_props) const
unsigned int *property_out) const
{ {
unsigned int property; unsigned int property;
property = info->glyph_props(); property = info->glyph_props();
*property_out = property;
return match_properties (info->codepoint, property, lookup_props); return match_properties (info->codepoint, property, lookup_props);
} }
inline bool inline bool
should_skip (hb_glyph_info_t *info, should_skip (hb_glyph_info_t *info,
unsigned int lookup_props, unsigned int lookup_props) const
unsigned int *property_out) const
{ {
unsigned int property; unsigned int property;
property = info->glyph_props(); property = info->glyph_props();
if (property_out)
*property_out = property;
return !match_properties (info->codepoint, property, lookup_props); return !match_properties (info->codepoint, property, lookup_props);
} }
@ -451,7 +443,7 @@ struct hb_apply_context_t
inline bool should_skip_current_glyph (void) const inline bool should_skip_current_glyph (void) const
{ {
return should_skip (&buffer->cur(), lookup_props, NULL); return should_skip (&buffer->cur(), lookup_props);
} }
inline void set_class (hb_codepoint_t glyph_index, unsigned int class_guess) const inline void set_class (hb_codepoint_t glyph_index, unsigned int class_guess) const
@ -618,7 +610,7 @@ static inline bool match_input (hb_apply_context_t *c,
* ligate with a conjunct...) * ligate with a conjunct...)
*/ */
bool is_mark_ligature = !!(c->property & HB_OT_LAYOUT_GLYPH_PROPS_MARK); bool is_mark_ligature = !!(c->buffer->cur().glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
unsigned int total_component_count = 0; unsigned int total_component_count = 0;
total_component_count += get_lig_num_comps (c->buffer->cur()); total_component_count += get_lig_num_comps (c->buffer->cur());
@ -628,9 +620,7 @@ static inline bool match_input (hb_apply_context_t *c,
for (unsigned int i = 1; i < count; i++) for (unsigned int i = 1; i < count; i++)
{ {
unsigned int property; if (!skippy_iter.next ()) return TRACE_RETURN (false);
if (!skippy_iter.next (&property)) return TRACE_RETURN (false);
if (likely (!match_func (c->buffer->info[skippy_iter.idx].codepoint, input[i - 1], match_data))) return TRACE_RETURN (false); if (likely (!match_func (c->buffer->info[skippy_iter.idx].codepoint, input[i - 1], match_data))) return TRACE_RETURN (false);
@ -651,7 +641,7 @@ static inline bool match_input (hb_apply_context_t *c,
return TRACE_RETURN (false); return TRACE_RETURN (false);
} }
is_mark_ligature = is_mark_ligature && (property & HB_OT_LAYOUT_GLYPH_PROPS_MARK); is_mark_ligature = is_mark_ligature && (c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
total_component_count += get_lig_num_comps (c->buffer->info[skippy_iter.idx]); total_component_count += get_lig_num_comps (c->buffer->info[skippy_iter.idx]);
} }