summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <andreas.kling@nokia.com>2010-06-18 16:10:31 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2010-06-18 16:21:01 +0200
commit5699175f55acbdfa4ac95ab6c727ebd4a201f3a2 (patch)
treed03c7eec20b8c89c25be2697b9900269d6a29aa1
parent508b02a252b524d34f3ed970eef3bdb6350a2b77 (diff)
Make HB_AnchorFormat3's Device tables a pointer array
Saves sizeof(pointer) * 1 when the font doesn't have these tables. Cuts resident memory consumption by 40kB when loading qt.nokia.com in QtWebKit. Signed-off-by: Simon Hausmann <simon.hausmann@nokia.com>
-rw-r--r--src/harfbuzz-gpos-private.h5
-rw-r--r--src/harfbuzz-gpos.c43
2 files changed, 31 insertions, 17 deletions
diff --git a/src/harfbuzz-gpos-private.h b/src/harfbuzz-gpos-private.h
index 3a4952b..39f3159 100644
--- a/src/harfbuzz-gpos-private.h
+++ b/src/harfbuzz-gpos-private.h
@@ -105,13 +105,14 @@ struct HB_AnchorFormat2_
typedef struct HB_AnchorFormat2_ HB_AnchorFormat2;
+#define AF3_X_DEVICE_TABLE 0
+#define AF3_Y_DEVICE_TABLE 1
struct HB_AnchorFormat3_
{
HB_Short XCoordinate; /* horizontal value */
HB_Short YCoordinate; /* vertical value */
- HB_Device* XDeviceTable; /* device table for X coordinate */
- HB_Device* YDeviceTable; /* device table for Y coordinate */
+ HB_Device** DeviceTables; /* device tables for coordinates */
};
typedef struct HB_AnchorFormat3_ HB_AnchorFormat3;
diff --git a/src/harfbuzz-gpos.c b/src/harfbuzz-gpos.c
index 1933f3d..d71a85e 100644
--- a/src/harfbuzz-gpos.c
+++ b/src/harfbuzz-gpos.c
@@ -631,19 +631,21 @@ static HB_Error Load_Anchor( HB_Anchor* an,
if ( new_offset )
{
+ if ( ALLOC_ARRAY( an->af.af3.DeviceTables, 2, HB_Device ) )
+ return error;
+
+ an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] = 0;
+ an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] = 0;
+
new_offset += base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Device( &an->af.af3.XDeviceTable,
+ ( error = _HB_OPEN_Load_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE],
stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
}
- else
- {
- an->af.af3.XDeviceTable = 0;
- }
if ( ACCESS_Frame( 2L ) )
goto Fail;
@@ -654,19 +656,24 @@ static HB_Error Load_Anchor( HB_Anchor* an,
if ( new_offset )
{
+ if ( !an->af.af3.DeviceTables )
+ {
+ if ( ALLOC_ARRAY( an->af.af3.DeviceTables, 2, HB_Device ) )
+ return error;
+
+ an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] = 0;
+ an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] = 0;
+ }
+
new_offset += base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Device( &an->af.af3.YDeviceTable,
+ ( error = _HB_OPEN_Load_Device( &an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE],
stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- else
- {
- an->af.af3.YDeviceTable = 0;
- }
break;
case 4:
@@ -691,7 +698,9 @@ static HB_Error Load_Anchor( HB_Anchor* an,
return HB_Err_Ok;
Fail:
- _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable );
+ _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
+
+ FREE( an->af.af3.DeviceTables );
return error;
}
@@ -700,8 +709,9 @@ static void Free_Anchor( HB_Anchor* an)
{
if ( an->PosFormat == 3 )
{
- _HB_OPEN_Free_Device( &an->af.af3.YDeviceTable );
- _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable );
+ _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
+ _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] );
+ FREE( an->af.af3.DeviceTables );
}
}
@@ -769,9 +779,12 @@ static HB_Error Get_Anchor( GPOS_Instance* gpi,
case 3:
if ( !gpi->dvi )
{
- _HB_OPEN_Get_Device( &an->af.af3.XDeviceTable, x_ppem, &pixel_value );
+ if ( ALLOC_ARRAY( an->af.af3.DeviceTables, 2, HB_Device ) )
+ return error;
+
+ _HB_OPEN_Get_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE], x_ppem, &pixel_value );
*x_value = pixel_value << 6;
- _HB_OPEN_Get_Device( &an->af.af3.YDeviceTable, y_ppem, &pixel_value );
+ _HB_OPEN_Get_Device( &an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE], y_ppem, &pixel_value );
*y_value = pixel_value << 6;
}
else