[raster] Allocate render pool for mono rasterizer on the stack.

Instead of using the `render_pool' member of `FT_Library' that is
provided down to the rasterizer, completely ignore that and allocate
needed objects on the stack instead.

With this patch, rasterizing glyphs from different faces from
different threads doesn't crash in the monochrome rasterizer.

* src/raster/ftraster.c (black_TRaster): Remove `buffer',
`buffer_size', and `worker' members.

(ft_black_render): Create `buffer' locally.
(ft_black_reset): Updated.
This commit is contained in:
Behdad Esfahbod 2015-01-14 18:16:20 +01:00 committed by Werner Lemberg
parent 8dc8635874
commit a773c3041e
2 changed files with 27 additions and 29 deletions

View File

@ -1,3 +1,20 @@
2015-01-14 Behdad Esfahbod <behdad@behdad.org>
[raster] Allocate render pool for mono rasterizer on the stack.
Instead of using the `render_pool' member of `FT_Library' that is
provided down to the rasterizer, completely ignore that and allocate
needed objects on the stack instead.
With this patch, rasterizing glyphs from different faces from
different threads doesn't crash in the monochrome rasterizer.
* src/raster/ftraster.c (black_TRaster): Remove `buffer',
`buffer_size', and `worker' members.
(ft_black_render): Create `buffer' locally.
(ft_black_reset): Updated.
2015-01-14 Behdad Esfahbod <behdad@behdad.org>
[raster] Remove 5-level gray AA mode from monochrome rasterizer.

View File

@ -530,10 +530,7 @@
typedef struct black_TRaster_
{
char* buffer;
long buffer_size;
void* memory;
black_PWorker worker;
} black_TRaster, *black_PRaster;
@ -3058,25 +3055,9 @@
char* pool_base,
long pool_size )
{
if ( raster )
{
if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
{
black_PWorker worker = (black_PWorker)pool_base;
raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
raster->buffer_size = (long)( pool_base + pool_size -
(char*)raster->buffer );
raster->worker = worker;
}
else
{
raster->buffer = NULL;
raster->buffer_size = 0;
raster->worker = NULL;
}
}
FT_UNUSED( raster );
FT_UNUSED( pool_base );
FT_UNUSED( pool_size );
}
@ -3099,10 +3080,13 @@
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
black_PWorker worker;
black_TWorker worker[1];
Long buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( Long )];
if ( !raster || !raster->buffer || !raster->buffer_size )
if ( !raster )
return FT_THROW( Not_Ini );
if ( !outline )
@ -3119,8 +3103,6 @@
outline->contours[outline->n_contours - 1] + 1 )
return FT_THROW( Invalid );
worker = raster->worker;
/* this version of the raster does not support direct rendering, sorry */
if ( params->flags & FT_RASTER_FLAG_DIRECT )
return FT_THROW( Unsupported );
@ -3138,9 +3120,8 @@
ras.outline = *outline;
ras.target = *target_map;
worker->buff = (PLong) raster->buffer;
worker->sizeBuff = worker->buff +
raster->buffer_size / sizeof ( Long );
worker->buff = buffer;
worker->sizeBuff = (&buffer)[1]; /* Points to right after buffer. */
return Render_Glyph( RAS_VAR );
}