[pango/harfbuzz-ng] [HB] Simplify buffer



commit 92c65d29132105784b18b60ba938a3ec86dfcb76
Author: Behdad Esfahbod <behdad behdad org>
Date:   Sun May 17 06:03:42 2009 -0400

    [HB] Simplify buffer
---
 pango/opentype/harfbuzz-buffer-private.h   |   14 ++++------
 pango/opentype/harfbuzz-buffer.c           |   35 ++++++++++++---------------
 pango/opentype/harfbuzz-gsub.c             |    6 ++--
 pango/opentype/hb-ot-layout-gsub-private.h |   12 ++++----
 4 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/pango/opentype/harfbuzz-buffer-private.h b/pango/opentype/harfbuzz-buffer-private.h
index dbecc7a..8dc8447 100644
--- a/pango/opentype/harfbuzz-buffer-private.h
+++ b/pango/opentype/harfbuzz-buffer-private.h
@@ -59,12 +59,11 @@ _hb_buffer_add_output_glyph ( HB_Buffer buffer,
 			      HB_UShort ligID );
 
 HB_INTERNAL HB_Error
-_hb_buffer_copy_output_glyph ( HB_Buffer buffer );
+_hb_buffer_next_glyph ( HB_Buffer buffer );
 
 HB_INTERNAL HB_Error
-_hb_buffer_replace_output_glyph ( HB_Buffer buffer,
-				  HB_UInt   glyph_index,
-				  HB_Bool   inplace );
+_hb_buffer_replace_glyph ( HB_Buffer buffer,
+			   HB_UInt   glyph_index );
 
 HB_INTERNAL HB_UShort
 _hb_buffer_allocate_ligid( HB_Buffer buffer );
@@ -96,11 +95,10 @@ _hb_buffer_allocate_ligid( HB_Buffer buffer );
           ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \
                                                     (glyph_index), (component), (ligID) \
                                                   ) ) != HB_Err_Ok )
-#define REPLACE_Glyph( buffer, glyph_index, nesting_level )				\
-          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),		\
-						      (nesting_level) == 1 ) ) != HB_Err_Ok )
+#define REPLACE_Glyph( buffer, glyph_index )				\
+          ( ( error = _hb_buffer_replace_glyph( (buffer), (glyph_index) ) ) != HB_Err_Ok )
 #define COPY_Glyph( buffer )								\
-	  ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )
+	  ( (error = _hb_buffer_next_glyph ( buffer ) ) != HB_Err_Ok )
 
 HB_END_HEADER
 
