[HarfBuzz] harfbuzz: Branch 'master' - 3 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Dec 4 14:13:24 PST 2012


 src/hb-ot-layout-gpos-table.hh       |   30 +++++++++---------
 src/hb-ot-layout-gsub-table.hh       |   30 +++++++++---------
 src/hb-ot-layout-gsubgpos-private.hh |   57 ++++++++++++++++++++++-------------
 3 files changed, 66 insertions(+), 51 deletions(-)

New commits:
commit 4a350d0eb25db60d95638664c892d4c8dacf050b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Dec 4 17:13:09 2012 -0500

    [OTLayout] Reuse context in collect_glyphs() recursion

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 69c1739..63c23d5 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -158,13 +158,24 @@ struct hb_collect_glyphs_context_t
 
     /* Note that GPOS sets recurse_func to NULL already, so it doesn't get
      * past the previous check.  For GSUB, we only want to collect the output
-     * glyphs in the recursion.  If those are not requested, we can go home now. */
+     * glyphs in the recursion.  If output is not requested, we can go home now. */
+
+    if (output == hb_set_get_empty ())
+      return VOID;
+
+    hb_set_t *old_before = before;
+    hb_set_t *old_input  = input;
+    hb_set_t *old_after  = after;
+    before = input = after = hb_set_get_empty ();
 
     nesting_level_left--;
-    /* Only collect output glyphs in the recursion. */
-    hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, output, nesting_level_left);
-    recurse_func (&new_c, lookup_index);
+    recurse_func (this, lookup_index);
     nesting_level_left++;
+
+    before = old_before;
+    input  = old_input;
+    after  = old_after;
+
     return VOID;
   }
 
commit 8303593ba1db06e402eab52df47f21f13049112d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Dec 4 17:08:41 2012 -0500

    Minor
    
    Use pointers instead of references, in preparation for upcoming change.

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index f98bd13..d27ce4f 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -422,7 +422,7 @@ struct SinglePosFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
   }
 
   inline const Coverage &get_coverage (void) const
@@ -467,7 +467,7 @@ struct SinglePosFormat2
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
   }
 
   inline const Coverage &get_coverage (void) const
@@ -572,7 +572,7 @@ struct PairSet
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
     {
-      c->input.add (record->secondGlyph);
+      c->input->add (record->secondGlyph);
       record = &StructAtOffset<PairValueRecord> (record, record_size);
     }
   }
@@ -638,7 +638,7 @@ struct PairPosFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
     unsigned int count = pairSet.len;
     for (unsigned int i = 0; i < count; i++)
       (this+pairSet[i]).collect_glyphs (c, &valueFormat1);
@@ -701,19 +701,19 @@ struct PairPosFormat2
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    /* (this+coverage).add_coverage (&c->input); // Don't need this. */
+    /* (this+coverage).add_coverage (c->input); // Don't need this. */
 
     /* TODO only add values for pairs that have nonzero adjustments. */
 
     unsigned int count1 = class1Count;
     const ClassDef &klass1 = this+classDef1;
     for (unsigned int i = 0; i < count1; i++)
-      klass1.add_class (&c->input, i);
+      klass1.add_class (c->input, i);
 
     unsigned int count2 = class2Count;
     const ClassDef &klass2 = this+classDef2;
     for (unsigned int i = 0; i < count2; i++)
-      klass2.add_class (&c->input, i);
+      klass2.add_class (c->input, i);
   }
 
   inline const Coverage &get_coverage (void) const
@@ -859,7 +859,7 @@ struct CursivePosFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
   }
 
   inline const Coverage &get_coverage (void) const
@@ -1005,8 +1005,8 @@ struct MarkBasePosFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+markCoverage).add_coverage (&c->input);
-    (this+baseCoverage).add_coverage (&c->input);
+    (this+markCoverage).add_coverage (c->input);
+    (this+baseCoverage).add_coverage (c->input);
     /* TODO only add combinations that have nonzero adjustment. */
   }
 
@@ -1109,8 +1109,8 @@ struct MarkLigPosFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+markCoverage).add_coverage (&c->input);
-    (this+ligatureCoverage).add_coverage (&c->input);
+    (this+markCoverage).add_coverage (c->input);
+    (this+ligatureCoverage).add_coverage (c->input);
     /* TODO only add combinations that have nonzero adjustment. */
   }
 
