Commit f6370e2f0582cf8dd2850756794e9dbbc0f035bc

Alexei Podtelezhnikov 2021-06-25T22:59:39

[raster] Adjust sub-band bisecting limits. We can bisect a band until it is just a single scan line. This might be slow and cause time-outs but if we need to impose limits it should be elsewhere. * src/raster/ftraster.c (Render_Single_Pass): Tweak sub-banding.

diff --git a/ChangeLog b/ChangeLog
index cc5c1f9..fc6d8b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-06-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
+	[raster] Adjust sub-band bisecting limits.
+
+	We can bisect a band until it is just a single scan line.  This might
+	be slow and cause time-outs but if we need to impose limits it should
+	be elsewhere.
+
+	* src/raster/ftraster.c (Render_Single_Pass): Tweak sub-banding.
+
+2021-06-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
 	* src/raster/ftraster.c (Render_Single_Pass): Remove dead code.
 
 2021-06-25  Werner Lemberg  <wl@gnu.org>
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index a1cbf62..b88a436 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -528,6 +528,7 @@
     TPoint      arcs[3 * MaxBezier + 1]; /* The Bezier stack               */
 
     black_TBand  band_stack[16];    /* band stack used for sub-banding     */
+                                    /* enough for signed short bands       */
     Int          band_top;          /* band stack top                      */
 
   };
@@ -3054,19 +3055,19 @@
         i = ras.band_stack[ras.band_top].y_min;
         j = ras.band_stack[ras.band_top].y_max;
 
-        k = (Short)( ( i + j ) / 2 );
-
-        if ( ras.band_top >= 7 || k < i )
+        if ( i == j )
         {
           ras.band_top = 0;
 
           return ras.error;  /* still Raster_Overflow */
         }
 
-        ras.band_stack[ras.band_top + 1].y_min = k;
+        k = (Short)( ( i + j ) / 2 );
+
+        ras.band_stack[ras.band_top + 1].y_min = (Short)( k + 1 );
         ras.band_stack[ras.band_top + 1].y_max = j;
 
-        ras.band_stack[ras.band_top].y_max = (Short)( k - 1 );
+        ras.band_stack[ras.band_top].y_max = k;
 
         ras.band_top++;
       }