diff --git a/pango/opentype/harfbuzz-buffer.c b/pango/opentype/harfbuzz-buffer.c
index b99639c..02842ea 100644
--- a/pango/opentype/harfbuzz-buffer.c
+++ b/pango/opentype/harfbuzz-buffer.c
@@ -208,6 +208,8 @@ _hb_buffer_clear_output( HB_Buffer buffer )
 HB_INTERNAL HB_Error
 _hb_buffer_clear_positions( HB_Buffer buffer )
 {
+  _hb_buffer_clear_output (buffer);
+
   if ( !buffer->positions )
     {
       HB_Error error;
@@ -328,16 +330,16 @@ _hb_buffer_add_output_glyph( HB_Buffer buffer,
 }
 
 HB_INTERNAL HB_Error
-_hb_buffer_copy_output_glyph ( HB_Buffer buffer )
-{  
+_hb_buffer_next_glyph ( HB_Buffer buffer )
+{
   HB_Error  error;
 
-  error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
-  if ( error )
-    return error;
-  
   if ( buffer->separate_out )
     {
+      error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
+      if ( error )
+	return error;
+
       buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
     }
 
@@ -349,20 +351,19 @@ _hb_buffer_copy_output_glyph ( HB_Buffer buffer )
 }
 
 HB_INTERNAL HB_Error
-_hb_buffer_replace_output_glyph( HB_Buffer buffer,
-				 HB_UInt   glyph_index,
-				 HB_Bool   inplace )
+_hb_buffer_replace_glyph( HB_Buffer buffer,
+			  HB_UInt   glyph_index )
 {
 
   HB_Error error;
 
-  if ( inplace )
+  if ( !buffer->separate_out )
     {
-      error = _hb_buffer_copy_output_glyph ( buffer );
-      if ( error )
-	return error;
+      buffer->out_string[buffer->out_pos].gindex = glyph_index;
 
-      buffer->out_string[buffer->out_pos-1].gindex = glyph_index;
+      buffer->in_pos++;
+      buffer->out_pos++;
+      buffer->out_length = buffer->out_pos;
     }
   else
     {
@@ -375,9 +376,5 @@ _hb_buffer_replace_output_glyph( HB_Buffer buffer,
 HB_INTERNAL HB_UShort
 _hb_buffer_allocate_ligid( HB_Buffer buffer )
 {
-  buffer->max_ligID++;
-  if (HB_UNLIKELY (buffer->max_ligID == 0))
-    buffer->max_ligID++;
-
-  return buffer->max_ligID;
+  return ++buffer->max_ligID;
 }
diff --git a/pango/opentype/harfbuzz-gsub.c b/pango/opentype/harfbuzz-gsub.c
index 38879a8..cb8c9c3 100644
--- a/pango/opentype/harfbuzz-gsub.c
+++ b/pango/opentype/harfbuzz-gsub.c
@@ -281,7 +281,7 @@ static HB_Error  Lookup_SingleSubst( HB_GSUBHeader*   gsub,
   {
   case 1:
     value = (IN_CURGLYPH() + ss->ssf.ssf1.DeltaGlyphID ) & 0xFFFF;
-    if ( REPLACE_Glyph( buffer, value, nesting_level ) )
+    if ( REPLACE_Glyph( buffer, value ) )
       return error;
     break;
 
@@ -289,7 +289,7 @@ static HB_Error  Lookup_SingleSubst( HB_GSUBHeader*   gsub,
     if ( index >= ss->ssf.ssf2.GlyphCount )
       return ERR(HB_Err_Invalid_SubTable);
     value = ss->ssf.ssf2.Substitute[index];
-    if ( REPLACE_Glyph( buffer, value, nesting_level ) )
+    if ( REPLACE_Glyph( buffer, value ) )
       return error;
     break;
 
@@ -687,7 +687,7 @@ static HB_Error  Lookup_AlternateSubst( HB_GSUBHeader*    gsub,
     alt_index = 0;
 
   value = aset.Alternate[alt_index];
-  if ( REPLACE_Glyph( buffer, value, nesting_level ) )
+  if ( REPLACE_Glyph( buffer, value ) )
     return error;
 
   if ( _hb_ot_layout_has_new_glyph_classes (layout) )
diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h
index 82fd7a4..9b07f53 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.h
+++ b/pango/opentype/hb-ot-layout-gsub-private.h
@@ -127,7 +127,7 @@ struct SingleSubst {
     if (!single_substitute (glyph_id))
       return false;
 
-    _hb_buffer_replace_output_glyph (buffer, glyph_id, context_length == NO_CONTEXT);
+    _hb_buffer_replace_glyph (buffer, glyph_id);
 
     if ( _hb_ot_layout_has_new_glyph_classes (layout) )
     {
@@ -276,7 +276,7 @@ struct AlternateSubstFormat1 {
 
     glyph_id = alt_set[alt_index];
 
-    _hb_buffer_replace_output_glyph (buffer, glyph_id, context_length == NO_CONTEXT);
+    _hb_buffer_replace_glyph (buffer, glyph_id);
 
     if ( _hb_ot_layout_has_new_glyph_classes (layout) )
     {
@@ -549,7 +549,7 @@ struct SubRule {
       {
       no_subst:
 	/* No substitution for this index */
-	_hb_buffer_copy_output_glyph (buffer);
+	_hb_buffer_next_glyph (buffer);
 	i++;
       }
     }
@@ -677,7 +677,7 @@ struct SubClassRule {
       {
       no_subst:
 	/* No substitution for this index */
-	_hb_buffer_copy_output_glyph (buffer);
+	_hb_buffer_next_glyph (buffer);
 	i++;
       }
     }
@@ -820,7 +820,7 @@ struct ContextSubstFormat3 {
       {
       no_subst:
 	/* No substitution for this index */
-	_hb_buffer_copy_output_glyph (buffer);
+	_hb_buffer_next_glyph (buffer);
 	i++;
       }
     }
@@ -1246,7 +1246,7 @@ struct SubstLookup : Lookup {
 	      substitute_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
 	    ret = true;
 	  else
-	    _hb_buffer_copy_output_glyph (buffer);
+	    _hb_buffer_next_glyph (buffer);
 
 	}
 	if (ret)



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