From 8f255c89e14219ca2489043f699797ee106ec6e9 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Mon, 27 Nov 2023 22:44:36 -0500 Subject: [PATCH] =?UTF-8?q?[raster]=20Speed=20up=20B=C3=A9zier=20arches=20?= =?UTF-8?q?with=20extrema.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While it is recommended to have an explicit point at each curve extrema, they might be missing or outline could be rotated. This leads to excessive bisections in raster to find them. This change helps to decrease the number of bisections. The scanline intersections remain monotonous, of course. * src/raster/ftraster.c (Conic_To, Cubic_To): Check that control points cross the scanlines to bisect. --- src/raster/ftraster.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 7d5e9e59e..043d2faf0 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -1342,7 +1342,7 @@ ymax = y1; } - if ( y2 < ymin || y2 > ymax ) + if ( y2 < FLOOR( ymin ) || y2 > CEILING( ymax ) ) { /* this arc has no given direction, split it! */ Split_Conic( arc ); @@ -1350,7 +1350,8 @@ } else if ( y1 == y3 ) { - /* this arc is flat, ignore it and pop it from the Bezier stack */ + /* this arc is flat, advance position */ + /* and pop it from the Bezier stack */ arc -= 2; ras.lastX = x3; @@ -1488,7 +1489,7 @@ ymax2 = y2; } - if ( ymin2 < ymin1 || ymax2 > ymax1 ) + if ( ymin2 < FLOOR( ymin1 ) || ymax2 > CEILING( ymax1 ) ) { /* this arc has no given direction, split it! */ Split_Cubic( arc ); @@ -1496,7 +1497,8 @@ } else if ( y1 == y4 ) { - /* this arc is flat, ignore it and pop it from the Bezier stack */ + /* this arc is flat, advance position */ + /* and pop it from the Bezier stack */ arc -= 3; ras.lastX = x4;