diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2007-10-11 07:05:09 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2007-10-11 07:05:09 +0000 |
commit | cd7d8ecfaf06b25974edcbcb76847f80c6522e91 (patch) | |
tree | a95dc9fae2780313d7315daca9a3dde4b2737467 | |
parent | a178a6938593216b335e5c562fdbdccfaea06d9b (diff) | |
download | pango-cd7d8ecfaf06b25974edcbcb76847f80c6522e91.tar.gz |
Allocate buffer->positions lazily.
2007-10-11 Behdad Esfahbod <behdad@gnome.org>
* pango/opentype/*: Allocate buffer->positions lazily.
svn path=/trunk/; revision=2433
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pango/opentype/harfbuzz-buffer.c | 25 | ||||
-rw-r--r-- | pango/opentype/harfbuzz-buffer.h | 3 | ||||
-rw-r--r-- | pango/opentype/harfbuzz-gpos.c | 13 | ||||
-rw-r--r-- | pango/opentype/harfbuzz-gsub.c | 5 |
5 files changed, 41 insertions, 9 deletions
@@ -1,5 +1,9 @@ 2007-10-11 Behdad Esfahbod <behdad@gnome.org> + * pango/opentype/*: Allocate buffer->positions lazily. + +2007-10-11 Behdad Esfahbod <behdad@gnome.org> + Bug 485621 – Get rid of freetype memory allocator in harfbuzz * pango/opentype/*: Remove all occurences of FT_Memory. Use diff --git a/pango/opentype/harfbuzz-buffer.c b/pango/opentype/harfbuzz-buffer.c index f597ac9a..e39a24b1 100644 --- a/pango/opentype/harfbuzz-buffer.c +++ b/pango/opentype/harfbuzz-buffer.c @@ -51,10 +51,15 @@ hb_buffer_ensure( HB_Buffer buffer, while (size > new_allocated) new_allocated += (new_allocated >> 1) + 8; - if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) ) - return error; + if ( buffer->positions ) + { + if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) ) + return error; + } + if ( REALLOC_ARRAY( buffer->in_string, new_allocated, HB_GlyphItemRec ) ) return error; + if ( buffer->inplace ) { buffer->out_string = buffer->in_string; @@ -121,6 +126,22 @@ hb_buffer_new( HB_Buffer *buffer ) return HB_Err_Ok; } +HB_Error +hb_buffer_clear_positions( HB_Buffer buffer ) +{ + if ( !buffer->positions ) + { + HB_Error error; + + if ( ALLOC_ARRAY( buffer->positions, buffer->allocated, HB_PositionRec ) ) + return error; + } + + memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length); + + return HB_Err_Ok; +} + void hb_buffer_clear_output( HB_Buffer buffer ) { diff --git a/pango/opentype/harfbuzz-buffer.h b/pango/opentype/harfbuzz-buffer.h index 9adfc573..c0b047fa 100644 --- a/pango/opentype/harfbuzz-buffer.h +++ b/pango/opentype/harfbuzz-buffer.h @@ -79,6 +79,9 @@ void hb_buffer_clear_output( HB_Buffer buffer ); HB_Error +hb_buffer_clear_positions( HB_Buffer buffer ); + +HB_Error hb_buffer_add_glyph( HB_Buffer buffer, FT_UInt glyph_index, FT_UInt properties, diff --git a/pango/opentype/harfbuzz-gpos.c b/pango/opentype/harfbuzz-gpos.c index 5c91f6ea..52ed1206 100644 --- a/pango/opentype/harfbuzz-gpos.c +++ b/pango/opentype/harfbuzz-gpos.c @@ -6091,7 +6091,7 @@ HB_Error HB_GPOS_Apply_String( FT_Face face, { HB_Error error, retError = HB_Err_Not_Covered; GPOS_Instance gpi; - FT_UShort i, j, lookup_count; + int i, j, lookup_count, num_features; if ( !face || !gpos || !buffer ) return HB_Err_Invalid_Argument; @@ -6106,13 +6106,16 @@ HB_Error HB_GPOS_Apply_String( FT_Face face, gpi.dvi = dvi; lookup_count = gpos->LookupList.LookupCount; + num_features = gpos->FeatureList.ApplyCount; - if ( gpos->FeatureList.ApplyCount ) + if ( num_features ) { - memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length); + error = hb_buffer_clear_positions( buffer ); + if ( error ) + return error; } - for ( i = 0; i < gpos->FeatureList.ApplyCount; i++ ) + for ( i = 0; i < num_features; i++ ) { FT_UShort feature_index = gpos->FeatureList.ApplyOrder[i]; HB_Feature feature = gpos->FeatureList.FeatureRecord[feature_index].Feature; @@ -6136,7 +6139,7 @@ HB_Error HB_GPOS_Apply_String( FT_Face face, } } - if ( gpos->FeatureList.ApplyCount ) + if ( num_features ) { error = Position_CursiveChain ( buffer ); if ( error ) diff --git a/pango/opentype/harfbuzz-gsub.c b/pango/opentype/harfbuzz-gsub.c index 16a53850..3f70e0d0 100644 --- a/pango/opentype/harfbuzz-gsub.c +++ b/pango/opentype/harfbuzz-gsub.c @@ -4319,7 +4319,7 @@ HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub, HB_Buffer buffer ) { HB_Error error, retError = HB_Err_Not_Covered; - FT_UShort i, j, lookup_count; + int i, j, lookup_count, num_features; if ( !gsub || !buffer) @@ -4329,8 +4329,9 @@ HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub, return retError; lookup_count = gsub->LookupList.LookupCount; + num_features = gsub->FeatureList.ApplyCount; - for ( i = 0; i < gsub->FeatureList.ApplyCount; i++) + for ( i = 0; i < num_features; i++) { FT_UShort feature_index = gsub->FeatureList.ApplyOrder[i]; HB_Feature feature = gsub->FeatureList.FeatureRecord[feature_index].Feature; |