* src/raster/ftraster.c: removing dynamically generated "count_table",

and replace it with a constant array of bytes
This commit is contained in:
David Turner 2007-01-04 18:50:12 +00:00
parent 8a2c7f8fb8
commit 38d1002b8a
2 changed files with 27 additions and 22 deletions

View File

@ -1,5 +1,8 @@
2007-01-04 David Turner <david@freetype.org> 2007-01-04 David Turner <david@freetype.org>
* src/raster/ftraster.c: removing dynamically generated "count_table",
and replace it with a constant array of bytes
* src/raster/ftraster.c, src/smooth/ftgrays.c: small optimization, the * src/raster/ftraster.c, src/smooth/ftgrays.c: small optimization, the
rasterizers now uses the render pool to store their state during scanline rasterizers now uses the render pool to store their state during scanline
convertion. this saves about 6 KB of heap space for each FT_Library instance convertion. this saves about 6 KB of heap space for each FT_Library instance

View File

@ -498,8 +498,6 @@
TBand band_stack[16]; /* band stack used for sub-banding */ TBand band_stack[16]; /* band stack used for sub-banding */
Int band_top; /* band stack top */ Int band_top; /* band stack top */
Int* count_table;
#ifdef FT_RASTER_OPTION_ANTI_ALIASING #ifdef FT_RASTER_OPTION_ANTI_ALIASING
Byte* grays; Byte* grays;
@ -528,8 +526,6 @@
long buffer_size; long buffer_size;
void* memory; void* memory;
PWorker worker; PWorker worker;
Int count_table[256]; /* Look-up table used to quickly count */
/* set bits in a gray 2x2 cell */
Byte grays[5]; Byte grays[5];
Short gray_width; Short gray_width;
@ -547,6 +543,27 @@
#endif /* FT_STATIC_RASTER */ #endif /* FT_STATIC_RASTER */
static const char count_table[256] =
{
0 , 1 , 1 , 2 , 1 , 2 , 2 , 3 , 1 , 2 , 2 , 3 , 2 , 3 , 3 , 4,
1 , 2 , 2 , 3 , 2 , 3 , 3 , 4 , 2 , 3 , 3 , 4 , 3 , 4 , 4 , 5,
1 , 2 , 2 , 3 , 2 , 3 , 3 , 4 , 2 , 3 , 3 , 4 , 3 , 4 , 4 , 5,
2 , 3 , 3 , 4 , 3 , 4 , 4 , 5 , 3 , 4 , 4 , 5 , 4 , 5 , 5 , 6,
1 , 2 , 2 , 3 , 2 , 3 , 3 , 4 , 2 , 3 , 3 , 4 , 3 , 4 , 4 , 5,
2 , 3 , 3 , 4 , 3 , 4 , 4 , 5 , 3 , 4 , 4 , 5 , 4 , 5 , 5 , 6,
2 , 3 , 3 , 4 , 3 , 4 , 4 , 5 , 3 , 4 , 4 , 5 , 4 , 5 , 5 , 6,
3 , 4 , 4 , 5 , 4 , 5 , 5 , 6 , 4 , 5 , 5 , 6 , 5 , 6 , 6 , 7,
1 , 2 , 2 , 3 , 2 , 3 , 3 , 4 , 2 , 3 , 3 , 4 , 3 , 4 , 4 , 5,
2 , 3 , 3 , 4 , 3 , 4 , 4 , 5 , 3 , 4 , 4 , 5 , 4 , 5 , 5 , 6,
2 , 3 , 3 , 4 , 3 , 4 , 4 , 5 , 3 , 4 , 4 , 5 , 4 , 5 , 5 , 6,
3 , 4 , 4 , 5 , 4 , 5 , 5 , 6 , 4 , 5 , 5 , 6 , 5 , 6 , 6 , 7,
2 , 3 , 3 , 4 , 3 , 4 , 4 , 5 , 3 , 4 , 4 , 5 , 4 , 5 , 5 , 6,
3 , 4 , 4 , 5 , 4 , 5 , 5 , 6 , 4 , 5 , 5 , 6 , 5 , 6 , 6 , 7,
3 , 4 , 4 , 5 , 4 , 5 , 5 , 6 , 4 , 5 , 5 , 6 , 5 , 6 , 6 , 7,
4 , 5 , 5 , 6 , 5 , 6 , 6 , 7 , 5 , 6 , 6 , 7 , 6 , 7 , 7 , 8 };
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/** **/ /** **/
@ -2494,7 +2511,7 @@
{ {
Int c1, c2; Int c1, c2;
PByte pix, bit, bit2; PByte pix, bit, bit2;
Int* count = ras.count_table; char* count = (char*)count_table;
Byte* grays; Byte* grays;
@ -3155,24 +3172,10 @@
static void static void
ft_black_init( PRaster raster ) ft_black_init( PRaster raster )
{ {
FT_UInt n; FT_UNUSED( raster );
FT_ULong c;
/* setup count table */
for ( n = 0; n < 256; n++ )
{
c = ( n & 0x55 ) + ( ( n & 0xAA ) >> 1 );
c = ( ( c << 6 ) & 0x3000 ) |
( ( c << 4 ) & 0x0300 ) |
( ( c << 2 ) & 0x0030 ) |
(c & 0x0003 );
raster->count_table[n] = (UInt)c;
}
#ifdef FT_RASTER_OPTION_ANTI_ALIASING #ifdef FT_RASTER_OPTION_ANTI_ALIASING
FT_UInt n;
/* set default 5-levels gray palette */ /* set default 5-levels gray palette */
for ( n = 0; n < 5; n++ ) for ( n = 0; n < 5; n++ )
@ -3335,7 +3338,6 @@
ras.outline = *outline; ras.outline = *outline;
ras.target = *target_map; ras.target = *target_map;
worker->count_table = raster->count_table;
worker->buff = (PLong) raster->buffer; worker->buff = (PLong) raster->buffer;
worker->sizeBuff = worker->buff + raster->buffer_size/sizeof(Long); worker->sizeBuff = worker->buff + raster->buffer_size/sizeof(Long);
#ifdef FT_RASTER_OPTION_ANTI_ALIASING #ifdef FT_RASTER_OPTION_ANTI_ALIASING