From 4634d859e9a5f0b9251debb6b1fcc0f1ae5dad79 Mon Sep 17 00:00:00 2001 From: Dmitry Karasik Date: Wed, 31 Jul 2024 22:54:35 +0200 Subject: [PATCH] harmonize +/-1 conditions some more --- img/aafill.c | 10 +++++++--- img/polyfill.c | 7 ++----- img/region.c | 2 +- include/img_conv.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/img/aafill.c b/img/aafill.c index 617e11ee..662ac69b 100644 --- a/img/aafill.c +++ b/img/aafill.c @@ -60,7 +60,7 @@ skipto( ScanlinePtr* scan, int x, Bool subsample_last_pixel) if ( subsample_last_pixel) { register int x1 = p->x; - register int x2 = p[1].x; + register int x2 = p[1].x - 1; if ( x1 <= x_to && x2 >= x_from ) { if ( x1 < x_from ) x1 = x_from; if ( x2 > x_to ) x2 = x_to; @@ -248,7 +248,11 @@ aafill_init( NPoint *pts, int n_pts, int rule, Rect clip, PAAFillRec ctx) clip.left *= AAX; clip.bottom *= AAY; - clip.right = (clip.right + 1) * AAX - 1; /* convert to exclusive-inclusive coordinates */ + /* convert to exclusive-inclusive coordinates, however, add extra pixel to the right + because poly_poly2points always returns that extra pixel since it is may be needed + for superimpose_outline() later on. + */ + clip.right = (clip.right + 1) * AAX - 1 + 1; clip.top = (clip.top + 1) * AAY - 1; if ( !intersect(&aa_extents, &clip)) { free( pXpts ); @@ -262,7 +266,7 @@ aafill_init( NPoint *pts, int n_pts, int rule, Rect clip, PAAFillRec ctx) DEBUG("EXTENTS %d-%d/%d-%d = %d-%d = %d\n", aa_extents.left, aa_extents.right, aa_extents.bottom, aa_extents.top, ctx->x, xmax_px , ctx->maplen); - ctx->block = poly_poly2points(pXpts, n_pts, rule, &clip); + ctx->block = poly_poly2points(pXpts, n_pts, rule & fmWinding, &clip); free( pXpts ); if ( ctx->block == NULL ) return 0; diff --git a/img/polyfill.c b/img/polyfill.c index 654e469d..d3b32c3b 100644 --- a/img/polyfill.c +++ b/img/polyfill.c @@ -747,7 +747,7 @@ PolyPointBlock* poly_poly2points( Point *Pts, /* the pts */ int Count, /* number of pts */ - int rule, /* winding and outline */ + Bool winding, PRect clip ) { register EdgeTableEntry *pAET; /* Active Edge Table */ @@ -762,12 +762,9 @@ poly_poly2points( ScanLineListBlock SLLBlock; /* header for scanlinelist */ int fixWAET = 0; PolyPointBlock *ret; - Bool outline, winding; unsigned long curr_max_size; - outline = (rule & fmOverlay) ? 1 : 0; - winding = (rule & fmWinding) ? 1 : 0; - DEBUG("init: %s %s\n", winding ? "wind" : "alt", outline ? "outl" : "raw"); + DEBUG("init: %s\n", winding ? "wind" : "alt"); if ( Count < 2 ) return NULL; diff --git a/img/region.c b/img/region.c index edf8a11a..e63909af 100644 --- a/img/region.c +++ b/img/region.c @@ -1122,7 +1122,7 @@ img_region_polygon( Point *pts, int count, int rule) return rect_region(&single); } - if (( pt_block = poly_poly2points(pts, count, rule, NULL)) == NULL ) + if (( pt_block = poly_poly2points(pts, count, rule & fmWinding, NULL)) == NULL ) return NULL; region = points2region(pt_block, outline); free( pt_block ); diff --git a/include/img_conv.h b/include/img_conv.h index 31c51e36..a2671392 100644 --- a/include/img_conv.h +++ b/include/img_conv.h @@ -388,7 +388,7 @@ typedef struct { unsigned long size; Point pts[1]; } PolyPointBlock; -extern PolyPointBlock* poly_poly2points(Point *pts, int count, int rule, PRect clip); +extern PolyPointBlock* poly_poly2points(Point *pts, int count, Bool winding, PRect clip); /* istXXX function */ typedef double FilterFunc( const double x );