Skip to content

Commit

Permalink
harmonize +/-1 conditions some more
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Jul 31, 2024
1 parent 250a9a1 commit 4634d85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
10 changes: 7 additions & 3 deletions img/aafill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions img/polyfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion img/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion include/img_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 4634d85

Please sign in to comment.