[cache] Switch to lazy SBit setting. * src/cache/ftcsbits.c (ftc_sbit_copy_bitmap): Removed. (ftc_snode_load): Take the bitmap ownership instead of copying.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
diff --git a/ChangeLog b/ChangeLog
index a6d8f80..4b41688 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-04-18 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [cache] Switch to lazy SBit setting.
+
+ * src/cache/ftcsbits.c (ftc_sbit_copy_bitmap): Removed.
+ (ftc_snode_load): Take the bitmap ownership instead of copying.
+
2021-04-16 Daniel Welty <@danielwelty>
* src/cache/ftcsbits.c (ftc_snode_load): Properly handle short pitch.
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 93d5367..01d94ec 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -38,30 +38,6 @@
/*************************************************************************/
- static FT_Error
- ftc_sbit_copy_bitmap( FTC_SBit sbit,
- FT_Bitmap* bitmap,
- FT_Memory memory )
- {
- FT_Error error;
- FT_Int pitch = bitmap->pitch;
- FT_ULong size;
-
-
- if ( pitch < 0 )
- pitch = -pitch;
-
- size = (FT_ULong)pitch * bitmap->rows;
- if ( !size )
- return FT_Err_Ok;
-
- if ( !FT_ALLOC( sbit->buffer, size ) )
- FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
-
- return error;
- }
-
-
FT_LOCAL_DEF( void )
ftc_snode_free( FTC_Node ftcsnode,
FTC_Cache cache )
@@ -108,7 +84,6 @@
FT_Error error;
FTC_GNode gnode = FTC_GNODE( snode );
FTC_Family family = gnode->family;
- FT_Memory memory = manager->memory;
FT_Face face;
FTC_SBit sbit;
FTC_SFamilyClass clazz;
@@ -123,7 +98,7 @@
sbit = snode->sbits + ( gindex - gnode->gindex );
clazz = (FTC_SFamilyClass)family->clazz;
- sbit->buffer = 0;
+ sbit->buffer = NULL;
error = clazz->family_load_glyph( family, gindex, manager, &face );
if ( error )
@@ -178,8 +153,9 @@
sbit->format = (FT_Byte)bitmap->pixel_mode;
sbit->max_grays = (FT_Byte)(bitmap->num_grays - 1);
- /* copy the bitmap into a new buffer -- ignore error */
- error = ftc_sbit_copy_bitmap( sbit, bitmap, memory );
+ /* take the bitmap ownership */
+ sbit->buffer = bitmap->buffer;
+ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
/* now, compute size */
if ( asize )