src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh
changeset 50826 f5b95be8b6e2
parent 50352 25db2c8f3cf8
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh	Thu Jun 21 09:53:50 2018 -0700
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh	Thu Jun 21 12:54:30 2018 -0700
@@ -32,6 +32,7 @@
 #include "hb-private.hh"
 #include "hb-debug.hh"
 #include "hb-buffer-private.hh"
+#include "hb-map-private.hh"
 #include "hb-ot-layout-gdef-table.hh"
 #include "hb-set-private.hh"
 
@@ -59,6 +60,20 @@
     return HB_VOID;
   }
 
+  bool should_visit_lookup (unsigned int lookup_index)
+  {
+    if (is_lookup_done (lookup_index))
+      return false;
+    done_lookups->set (lookup_index, glyphs->get_population ());
+    return true;
+  }
+
+  bool is_lookup_done (unsigned int lookup_index)
+  {
+    // Have we visited this lookup with the current set of glyphs?
+    return done_lookups->get (lookup_index) == glyphs->get_population ();
+  }
+
   hb_face_t *face;
   hb_set_t *glyphs;
   recurse_func_t recurse_func;
@@ -67,14 +82,19 @@
 
   hb_closure_context_t (hb_face_t *face_,
                         hb_set_t *glyphs_,
+                        hb_map_t *done_lookups_,
                         unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
                           face (face_),
                           glyphs (glyphs_),
                           recurse_func (nullptr),
                           nesting_level_left (nesting_level_left_),
-                          debug_depth (0) {}
+                          debug_depth (0),
+                          done_lookups (done_lookups_) {}
 
   void set_recurse_func (recurse_func_t func) { recurse_func = func; }
+
+  private:
+  hb_map_t *done_lookups;
 };
 
 
@@ -855,7 +875,7 @@
 
   for (unsigned int i = 1; i < count; i++)
   {
-    while (buffer->idx < match_positions[i] && !buffer->in_error)
+    while (buffer->idx < match_positions[i] && buffer->successful)
     {
       if (!is_mark_ligature) {
         unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
@@ -990,7 +1010,7 @@
       match_positions[j] += delta;
   }
 
-  for (unsigned int i = 0; i < lookupCount && !buffer->in_error; i++)
+  for (unsigned int i = 0; i < lookupCount && buffer->successful; i++)
   {
     unsigned int idx = lookupRecord[i].sequenceIndex;
     if (idx >= count)
@@ -1713,10 +1733,10 @@
     const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     chain_context_closure_lookup (c,
-                                  backtrack.len, backtrack.array,
-                                  input.len, input.array,
-                                  lookahead.len, lookahead.array,
-                                  lookup.len, lookup.array,
+                                  backtrack.len, backtrack.arrayZ,
+                                  input.len, input.arrayZ,
+                                  lookahead.len, lookahead.arrayZ,
+                                  lookup.len, lookup.arrayZ,
                                   lookup_context);
   }
 
@@ -1727,10 +1747,10 @@
     const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     chain_context_collect_glyphs_lookup (c,
-                                         backtrack.len, backtrack.array,
-                                         input.len, input.array,
-                                         lookahead.len, lookahead.array,
-                                         lookup.len, lookup.array,
+                                         backtrack.len, backtrack.arrayZ,
+                                         input.len, input.arrayZ,
+                                         lookahead.len, lookahead.arrayZ,
+                                         lookup.len, lookup.arrayZ,
                                          lookup_context);
   }
 
@@ -1741,10 +1761,10 @@
     const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return_trace (chain_context_would_apply_lookup (c,
-                                                    backtrack.len, backtrack.array,
-                                                    input.len, input.array,
-                                                    lookahead.len, lookahead.array, lookup.len,
-                                                    lookup.array, lookup_context));
+                                                    backtrack.len, backtrack.arrayZ,
+                                                    input.len, input.arrayZ,
+                                                    lookahead.len, lookahead.arrayZ, lookup.len,
+                                                    lookup.arrayZ, lookup_context));
   }
 
   inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const
@@ -1754,10 +1774,10 @@
     const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return_trace (chain_context_apply_lookup (c,
-                                              backtrack.len, backtrack.array,
-                                              input.len, input.array,
-                                              lookahead.len, lookahead.array, lookup.len,
-                                              lookup.array, lookup_context));
+                                              backtrack.len, backtrack.arrayZ,
+                                              input.len, input.arrayZ,
+                                              lookahead.len, lookahead.arrayZ, lookup.len,
+                                              lookup.arrayZ, lookup_context));
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -2072,10 +2092,10 @@
       {this, this, this}
     };
     chain_context_closure_lookup (c,
-                                  backtrack.len, (const HBUINT16 *) backtrack.array,
-                                  input.len, (const HBUINT16 *) input.array + 1,
-                                  lookahead.len, (const HBUINT16 *) lookahead.array,
-                                  lookup.len, lookup.array,
+                                  backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
+                                  input.len, (const HBUINT16 *) input.arrayZ + 1,
+                                  lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
+                                  lookup.len, lookup.arrayZ,
                                   lookup_context);
   }
 
@@ -2093,10 +2113,10 @@
       {this, this, this}
     };
     chain_context_collect_glyphs_lookup (c,
-                                         backtrack.len, (const HBUINT16 *) backtrack.array,
-                                         input.len, (const HBUINT16 *) input.array + 1,
-                                         lookahead.len, (const HBUINT16 *) lookahead.array,
-                                         lookup.len, lookup.array,
+                                         backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
+                                         input.len, (const HBUINT16 *) input.arrayZ + 1,
+                                         lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
+                                         lookup.len, lookup.arrayZ,
                                          lookup_context);
   }
 
@@ -2112,10 +2132,10 @@
       {this, this, this}
     };
     return_trace (chain_context_would_apply_lookup (c,
-                                                    backtrack.len, (const HBUINT16 *) backtrack.array,
-                                                    input.len, (const HBUINT16 *) input.array + 1,
-                                                    lookahead.len, (const HBUINT16 *) lookahead.array,
-                                                    lookup.len, lookup.array, lookup_context));
+                                                    backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
+                                                    input.len, (const HBUINT16 *) input.arrayZ + 1,
+                                                    lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
+                                                    lookup.len, lookup.arrayZ, lookup_context));
   }
 
   inline const Coverage &get_coverage (void) const
@@ -2139,10 +2159,10 @@
       {this, this, this}
     };
     return_trace (chain_context_apply_lookup (c,
-                                              backtrack.len, (const HBUINT16 *) backtrack.array,
-                                              input.len, (const HBUINT16 *) input.array + 1,
-                                              lookahead.len, (const HBUINT16 *) lookahead.array,
-                                              lookup.len, lookup.array, lookup_context));
+                                              backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
+                                              input.len, (const HBUINT16 *) input.arrayZ + 1,
+                                              lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
+                                              lookup.len, lookup.arrayZ, lookup_context));
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const