[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.
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/ChangeLog b/ChangeLog
index 5808490..51d05a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
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.
It was off by default and couldn't be turned on at runtime. And the
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 54fb579..552a568 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 );
}