Commit 0e93387d authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Use the add_rect() helper to add a rectangle.

parent b1930ee4
...@@ -2592,18 +2592,15 @@ static BOOL REGION_PtsToRegion( struct point_block *FirstPtBlock, WINEREGION *re ...@@ -2592,18 +2592,15 @@ static BOOL REGION_PtsToRegion( struct point_block *FirstPtBlock, WINEREGION *re
RECT *rects; RECT *rects;
POINT *pts; POINT *pts;
struct point_block *pb; struct point_block *pb;
int i; int i, size;
RECT *extents; RECT *extents;
INT numRects;
extents = &reg->extents; extents = &reg->extents;
for (pb = FirstPtBlock, numRects = 0; pb; pb = pb->next) numRects += pb->count; for (pb = FirstPtBlock, size = 0; pb; pb = pb->next) size += pb->count;
if (!init_region( reg, numRects )) return FALSE; if (!init_region( reg, size )) return FALSE;
reg->size = numRects;
rects = reg->rects - 1; rects = reg->rects - 1;
numRects = 0;
extents->left = LARGE_COORDINATE, extents->right = SMALL_COORDINATE; extents->left = LARGE_COORDINATE, extents->right = SMALL_COORDINATE;
for (pb = FirstPtBlock; pb; pb = pb->next) for (pb = FirstPtBlock; pb; pb = pb->next)
...@@ -2613,34 +2610,31 @@ static BOOL REGION_PtsToRegion( struct point_block *FirstPtBlock, WINEREGION *re ...@@ -2613,34 +2610,31 @@ static BOOL REGION_PtsToRegion( struct point_block *FirstPtBlock, WINEREGION *re
for (pts = pb->pts; i--; pts += 2) { for (pts = pb->pts; i--; pts += 2) {
if (pts->x == pts[1].x) if (pts->x == pts[1].x)
continue; continue;
if (numRects && pts->x == rects->left && pts->y == rects->bottom && if (reg->numRects && pts->x == rects->left && pts->y == rects->bottom &&
pts[1].x == rects->right && pts[1].x == rects->right &&
(numRects == 1 || rects[-1].top != rects->top) && (reg->numRects == 1 || rects[-1].top != rects->top) &&
(i && pts[2].y > pts[1].y)) { (i && pts[2].y > pts[1].y)) {
rects->bottom = pts[1].y + 1; rects->bottom = pts[1].y + 1;
continue; continue;
} }
numRects++; add_rect( reg, pts[0].x, pts[0].y, pts[1].x, pts[1].y + 1 );
rects++; rects++;
rects->left = pts->x; rects->top = pts->y; if (pts[0].x < extents->left)
rects->right = pts[1].x; rects->bottom = pts[1].y + 1; extents->left = pts[0].x;
if (rects->left < extents->left) if (pts[1].x > extents->right)
extents->left = rects->left; extents->right = pts[1].x;
if (rects->right > extents->right)
extents->right = rects->right;
} }
} }
if (numRects) { if (reg->numRects) {
extents->top = reg->rects->top; extents->top = reg->rects[0].top;
extents->bottom = rects->bottom; extents->bottom = reg->rects[reg->numRects-1].bottom;
} else { } else {
extents->left = 0; extents->left = 0;
extents->top = 0; extents->top = 0;
extents->right = 0; extents->right = 0;
extents->bottom = 0; extents->bottom = 0;
} }
reg->numRects = numRects;
return(TRUE); return(TRUE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment