freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 32081d812 2/3: [raster] Consolidate profile increment


From: Werner Lemberg
Subject: [freetype2] master 32081d812 2/3: [raster] Consolidate profile increment to the next line.
Date: Sat, 4 Nov 2023 00:06:27 -0400 (EDT)

branch: master
commit 32081d8123342f14b7a0b9811f211c52753de63a
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [raster] Consolidate profile increment to the next line.
    
    * src/raster/ftraster.c (s/Sort/Increment): Rename this function to
    reflect its true purpose, delete exhausted profiles here...
    (Draw_Sweep): ... instead of here.
---
 src/raster/ftraster.c | 69 ++++++++++++++++-----------------------------------
 1 file changed, 22 insertions(+), 47 deletions(-)

diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 5538c0c07..8f4967cd7 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -2019,26 +2019,32 @@
 
   /**************************************************************************
    *
-   * Sort
+   * Increment
    *
-   *   Sorts a trace list.  In 95%, the list is already sorted.  We need
-   *   an algorithm which is fast in this case.  Bubble sort is enough
-   *   and simple.
+   *   Advances all profile in the list to the next scanline.  It also
+   *   sorts the trace list in the unlikely case of profile crossing.
+   *   In 95%, the list is already sorted.  We need an algorithm which
+   *   is fast in this case.  Bubble sort is enough and simple.
    */
   static void
-  Sort( PProfileList  list )
+  Increment( PProfileList  list )
   {
     PProfile  *old, current, next;
 
 
-    /* First, set the new X coordinate of each profile */
-    current = *list;
-    while ( current )
+    /* First, set the new X coordinates and remove exhausted profiles */
+    old = list;
+    while ( *old )
     {
-      current->X       = current->x[current->offset];
-      current->offset += ( current->flags & Flow_Up ) ? 1 : -1;
-      current->height--;
-      current = current->link;
+      current = *old;
+      if ( --current->height )
+      {        
+        current->offset += ( current->flags & Flow_Up ) ? 1 : -1;
+        current->X       = current->x[current->offset];
+        old = &current->link;
+      }
+      else
+        *old = current->link;  /* remove */
     }
 
     /* Then sort them */
@@ -2610,15 +2616,10 @@
           Q = &P->link;
       }
 
-      /* sort the drawing lists */
-
-      Sort( &draw_left );
-      Sort( &draw_right );
-
       y_change = (Int)*ras.maxBuff;
       y_height = y_change - y;
 
-      while ( y < y_change )
+      do
       {
         /* let's trace */
 
@@ -2674,36 +2675,10 @@
 
         ras.Proc_Sweep_Step( RAS_VAR );
 
-        y++;
-
-        if ( y < y_change )
-        {
-          Sort( &draw_left  );
-          Sort( &draw_right );
-        }
-      }
-
-      /* remove exhausted profiles */
-
-      Q = &draw_left;
-      while ( *Q )
-      {
-        P = *Q;
-        if ( P->height == 0 )
-          *Q = P->link;
-        else
-          Q = &P->link;
-      }
-
-      Q = &draw_right;
-      while ( *Q )
-      {
-        P = *Q;
-        if ( P->height == 0 )
-          *Q = P->link;
-        else
-          Q = &P->link;
+        Increment( &draw_left  );
+        Increment( &draw_right );
       }
+      while ( ++y < y_change );
     }
 
     return SUCCESS;



reply via email to

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