@@ -1225,8 +1225,8 @@ struct MarkMarkPosFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+mark1Coverage).add_coverage (&c->input);
-    (this+mark2Coverage).add_coverage (&c->input);
+    (this+mark1Coverage).add_coverage (c->input);
+    (this+mark2Coverage).add_coverage (c->input);
     /* TODO only add combinations that have nonzero adjustment. */
   }
 
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 69572ef..2642acb 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -54,8 +54,8 @@ struct SingleSubstFormat1
     Coverage::Iter iter;
     for (iter.init (this+coverage); iter.more (); iter.next ()) {
       hb_codepoint_t glyph_id = iter.get_glyph ();
-      c->input.add (glyph_id);
-      c->output.add ((glyph_id + deltaGlyphID) & 0xFFFF);
+      c->input->add (glyph_id);
+      c->output->add ((glyph_id + deltaGlyphID) & 0xFFFF);
     }
   }
 
@@ -130,8 +130,8 @@ struct SingleSubstFormat2
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
     for (iter.init (this+coverage); iter.more (); iter.next ()) {
-      c->input.add (iter.get_glyph ());
-      c->output.add (substitute[iter.get_coverage ()]);
+      c->input->add (iter.get_glyph ());
+      c->output->add (substitute[iter.get_coverage ()]);
     }
   }
 
@@ -264,7 +264,7 @@ struct Sequence
     TRACE_COLLECT_GLYPHS (this);
     unsigned int count = substitute.len;
     for (unsigned int i = 0; i < count; i++)
-      c->output.add (substitute[i]);
+      c->output->add (substitute[i]);
   }
 
   inline bool apply (hb_apply_context_t *c) const
@@ -320,7 +320,7 @@ struct MultipleSubstFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
     unsigned int count = sequence.len;
     for (unsigned int i = 0; i < count; i++)
 	(this+sequence[i]).collect_glyphs (c);
@@ -451,11 +451,11 @@ struct AlternateSubstFormat1
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
     for (iter.init (this+coverage); iter.more (); iter.next ()) {
-      c->input.add (iter.get_glyph ());
+      c->input->add (iter.get_glyph ());
       const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()];
       unsigned int count = alt_set.len;
       for (unsigned int i = 0; i < count; i++)
-	c->output.add (alt_set[i]);
+	c->output->add (alt_set[i]);
     }
   }
 
@@ -595,8 +595,8 @@ struct Ligature
     TRACE_COLLECT_GLYPHS (this);
     unsigned int count = component.len;
     for (unsigned int i = 1; i < count; i++)
-      c->input.add (component[i]);
-    c->output.add (ligGlyph);
+      c->input->add (component[i]);
+    c->output->add (ligGlyph);
   }
 
   inline bool would_apply (hb_would_apply_context_t *c) const
@@ -767,7 +767,7 @@ struct LigatureSubstFormat1
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
     for (iter.init (this+coverage); iter.more (); iter.next ()) {
-      c->input.add (iter.get_glyph ());
+      c->input->add (iter.get_glyph ());
       (this+ligatureSet[iter.get_coverage ()]).collect_glyphs (c);
     }
   }
@@ -933,20 +933,20 @@ struct ReverseChainSingleSubstFormat1
 
     unsigned int count;
 
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
 
     count = backtrack.len;
     for (unsigned int i = 0; i < count; i++)
-      (this+backtrack[i]).add_coverage (&c->before);
+      (this+backtrack[i]).add_coverage (c->before);
 
     count = lookahead.len;
     for (unsigned int i = 0; i < count; i++)
-      (this+lookahead[i]).add_coverage (&c->after);
+      (this+lookahead[i]).add_coverage (c->after);
 
     const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
     count = substitute.len;
     for (unsigned int i = 0; i < count; i++)
-      c->output.add (substitute[i]);
+      c->output->add (substitute[i]);
   }
 
   inline const Coverage &get_coverage (void) const
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index bdeae84..69c1739 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -162,17 +162,17 @@ struct hb_collect_glyphs_context_t
 
     nesting_level_left--;
     /* Only collect output glyphs in the recursion. */
-    hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, &output, nesting_level_left);
+    hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, output, nesting_level_left);
     recurse_func (&new_c, lookup_index);
     nesting_level_left++;
     return VOID;
   }
 
   hb_face_t *face;
-  hb_set_t &before;
-  hb_set_t &input;
-  hb_set_t &after;
-  hb_set_t &output;
+  hb_set_t *before;
+  hb_set_t *input;
+  hb_set_t *after;
+  hb_set_t *output;
   recurse_func_t recurse_func;
   unsigned int nesting_level_left;
   unsigned int debug_depth;
@@ -184,10 +184,10 @@ struct hb_collect_glyphs_context_t
 			       hb_set_t  *glyphs_output, /* OUT. May be NULL */
 			       unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
 			      face (face_),
