shithub: freetype+ttf2subf

Download patch

ref: e73055c791776ec35cb43c39614d35ec5fd99539
parent: a6ee6fe67b7336e2b4bb4d0b881e7ef5e65f07a2
author: Alexei Podtelezhnikov <[email protected]>
date: Mon Aug 29 19:15:35 EDT 2016

[smooth] Streamline pixmap drawing.

This gives 2% speed improvement in rendering simple glyphs.

* src/smooth/ftgrays.c (TPixmap): Reduced pixmap descriptor with a
pointer to its bottom-left and pitch to be used in...
(gray_TWorker): ... here.
(gray_render_span): Move pixmap flow check from here...
(gray_raster_render): .. to here.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2016-08-29  Alexei Podtelezhnikov  <[email protected]>
+
+	[smooth] Streamline pixmap drawing.
+
+	This gives 2% speed improvement in rendering simple glyphs.
+
+	* src/smooth/ftgrays.c (TPixmap): Reduced pixmap descriptor with a
+	pointer to its bottom-left and pitch to be used in...
+	(gray_TWorker): ... here.
+	(gray_render_span): Move pixmap flow check from here...
+	(gray_raster_render): .. to here.
+
 2016-08-27  Alexei Podtelezhnikov  <[email protected]>
 
 	[smooth] Reduce stack of band boundaries.
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -403,7 +403,13 @@
 
   } TCell;
 
+  typedef struct TPixmap_
+  {
+    unsigned char*  origin;  /* pixmap origin at the bottom-left */
+    int             pitch;   /* pitch to go down one row */
 
+  } TPixmap;
+
   /* 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 ) )
@@ -440,7 +446,7 @@
     TPos    x,  y;
 
     FT_Outline  outline;
-    FT_Bitmap   target;
+    TPixmap     target;
 
     FT_Raster_Span_Func  render_span;
     void*                render_span_data;
@@ -1270,15 +1276,9 @@
                     const FT_Span*  spans,
                     gray_PWorker    worker )
   {
-    unsigned char*  p;
-    FT_Bitmap*      map = &worker->target;
+    unsigned char*  p = worker->target.origin - y * worker->target.pitch;
 
 
-    /* first of all, compute the scanline offset */
-    p = (unsigned char*)map->buffer - y * map->pitch;
-    if ( map->pitch >= 0 )
-      p += ( map->rows - 1 ) * (unsigned int)map->pitch;
-
     for ( ; count > 0; count--, spans++ )
     {
       unsigned char  coverage = spans->coverage;
@@ -1962,7 +1962,14 @@
       if ( !target_map->buffer )
         return FT_THROW( Invalid_Argument );
 
-      ras.target           = *target_map;
+      if ( target_map->pitch < 0 )
+        ras.target.origin = target_map->buffer;
+      else
+        ras.target.origin = target_map->buffer
+              + ( target_map->rows - 1 ) * (unsigned int)target_map->pitch;
+
+      ras.target.pitch = target_map->pitch;
+
       ras.render_span      = (FT_Raster_Span_Func)gray_render_span;
       ras.render_span_data = &ras;
     }