freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master cb43887: [smooth] Simplify span rendering.


From: Alexei Podtelezhnikov
Subject: [freetype2] master cb43887: [smooth] Simplify span rendering.
Date: Tue, 23 Aug 2016 03:08:11 +0000 (UTC)

branch: master
commit cb4388783cecc893d0542541f3326f3614ca209d
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [smooth] Simplify span rendering.
    
    This removes unnecessary complexity of span merging and buffering.
    Instead, the spans are rendered as they come, speeding up the
    rendering by about 5% percents as a result.
    
    * src/smooth/ftgrays.c [FT_MAX_GRAY_SPANS]: Macro removed.
    (gray_TWorker): Remove span buffer and related fields.
    (gray_sweep, gray_hline): Updated.
    
    * include/freetype/ftimage.h: Remove documentation note about
    `FT_MAX_GRAY_SPANS', which was never in `ftoption.h' and is now gone.
---
 ChangeLog                  |   15 ++++++++
 include/freetype/ftimage.h |   10 -----
 src/smooth/ftgrays.c       |   91 +++-----------------------------------------
 3 files changed, 20 insertions(+), 96 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cfb9ae5..04e9873 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2016-08-22  Alexei Podtelezhnikov  <address@hidden>
+
+       [smooth] Simplify span rendering.
+
+       This removes unnecessary complexity of span merging and buffering.
+       Instead, the spans are rendered as they come, speeding up the
+       rendering by about 5% percents as a result.
+
+       * src/smooth/ftgrays.c [FT_MAX_GRAY_SPANS]: Macro removed.
+       (gray_TWorker): Remove span buffer and related fields.
+       (gray_sweep, gray_hline): Updated.
+
+       * include/freetype/ftimage.h: Remove documentation note about
+       `FT_MAX_GRAY_SPANS', which was never in `ftoption.h' and is now gone.
+
 2016-08-16  Werner Lemberg  <address@hidden>
 
        [truetype] Fix `MPS' instruction.
diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h
index 28b2704..4f86c56 100644
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -860,16 +860,6 @@ FT_BEGIN_HEADER
   /*    This can be used to write anti-aliased outlines directly to a      */
   /*    given background bitmap, and even perform translucency.            */
   /*                                                                       */
-  /*    Note that the `count' field cannot be greater than a fixed value   */
-  /*    defined by the `FT_MAX_GRAY_SPANS' configuration macro in          */
-  /*    `ftoption.h'.  By default, this value is set to~32, which means    */
-  /*    that if there are more than 32~spans on a given scanline, the      */
-  /*    callback is called several times with the same `y' parameter in    */
-  /*    order to draw all callbacks.                                       */
-  /*                                                                       */
-  /*    Otherwise, the callback is only called once per scan-line, and     */
-  /*    only for those scanlines that do have `gray' pixels on them.       */
-  /*                                                                       */
   typedef void
   (*FT_SpanFunc)( int             y,
                   int             count,
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index f23dbe2..6f438ab 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -404,9 +404,6 @@ 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 ) )
@@ -445,12 +442,8 @@ typedef ptrdiff_t  FT_PtrDist;
     FT_Outline  outline;
     FT_Bitmap   target;
 
-    FT_Span     gray_spans[FT_MAX_GRAY_SPANS];
-    int         num_gray_spans;
-
     FT_Raster_Span_Func  render_span;
     void*                render_span_data;
-    int                  span_y;
 
     PCell*     ycells;
 
@@ -1353,64 +1346,16 @@ typedef ptrdiff_t  FT_PtrDist;
         coverage = 255;
     }
 
-    y += ras.min_ey;
-    x += ras.min_ex;
-
     if ( coverage )
     {
-      FT_Span*  span;
-      int       count;
-
-
-      /* see whether we can add this span to the current list */
-      count = ras.num_gray_spans;
-      span  = ras.gray_spans + count - 1;
-      if ( count > 0                  &&
-           span->coverage == coverage &&
-           span->x + span->len == x   &&
-           ras.span_y == y            )
-      {
-        span->len = (unsigned short)( span->len + acount );
-        return;
-      }
-
-      if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
-      {
-        if ( ras.render_span && count > 0 )
-          ras.render_span( ras.span_y, count, ras.gray_spans,
-                           ras.render_span_data );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
-        if ( count > 0 )
-        {
-          int  n;
-
-
-          FT_TRACE7(( "y = %3d ", ras.span_y ));
-          span = ras.gray_spans;
-          for ( n = 0; n < count; n++, span++ )
-            FT_TRACE7(( "[%d..%d]:%02x ",
-                        span->x, span->x + span->len - 1, span->coverage ));
-          FT_TRACE7(( "\n" ));
-        }
+      FT_Span  span;
 
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-        ras.num_gray_spans = 0;
-        ras.span_y         = (int)y;
-
-        span  = ras.gray_spans;
-      }
-      else
-        span++;
 
-      /* add a gray span to the current list */
-      span->x        = (short)x;
-      span->len      = (unsigned short)acount;
-      span->coverage = (unsigned char)coverage;
+      span.x        = (short)( x + ras.min_ex );
+      span.len      = (unsigned short)acount;
+      span.coverage = (unsigned char)coverage;
 
-      ras.num_gray_spans++;
+      ras.render_span( y + ras.min_ey, 1, &span, ras.render_span_data );
     }
   }
 
@@ -1424,9 +1369,6 @@ typedef ptrdiff_t  FT_PtrDist;
     if ( ras.num_cells == 0 )
       return;
 
-    ras.num_gray_spans = 0;
-    ras.span_y         = 0;
-
     FT_TRACE7(( "gray_sweep: start\n" ));
 
     for ( yindex = 0; yindex < ras.count_ey; yindex++ )
@@ -1459,30 +1401,7 @@ typedef ptrdiff_t  FT_PtrDist;
                     ras.count_ex - x );
     }
 
-    if ( ras.render_span && ras.num_gray_spans > 0 )
-      ras.render_span( ras.span_y, ras.num_gray_spans,
-                       ras.gray_spans, ras.render_span_data );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
-    if ( ras.num_gray_spans > 0 )
-    {
-      FT_Span*  span;
-      int       n;
-
-
-      FT_TRACE7(( "y = %3d ", ras.span_y ));
-      span = ras.gray_spans;
-      for ( n = 0; n < ras.num_gray_spans; n++, span++ )
-        FT_TRACE7(( "[%d..%d]:%02x ",
-                    span->x, span->x + span->len - 1, span->coverage ));
-      FT_TRACE7(( "\n" ));
-    }
-
     FT_TRACE7(( "gray_sweep: end\n" ));
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
   }
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]