-			      before (glyphs_before ? *glyphs_before : *hb_set_get_empty ()),
-			      input  (glyphs_input  ? *glyphs_input  : *hb_set_get_empty ()),
-			      after  (glyphs_after  ? *glyphs_after  : *hb_set_get_empty ()),
-			      output (glyphs_output ? *glyphs_output : *hb_set_get_empty ()),
+			      before (glyphs_before ? glyphs_before : hb_set_get_empty ()),
+			      input  (glyphs_input  ? glyphs_input  : hb_set_get_empty ()),
+			      after  (glyphs_after  ? glyphs_after  : hb_set_get_empty ()),
+			      output (glyphs_output ? glyphs_output : hb_set_get_empty ()),
 			      recurse_func (NULL),
 			      nesting_level_left (nesting_level_left_),
 			      debug_depth (0) {}
@@ -918,7 +918,7 @@ static inline void context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c
 						  const LookupRecord lookupRecord[],
 						  ContextCollectGlyphsLookupContext &lookup_context)
 {
-  collect_array (c, &c->input,
+  collect_array (c, c->input,
 		 inputCount ? inputCount - 1 : 0, input,
 		 lookup_context.funcs.collect, lookup_context.collect_data);
   recurse_lookups (c,
@@ -1090,7 +1090,7 @@ struct ContextFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
 
     struct ContextCollectGlyphsLookupContext lookup_context = {
       {collect_glyph},
@@ -1178,7 +1178,7 @@ struct ContextFormat2
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
 
     struct ContextCollectGlyphsLookupContext lookup_context = {
       {collect_class},
@@ -1268,7 +1268,7 @@ struct ContextFormat3
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage[0]).add_coverage (&c->input);
+    (this+coverage[0]).add_coverage (c->input);
 
     const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
     struct ContextCollectGlyphsLookupContext lookup_context = {
@@ -1428,13 +1428,13 @@ static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_contex
 						        const LookupRecord lookupRecord[],
 						        ChainContextCollectGlyphsLookupContext &lookup_context)
 {
-  collect_array (c, &c->before,
+  collect_array (c, c->before,
 		 backtrackCount, backtrack,
 		 lookup_context.funcs.collect, lookup_context.collect_data[0]);
-  collect_array (c, &c->input,
+  collect_array (c, c->input,
 		 inputCount ? inputCount - 1 : 0, input,
 		 lookup_context.funcs.collect, lookup_context.collect_data[1]);
-  collect_array (c, &c->after,
+  collect_array (c, c->after,
 		 lookaheadCount, lookahead,
 		 lookup_context.funcs.collect, lookup_context.collect_data[2]);
   recurse_lookups (c,
@@ -1647,7 +1647,7 @@ struct ChainContextFormat1
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
 
     struct ChainContextCollectGlyphsLookupContext lookup_context = {
       {collect_glyph},
@@ -1737,7 +1737,7 @@ struct ChainContextFormat2
   inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    (this+coverage).add_coverage (&c->input);
+    (this+coverage).add_coverage (c->input);
 
     struct ChainContextCollectGlyphsLookupContext lookup_context = {
       {collect_class},
@@ -1850,7 +1850,7 @@ struct ChainContextFormat3
     TRACE_COLLECT_GLYPHS (this);
     const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
 
-    (this+input[0]).add_coverage (&c->input);
+    (this+input[0]).add_coverage (c->input);
 
     const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
commit 1bcfa06d1173f219809542a7380ce77f1c907bec
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Dec 4 16:58:09 2012 -0500

    [OTLayout] Don't recurse in collect_glyphs() for GPOS

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 5ec7e07..f98bd13 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1446,7 +1446,7 @@ struct PosLookup : Lookup
   inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c) const
   {
     TRACE_COLLECT_GLYPHS (this);
-    c->set_recurse_func (process_recurse_func<hb_collect_glyphs_context_t>);
+    c->set_recurse_func (NULL);
     return TRACE_RETURN (process (c));
   }
 
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 7bf3e71..bdeae84 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -156,6 +156,10 @@ struct hb_collect_glyphs_context_t
     if (unlikely (nesting_level_left == 0 || !recurse_func))
       return default_return_value ();
 
+    /* Note that GPOS sets recurse_func to NULL already, so it doesn't get
+     * past the previous check.  For GSUB, we only want to collect the output
+     * glyphs in the recursion.  If those are not requested, we can go home now. */
+
     nesting_level_left--;
     /* Only collect output glyphs in the recursion. */
     hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, &output, nesting_level_left);



More information about the HarfBuzz mailing list