Commit 516342534468565abf0dafbd5bbb2891bfc19990

Behdad Esfahbod 2015-01-14T18:30:59

[base] Don't allocate `library->raster_pool' anymore. It's unused after the following commits: [raster] Allocate render pool for mono rasterizer on the stack. [raster] Remove 5-level gray AA mode from monochrome rasterizer. The value of FT_RENDER_POOL_SIZE still serves the purpose it used to serve, which is, to adjust the pool size. But the pool is now allocated on the stack on demand. * src/base/ftobjs.c (FT_New_Library, FT_Done_Library): Implement.

diff --git a/ChangeLog b/ChangeLog
index b1b6ba8..6aca637 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2015-01-14  Behdad Esfahbod  <behdad@behdad.org>
 
+	[base] Don't allocate `library->raster_pool' anymore.
+
+	It's unused after the following commits:
+
+	  [raster] Allocate render pool for mono rasterizer on the stack.
+	  [raster] Remove 5-level gray AA mode from monochrome rasterizer.
+
+	The value of FT_RENDER_POOL_SIZE still serves the purpose it used to
+	serve, which is, to adjust the pool size.  But the pool is now
+	allocated on the stack on demand.
+
+	* src/base/ftobjs.c (FT_New_Library, FT_Done_Library): Implement.
+
+2015-01-14  Behdad Esfahbod  <behdad@behdad.org>
+
 	[base] Do not reorder library->renderers upon use.
 
 	Instead of keeping `library->renderers' in a MRU order, just leave
diff --git a/devel/ftoption.h b/devel/ftoption.h
index 5984601..3d0c77d 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -378,10 +378,6 @@ FT_BEGIN_HEADER
   /* The size in bytes of the render pool used by the scan-line converter  */
   /* to do all of its work.                                                */
   /*                                                                       */
-  /* This must be greater than 4KByte if you use FreeType to rasterize     */
-  /* glyphs; otherwise, you may set it to zero to avoid unnecessary        */
-  /* allocation of the render pool.                                        */
-  /*                                                                       */
 #define FT_RENDER_POOL_SIZE  16384L
 
 
diff --git a/include/config/ftoption.h b/include/config/ftoption.h
index a40e88c..c85519d 100644
--- a/include/config/ftoption.h
+++ b/include/config/ftoption.h
@@ -378,10 +378,6 @@ FT_BEGIN_HEADER
   /* The size in bytes of the render pool used by the scan-line converter  */
   /* to do all of its work.                                                */
   /*                                                                       */
-  /* This must be greater than 4KByte if you use FreeType to rasterize     */
-  /* glyphs; otherwise, you may set it to zero to avoid unnecessary        */
-  /* allocation of the render pool.                                        */
-  /*                                                                       */
 #define FT_RENDER_POOL_SIZE  16384L
 
 
diff --git a/include/ftimage.h b/include/ftimage.h
index 2f7ca2a..42815c0 100644
--- a/include/ftimage.h
+++ b/include/ftimage.h
@@ -1078,10 +1078,10 @@ FT_BEGIN_HEADER
   /*    FT_Raster_ResetFunc                                                */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    FreeType provides an area of memory called the `render pool',      */
-  /*    available to all registered rasters.  This pool can be freely used */
-  /*    during a given scan-conversion but is shared by all rasters.  Its  */
-  /*    content is thus transient.                                         */
+  /*    FreeType used to provide an area of memory called the `render      */
+  /*    pool' available to all registered rasters.  This was not thread    */
+  /*    safe however and now FreeType never allocates this pool.  NULL     */
+  /*    is always passed in as pool_base.                                  */
   /*                                                                       */
   /*    This function is called each time the render pool changes, or just */
   /*    after a new raster object is created.                              */
@@ -1094,10 +1094,9 @@ FT_BEGIN_HEADER
   /*    pool_size :: The size in bytes of the render pool.                 */
   /*                                                                       */
   /* <Note>                                                                */
-  /*    Rasters can ignore the render pool and rely on dynamic memory      */
+  /*    Rasters should ignore the render pool and rely on dynamic or stack */
   /*    allocation if they want to (a handle to the memory allocator is    */
-  /*    passed to the raster constructor).  However, this is not           */
-  /*    recommended for efficiency purposes.                               */
+  /*    passed to the raster constructor).                                 */
   /*                                                                       */
   typedef void
   (*FT_Raster_ResetFunc)( FT_Raster       raster,
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 6d685b5..ba5a24b 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4666,12 +4666,9 @@
       goto Fail;
 #endif
 
-    /* allocate the render pool */
-    library->raster_pool_size = FT_RENDER_POOL_SIZE;
-#if FT_RENDER_POOL_SIZE > 0
-    if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
-      goto Fail;
-#endif
+    /* we don't use raster_pool anymore. */
+    library->raster_pool_size = 0;
+    library->raster_pool      = NULL;
 
     library->version_major = FREETYPE_MAJOR;
     library->version_minor = FREETYPE_MINOR;
@@ -4820,10 +4817,6 @@
     }
 #endif
 
-    /* Destroy raster objects */
-    FT_FREE( library->raster_pool );
-    library->raster_pool_size = 0;
-
 #ifdef FT_CONFIG_OPTION_PIC
     /* Destroy pic container contents */
     ft_pic_container_destroy( library );