src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh
changeset 50826 f5b95be8b6e2
parent 50352 25db2c8f3cf8
equal deleted inserted replaced
50825:aa0a35b071fb 50826:f5b95be8b6e2
    30 #define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
    30 #define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
    31 
    31 
    32 #include "hb-private.hh"
    32 #include "hb-private.hh"
    33 #include "hb-debug.hh"
    33 #include "hb-debug.hh"
    34 #include "hb-buffer-private.hh"
    34 #include "hb-buffer-private.hh"
       
    35 #include "hb-map-private.hh"
    35 #include "hb-ot-layout-gdef-table.hh"
    36 #include "hb-ot-layout-gdef-table.hh"
    36 #include "hb-set-private.hh"
    37 #include "hb-set-private.hh"
    37 
    38 
    38 
    39 
    39 namespace OT {
    40 namespace OT {
    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>
   853   }
   873   }
   854   c->replace_glyph_with_ligature (lig_glyph, klass);
   874   c->replace_glyph_with_ligature (lig_glyph, klass);
   855 
   875 
   856   for (unsigned int i = 1; i < count; i++)
   876   for (unsigned int i = 1; i < count; i++)
   857   {
   877   {
   858     while (buffer->idx < match_positions[i] && !buffer->in_error)
   878     while (buffer->idx < match_positions[i] && buffer->successful)
   859     {
   879     {
   860       if (!is_mark_ligature) {
   880       if (!is_mark_ligature) {
   861         unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
   881         unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
   862         if (this_comp == 0)
   882         if (this_comp == 0)
   863           this_comp = last_num_components;
   883           this_comp = last_num_components;
   988     /* Convert positions to new indexing. */
  1008     /* Convert positions to new indexing. */
   989     for (unsigned int j = 0; j < count; j++)
  1009     for (unsigned int j = 0; j < count; j++)
   990       match_positions[j] += delta;
  1010       match_positions[j] += delta;
   991   }
  1011   }
   992 
  1012 
   993   for (unsigned int i = 0; i < lookupCount && !buffer->in_error; i++)
  1013   for (unsigned int i = 0; i < lookupCount && buffer->successful; i++)
   994   {
  1014   {
   995     unsigned int idx = lookupRecord[i].sequenceIndex;
  1015     unsigned int idx = lookupRecord[i].sequenceIndex;
   996     if (idx >= count)
  1016     if (idx >= count)
   997       continue;
  1017       continue;
   998 
  1018 
  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   {
  2091     struct ChainContextCollectGlyphsLookupContext lookup_context = {
  2111     struct ChainContextCollectGlyphsLookupContext lookup_context = {
  2092       {collect_coverage},
  2112       {collect_coverage},
  2093       {this, this, this}
  2113       {this, this, this}
  2094     };
  2114     };
  2095     chain_context_collect_glyphs_lookup (c,
  2115     chain_context_collect_glyphs_lookup (c,
  2096                                          backtrack.len, (const HBUINT16 *) backtrack.array,
  2116                                          backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
  2097                                          input.len, (const HBUINT16 *) input.array + 1,
  2117                                          input.len, (const HBUINT16 *) input.arrayZ + 1,
  2098                                          lookahead.len, (const HBUINT16 *) lookahead.array,
  2118                                          lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
  2099                                          lookup.len, lookup.array,
  2119                                          lookup.len, lookup.arrayZ,
  2100                                          lookup_context);
  2120                                          lookup_context);
  2101   }
  2121   }
  2102 
  2122 
  2103   inline bool would_apply (hb_would_apply_context_t *c) const
  2123   inline bool would_apply (hb_would_apply_context_t *c) const
  2104   {
  2124   {
  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);
  2137     struct ChainContextApplyLookupContext lookup_context = {
  2157     struct ChainContextApplyLookupContext lookup_context = {
  2138       {match_coverage},
  2158       {match_coverage},
  2139       {this, this, this}
  2159       {this, this, this}
  2140     };
  2160     };
  2141     return_trace (chain_context_apply_lookup (c,
  2161     return_trace (chain_context_apply_lookup (c,
  2142                                               backtrack.len, (const HBUINT16 *) backtrack.array,
  2162                                               backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
  2143                                               input.len, (const HBUINT16 *) input.array + 1,
  2163                                               input.len, (const HBUINT16 *) input.arrayZ + 1,
  2144                                               lookahead.len, (const HBUINT16 *) lookahead.array,
  2164                                               lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
  2145                                               lookup.len, lookup.array, lookup_context));
  2165                                               lookup.len, lookup.arrayZ, lookup_context));
  2146   }
  2166   }
  2147 
  2167 
  2148   inline bool sanitize (hb_sanitize_context_t *c) const
  2168   inline bool sanitize (hb_sanitize_context_t *c) const
  2149   {
  2169   {
  2150     TRACE_SANITIZE (this);
  2170     TRACE_SANITIZE (this);