From a773c3041e024975241d110989f617f032c4b7e3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 14 Jan 2015 18:16:20 +0100 Subject: [PATCH] [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. --- ChangeLog | 17 +++++++++++++++++ src/raster/ftraster.c | 39 ++++++++++----------------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 580849015..51d05a2f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2015-01-14 Behdad Esfahbod + + [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 [raster] Remove 5-level gray AA mode from monochrome rasterizer. diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 54fb579bc..552a56858 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -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]; - if ( !raster || !raster->buffer || !raster->buffer_size ) + Long buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( Long )]; + + + 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 ); }