This patch is a trivial move of band check out of the loop in the
cubic flattener.
The arcs resulting from any split are always smaller than the original.
If the original is inside the band, the children are inside by definition,
so there is no need to loop this rather long check.

I am working on similar optimization for conic too. What would you suggest as
a proper benchmark here?
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 40de269..53a3a44 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -973,6 +971,7 @@ typedef ptrdiff_t  FT_PtrDist;
                               const FT_Vector*  to )
   {
     FT_Vector*  arc;
+    TPos        min, max, y;
 
 
     arc      = ras.bez_stack;
@@ -985,35 +984,32 @@ typedef ptrdiff_t  FT_PtrDist;
     arc[3].x = ras.x;
     arc[3].y = ras.y;
 
-    for (;;)
-    {
-      /* Check that the arc crosses the current band. */
-      TPos  min, max, y;
-
+    /* Short-cut the arc that crosses the current band. */
+    min = max = arc[0].y;
 
-      min = max = arc[0].y;
+    y = arc[1].y;
+    if ( y < min )
+      min = y;
+    if ( y > max )
+      max = y;
 
-      y = arc[1].y;
-      if ( y < min )
-        min = y;
-      if ( y > max )
-        max = y;
+    y = arc[2].y;
+    if ( y < min )
+      min = y;
+    if ( y > max )
+      max = y;
 
-      y = arc[2].y;
-      if ( y < min )
-        min = y;
-      if ( y > max )
-        max = y;
+    y = arc[3].y;
+    if ( y < min )
+      min = y;
+    if ( y > max )
+      max = y;
 
-      y = arc[3].y;
-      if ( y < min )
-        min = y;
-      if ( y > max )
-        max = y;
-
-      if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
-        goto Draw;
+    if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
+      goto Draw;
 
+    for (;;)
+    {
       /* Decide whether to split or draw. See `Rapid Termination          */
       /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
       /* F. Hain, at                                                      */
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to