Huw Davies : gdi32: Try to compact the region.
Alexandre Julliard
julliard at winehq.org
Tue Jul 5 11:07:49 CDT 2016
Module: wine
Branch: master
Commit: 6526ac1999f99a9e24ee2002219b39a9a7e2126e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6526ac1999f99a9e24ee2002219b39a9a7e2126e
Author: Huw Davies <huw at codeweavers.com>
Date: Mon Jul 4 09:05:45 2016 +0100
gdi32: Try to compact the region.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/region.c | 43 +++++++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c
index 834e6be..646512f 100644
--- a/dlls/gdi32/region.c
+++ b/dlls/gdi32/region.c
@@ -1598,6 +1598,28 @@ static INT REGION_Coalesce (
return (curStart);
}
+/**********************************************************************
+ * REGION_compact
+ *
+ * To keep regions from growing without bound, shrink the array of rectangles
+ * to match the new number of rectangles in the region.
+ *
+ * Only do this if the number of rectangles allocated is more than
+ * twice the number of rectangles in the region.
+ */
+static void REGION_compact( WINEREGION *reg )
+{
+ if ((reg->numRects < reg->size / 2) && (reg->numRects > 2))
+ {
+ RECT *new_rects = HeapReAlloc( GetProcessHeap(), 0, reg->rects, reg->numRects * sizeof(RECT) );
+ if (new_rects)
+ {
+ reg->rects = new_rects;
+ reg->size = reg->numRects;
+ }
+ }
+}
+
/***********************************************************************
* REGION_RegionOp
*
@@ -1839,23 +1861,7 @@ static BOOL REGION_RegionOp(
REGION_Coalesce (&newReg, prevBand, curBand);
}
- /*
- * A bit of cleanup. To keep regions from growing without bound,
- * we shrink the array of rectangles to match the new number of
- * rectangles in the region. This never goes to 0, however...
- *
- * Only do this stuff if the number of rectangles allocated is more than
- * twice the number of rectangles in the region (a simple optimization...).
- */
- if ((newReg.numRects < (newReg.size >> 1)) && (newReg.numRects > 2))
- {
- RECT *new_rects = HeapReAlloc( GetProcessHeap(), 0, newReg.rects, newReg.numRects * sizeof(RECT) );
- if (new_rects)
- {
- newReg.rects = new_rects;
- newReg.size = newReg.numRects;
- }
- }
+ REGION_compact( &newReg );
HeapFree( GetProcessHeap(), 0, destReg->rects );
destReg->rects = newReg.rects;
destReg->size = newReg.size;
@@ -2633,8 +2639,9 @@ static BOOL REGION_PtsToRegion( struct point_block *FirstPtBlock, WINEREGION *re
extents->right = 0;
extents->bottom = 0;
}
+ REGION_compact( reg );
- return(TRUE);
+ return TRUE;
}
/***********************************************************************
More information about the wine-cvs
mailing list