[raster, smooth] Handle FT_RENDER_POOL_SIZE better. * src/raster/ftraster.c (FT_MAX_BLACK_POOL): New macro. (ft_black_render): Updated. * src/smooth/ftgrays.c (FT_MAX_GRAY_POOL): New macro. (gray_raster_render): 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 109 110 111 112 113 114 115 116 117 118 119 120
diff --git a/ChangeLog b/ChangeLog
index df164f7..d1d7465 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-17 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [raster, smooth] Handle FT_RENDER_POOL_SIZE better.
+
+ * src/raster/ftraster.c (FT_MAX_BLACK_POOL): New macro.
+ (ft_black_render): Updated.
+ * src/smooth/ftgrays.c (FT_MAX_GRAY_POOL): New macro.
+ (gray_raster_render): Updated.
+
2016-06-16 Werner Lemberg <wl@gnu.org>
* src/base/md5.c: Updated to recent version.
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 01ed1c5..3d75c10 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -179,8 +179,6 @@
#define FT_ERR_XCAT( x, y ) x ## y
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
-#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
-
/* This macro is used to indicate that a function parameter is unused. */
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
@@ -459,6 +457,12 @@
#define IS_TOP_OVERSHOOT( x ) \
(Bool)( x - FLOOR( x ) >= ras.precision_half )
+#if FT_RENDER_POOL_SIZE > 2048
+#define FT_MAX_BLACK_POOL ( FT_RENDER_POOL_SIZE / sizeof ( Long ) )
+#elif
+#define FT_MAX_BLACK_POOL ( 2048 / sizeof ( Long ) )
+#endif
+
/* The most used variables are positioned at the top of the structure. */
/* Thus, their offset can be coded with less opcodes, resulting in a */
/* smaller executable. */
@@ -3138,7 +3142,7 @@
black_TWorker worker[1];
- Long buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( Long )];
+ Long buffer[FT_MAX_BLACK_POOL];
if ( !raster )
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 07c6ef8..01b5bff 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -106,7 +106,6 @@
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
-#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
@@ -391,10 +390,6 @@ typedef ptrdiff_t FT_PtrDist;
typedef long TArea; /* cell areas, coordinate products */
- /* maximum number of gray spans in a call to the span callback */
-#define FT_MAX_GRAY_SPANS 32
-
-
typedef struct TCell_* PCell;
typedef struct TCell_
@@ -407,6 +402,17 @@ typedef ptrdiff_t FT_PtrDist;
} TCell;
+ /* maximum number of gray spans in a call to the span callback */
+#define FT_MAX_GRAY_SPANS 32
+
+ /* maximum number of gray cells in the buffer */
+#if FT_RENDER_POOL_SIZE > 2048
+#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
+#elif
+#define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) )
+#endif
+
+
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `structure was padded due to */
/* __declspec(align())' in order to compile cleanly with */
@@ -2024,10 +2030,7 @@ typedef ptrdiff_t FT_PtrDist;
gray_TWorker worker[1];
- TCell buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( TCell )];
- long buffer_size = sizeof ( buffer );
- int band_size = (int)( buffer_size /
- (long)( sizeof ( TCell ) * 8 ) );
+ TCell buffer[FT_MAX_GRAY_POOL];
if ( !raster )
@@ -2098,12 +2101,12 @@ typedef ptrdiff_t FT_PtrDist;
ras.clip_box.yMax = 32767L;
}
- gray_init_cells( RAS_VAR_ buffer, buffer_size );
+ gray_init_cells( RAS_VAR_ buffer, sizeof ( buffer ) );
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
- ras.band_size = band_size;
+ ras.band_size = FT_MAX_GRAY_POOL / 8;
ras.num_gray_spans = 0;
ras.span_y = 0;