From 6d6607b8b3a78a305cc92d6016c411344c8c7b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexei=20Podtelezhnikov=20=28=D0=90=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=B4=D1=82=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=B6=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=29?= Date: Thu, 2 Nov 2023 22:09:18 -0400 Subject: [PATCH] [raster] Modify the split condition. While curving close to a pixel center, vertical and horizontal pass might split the curve differently and cause a rare dropout. This makes the split condition invariant of the sweep direction and more robust. * src/raster/ftraster.c (Bezier_Up): Modify the split condition. --- src/raster/ftraster.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index a77b57fd1..1182ff4b8 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -1124,7 +1124,8 @@ Long miny, Long maxy ) { - Long y1, y2, e, e2, e0; + Long y1, y2, e, e2, e0, dy; + Long dx, x2; TPoint* start_arc; @@ -1189,19 +1190,25 @@ ras.joint = FALSE; y2 = arc[0].y; + x2 = arc[0].x; if ( y2 > e ) { - y1 = arc[degree].y; - if ( y2 - y1 >= ras.precision_step ) + dy = y2 - arc[degree].y; + dx = x2 - arc[degree].x; + + + /* split condition should be invariant of direction */ + if ( dy > ras.precision_step || + dx > ras.precision_step || + -dx > ras.precision_step ) { splitter( arc ); arc += degree; } else { - *top++ = arc[degree].x + FMulDiv( arc[0].x - arc[degree].x, - e - y1, y2 - y1 ); + *top++ = x2 - FMulDiv( y2 - e, dx, dy ); arc -= degree; e += ras.precision; } @@ -1211,7 +1218,7 @@ if ( y2 == e ) { ras.joint = TRUE; - *top++ = arc[0].x; + *top++ = x2; e += ras.precision; }