57 recurse_func (this, lookup_index); |
58 recurse_func (this, lookup_index); |
58 nesting_level_left++; |
59 nesting_level_left++; |
59 return HB_VOID; |
60 return HB_VOID; |
60 } |
61 } |
61 |
62 |
|
63 bool should_visit_lookup (unsigned int lookup_index) |
|
64 { |
|
65 if (is_lookup_done (lookup_index)) |
|
66 return false; |
|
67 done_lookups->set (lookup_index, glyphs->get_population ()); |
|
68 return true; |
|
69 } |
|
70 |
|
71 bool is_lookup_done (unsigned int lookup_index) |
|
72 { |
|
73 // Have we visited this lookup with the current set of glyphs? |
|
74 return done_lookups->get (lookup_index) == glyphs->get_population (); |
|
75 } |
|
76 |
62 hb_face_t *face; |
77 hb_face_t *face; |
63 hb_set_t *glyphs; |
78 hb_set_t *glyphs; |
64 recurse_func_t recurse_func; |
79 recurse_func_t recurse_func; |
65 unsigned int nesting_level_left; |
80 unsigned int nesting_level_left; |
66 unsigned int debug_depth; |
81 unsigned int debug_depth; |
67 |
82 |
68 hb_closure_context_t (hb_face_t *face_, |
83 hb_closure_context_t (hb_face_t *face_, |
69 hb_set_t *glyphs_, |
84 hb_set_t *glyphs_, |
|
85 hb_map_t *done_lookups_, |
70 unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
86 unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
71 face (face_), |
87 face (face_), |
72 glyphs (glyphs_), |
88 glyphs (glyphs_), |
73 recurse_func (nullptr), |
89 recurse_func (nullptr), |
74 nesting_level_left (nesting_level_left_), |
90 nesting_level_left (nesting_level_left_), |
75 debug_depth (0) {} |
91 debug_depth (0), |
|
92 done_lookups (done_lookups_) {} |
76 |
93 |
77 void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
94 void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
|
95 |
|
96 private: |
|
97 hb_map_t *done_lookups; |
78 }; |
98 }; |
79 |
99 |
80 |
100 |
81 struct hb_would_apply_context_t : |
101 struct hb_would_apply_context_t : |
82 hb_dispatch_context_t<hb_would_apply_context_t, bool, HB_DEBUG_WOULD_APPLY> |
102 hb_dispatch_context_t<hb_would_apply_context_t, bool, HB_DEBUG_WOULD_APPLY> |
1711 TRACE_CLOSURE (this); |
1731 TRACE_CLOSURE (this); |
1712 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1732 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1713 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1733 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1714 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1734 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1715 chain_context_closure_lookup (c, |
1735 chain_context_closure_lookup (c, |
1716 backtrack.len, backtrack.array, |
1736 backtrack.len, backtrack.arrayZ, |
1717 input.len, input.array, |
1737 input.len, input.arrayZ, |
1718 lookahead.len, lookahead.array, |
1738 lookahead.len, lookahead.arrayZ, |
1719 lookup.len, lookup.array, |
1739 lookup.len, lookup.arrayZ, |
1720 lookup_context); |
1740 lookup_context); |
1721 } |
1741 } |
1722 |
1742 |
1723 inline void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const |
1743 inline void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const |
1724 { |
1744 { |
1725 TRACE_COLLECT_GLYPHS (this); |
1745 TRACE_COLLECT_GLYPHS (this); |
1726 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1746 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1727 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1747 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1728 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1748 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1729 chain_context_collect_glyphs_lookup (c, |
1749 chain_context_collect_glyphs_lookup (c, |
1730 backtrack.len, backtrack.array, |
1750 backtrack.len, backtrack.arrayZ, |
1731 input.len, input.array, |
1751 input.len, input.arrayZ, |
1732 lookahead.len, lookahead.array, |
1752 lookahead.len, lookahead.arrayZ, |
1733 lookup.len, lookup.array, |
1753 lookup.len, lookup.arrayZ, |
1734 lookup_context); |
1754 lookup_context); |
1735 } |
1755 } |
1736 |
1756 |
1737 inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
1757 inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
1738 { |
1758 { |
1739 TRACE_WOULD_APPLY (this); |
1759 TRACE_WOULD_APPLY (this); |
1740 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1760 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1741 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1761 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1742 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1762 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1743 return_trace (chain_context_would_apply_lookup (c, |
1763 return_trace (chain_context_would_apply_lookup (c, |
1744 backtrack.len, backtrack.array, |
1764 backtrack.len, backtrack.arrayZ, |
1745 input.len, input.array, |
1765 input.len, input.arrayZ, |
1746 lookahead.len, lookahead.array, lookup.len, |
1766 lookahead.len, lookahead.arrayZ, lookup.len, |
1747 lookup.array, lookup_context)); |
1767 lookup.arrayZ, lookup_context)); |
1748 } |
1768 } |
1749 |
1769 |
1750 inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
1770 inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
1751 { |
1771 { |
1752 TRACE_APPLY (this); |
1772 TRACE_APPLY (this); |
1753 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1773 const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); |
1754 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1774 const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); |
1755 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1775 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
1756 return_trace (chain_context_apply_lookup (c, |
1776 return_trace (chain_context_apply_lookup (c, |
1757 backtrack.len, backtrack.array, |
1777 backtrack.len, backtrack.arrayZ, |
1758 input.len, input.array, |
1778 input.len, input.arrayZ, |
1759 lookahead.len, lookahead.array, lookup.len, |
1779 lookahead.len, lookahead.arrayZ, lookup.len, |
1760 lookup.array, lookup_context)); |
1780 lookup.arrayZ, lookup_context)); |
1761 } |
1781 } |
1762 |
1782 |
1763 inline bool sanitize (hb_sanitize_context_t *c) const |
1783 inline bool sanitize (hb_sanitize_context_t *c) const |
1764 { |
1784 { |
1765 TRACE_SANITIZE (this); |
1785 TRACE_SANITIZE (this); |
2070 struct ChainContextClosureLookupContext lookup_context = { |
2090 struct ChainContextClosureLookupContext lookup_context = { |
2071 {intersects_coverage}, |
2091 {intersects_coverage}, |
2072 {this, this, this} |
2092 {this, this, this} |
2073 }; |
2093 }; |
2074 chain_context_closure_lookup (c, |
2094 chain_context_closure_lookup (c, |
2075 backtrack.len, (const HBUINT16 *) backtrack.array, |
2095 backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
2076 input.len, (const HBUINT16 *) input.array + 1, |
2096 input.len, (const HBUINT16 *) input.arrayZ + 1, |
2077 lookahead.len, (const HBUINT16 *) lookahead.array, |
2097 lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
2078 lookup.len, lookup.array, |
2098 lookup.len, lookup.arrayZ, |
2079 lookup_context); |
2099 lookup_context); |
2080 } |
2100 } |
2081 |
2101 |
2082 inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
2102 inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
2083 { |
2103 { |
2110 struct ChainContextApplyLookupContext lookup_context = { |
2130 struct ChainContextApplyLookupContext lookup_context = { |
2111 {match_coverage}, |
2131 {match_coverage}, |
2112 {this, this, this} |
2132 {this, this, this} |
2113 }; |
2133 }; |
2114 return_trace (chain_context_would_apply_lookup (c, |
2134 return_trace (chain_context_would_apply_lookup (c, |
2115 backtrack.len, (const HBUINT16 *) backtrack.array, |
2135 backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
2116 input.len, (const HBUINT16 *) input.array + 1, |
2136 input.len, (const HBUINT16 *) input.arrayZ + 1, |
2117 lookahead.len, (const HBUINT16 *) lookahead.array, |
2137 lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
2118 lookup.len, lookup.array, lookup_context)); |
2138 lookup.len, lookup.arrayZ, lookup_context)); |
2119 } |
2139 } |
2120 |
2140 |
2121 inline const Coverage &get_coverage (void) const |
2141 inline const Coverage &get_coverage (void) const |
2122 { |
2142 { |
2123 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
2143 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |