[smooth] Consolidate memory management. * src/smooth/ftgrays.c (gray_init_cells): Remove function. (gray_TWorker): Remove fields that become local variables. (gray_raster_render): Move rendering buffer declaration from here. (gray_convert_glyph): ... to here and update accordingly.
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 121 122 123
diff --git a/ChangeLog b/ChangeLog
index 219b5a6..a57b267 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-23 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [smooth] Consolidate memory management.
+
+ * src/smooth/ftgrays.c (gray_init_cells): Remove function.
+ (gray_TWorker): Remove fields that become local variables.
+ (gray_raster_render): Move rendering buffer declaration from here.
+ (gray_convert_glyph): ... to here and update accordingly.
+
2016-06-22 Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Consolidate boundary checks.
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 85d39c1..140ec8e 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -452,11 +452,6 @@ typedef ptrdiff_t FT_PtrDist;
void* render_span_data;
int span_y;
- int band_size;
-
- void* buffer;
- long buffer_size;
-
PCell* ycells;
TPos ycount;
@@ -510,27 +505,6 @@ typedef ptrdiff_t FT_PtrDist;
/*************************************************************************/
/* */
- /* Initialize the cells table. */
- /* */
- static void
- gray_init_cells( RAS_ARG_ void* buffer,
- long byte_size )
- {
- ras.buffer = buffer;
- ras.buffer_size = byte_size;
-
- ras.ycells = (PCell*) buffer;
- ras.cells = NULL;
- ras.max_cells = 0;
- ras.num_cells = 0;
- ras.area = 0;
- ras.cover = 0;
- ras.invalid = 1;
- }
-
-
- /*************************************************************************/
- /* */
/* Record the current cell in the table. */
/* */
static PCell
@@ -1910,6 +1884,8 @@ typedef ptrdiff_t FT_PtrDist;
static int
gray_convert_glyph( RAS_ARG )
{
+ TCell buffer[FT_MAX_GRAY_POOL];
+ const int band_size = FT_MAX_GRAY_POOL / 8;
gray_TBand bands[40];
gray_TBand* volatile band;
int volatile n, num_bands;
@@ -1917,7 +1893,7 @@ typedef ptrdiff_t FT_PtrDist;
/* set up vertical bands */
- num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
+ num_bands = (int)( ( ras.max_ey - ras.min_ey ) / band_size );
if ( num_bands == 0 )
num_bands = 1;
if ( num_bands >= 39 )
@@ -1928,7 +1904,7 @@ typedef ptrdiff_t FT_PtrDist;
for ( n = 0; n < num_bands; n++, min = max )
{
- max = min + ras.band_size;
+ max = min + band_size;
if ( n == num_bands - 1 || max > max_y )
max = max_y;
@@ -1954,10 +1930,10 @@ typedef ptrdiff_t FT_PtrDist;
if ( FT_MAX_GRAY_POOL - cell_start < 2 )
goto ReduceBands;
- ras.cells = (PCell)ras.buffer + cell_start;
+ ras.cells = buffer + cell_start;
ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - cell_start );
- ras.ycells = (PCell*)ras.buffer;
+ ras.ycells = (PCell*)buffer;
ras.ycount = (TPos)ycount;
while ( ycount )
ras.ycells[--ycount] = NULL;
@@ -2018,8 +1994,6 @@ typedef ptrdiff_t FT_PtrDist;
gray_TWorker worker[1];
- TCell buffer[FT_MAX_GRAY_POOL];
-
if ( !raster )
return FT_THROW( Invalid_Argument );
@@ -2100,12 +2074,7 @@ typedef ptrdiff_t FT_PtrDist;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
- gray_init_cells( RAS_VAR_ buffer, sizeof ( buffer ) );
-
ras.outline = *outline;
- ras.num_cells = 0;
- ras.invalid = 1;
- ras.band_size = FT_MAX_GRAY_POOL / 8;
ras.num_gray_spans = 0;
ras.span_y = 0;