shithub: freetype+ttf2subf

Download patch

ref: 25e82bc2b54054b1819c92bad01b623de7d380c7
parent: e22334812f83cd03fe988b5f903d66247e049b7d
author: Alexei Podtelezhnikov <[email protected]>
date: Thu Jun 23 19:17:39 EDT 2016

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-23  Alexei Podtelezhnikov  <[email protected]>
+
+	[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  <[email protected]>
 
 	[smooth] Consolidate boundary checks.
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -452,11 +452,6 @@
     void*                render_span_data;
     int                  span_y;
 
-    int  band_size;
-
-    void*       buffer;
-    long        buffer_size;
-
     PCell*     ycells;
     TPos       ycount;
 
@@ -510,27 +505,6 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* 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 @@
   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 @@
 
 
     /* 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 @@
 
     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 @@
           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,9 +1994,7 @@
 
     gray_TWorker  worker[1];
 
-    TCell  buffer[FT_MAX_GRAY_POOL];
 
-
     if ( !raster )
       return FT_THROW( Invalid_Argument );
 
@@ -2100,12 +2074,7 @@
     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;