[pango/harfbuzz-ng] [HB] Propagate property of first glyph



commit 8bd68ca2afab4a0703c9a678bffbc683c310a408
Author: Behdad Esfahbod <behdad behdad org>
Date:   Sun May 17 09:34:41 2009 -0400

    [HB] Propagate property of first glyph
    
    This slightly grows code size.
---
 pango/opentype/hb-ot-layout-gsub-private.h     |  100 ++++++++++++-----------
 pango/opentype/hb-ot-layout-gsubgpos-private.h |    7 +-
 2 files changed, 56 insertions(+), 51 deletions(-)

diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h
index 044703a..74f4e36 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.h
+++ b/pango/opentype/hb-ot-layout-gsub-private.h
@@ -98,7 +98,7 @@ struct SingleSubst {
     }
   }
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
 
     hb_codepoint_t glyph_id = IN_CURGLYPH ();
 
@@ -139,7 +139,7 @@ struct Sequence {
       _hb_ot_layout_set_glyph_property (layout, substitute[n], property);
   }
 
-  inline bool substitute_sequence (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute_sequence (LOOKUP_ARGS_DEF) const {
 
     if (HB_UNLIKELY (!substitute.len))
       return false;
@@ -173,10 +173,10 @@ struct MultipleSubstFormat1 {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
 
     unsigned int index = (this+coverage) (IN_CURGLYPH ());
-    return (this+sequence[index]).substitute_sequence (LOOKUP_ARGS, property);
+    return (this+sequence[index]).substitute_sequence (LOOKUP_ARGS);
   }
 
   private:
@@ -196,9 +196,9 @@ struct MultipleSubst {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     switch (u.substFormat) {
-    case 1: return u.format1.substitute (LOOKUP_ARGS, property);
+    case 1: return u.format1.substitute (LOOKUP_ARGS);
     default:return false;
     }
   }
@@ -222,7 +222,7 @@ struct AlternateSubstFormat1 {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
 
     hb_codepoint_t glyph_id = IN_CURGLYPH ();
 
@@ -274,9 +274,9 @@ struct AlternateSubst {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     switch (u.substFormat) {
-    case 1: return u.format1.substitute (LOOKUP_ARGS, property);
+    case 1: return u.format1.substitute (LOOKUP_ARGS);
     default:return false;
     }
   }
@@ -300,7 +300,6 @@ struct Ligature {
   inline bool substitute_ligature (LOOKUP_ARGS_DEF, bool is_mark) const {
 
     unsigned int i, j;
-    unsigned int property;
     unsigned int count = compCount;
 
     if (HB_UNLIKELY (buffer->in_pos + count > buffer->in_length ||
@@ -403,7 +402,7 @@ struct LigatureSubstFormat1 {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
 
     hb_codepoint_t glyph_id = IN_CURGLYPH ();
 
@@ -432,9 +431,9 @@ struct LigatureSubst {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     switch (u.substFormat) {
-    case 1: return u.format1.substitute (LOOKUP_ARGS, property);
+    case 1: return u.format1.substitute (LOOKUP_ARGS);
     default:return false;
     }
   }
@@ -453,7 +452,7 @@ static inline bool substitute_lookup (LOOKUP_ARGS_DEF, unsigned int lookup_index
 
 struct ContextSubst : Context {
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     return this->apply (LOOKUP_ARGS, substitute_lookup);
   }
 };
@@ -500,7 +499,7 @@ ASSERT_SIZE (ChainSubRuleSet, 2);
 
 struct ChainContextSubstFormat1 {
   /* TODO */
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     return false;
   }
 
@@ -560,7 +559,7 @@ ASSERT_SIZE (ChainSubClassSet, 2);
 
 struct ChainContextSubstFormat2 {
   /* TODO */
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     return false;
   }
 
@@ -590,7 +589,7 @@ ASSERT_SIZE (ChainContextSubstFormat2, 12);
 
 struct ChainContextSubstFormat3 {
   /* TODO */
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     return false;
   }
 
@@ -622,11 +621,11 @@ struct ChainContextSubst {
 
   private:
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     switch (u.substFormat) {
-    case 1: return u.format1.substitute (LOOKUP_ARGS, property);
-    case 2: return u.format2.substitute (LOOKUP_ARGS, property);
-    case 3: return u.format3.substitute (LOOKUP_ARGS, property);
+    case 1: return u.format1.substitute (LOOKUP_ARGS);
+    case 2: return u.format2.substitute (LOOKUP_ARGS);
+    case 3: return u.format3.substitute (LOOKUP_ARGS);
     default:return false;
     }
   }
@@ -648,7 +647,7 @@ struct ExtensionSubstFormat1 {
 
   private:
   inline unsigned int get_type (void) const { return extensionLookupType; }
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const;
+  inline bool substitute (LOOKUP_ARGS_DEF) const;
 
   private:
   USHORT	substFormat;		/* Format identifier. Set to 1. */
@@ -674,9 +673,9 @@ struct ExtensionSubst {
     }
   }
 
-  inline bool substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+  inline bool substitute (LOOKUP_ARGS_DEF) const {
     switch (u.substFormat) {
-    case 1: return u.format1.substitute (LOOKUP_ARGS, property);
+    case 1: return u.format1.substitute (LOOKUP_ARGS);
     default:return false;
     }
   }
@@ -735,21 +734,20 @@ struct SubstLookupSubTable {
   friend struct SubstLookup;
 
   inline bool substitute (LOOKUP_ARGS_DEF,
-			  unsigned int property,
 			  unsigned int lookup_type) const {
 
     switch (lookup_type) {
-    case GSUB_Single:				return u.single.substitute (LOOKUP_ARGS, property);
-    case GSUB_Multiple:				return u.multiple.substitute (LOOKUP_ARGS, property);
-    case GSUB_Alternate:			return u.alternate.substitute (LOOKUP_ARGS, property);
-    case GSUB_Ligature:				return u.ligature.substitute (LOOKUP_ARGS, property);
-    case GSUB_Context:				return u.context.substitute (LOOKUP_ARGS, property);
+    case GSUB_Single:				return u.single.substitute (LOOKUP_ARGS);
+    case GSUB_Multiple:				return u.multiple.substitute (LOOKUP_ARGS);
+    case GSUB_Alternate:			return u.alternate.substitute (LOOKUP_ARGS);
+    case GSUB_Ligature:				return u.ligature.substitute (LOOKUP_ARGS);
+    case GSUB_Context:				return u.context.substitute (LOOKUP_ARGS);
     /*
-    case GSUB_ChainingContext:			return u.chainingContext.substitute (LOOKUP_ARGS, property);
+    case GSUB_ChainingContext:			return u.chainingContext.substitute (LOOKUP_ARGS);
     */
-    case GSUB_Extension:			return u.extension.substitute (LOOKUP_ARGS, property);
+    case GSUB_Extension:			return u.extension.substitute (LOOKUP_ARGS);
 			/*
-    case GSUB_ReverseChainingContextSingle:	return u.reverseChainingContextSingle.substitute (LOOKUP_ARGS, property);
+    case GSUB_ReverseChainingContextSingle:	return u.reverseChainingContextSingle.substitute (LOOKUP_ARGS);
     */
     default:return false;
     }
@@ -802,27 +800,34 @@ struct SubstLookup : Lookup {
     }
   }
 
-  inline bool substitute_once (hb_ot_layout_t *layout,
-			       hb_buffer_t    *buffer,
-			       unsigned int    context_length,
-			       unsigned int    nesting_level_left) const {
-
+  inline bool substitute_subtables (hb_ot_layout_t *layout,
+				    hb_buffer_t    *buffer,
+				    unsigned int    context_length,
+				    unsigned int    nesting_level_left,
+				    unsigned int    property) const {
     unsigned int lookup_type = get_type ();
     unsigned int lookup_flag = get_flag ();
 
-    unsigned int property;
-    if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property))
-      return false;
-
     for (unsigned int i = 0; i < get_subtable_count (); i++)
       if (get_subtable (i).substitute (LOOKUP_ARGS,
-				       property,
 				       lookup_type))
 	return true;
 
     return false;
   }
 
+  inline bool substitute_once (hb_ot_layout_t *layout,
+			       hb_buffer_t    *buffer) const {
+
+    unsigned int lookup_flag = get_flag ();
+
+    unsigned int property;
+    if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property))
+      return false;
+
+    return substitute_subtables (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, property);
+  }
+
   bool substitute_string (hb_ot_layout_t *layout,
 			  hb_buffer_t    *buffer,
 			  hb_ot_layout_feature_mask_t mask) const {
@@ -837,7 +842,7 @@ struct SubstLookup : Lookup {
 	while (buffer->in_pos < buffer->in_length) {
 
 	  if ((~IN_PROPERTIES (buffer->in_pos) & mask) &&
-	      substitute_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+	      substitute_once (layout, buffer))
 	    ret = true;
 	  else
 	    _hb_buffer_next_glyph (buffer);
@@ -853,7 +858,7 @@ struct SubstLookup : Lookup {
 	do {
 
 	  if ((~IN_PROPERTIES (buffer->in_pos) & mask) &&
-	      substitute_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+	      substitute_once (layout, buffer))
 	    ret = true;
 	  else
 	    buffer->in_pos--;
@@ -894,11 +899,10 @@ struct GSUB : GSUBGPOS {
 
 /* Out-of-class implementation for methods chaining */
 
-inline bool ExtensionSubstFormat1::substitute (LOOKUP_ARGS_DEF, unsigned int property) const {
+inline bool ExtensionSubstFormat1::substitute (LOOKUP_ARGS_DEF) const {
   /* XXX either check in sanitize or here that the lookuptype is not 7 again,
    * or we can loop indefinitely. */
   return (*(SubstLookupSubTable *)(((char *) this) + extensionOffset)).substitute (LOOKUP_ARGS,
-										   property,
 										   get_type ());
 }
 
@@ -913,7 +917,7 @@ static inline bool substitute_lookup (LOOKUP_ARGS_DEF, unsigned int lookup_index
   if (HB_UNLIKELY (context_length < 1))
     return false;
 
-  return l.substitute_once (layout, buffer, context_length, nesting_level_left);
+  return l.substitute_subtables (layout, buffer, context_length, nesting_level_left, property);
 }
 
 
diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.h b/pango/opentype/hb-ot-layout-gsubgpos-private.h
index 6757720..b537015 100644
--- a/pango/opentype/hb-ot-layout-gsubgpos-private.h
+++ b/pango/opentype/hb-ot-layout-gsubgpos-private.h
@@ -35,13 +35,15 @@
 	hb_buffer_t    *buffer, \
 	unsigned int    context_length HB_GNUC_UNUSED, \
 	unsigned int    nesting_level_left HB_GNUC_UNUSED, \
-	unsigned int    lookup_flag
+	unsigned int    lookup_flag, \
+	unsigned int    property HB_GNUC_UNUSED /* propety of first glyph */
 #define LOOKUP_ARGS \
 	layout, \
 	buffer, \
 	context_length, \
 	nesting_level_left, \
-	lookup_flag
+	lookup_flag, \
+	property
 
 
 /* Context lookups */
@@ -83,7 +85,6 @@ static inline bool context_lookup (LOOKUP_ARGS_DEF,
 				   ContextLookupContext &context) {
 
   unsigned int i, j;
-  unsigned int property;
   unsigned int count = glyphCount;
 
   if (HB_UNLIKELY (buffer->in_pos + count > buffer->in_length ||



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]