Author: jgardou
Date: Wed Sep 17 09:54:27 2014
New Revision: 64177
URL:
http://svn.reactos.org/svn/reactos?rev=64177&view=rev
Log:
[WIN32K]
- Slap *a bit* of sense in the way we use region objects and handles, avoiding a massive
orgy of handle allocations, locks, leaks and so on.
The motto here being "if you don't need a valid user-mode handle, then chances
are that you don't need one at all."
CORE-8506 #resolve #comment Stale region handles should not be passed anymore to user-mode
apps now.
Modified:
trunk/reactos/win32ss/gdi/eng/engwindow.c
trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c
trunk/reactos/win32ss/gdi/ntgdi/fillshap.c
trunk/reactos/win32ss/gdi/ntgdi/path.c
trunk/reactos/win32ss/gdi/ntgdi/path.h
trunk/reactos/win32ss/gdi/ntgdi/region.c
trunk/reactos/win32ss/gdi/ntgdi/region.h
trunk/reactos/win32ss/user/ntuser/defwnd.c
trunk/reactos/win32ss/user/ntuser/desktop.c
trunk/reactos/win32ss/user/ntuser/message.c
trunk/reactos/win32ss/user/ntuser/monitor.c
trunk/reactos/win32ss/user/ntuser/painting.c
trunk/reactos/win32ss/user/ntuser/painting.h
trunk/reactos/win32ss/user/ntuser/simplecall.c
trunk/reactos/win32ss/user/ntuser/vis.c
trunk/reactos/win32ss/user/ntuser/vis.h
trunk/reactos/win32ss/user/ntuser/windc.c
trunk/reactos/win32ss/user/ntuser/winpos.c
Modified: trunk/reactos/win32ss/gdi/eng/engwindow.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/engwindow.…
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/engwindow.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/engwindow.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -52,41 +52,31 @@
XCLIPOBJ* Clip,
PWND Window)
{
- HRGN hVisRgn;
PROSRGNDATA visRgn;
TRACE("IntEngWndUpdateClipObj\n");
- hVisRgn = VIS_ComputeVisibleRegion(Window, TRUE, TRUE, TRUE);
- if (hVisRgn != NULL)
- {
- visRgn = RGNOBJAPI_Lock(hVisRgn, NULL);
- if (visRgn != NULL)
+ visRgn = VIS_ComputeVisibleRegion(Window, TRUE, TRUE, TRUE);
+ if (visRgn != NULL)
+ {
+ if (visRgn->rdh.nCount > 0)
{
- if (visRgn->rdh.nCount > 0)
+ IntEngUpdateClipRegion(Clip, visRgn->rdh.nCount, visRgn->Buffer,
&visRgn->rdh.rcBound);
+ TRACE("Created visible region with %lu rects\n",
visRgn->rdh.nCount);
+ TRACE(" BoundingRect: %d, %d %d, %d\n",
+ visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top,
+ visRgn->rdh.rcBound.right, visRgn->rdh.rcBound.bottom);
{
- IntEngUpdateClipRegion(Clip, visRgn->rdh.nCount, visRgn->Buffer,
&visRgn->rdh.rcBound);
- TRACE("Created visible region with %lu rects\n",
visRgn->rdh.nCount);
- TRACE(" BoundingRect: %d, %d %d, %d\n",
- visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top,
- visRgn->rdh.rcBound.right, visRgn->rdh.rcBound.bottom);
+ ULONG i;
+ for (i = 0; i < visRgn->rdh.nCount; i++)
{
- ULONG i;
- for (i = 0; i < visRgn->rdh.nCount; i++)
- {
- TRACE(" Rect #%lu: %ld,%ld %ld,%ld\n", i+1,
- visRgn->Buffer[i].left, visRgn->Buffer[i].top,
- visRgn->Buffer[i].right, visRgn->Buffer[i].bottom);
- }
+ TRACE(" Rect #%lu: %ld,%ld %ld,%ld\n", i+1,
+ visRgn->Buffer[i].left, visRgn->Buffer[i].top,
+ visRgn->Buffer[i].right, visRgn->Buffer[i].bottom);
}
}
- RGNOBJAPI_Unlock(visRgn);
}
- else
- {
- WARN("Couldn't lock visible region of window DC\n");
- }
- GreDeleteObject(hVisRgn);
+ REGION_Delete(visRgn);
}
else
{
Modified: trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -477,7 +477,7 @@
HDC hDC,
int Mode)
{
- HRGN hrgnPath;
+ PREGION RgnPath;
PPATH pPath;
BOOL success = FALSE;
PDC_ATTR pdcattr;
@@ -507,20 +507,30 @@
}
/* Construct a region from the path */
- else if (PATH_PathToRegion(pPath, pdcattr->jFillMode, &hrgnPath))
- {
- PREGION prgnPath = REGION_LockRgn(hrgnPath);
- ASSERT(prgnPath);
- success = IntGdiExtSelectClipRgn(pdc, prgnPath, Mode) != ERROR;
- REGION_UnlockRgn(prgnPath);
- GreDeleteObject( hrgnPath );
-
- /* Empty the path */
- if (success)
- PATH_EmptyPath(pPath);
-
- /* FIXME: Should this function delete the path even if it failed? */
- }
+ RgnPath = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (!RgnPath)
+ {
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ DC_UnlockDc(pdc);
+ return FALSE;
+ }
+
+ if (!PATH_PathToRegion(pPath, pdcattr->jFillMode, RgnPath))
+ {
+ EngSetLastError(ERROR_CAN_NOT_COMPLETE);
+ REGION_Delete(RgnPath);
+ DC_UnlockDc(pdc);
+ return FALSE;
+ }
+
+ success = IntGdiExtSelectClipRgn(pdc, RgnPath, Mode) != ERROR;
+ REGION_Delete(RgnPath);
+
+ /* Empty the path */
+ if (success)
+ PATH_EmptyPath(pPath);
+
+ /* FIXME: Should this function delete the path even if it failed? */
PATH_UnlockPath(pPath);
DC_UnlockDc(pdc);
Modified: trunk/reactos/win32ss/gdi/ntgdi/fillshap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/fillshap…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/fillshap.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/fillshap.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -458,8 +458,24 @@
/* Special handling for GdiPolyPolyRgn */
if (iFunc == GdiPolyPolyRgn)
{
+ PREGION Rgn;
HRGN hRgn;
- hRgn = IntCreatePolyPolygonRgn(SafePoints, SafeCounts, Count, (INT_PTR)hDC);
+
+ Rgn = REGION_AllocUserRgnWithHandle(0);
+ if (!Rgn)
+ {
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ ExFreePoolWithTag(pTemp, TAG_SHAPE);
+ return 0;
+ }
+ hRgn = Rgn->BaseObject.hHmgr;
+ if (!IntSetPolyPolygonRgn(SafePoints, SafeCounts, Count, hDC ? 1 : 2, Rgn))
+ {
+ /* EngSetLastError ? */
+ GreDeleteObject(hRgn);
+ hRgn = NULL;
+ }
+ RGNOBJAPI_Unlock(Rgn);
ExFreePoolWithTag(pTemp, TAG_SHAPE);
return (ULONG_PTR)hRgn;
}
Modified: trunk/reactos/win32ss/gdi/ntgdi/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/path.c?r…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/path.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/path.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -98,7 +98,7 @@
//SIZE ptViewportExt, ptWindowExt;
//POINTL ptViewportOrg, ptWindowOrg;
XFORM xform;
- HRGN hrgn;
+ PREGION Rgn;
PDC_ATTR pdcattr = dc->pdcattr;
if (pPath->state != PATH_Closed)
@@ -107,61 +107,72 @@
return FALSE;
}
- if (PATH_PathToRegion(pPath, pdcattr->jFillMode, &hrgn))
- {
- /* Since PaintRgn interprets the region as being in logical coordinates
- * but the points we store for the path are already in device
- * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
- * Using SaveDC to save information about the mapping mode / world
- * transform would be easier but would require more overhead, especially
- * now that SaveDC saves the current path.
- */
-
- /* Save the information about the old mapping mode */
- //mapMode = pdcattr->iMapMode;
- //ptViewportExt = pdcattr->szlViewportExt;
- //ptViewportOrg = pdcattr->ptlViewportOrg;
- //ptWindowExt = pdcattr->szlWindowExt;
- //ptWindowOrg = pdcattr->ptlWindowOrg;
-
- /* Save world transform
- * NB: The Windows documentation on world transforms would lead one to
- * believe that this has to be done only in GM_ADVANCED; however, my
- * tests show that resetting the graphics mode to GM_COMPATIBLE does
- * not reset the world transform.
- */
- MatrixS2XForm(&xform, &dc->pdcattr->mxWorldToPage);
-
- /* Set MM_TEXT */
+ /* Allocate a temporary region */
+ Rgn = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (!Rgn)
+ {
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ if (!PATH_PathToRegion(pPath, pdcattr->jFillMode, Rgn))
+ {
+ /* EngSetLastError ? */
+ REGION_Delete(Rgn);
+ return FALSE;
+ }
+
+ /* Since PaintRgn interprets the region as being in logical coordinates
+ * but the points we store for the path are already in device
+ * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
+ * Using SaveDC to save information about the mapping mode / world
+ * transform would be easier but would require more overhead, especially
+ * now that SaveDC saves the current path.
+ */
+
+ /* Save the information about the old mapping mode */
+ //mapMode = pdcattr->iMapMode;
+ //ptViewportExt = pdcattr->szlViewportExt;
+ //ptViewportOrg = pdcattr->ptlViewportOrg;
+ //ptWindowExt = pdcattr->szlWindowExt;
+ //ptWindowOrg = pdcattr->ptlWindowOrg;
+
+ /* Save world transform
+ * NB: The Windows documentation on world transforms would lead one to
+ * believe that this has to be done only in GM_ADVANCED; however, my
+ * tests show that resetting the graphics mode to GM_COMPATIBLE does
+ * not reset the world transform.
+ */
+ MatrixS2XForm(&xform, &dc->pdcattr->mxWorldToPage);
+
+ /* Set MM_TEXT */
// IntGdiSetMapMode(dc, MM_TEXT);
// pdcattr->ptlViewportOrg.x = 0;
// pdcattr->ptlViewportOrg.y = 0;
// pdcattr->ptlWindowOrg.x = 0;
// pdcattr->ptlWindowOrg.y = 0;
- // graphicsMode = pdcattr->iGraphicsMode;
+ // graphicsMode = pdcattr->iGraphicsMode;
// pdcattr->iGraphicsMode = GM_ADVANCED;
// IntGdiModifyWorldTransform(dc, &xform, MWT_IDENTITY);
// pdcattr->iGraphicsMode = graphicsMode;
- /* Paint the region */
- IntGdiPaintRgn(dc, hrgn);
- GreDeleteObject(hrgn);
- /* Restore the old mapping mode */
+ /* Paint the region */
+ IntGdiPaintRgn(dc, Rgn);
+ REGION_Delete(Rgn);
+ /* Restore the old mapping mode */
// IntGdiSetMapMode(dc, mapMode);
// pdcattr->szlViewportExt = ptViewportExt;
// pdcattr->ptlViewportOrg = ptViewportOrg;
// pdcattr->szlWindowExt = ptWindowExt;
// pdcattr->ptlWindowOrg = ptWindowOrg;
- /* Go to GM_ADVANCED temporarily to restore the world transform */
- //graphicsMode = pdcattr->iGraphicsMode;
+ /* Go to GM_ADVANCED temporarily to restore the world transform */
+ //graphicsMode = pdcattr->iGraphicsMode;
// pdcattr->iGraphicsMode = GM_ADVANCED;
// IntGdiModifyWorldTransform(dc, &xform, MWT_MAX+1);
// pdcattr->iGraphicsMode = graphicsMode;
- return TRUE;
- }
- return FALSE;
+ return TRUE;
}
/* PATH_InitGdiPath
@@ -1221,14 +1232,14 @@
PATH_PathToRegion(
PPATH pPath,
INT nPolyFillMode,
- HRGN *pHrgn)
+ PREGION Rgn)
{
int numStrokes, iStroke, i;
PULONG pNumPointsInStroke;
- HRGN hrgn = 0;
+ BOOL Ret;
ASSERT(pPath != NULL);
- ASSERT(pHrgn != NULL);
+ ASSERT(Rgn != NULL);
PATH_FlattenPath(pPath);
@@ -1268,23 +1279,18 @@
pNumPointsInStroke[iStroke]++;
}
- /* Create a region from the strokes */
- hrgn = IntCreatePolyPolygonRgn(pPath->pPoints,
- pNumPointsInStroke,
- numStrokes,
- nPolyFillMode);
- if (hrgn == (HRGN)0)
- {
- EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
+ /* Fill the region with the strokes */
+ Ret = IntSetPolyPolygonRgn(pPath->pPoints,
+ pNumPointsInStroke,
+ numStrokes,
+ nPolyFillMode,
+ Rgn);
/* Free memory for number-of-points-in-stroke array */
ExFreePoolWithTag(pNumPointsInStroke, TAG_PATH);
/* Success! */
- *pHrgn = hrgn;
- return TRUE;
+ return Ret;
}
/* PATH_EmptyPath
@@ -2675,6 +2681,7 @@
{
PPATH pPath;
HRGN hrgnRval = 0;
+ PREGION Rgn;
DC *pDc;
PDC_ATTR pdcattr;
@@ -2703,9 +2710,25 @@
}
else
{
+ /* Create the region and fill it with the path strokes */
+ Rgn = REGION_AllocUserRgnWithHandle(1);
+ if (!Rgn)
+ {
+ PATH_UnlockPath(pPath);
+ DC_UnlockDc(pDc);
+ }
+ hrgnRval = Rgn->BaseObject.hHmgr;
/* FIXME: Should we empty the path even if conversion failed? */
- if (PATH_PathToRegion(pPath, pdcattr->jFillMode, &hrgnRval))
+ if (PATH_PathToRegion(pPath, pdcattr->jFillMode, Rgn))
+ {
PATH_EmptyPath(pPath);
+ }
+ else
+ {
+ GreDeleteObject(hrgnRval);
+ hrgnRval = NULL;
+ }
+ RGNOBJAPI_Unlock(Rgn);
}
PATH_UnlockPath(pPath);
Modified: trunk/reactos/win32ss/gdi/ntgdi/path.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/path.h?r…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/path.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/path.h [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -67,7 +67,7 @@
BOOL FASTCALL PATH_PolyPolyline( PDC dc, const POINT* pts, const DWORD* counts, DWORD
polylines);
BOOL FASTCALL PATH_Rectangle (PDC dc, INT x1, INT y1, INT x2, INT y2);
BOOL FASTCALL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT
ell_height);
-BOOL FASTCALL PATH_PathToRegion (PPATH pPath, INT nPolyFillMode, HRGN *pHrgn);
+BOOL FASTCALL PATH_PathToRegion (PPATH pPath, INT nPolyFillMode, PREGION Rgn);
BOOL FASTCALL PATH_ExtTextOut(PDC dc,INT x,INT y,UINT flags,const RECTL *lprc,LPCWSTR
str,UINT count,const INT *dx);
BOOL FASTCALL PATH_AddEntry (PPATH pPath, const POINT *pPoint, BYTE flags);
Modified: trunk/reactos/win32ss/gdi/ntgdi/region.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/region.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/region.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/region.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -1956,46 +1956,35 @@
}
+static
BOOL FASTCALL
REGION_LPTODP(
- PDC dc,
- HRGN hDest,
- HRGN hSrc)
+ _In_ PDC dc,
+ _Inout_ PREGION RgnDest,
+ _In_ PREGION RgnSrc)
{
RECTL *pCurRect, *pEndRect;
- PROSRGNDATA srcObj = NULL;
- PROSRGNDATA destObj = NULL;
-
RECTL tmpRect;
- BOOL ret = FALSE;
PDC_ATTR pdcattr;
if (!dc)
- return ret;
+ return FALSE;
pdcattr = dc->pdcattr;
if (pdcattr->iMapMode == MM_TEXT) // Requires only a translation
{
- if (NtGdiCombineRgn(hDest, hSrc, 0, RGN_COPY) == ERROR)
- goto done;
-
- NtGdiOffsetRgn(hDest, pdcattr->ptlViewportOrg.x - pdcattr->ptlWindowOrg.x,
+ if (IntGdiCombineRgn(RgnDest, RgnSrc, 0, RGN_COPY) == ERROR)
+ return FALSE;
+
+ IntGdiOffsetRgn(RgnDest, pdcattr->ptlViewportOrg.x -
pdcattr->ptlWindowOrg.x,
pdcattr->ptlViewportOrg.y - pdcattr->ptlWindowOrg.y);
- ret = TRUE;
- goto done;
- }
-
- if ( !(srcObj = RGNOBJAPI_Lock(hSrc, NULL)) )
- goto done;
- if ( !(destObj = RGNOBJAPI_Lock(hDest, NULL)) )
- {
- RGNOBJAPI_Unlock(srcObj);
- goto done;
- }
- EMPTY_REGION(destObj);
-
- pEndRect = srcObj->Buffer + srcObj->rdh.nCount;
- for (pCurRect = srcObj->Buffer; pCurRect < pEndRect; pCurRect++)
+ return TRUE;
+ }
+
+ EMPTY_REGION(RgnDest);
+
+ pEndRect = RgnSrc->Buffer + RgnSrc->rdh.nCount;
+ for (pCurRect = RgnSrc->Buffer; pCurRect < pEndRect; pCurRect++)
{
tmpRect = *pCurRect;
tmpRect.left = XLPTODP(pdcattr, tmpRect.left);
@@ -2016,15 +2005,10 @@
tmpRect.bottom = tmp;
}
- REGION_UnionRectWithRgn(destObj, &tmpRect);
- }
- ret = TRUE;
-
- RGNOBJAPI_Unlock(srcObj);
- RGNOBJAPI_Unlock(destObj);
-
-done:
- return ret;
+ REGION_UnionRectWithRgn(RgnDest, &tmpRect);
+ }
+
+ return TRUE;
}
PROSRGNDATA
@@ -2236,7 +2220,7 @@
PREGION prgn;
/* Allocate a region, witout a handle */
- prgn = (PREGION)GDIOBJ_AllocateObject(GDIObjType_RGN_TYPE, sizeof(REGION), 0);
+ prgn = (PREGION)GDIOBJ_AllocateObject(GDIObjType_RGN_TYPE, sizeof(REGION),
BASEFLAG_LOOKASIDE);
if (!prgn)
{
return NULL;
@@ -2248,31 +2232,6 @@
REGION_SetRectRgn(prgn, LeftRect, TopRect, RightRect, BottomRect);
return prgn;
-}
-
-HRGN
-FASTCALL
-IntSysCreateRectRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
-{
- PREGION prgn;
- HRGN hrgn;
-
- /* Allocate a region, witout a handle */
- prgn = (PREGION)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_REGION, sizeof(REGION));
- if (!prgn)
- {
- return NULL;
- }
-
- /* Initialize it */
- prgn->Buffer = &prgn->rdh.rcBound;
- REGION_SetRectRgn(prgn, LeftRect, TopRect, RightRect, BottomRect);
- hrgn = prgn->BaseObject.hHmgr;
- prgn->prgnattr = &prgn->rgnattr;
-
- REGION_UnlockRgn(prgn);
-
- return hrgn;
}
VOID NTAPI
@@ -2479,44 +2438,42 @@
FASTCALL
IntGdiPaintRgn(
PDC dc,
- HRGN hRgn
+ PREGION Rgn
)
{
- HRGN tmpVisRgn;
- PROSRGNDATA visrgn;
+ PROSRGNDATA VisRgn;
XCLIPOBJ ClipRegion;
BOOL bRet = FALSE;
POINTL BrushOrigin;
SURFACE *psurf;
PDC_ATTR pdcattr;
- if (!dc) return FALSE;
+ if (!dc || !Rgn)
+ return FALSE;
+
pdcattr = dc->pdcattr;
ASSERT(!(pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)));
- if (!(tmpVisRgn = IntSysCreateRectRgn(0, 0, 0, 0))) return FALSE;
+ VisRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (!VisRgn)
+ {
+ return FALSE;
+ }
// Transform region into device co-ords
- if (!REGION_LPTODP(dc, tmpVisRgn, hRgn) ||
- NtGdiOffsetRgn(tmpVisRgn, dc->ptlDCOrig.x, dc->ptlDCOrig.y) == ERROR)
- {
- GreDeleteObject(tmpVisRgn);
+ if (!REGION_LPTODP(dc, VisRgn, Rgn) ||
+ IntGdiOffsetRgn(VisRgn, dc->ptlDCOrig.x, dc->ptlDCOrig.y) == ERROR)
+ {
+ REGION_Delete(VisRgn);
return FALSE;
}
- visrgn = RGNOBJAPI_Lock(tmpVisRgn, NULL);
- if (visrgn == NULL)
- {
- GreDeleteObject(tmpVisRgn);
- return FALSE;
- }
-
if (dc->prgnRao)
- IntGdiCombineRgn(visrgn, visrgn, dc->prgnRao, RGN_AND);
+ IntGdiCombineRgn(VisRgn, VisRgn, dc->prgnRao, RGN_AND);
IntEngInitClipObj(&ClipRegion);
- IntEngUpdateClipRegion(&ClipRegion, visrgn->rdh.nCount, visrgn->Buffer,
&visrgn->rdh.rcBound );
+ IntEngUpdateClipRegion(&ClipRegion, VisRgn->rdh.nCount, VisRgn->Buffer,
&VisRgn->rdh.rcBound );
BrushOrigin.x = pdcattr->ptlBrushOrigin.x;
BrushOrigin.y = pdcattr->ptlBrushOrigin.y;
@@ -2529,8 +2486,7 @@
&BrushOrigin,
0xFFFF); // FIXME: Don't know what to put here
- RGNOBJAPI_Unlock(visrgn);
- GreDeleteObject(tmpVisRgn);
+ REGION_Delete(VisRgn);
IntEngFreeClipResources(&ClipRegion);
// Fill the region
@@ -3129,16 +3085,15 @@
}
}
-HRGN FASTCALL
-IntCreatePolyPolygonRgn(
+BOOL FASTCALL
+IntSetPolyPolygonRgn(
POINT *Pts,
PULONG Count,
INT nbpolygons,
- INT mode
+ INT mode,
+ PREGION Rgn
)
{
- HRGN hrgn;
- ROSRGNDATA *region;
EdgeTableEntry *pAET; /* Active Edge Table */
INT y; /* Current scanline */
int iPts = 0; /* Number of pts in buffer */
@@ -3158,10 +3113,6 @@
if (mode == 0 || mode > 2) return 0;
- if (!(region = REGION_AllocUserRgnWithHandle(nbpolygons)))
- return 0;
- hrgn = region->BaseObject.hHmgr;
-
/* Special case a rectangle */
if (((nbpolygons == 1) && ((*Count == 4) ||
@@ -3175,18 +3126,19 @@
(Pts[2].x == Pts[3].x) &&
(Pts[3].y == Pts[0].y))))
{
- RGNOBJAPI_Unlock(region);
- NtGdiSetRectRgn(hrgn, min(Pts[0].x, Pts[2].x), min(Pts[0].y, Pts[2].y),
- max(Pts[0].x, Pts[2].x), max(Pts[0].y, Pts[2].y));
- return hrgn;
+ REGION_SetRectRgn(Rgn,
+ min(Pts[0].x, Pts[2].x),
+ min(Pts[0].y, Pts[2].y),
+ max(Pts[0].x, Pts[2].x),
+ max(Pts[0].y, Pts[2].y));
+ return TRUE;
}
for (poly = total = 0; poly < nbpolygons; poly++)
total += Count[poly];
if (! (pETEs = ExAllocatePoolWithTag(PagedPool, sizeof(EdgeTableEntry) * total,
TAG_REGION)) )
{
- GreDeleteObject(hrgn);
- return 0;
+ return FALSE;
}
pts = FirstPtBlock.pts;
REGION_CreateETandAET(Count, nbpolygons, Pts, &ET, &AET, pETEs,
&SLLBlock);
@@ -3230,7 +3182,7 @@
{
DPRINT1("Can't alloc tPB\n");
ExFreePoolWithTag(pETEs, TAG_REGION);
- return 0;
+ return FALSE;
}
curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock;
@@ -3289,8 +3241,7 @@
{
DPRINT1("Can't alloc tPB\n");
ExFreePoolWithTag(pETEs, TAG_REGION);
- GreDeleteObject(hrgn);
- return 0;
+ return FALSE;
}
curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock;
@@ -3315,7 +3266,7 @@
}
}
REGION_FreeStorage(SLLBlock.next);
- REGION_PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
+ REGION_PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, Rgn);
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;)
{
@@ -3324,8 +3275,7 @@
curPtBlock = tmpPtBlock;
}
ExFreePoolWithTag(pETEs, TAG_REGION);
- RGNOBJAPI_Unlock(region);
- return hrgn;
+ return TRUE;
}
BOOL
@@ -3431,6 +3381,8 @@
REGION_SetRectRgn(pRgn, LeftRect, TopRect, RightRect, BottomRect);
RGNOBJAPI_Unlock(pRgn);
+
+ DPRINT1("Returning %p.\n", hRgn);
return hRgn;
}
@@ -3762,7 +3714,7 @@
HRGN FrameRgn;
BOOL Ret;
- if (!(FrameRgn = IntSysCreateRectRgn(0, 0, 0, 0)))
+ if (!(FrameRgn = NtGdiCreateRectRgn(0, 0, 0, 0)))
{
return FALSE;
}
Modified: trunk/reactos/win32ss/gdi/ntgdi/region.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/region.h…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/region.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/region.h [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -40,8 +40,8 @@
VOID FASTCALL IntGdiReleaseVisRgn(PDC);
INT APIENTRY IntGdiGetRgnBox(HRGN, RECTL*);
-BOOL FASTCALL IntGdiPaintRgn(PDC, HRGN );
-HRGN FASTCALL IntCreatePolyPolygonRgn(PPOINT, PULONG, INT, INT);
+BOOL FASTCALL IntGdiPaintRgn(PDC, PREGION );
+BOOL FASTCALL IntSetPolyPolygonRgn(PPOINT, PULONG, INT, INT, PREGION);
INT FASTCALL IntGdiOffsetRgn(PROSRGNDATA,INT,INT);
BOOL FASTCALL IntRectInRegion(HRGN,LPRECTL);
@@ -49,12 +49,8 @@
INT FASTCALL REGION_Complexity(PROSRGNDATA);
PROSRGNDATA FASTCALL RGNOBJAPI_Lock(HRGN,PRGN_ATTR *);
VOID FASTCALL RGNOBJAPI_Unlock(PROSRGNDATA);
-HRGN FASTCALL IntSysCreateRectRgn(INT,INT,INT,INT);
PROSRGNDATA FASTCALL IntSysCreateRectpRgn(INT,INT,INT,INT);
BOOL FASTCALL IntGdiSetRegionOwner(HRGN,DWORD);
-
-#define IntSysCreateRectRgnIndirect(prc) \
- IntSysCreateRectRgn((prc)->left, (prc)->top, (prc)->right, (prc)->bottom)
#define IntSysCreateRectpRgnIndirect(prc) \
IntSysCreateRectpRgn((prc)->left, (prc)->top, (prc)->right, (prc)->bottom)
Modified: trunk/reactos/win32ss/user/ntuser/defwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/defwnd…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/defwnd.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -1010,16 +1010,20 @@
case WM_SYNCPAINT:
{
- HRGN hRgn;
+ PREGION Rgn;
Wnd->state &= ~WNDS_SYNCPAINTPENDING;
ERR("WM_SYNCPAINT\n");
- hRgn = IntSysCreateRectRgn(0, 0, 0, 0);
- if (co_UserGetUpdateRgn(Wnd, hRgn, FALSE) != NULLREGION)
+ Rgn = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (Rgn)
{
- if (!wParam) wParam = (RDW_ERASENOW | RDW_ERASE | RDW_FRAME |
RDW_ALLCHILDREN);
- co_UserRedrawWindow(Wnd, NULL, hRgn, wParam);
+ if (co_UserGetUpdateRgn(Wnd, Rgn, FALSE) != NULLREGION)
+ {
+ if (!wParam)
+ wParam = (RDW_ERASENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
+ co_UserRedrawWindow(Wnd, NULL, Rgn, wParam);
+ }
+ REGION_Delete(Rgn);
}
- GreDeleteObject(hRgn);
return 0;
}
Modified: trunk/reactos/win32ss/user/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -752,19 +752,19 @@
UserRedrawDesktop()
{
PWND Window = NULL;
- HRGN hRgn;
+ PREGION Rgn;
Window = UserGetDesktopWindow();
- hRgn = IntSysCreateRectRgnIndirect(&Window->rcWindow);
+ Rgn = IntSysCreateRectpRgnIndirect(&Window->rcWindow);
IntInvalidateWindows( Window,
- hRgn,
+ Rgn,
RDW_FRAME |
RDW_ERASE |
RDW_INVALIDATE |
RDW_ALLCHILDREN);
- GreDeleteObject(hRgn);
+ REGION_Delete(Rgn);
}
Modified: trunk/reactos/win32ss/user/ntuser/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/messag…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -652,7 +652,6 @@
LRESULT retval = 0;
PTHREADINFO pti;
PWND Window = NULL;
- HRGN hrgn;
BOOL DoCallBack = TRUE;
if (pMsg->hwnd)
@@ -743,11 +742,12 @@
if (pMsg->message == WM_PAINT)
{
+ PREGION Rgn;
Window->state2 &= ~WNDS2_WMPAINTSENT;
/* send a WM_NCPAINT and WM_ERASEBKGND if the non-client area is still invalid
*/
- hrgn = IntSysCreateRectRgn( 0, 0, 0, 0 );
- co_UserGetUpdateRgn( Window, hrgn, TRUE );
- GreDeleteObject(hrgn);
+ Rgn = IntSysCreateRectpRgn( 0, 0, 0, 0 );
+ co_UserGetUpdateRgn( Window, Rgn, TRUE );
+ REGION_Delete(Rgn);
}
return retval;
Modified: trunk/reactos/win32ss/user/ntuser/monitor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/monito…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/monitor.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/monitor.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -258,7 +258,11 @@
}
/* ...and create new one */
- pMonitor->hrgnMonitor = IntSysCreateRectRgnIndirect(&pMonitor->rcMonitor);
+ pMonitor->hrgnMonitor = NtGdiCreateRectRgn(
+ pMonitor->rcMonitor.left,
+ pMonitor->rcMonitor.top,
+ pMonitor->rcMonitor.right,
+ pMonitor->rcMonitor.bottom);
if (pMonitor->hrgnMonitor)
IntGdiSetRegionOwner(pMonitor->hrgnMonitor, GDI_OBJ_HMGR_PUBLIC);
Modified: trunk/reactos/win32ss/user/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/painti…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/painting.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/painting.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -56,7 +56,7 @@
}
BOOL FASTCALL
-IntValidateParent(PWND Child, HRGN hValidateRgn, BOOL Recurse)
+IntValidateParent(PWND Child, PREGION ValidateRgn, BOOL Recurse)
{
PWND ParentWnd = Child;
@@ -81,7 +81,7 @@
return FALSE;
IntInvalidateWindows( ParentWnd,
- hValidateRgn,
+ ValidateRgn,
RDW_VALIDATE | RDW_NOCHILDREN);
}
@@ -177,9 +177,21 @@
HRGN hRgnWindow;
if (Client)
- hRgnWindow = IntSysCreateRectRgnIndirect(&Wnd->rcClient);
+ {
+ hRgnWindow = NtGdiCreateRectRgn(
+ Wnd->rcClient.left,
+ Wnd->rcClient.top,
+ Wnd->rcClient.right,
+ Wnd->rcClient.bottom);
+ }
else
- hRgnWindow = IntSysCreateRectRgnIndirect(&Wnd->rcWindow);
+ {
+ hRgnWindow = NtGdiCreateRectRgn(
+ Wnd->rcWindow.left,
+ Wnd->rcWindow.top,
+ Wnd->rcWindow.right,
+ Wnd->rcWindow.bottom);
+ }
if (Wnd->hrgnClip != NULL && !(Wnd->style & WS_MINIMIZE))
{
@@ -302,8 +314,16 @@
{
if (Wnd->hrgnUpdate)
{
- if (!IntValidateParent(Wnd, Wnd->hrgnUpdate, Recurse))
- return;
+ PREGION RgnUpdate = RGNOBJAPI_Lock(Wnd->hrgnUpdate, NULL);
+ if (RgnUpdate)
+ {
+ if (!IntValidateParent(Wnd, RgnUpdate, Recurse))
+ {
+ RGNOBJAPI_Unlock(RgnUpdate);
+ return;
+ }
+ RGNOBJAPI_Unlock(RgnUpdate);
+ }
}
if (Flags & RDW_UPDATENOW)
@@ -397,7 +417,7 @@
* co_WinPosSetWindowPos, IntValidateParent, co_UserRedrawWindow.
*/
VOID FASTCALL
-IntInvalidateWindows(PWND Wnd, HRGN hRgn, ULONG Flags)
+IntInvalidateWindows(PWND Wnd, PREGION Rgn, ULONG Flags)
{
INT RgnType;
BOOL HadPaintMessage;
@@ -412,11 +432,14 @@
*/
if (0 != (Flags & RDW_INVALIDATE) && 0 == (Flags & RDW_FRAME))
{
- HRGN hRgnClient;
-
- hRgnClient = IntSysCreateRectRgnIndirect(&Wnd->rcClient);
- RgnType = NtGdiCombineRgn(hRgn, hRgn, hRgnClient, RGN_AND);
- GreDeleteObject(hRgnClient);
+ PREGION RgnClient;
+
+ RgnClient = IntSysCreateRectpRgnIndirect(&Wnd->rcClient);
+ if (RgnClient)
+ {
+ RgnType = IntGdiCombineRgn(Rgn, Rgn, RgnClient, RGN_AND);
+ REGION_Delete(RgnClient);
+ }
}
/*
@@ -425,21 +448,27 @@
if (!Wnd->hrgnClip || (Wnd->style & WS_MINIMIZE))
{
- HRGN hRgnWindow;
-
- hRgnWindow = IntSysCreateRectRgnIndirect(&Wnd->rcWindow);
- RgnType = NtGdiCombineRgn(hRgn, hRgn, hRgnWindow, RGN_AND);
- GreDeleteObject(hRgnWindow);
+ PREGION RgnWindow = IntSysCreateRectpRgnIndirect(&Wnd->rcWindow);
+ if (RgnWindow)
+ {
+ RgnType = IntGdiCombineRgn(Rgn, Rgn, RgnWindow, RGN_AND);
+ REGION_Delete(RgnWindow);
+ }
}
else
{
- NtGdiOffsetRgn( hRgn,
- -Wnd->rcWindow.left,
- -Wnd->rcWindow.top);
- RgnType = NtGdiCombineRgn(hRgn, hRgn, Wnd->hrgnClip, RGN_AND);
- NtGdiOffsetRgn( hRgn,
- Wnd->rcWindow.left,
- Wnd->rcWindow.top);
+ PREGION RgnClip = RGNOBJAPI_Lock(Wnd->hrgnClip, NULL);
+ if (RgnClip)
+ {
+ IntGdiOffsetRgn( Rgn,
+ -Wnd->rcWindow.left,
+ -Wnd->rcWindow.top);
+ RgnType = IntGdiCombineRgn(Rgn, Rgn, RgnClip, RGN_AND);
+ IntGdiOffsetRgn( Rgn,
+ Wnd->rcWindow.left,
+ Wnd->rcWindow.top);
+ RGNOBJAPI_Unlock(RgnClip);
+ }
}
/*
@@ -462,6 +491,8 @@
if (Flags & RDW_INVALIDATE && RgnType != NULLREGION)
{
+ PREGION RgnUpdate;
+
Wnd->state &= ~WNDS_NONCPAINT;
/* If not the same thread set it dirty. */
@@ -479,16 +510,21 @@
if (Wnd->hrgnUpdate == NULL)
{
- Wnd->hrgnUpdate = IntSysCreateRectRgn(0, 0, 0, 0);
+ Wnd->hrgnUpdate = NtGdiCreateRectRgn(0, 0, 0, 0);
IntGdiSetRegionOwner(Wnd->hrgnUpdate, GDI_OBJ_HMGR_PUBLIC);
}
- if (NtGdiCombineRgn(Wnd->hrgnUpdate, Wnd->hrgnUpdate,
- hRgn, RGN_OR) == NULLREGION)
+ RgnUpdate = RGNOBJAPI_Lock(Wnd->hrgnUpdate, NULL);
+ if (RgnUpdate)
{
- IntGdiSetRegionOwner(Wnd->hrgnUpdate, GDI_OBJ_HMGR_POWNED);
- GreDeleteObject(Wnd->hrgnUpdate);
- Wnd->hrgnUpdate = NULL;
+ RgnType = IntGdiCombineRgn(RgnUpdate, RgnUpdate, Rgn, RGN_OR);
+ RGNOBJAPI_Unlock(RgnUpdate);
+ if (RgnType == NULLREGION)
+ {
+ IntGdiSetRegionOwner(Wnd->hrgnUpdate, GDI_OBJ_HMGR_POWNED);
+ GreDeleteObject(Wnd->hrgnUpdate);
+ Wnd->hrgnUpdate = NULL;
+ }
}
Flags |= RDW_FRAME; // For children.
}
@@ -511,13 +547,20 @@
if (Wnd->hrgnUpdate != NULL)
{
- if (NtGdiCombineRgn(Wnd->hrgnUpdate, Wnd->hrgnUpdate,
- hRgn, RGN_DIFF) == NULLREGION)
- {
- IntGdiSetRegionOwner(Wnd->hrgnUpdate, GDI_OBJ_HMGR_POWNED);
- GreDeleteObject(Wnd->hrgnUpdate);
- Wnd->hrgnUpdate = NULL;
- }
+ PREGION RgnUpdate = RGNOBJAPI_Lock(Wnd->hrgnUpdate, NULL);
+
+ if (RgnUpdate)
+ {
+ RgnType = IntGdiCombineRgn(RgnUpdate, RgnUpdate, Rgn, RGN_DIFF);
+ RGNOBJAPI_Unlock(RgnUpdate);
+
+ if(RgnType == NULLREGION)
+ {
+ IntGdiSetRegionOwner(Wnd->hrgnUpdate, GDI_OBJ_HMGR_POWNED);
+ GreDeleteObject(Wnd->hrgnUpdate);
+ Wnd->hrgnUpdate = NULL;
+ }
+ }
}
if (Wnd->hrgnUpdate == NULL)
@@ -541,10 +584,13 @@
/*
* Recursive call to update children hrgnUpdate
*/
- HRGN hRgnTemp = IntSysCreateRectRgn(0, 0, 0, 0);
- NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
- IntInvalidateWindows(Child, hRgnTemp, Flags);
- GreDeleteObject(hRgnTemp);
+ PREGION RgnTemp = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (RgnTemp)
+ {
+ IntGdiCombineRgn(RgnTemp, Rgn, 0, RGN_COPY);
+ IntInvalidateWindows(Child, RgnTemp, Flags);
+ REGION_Delete(RgnTemp);
+ }
}
}
}
@@ -602,10 +648,10 @@
co_UserRedrawWindow(
PWND Window,
const RECTL* UpdateRect,
- HRGN UpdateRgn,
+ PREGION UpdateRgn,
ULONG Flags)
{
- HRGN hRgn = NULL;
+ PREGION TmpRgn = NULL;
TRACE("co_UserRedrawWindow start\n");
/*
@@ -626,35 +672,37 @@
if (Flags & (RDW_INVALIDATE | RDW_VALIDATE)) // Both are OKAY!
{
- if (UpdateRgn != NULL)
- {
- hRgn = IntSysCreateRectRgn(0, 0, 0, 0);
- if (NtGdiCombineRgn(hRgn, UpdateRgn, NULL, RGN_COPY) == NULLREGION)
- {
- GreDeleteObject(hRgn);
- hRgn = NULL;
- }
- else
- NtGdiOffsetRgn(hRgn, Window->rcClient.left, Window->rcClient.top);
+ if (UpdateRgn)
+ {
+ TmpRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (IntGdiCombineRgn(TmpRgn, UpdateRgn, NULL, RGN_COPY) == NULLREGION)
+ {
+ REGION_Delete(TmpRgn);
+ TmpRgn = NULL;
+ }
+ else
+ {
+ IntGdiOffsetRgn(TmpRgn, Window->rcClient.left,
Window->rcClient.top);
+ }
}
else if (UpdateRect != NULL)
{
if (!RECTL_bIsEmptyRect(UpdateRect))
{
- hRgn = IntSysCreateRectRgnIndirect((RECTL *)UpdateRect);
- NtGdiOffsetRgn(hRgn, Window->rcClient.left, Window->rcClient.top);
+ TmpRgn = IntSysCreateRectpRgnIndirect(UpdateRect);
+ IntGdiOffsetRgn(TmpRgn, Window->rcClient.left, Window->rcClient.top);
}
}
else if ((Flags & (RDW_INVALIDATE | RDW_FRAME)) == (RDW_INVALIDATE | RDW_FRAME)
||
(Flags & (RDW_VALIDATE | RDW_NOFRAME)) == (RDW_VALIDATE |
RDW_NOFRAME))
{
if (!RECTL_bIsEmptyRect(&Window->rcWindow))
- hRgn = IntSysCreateRectRgnIndirect(&Window->rcWindow);
+ TmpRgn = IntSysCreateRectpRgnIndirect(&Window->rcWindow);
}
else
{
if (!RECTL_bIsEmptyRect(&Window->rcClient))
- hRgn = IntSysCreateRectRgnIndirect(&Window->rcClient);
+ TmpRgn = IntSysCreateRectpRgnIndirect(&Window->rcClient);
}
}
@@ -664,9 +712,9 @@
*/
if (Flags & (RDW_INVALIDATE | RDW_VALIDATE | RDW_INTERNALPAINT |
RDW_NOINTERNALPAINT) &&
- hRgn != NULL)
- {
- IntInvalidateWindows(Window, hRgn, Flags);
+ TmpRgn != NULL)
+ {
+ IntInvalidateWindows(Window, TmpRgn, Flags);
}
/*
@@ -685,9 +733,9 @@
* Cleanup ;-)
*/
- if (hRgn != NULL)
- {
- GreDeleteObject(hRgn);
+ if (TmpRgn != NULL)
+ {
+ REGION_Delete(TmpRgn);
}
TRACE("co_UserRedrawWindow exit\n");
@@ -991,7 +1039,7 @@
for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
{
if (Child->hrgnUpdate == NULL && Child->state &
WNDS_SENDNCPAINT) // Helped fixing test_redrawnow.
- IntInvalidateWindows(Child, Window->hrgnUpdate, RDW_FRAME | RDW_ERASE |
RDW_INVALIDATE | RDW_ALLCHILDREN);
+ IntInvalidateWindows(Child, NULL, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
RDW_ALLCHILDREN);
}
}
}
@@ -1157,32 +1205,38 @@
}
INT FASTCALL
-co_UserGetUpdateRgn(PWND Window, HRGN hRgn, BOOL bErase)
-{
- int RegionType;
- RECTL Rect;
-
- ASSERT_REFS_CO(Window);
-
- Window->state &= ~WNDS_UPDATEDIRTY;
-
- if (Window->hrgnUpdate == NULL)
- {
- RegionType = (NtGdiSetRectRgn(hRgn, 0, 0, 0, 0) ? NULLREGION : ERROR);
- }
- else
- {
- Rect = Window->rcClient;
- IntIntersectWithParents(Window, &Rect);
- NtGdiSetRectRgn(hRgn, Rect.left, Rect.top, Rect.right, Rect.bottom);
- RegionType = NtGdiCombineRgn(hRgn, hRgn, Window->hrgnUpdate, RGN_AND);
- NtGdiOffsetRgn(hRgn, -Window->rcClient.left, -Window->rcClient.top);
- }
+co_UserGetUpdateRgn(PWND Window, PREGION Rgn, BOOL bErase)
+{
+ int RegionType;
+ RECTL Rect;
+ PREGION UpdateRgn;
+
+ ASSERT_REFS_CO(Window);
+
+ Window->state &= ~WNDS_UPDATEDIRTY;
+
+ if (Window->hrgnUpdate == NULL)
+ {
+ REGION_SetRectRgn(Rgn, 0, 0, 0, 0);
+ return NULLREGION;
+ }
+
+ UpdateRgn = RGNOBJAPI_Lock(Window->hrgnUpdate, NULL);
+ if (!UpdateRgn)
+ return ERROR;
+
+ Rect = Window->rcClient;
+ IntIntersectWithParents(Window, &Rect);
+ REGION_SetRectRgn(Rgn, Rect.left, Rect.top, Rect.right, Rect.bottom);
+ RegionType = IntGdiCombineRgn(Rgn, Rgn, UpdateRgn, RGN_AND);
+ IntGdiOffsetRgn(Rgn, -Window->rcClient.left, -Window->rcClient.top);
if (bErase && RegionType != NULLREGION && RegionType != ERROR)
{
co_UserRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN);
}
+
+ RGNOBJAPI_Unlock(UpdateRgn);
return RegionType;
}
@@ -1201,6 +1255,7 @@
PWND Window;
INT ret;
USER_REFERENCE_ENTRY Ref;
+ PREGION Rgn = NULL;
TRACE("Enter NtUserGetUpdateRgn\n");
UserEnterExclusive();
@@ -1210,13 +1265,19 @@
RETURN(ERROR);
}
+ Rgn = RGNOBJAPI_Lock(hRgn, NULL);
+ if (!Rgn)
+ RETURN(ERROR);
+
UserRefObjectCo(Window, &Ref);
- ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
+ ret = co_UserGetUpdateRgn(Window, Rgn, bErase);
UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
+ if (Rgn)
+ RGNOBJAPI_Unlock(Rgn);
TRACE("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
@@ -1327,6 +1388,7 @@
BOOL Ret;
USER_REFERENCE_ENTRY Ref;
NTSTATUS Status = STATUS_SUCCESS;
+ PREGION RgnUpdate = NULL;
DECLARE_RETURN(BOOL);
TRACE("Enter NtUserRedrawWindow\n");
@@ -1365,11 +1427,21 @@
RETURN( FALSE);
}
+ if (hrgnUpdate)
+ {
+ RgnUpdate = RGNOBJAPI_Lock(hrgnUpdate, NULL);
+ if (!RgnUpdate)
+ {
+ EngSetLastError(ERROR_INVALID_HANDLE);
+ RETURN(FALSE);
+ }
+ }
+
UserRefObjectCo(Wnd, &Ref);
Ret = co_UserRedrawWindow( Wnd,
lprcUpdate ? &SafeUpdateRect : NULL,
- hrgnUpdate,
+ RgnUpdate,
flags);
UserDerefObjectCo(Wnd);
@@ -1377,6 +1449,8 @@
RETURN( Ret);
CLEANUP:
+ if (RgnUpdate)
+ RGNOBJAPI_Unlock(RgnUpdate);
TRACE("Leave NtUserRedrawWindow, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
@@ -1390,7 +1464,7 @@
INT dy,
const RECTL *prcScroll,
const RECTL *prcClip,
- HRGN hrgnUpdate,
+ PREGION RgnUpdate,
RECTL *prcUpdate)
{
PDC pDC;
@@ -1435,10 +1509,9 @@
/* Calculate the region that was invalidated by moving or
could not be copied, because it was not visible */
- if (hrgnUpdate || prcUpdate)
- {
- HRGN hrgnOwn, hrgnTmp;
- PREGION prgnTmp;
+ if (RgnUpdate || prcUpdate)
+ {
+ PREGION RgnOwn, RgnTmp;
pDC = DC_LockDc(hDC);
if (!pDC)
@@ -1450,44 +1523,38 @@
rcDst = rcScroll;
RECTL_vOffsetRect(&rcDst, dx, dy);
RECTL_bIntersectRect(&rcDst, &rcDst, &rcClip);
- if (hrgnUpdate)
- {
- hrgnOwn = hrgnUpdate;
- if (!NtGdiSetRectRgn(hrgnOwn, rcDst.left, rcDst.top, rcDst.right,
rcDst.bottom))
- {
- DC_UnlockDc(pDC);
- return ERROR;
- }
+ if (RgnUpdate)
+ {
+ RgnOwn = RgnUpdate;
+ REGION_SetRectRgn(RgnOwn, rcDst.left, rcDst.top, rcDst.right, rcDst.bottom);
}
else
{
- hrgnOwn = IntSysCreateRectRgnIndirect(&rcDst);
+ RgnOwn = IntSysCreateRectpRgnIndirect(&rcDst);
}
/* Add the source rect */
- hrgnTmp = IntSysCreateRectRgnIndirect(&rcSrc);
- NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_OR);
+ RgnTmp = IntSysCreateRectpRgnIndirect(&rcSrc);
+ IntGdiCombineRgn(RgnOwn, RgnOwn, RgnTmp, RGN_OR);
/* Substract the part of the dest that was visible in source */
- prgnTmp = RGNOBJAPI_Lock(hrgnTmp, NULL);
- IntGdiCombineRgn(prgnTmp, prgnTmp, pDC->prgnVis, RGN_AND);
- RGNOBJAPI_Unlock(prgnTmp);
- NtGdiOffsetRgn(hrgnTmp, dx, dy);
- Result = NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_DIFF);
+ IntGdiCombineRgn(RgnTmp, RgnTmp, pDC->prgnVis, RGN_AND);
+ IntGdiOffsetRgn(RgnTmp, dx, dy);
+ Result = IntGdiCombineRgn(RgnOwn, RgnOwn, RgnTmp, RGN_DIFF);
/* DO NOT Unlock DC while messing with prgnVis! */
DC_UnlockDc(pDC);
- GreDeleteObject(hrgnTmp);
+ REGION_Delete(RgnTmp);
if (prcUpdate)
{
- IntGdiGetRgnBox(hrgnOwn, prcUpdate);
- }
-
- if (!hrgnUpdate)
- {
- GreDeleteObject(hrgnOwn);
+ REGION_GetRgnBox(RgnOwn, prcUpdate);
+ }
+
+ if (!RgnUpdate)
+ {
+ REGION_Delete(RgnOwn);
}
}
else
@@ -1516,6 +1583,7 @@
RECTL rcScroll, rcClip, rcUpdate;
NTSTATUS Status = STATUS_SUCCESS;
DWORD Result;
+ PREGION RgnUpdate = NULL;
TRACE("Enter NtUserScrollDC\n");
UserEnterExclusive();
@@ -1546,6 +1614,13 @@
{
SetLastNtError(Status);
RETURN(FALSE);
+ }
+
+ if (hrgnUpdate)
+ {
+ RgnUpdate = RGNOBJAPI_Lock(hrgnUpdate, NULL);
+ if (!RgnUpdate)
+ RETURN(FALSE);
}
Result = UserScrollDC( hDC,
@@ -1553,7 +1628,7 @@
dy,
prcUnsafeScroll? &rcScroll : 0,
prcUnsafeClip? &rcClip : 0,
- hrgnUpdate,
+ RgnUpdate,
prcUnsafeUpdate? &rcUpdate : NULL);
if(Result == ERROR)
{
@@ -1583,6 +1658,8 @@
RETURN(TRUE);
CLEANUP:
+ if (RgnUpdate)
+ RGNOBJAPI_Unlock(RgnUpdate);
TRACE("Leave NtUserScrollDC, ret=%lu\n",_ret_);
UserLeave();
END_CLEANUP;
@@ -1610,7 +1687,7 @@
INT Result;
PWND Window = NULL, CaretWnd;
HDC hDC;
- HRGN hrgnOwn = NULL, hrgnTemp, hrgnWinupd = NULL;
+ PREGION RgnOwn = NULL, RgnTemp, RgnWinupd = NULL;
HWND hwndCaret;
DWORD dcxflags = 0;
int rdw_flags;
@@ -1668,11 +1745,15 @@
if (hrgnUpdate)
{
- hrgnOwn = hrgnUpdate;
+ RgnOwn = RGNOBJAPI_Lock(hrgnUpdate, NULL);
+ if (!RgnOwn)
+ {
+ RETURN(ERROR);
+ }
bOwnRgn = FALSE;
}
else
- hrgnOwn = IntSysCreateRectRgn(0, 0, 0, 0);
+ RgnOwn = IntSysCreateRectpRgn(0, 0, 0, 0);
/* ScrollWindow uses the window DC, ScrollWindowEx doesn't */
if (flags & SW_SCROLLWNDDCE)
@@ -1709,7 +1790,7 @@
dy,
&rcScroll,
&rcClip,
- hrgnOwn,
+ RgnOwn,
prcUnsafeUpdate? &rcUpdate : NULL);
UserReleaseDC(Window, hDC, FALSE);
@@ -1719,22 +1800,29 @@
* the scroll. Keep a copy in hrgnWinupd to be added to hrngUpdate at the end.
*/
- hrgnTemp = IntSysCreateRectRgn(0, 0, 0, 0);
- if (co_UserGetUpdateRgn(Window, hrgnTemp, FALSE) != NULLREGION)
- {
- HRGN hrgnClip = IntSysCreateRectRgnIndirect(&rcClip);
- if (!bOwnRgn)
- {
- hrgnWinupd = IntSysCreateRectRgn( 0, 0, 0, 0);
- NtGdiCombineRgn( hrgnWinupd, hrgnTemp, 0, RGN_COPY);
- }
- NtGdiOffsetRgn(hrgnTemp, dx, dy);
- NtGdiCombineRgn(hrgnTemp, hrgnTemp, hrgnClip, RGN_AND);
- if (!bOwnRgn) NtGdiCombineRgn( hrgnWinupd, hrgnWinupd, hrgnTemp, RGN_OR );
- co_UserRedrawWindow(Window, NULL, hrgnTemp, rdw_flags );
- GreDeleteObject(hrgnClip);
- }
- GreDeleteObject(hrgnTemp);
+ RgnTemp = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (RgnTemp)
+ {
+ if (co_UserGetUpdateRgn(Window, RgnTemp, FALSE) != NULLREGION)
+ {
+ PREGION RgnClip = IntSysCreateRectpRgnIndirect(&rcClip);
+ if (RgnClip)
+ {
+ if (!bOwnRgn)
+ {
+ RgnWinupd = IntSysCreateRectpRgn( 0, 0, 0, 0);
+ IntGdiCombineRgn( RgnWinupd, RgnTemp, 0, RGN_COPY);
+ }
+ IntGdiOffsetRgn(RgnTemp, dx, dy);
+ IntGdiCombineRgn(RgnTemp, RgnTemp, RgnClip, RGN_AND);
+ if (!bOwnRgn)
+ IntGdiCombineRgn( RgnWinupd, RgnWinupd, RgnTemp, RGN_OR );
+ co_UserRedrawWindow(Window, NULL, RgnTemp, rdw_flags );
+ REGION_Delete(RgnClip);
+ }
+ }
+ REGION_Delete(RgnTemp);
+ }
if (flags & SW_SCROLLCHILDREN)
{
@@ -1766,7 +1854,7 @@
if (flags & (SW_INVALIDATE | SW_ERASE))
{
- co_UserRedrawWindow(Window, NULL, hrgnOwn, rdw_flags |
+ co_UserRedrawWindow(Window, NULL, RgnOwn, rdw_flags |
((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
}
@@ -1805,15 +1893,19 @@
RETURN(Result);
CLEANUP:
- if (hrgnWinupd && !bOwnRgn)
- {
- NtGdiCombineRgn( hrgnOwn, hrgnOwn, hrgnWinupd, RGN_OR);
- GreDeleteObject(hrgnWinupd);
- }
-
- if (hrgnOwn && !hrgnUpdate)
- {
- GreDeleteObject(hrgnOwn);
+ if (RgnWinupd && !bOwnRgn)
+ {
+ IntGdiCombineRgn( RgnOwn, RgnOwn, RgnWinupd, RGN_OR);
+ REGION_Delete(RgnWinupd);
+ }
+
+ if (RgnOwn && !hrgnUpdate)
+ {
+ REGION_Delete(RgnOwn);
+ }
+ else if (RgnOwn)
+ {
+ RGNOBJAPI_Unlock(RgnOwn);
}
if (Window)
Modified: trunk/reactos/win32ss/user/ntuser/painting.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/painti…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/painting.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/painting.h [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -1,12 +1,12 @@
#pragma once
-BOOL FASTCALL co_UserRedrawWindow(PWND Wnd, const RECTL* UpdateRect, HRGN UpdateRgn,
ULONG Flags);
-VOID FASTCALL IntInvalidateWindows(PWND Window, HRGN hRgn, ULONG Flags);
+BOOL FASTCALL co_UserRedrawWindow(PWND Wnd, const RECTL* UpdateRect, PREGION UpdateRgn,
ULONG Flags);
+VOID FASTCALL IntInvalidateWindows(PWND Window, PREGION Rgn, ULONG Flags);
BOOL FASTCALL IntGetPaintMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax,
PTHREADINFO Thread, MSG *Message, BOOL Remove);
INT FASTCALL UserRealizePalette(HDC);
-INT FASTCALL co_UserGetUpdateRgn(PWND, HRGN, BOOL);
+INT FASTCALL co_UserGetUpdateRgn(PWND, PREGION, BOOL);
VOID FASTCALL co_IntPaintWindows(PWND Window, ULONG Flags, BOOL Recurse);
-BOOL FASTCALL IntValidateParent(PWND Child, HRGN hValidateRgn, BOOL Recurse);
+BOOL FASTCALL IntValidateParent(PWND Child, PREGION ValidateRgn, BOOL Recurse);
BOOL FASTCALL IntIsWindowDirty(PWND);
BOOL FASTCALL IntEndPaint(PWND,PPAINTSTRUCT);
HDC FASTCALL IntBeginPaint(PWND,PPAINTSTRUCT);
Modified: trunk/reactos/win32ss/user/ntuser/simplecall.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/simple…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/simplecall.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/simplecall.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -793,8 +793,15 @@
switch (Routine)
{
case TWOPARAM_ROUTINE_VALIDATERGN:
- Ret = (DWORD)co_UserRedrawWindow( Window, NULL, (HRGN)Param, RDW_VALIDATE);
- break;
+ {
+ PREGION Rgn = RGNOBJAPI_Lock((HRGN)Param, NULL);
+ if (Rgn)
+ {
+ Ret = (DWORD)co_UserRedrawWindow( Window, NULL, Rgn, RDW_VALIDATE);
+ RGNOBJAPI_Unlock(Rgn);
+ }
+ break;
+ }
}
UserDerefObjectCo(Window);
Modified: trunk/reactos/win32ss/user/ntuser/vis.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/vis.c?…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/vis.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/vis.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -9,14 +9,14 @@
#include <win32k.h>
DBG_DEFAULT_CHANNEL(UserWinpos);
-HRGN FASTCALL
+PREGION FASTCALL
VIS_ComputeVisibleRegion(
PWND Wnd,
BOOLEAN ClientArea,
BOOLEAN ClipChildren,
BOOLEAN ClipSiblings)
{
- HRGN VisRgn, ClipRgn;
+ PREGION VisRgn, ClipRgn;
PWND PreviousWindow, CurrentWindow, CurrentSibling;
if (!Wnd || !(Wnd->style & WS_VISIBLE))
@@ -28,11 +28,11 @@
if (ClientArea)
{
- VisRgn = IntSysCreateRectRgnIndirect(&Wnd->rcClient);
+ VisRgn = IntSysCreateRectpRgnIndirect(&Wnd->rcClient);
}
else
{
- VisRgn = IntSysCreateRectRgnIndirect(&Wnd->rcWindow);
+ VisRgn = IntSysCreateRectpRgnIndirect(&Wnd->rcWindow);
}
/*
@@ -48,19 +48,21 @@
if (!VerifyWnd(CurrentWindow))
{
ERR("ATM the Current Window or Parent is dead! %p\n",CurrentWindow);
- if (VisRgn) GreDeleteObject(VisRgn);
+ if (VisRgn)
+ REGION_Delete(VisRgn);
return NULL;
}
if (!(CurrentWindow->style & WS_VISIBLE))
{
- if (VisRgn) GreDeleteObject(VisRgn);
+ if (VisRgn)
+ REGION_Delete(VisRgn);
return NULL;
}
- ClipRgn = IntSysCreateRectRgnIndirect(&CurrentWindow->rcClient);
- NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_AND);
- GreDeleteObject(ClipRgn);
+ ClipRgn = IntSysCreateRectpRgnIndirect(&CurrentWindow->rcClient);
+ IntGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_AND);
+ REGION_Delete(ClipRgn);
if ((PreviousWindow->style & WS_CLIPSIBLINGS) ||
(PreviousWindow == Wnd && ClipSiblings))
@@ -72,16 +74,21 @@
if ((CurrentSibling->style & WS_VISIBLE) &&
!(CurrentSibling->ExStyle & WS_EX_TRANSPARENT))
{
- ClipRgn = IntSysCreateRectRgnIndirect(&CurrentSibling->rcWindow);
+ ClipRgn = IntSysCreateRectpRgnIndirect(&CurrentSibling->rcWindow);
/* Combine it with the window region if available */
if (CurrentSibling->hrgnClip && !(CurrentSibling->style
& WS_MINIMIZE))
{
- NtGdiOffsetRgn(ClipRgn, -CurrentSibling->rcWindow.left,
-CurrentSibling->rcWindow.top);
- NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentSibling->hrgnClip,
RGN_AND);
- NtGdiOffsetRgn(ClipRgn, CurrentSibling->rcWindow.left,
CurrentSibling->rcWindow.top);
+ PREGION SiblingClipRgn = RGNOBJAPI_Lock(CurrentSibling->hrgnClip,
NULL);
+ if (SiblingClipRgn)
+ {
+ IntGdiOffsetRgn(ClipRgn, -CurrentSibling->rcWindow.left,
-CurrentSibling->rcWindow.top);
+ IntGdiCombineRgn(ClipRgn, ClipRgn, SiblingClipRgn, RGN_AND);
+ IntGdiOffsetRgn(ClipRgn, CurrentSibling->rcWindow.left,
CurrentSibling->rcWindow.top);
+ RGNOBJAPI_Unlock(SiblingClipRgn);
+ }
}
- NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
- GreDeleteObject(ClipRgn);
+ IntGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
+ REGION_Delete(ClipRgn);
}
CurrentSibling = CurrentSibling->spwndNext;
}
@@ -99,16 +106,20 @@
if ((CurrentWindow->style & WS_VISIBLE) &&
!(CurrentWindow->ExStyle & WS_EX_TRANSPARENT))
{
- ClipRgn = IntSysCreateRectRgnIndirect(&CurrentWindow->rcWindow);
+ ClipRgn = IntSysCreateRectpRgnIndirect(&CurrentWindow->rcWindow);
/* Combine it with the window region if available */
if (CurrentWindow->hrgnClip && !(CurrentWindow->style &
WS_MINIMIZE))
{
- NtGdiOffsetRgn(ClipRgn, -CurrentWindow->rcWindow.left,
-CurrentWindow->rcWindow.top);
- NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentWindow->hrgnClip, RGN_AND);
- NtGdiOffsetRgn(ClipRgn, CurrentWindow->rcWindow.left,
CurrentWindow->rcWindow.top);
+ PREGION CurrentRgnClip = RGNOBJAPI_Lock(CurrentWindow->hrgnClip,
NULL);
+ if (CurrentRgnClip)
+ {
+ IntGdiOffsetRgn(ClipRgn, -CurrentWindow->rcWindow.left,
-CurrentWindow->rcWindow.top);
+ IntGdiCombineRgn(ClipRgn, ClipRgn, CurrentRgnClip, RGN_AND);
+ IntGdiOffsetRgn(ClipRgn, CurrentWindow->rcWindow.left,
CurrentWindow->rcWindow.top);
+ }
}
- NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
- GreDeleteObject(ClipRgn);
+ IntGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
+ REGION_Delete(ClipRgn);
}
CurrentWindow = CurrentWindow->spwndNext;
}
@@ -116,9 +127,14 @@
if (Wnd->hrgnClip && !(Wnd->style & WS_MINIMIZE))
{
- NtGdiOffsetRgn(VisRgn, -Wnd->rcWindow.left, -Wnd->rcWindow.top);
- NtGdiCombineRgn(VisRgn, VisRgn, Wnd->hrgnClip, RGN_AND);
- NtGdiOffsetRgn(VisRgn, Wnd->rcWindow.left, Wnd->rcWindow.top);
+ PREGION WndRgnClip = RGNOBJAPI_Lock(Wnd->hrgnClip, NULL);
+ if (WndRgnClip)
+ {
+ IntGdiOffsetRgn(VisRgn, -Wnd->rcWindow.left, -Wnd->rcWindow.top);
+ IntGdiCombineRgn(VisRgn, VisRgn, WndRgnClip, RGN_AND);
+ IntGdiOffsetRgn(VisRgn, Wnd->rcWindow.left, Wnd->rcWindow.top);
+ RGNOBJAPI_Unlock(WndRgnClip);
+ }
}
return VisRgn;
@@ -127,9 +143,8 @@
VOID FASTCALL
co_VIS_WindowLayoutChanged(
PWND Wnd,
- HRGN NewlyExposed)
+ PREGION NewlyExposed)
{
- HRGN Temp;
PWND Parent;
USER_REFERENCE_ENTRY Ref;
@@ -138,20 +153,23 @@
Parent = Wnd->spwndParent;
if(Parent)
{
- Temp = IntSysCreateRectRgn(0, 0, 0, 0);
+ PREGION TempRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
- NtGdiCombineRgn(Temp, NewlyExposed, NULL, RGN_COPY);
- NtGdiOffsetRgn(Temp,
- Wnd->rcWindow.left - Parent->rcClient.left,
- Wnd->rcWindow.top - Parent->rcClient.top);
+ if (!TempRgn)
+ return;
- UserRefObjectCo(Parent, &Ref);
- co_UserRedrawWindow(Parent, NULL, Temp,
- RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
- RDW_ALLCHILDREN);
- UserDerefObjectCo(Parent);
+ IntGdiCombineRgn(TempRgn, NewlyExposed, NULL, RGN_COPY);
+ IntGdiOffsetRgn(TempRgn,
+ Wnd->rcWindow.left - Parent->rcClient.left,
+ Wnd->rcWindow.top - Parent->rcClient.top);
- GreDeleteObject(Temp);
+ UserRefObjectCo(Parent, &Ref);
+ co_UserRedrawWindow(Parent, NULL, TempRgn,
+ RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
+ RDW_ALLCHILDREN);
+ UserDerefObjectCo(Parent);
+
+ REGION_Delete(TempRgn);
}
}
Modified: trunk/reactos/win32ss/user/ntuser/vis.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/vis.h?…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/vis.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/vis.h [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -9,7 +9,7 @@
#pragma once
-HRGN FASTCALL VIS_ComputeVisibleRegion(PWND Window, BOOLEAN ClientArea, BOOLEAN
ClipChildren, BOOLEAN ClipSiblings);
-VOID FASTCALL co_VIS_WindowLayoutChanged(PWND Window, HRGN UncoveredRgn);
+PREGION FASTCALL VIS_ComputeVisibleRegion(PWND Window, BOOLEAN ClientArea, BOOLEAN
ClipChildren, BOOLEAN ClipSiblings);
+VOID FASTCALL co_VIS_WindowLayoutChanged(PWND Window, PREGION UncoveredRgn);
/* EOF */
Modified: trunk/reactos/win32ss/user/ntuser/windc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/windc.…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/windc.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/windc.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -69,24 +69,10 @@
PREGION FASTCALL
DceGetVisRgn(PWND Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
{
- PREGION RetRgn;
- HRGN hVisRgn;
- hVisRgn = VIS_ComputeVisibleRegion( Window,
- 0 == (Flags & DCX_WINDOW),
- 0 != (Flags & DCX_CLIPCHILDREN),
- 0 != (Flags & DCX_CLIPSIBLINGS));
-
- RetRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
-
- if (hVisRgn != NULL)
- {
- PREGION VisRgn = REGION_LockRgn(hVisRgn);
- IntGdiCombineRgn(RetRgn, VisRgn, NULL, RGN_COPY);
- REGION_UnlockRgn(VisRgn);
- GreDeleteObject(hVisRgn);
- }
-
- return RetRgn;
+ return VIS_ComputeVisibleRegion( Window,
+ 0 == (Flags & DCX_WINDOW),
+ 0 != (Flags & DCX_CLIPCHILDREN),
+ 0 != (Flags & DCX_CLIPSIBLINGS));
}
PDCE FASTCALL
@@ -582,11 +568,19 @@
{
if (!(Flags & DCX_WINDOW))
{
- Dce->hrgnClip = IntSysCreateRectRgnIndirect(&Wnd->rcClient);
+ Dce->hrgnClip = NtGdiCreateRectRgn(
+ Wnd->rcClient.left,
+ Wnd->rcClient.top,
+ Wnd->rcClient.right,
+ Wnd->rcClient.bottom);
}
else
{
- Dce->hrgnClip = IntSysCreateRectRgnIndirect(&Wnd->rcWindow);
+ Dce->hrgnClip = NtGdiCreateRectRgn(
+ Wnd->rcWindow.left,
+ Wnd->rcWindow.top,
+ Wnd->rcWindow.right,
+ Wnd->rcWindow.bottom);
}
Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
bUpdateVisRgn = TRUE;
Modified: trunk/reactos/win32ss/user/ntuser/winpos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winpos…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/winpos.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/winpos.c [iso-8859-1] Wed Sep 17 09:54:27 2014
@@ -1652,13 +1652,10 @@
RECTL NewWindowRect;
RECTL NewClientRect;
RECTL valid_rects[2];
- PROSRGNDATA VisRgn;
- HRGN VisBefore = NULL;
- HRGN VisBeforeJustClient = NULL;
- HRGN VisAfter = NULL;
- HRGN DirtyRgn = NULL;
- HRGN ExposedRgn = NULL;
- HRGN CopyRgn = NULL;
+ PREGION VisBefore = NULL;
+ PREGION VisBeforeJustClient = NULL;
+ PREGION VisAfter = NULL;
+ PREGION CopyRgn = NULL;
ULONG WvrFlags = 0;
RECTL OldWindowRect, OldClientRect;
int RgnType;
@@ -1736,20 +1733,16 @@
{
VisBefore = VIS_ComputeVisibleRegion(Window, FALSE, FALSE,
(Window->style & WS_CLIPSIBLINGS) ?
TRUE : FALSE);
- VisRgn = NULL;
if ( VisBefore != NULL &&
- (VisRgn = (PROSRGNDATA)RGNOBJAPI_Lock(VisBefore, NULL)) &&
- REGION_Complexity(VisRgn) == NULLREGION )
+ REGION_Complexity(VisBefore) == NULLREGION )
{
- RGNOBJAPI_Unlock(VisRgn);
- GreDeleteObject(VisBefore);
+ REGION_Delete(VisBefore);
VisBefore = NULL;
}
- else if(VisRgn)
+ else if(VisBefore)
{
- RGNOBJAPI_Unlock(VisRgn);
- NtGdiOffsetRgn(VisBefore, -Window->rcWindow.left,
-Window->rcWindow.top);
+ IntGdiOffsetRgn(VisBefore, -Window->rcWindow.left,
-Window->rcWindow.top);
}
/* Calculate the non client area for resizes, as this is used in the copy region
*/
@@ -1757,20 +1750,16 @@
{
VisBeforeJustClient = VIS_ComputeVisibleRegion(Window, TRUE, FALSE,
(Window->style & WS_CLIPSIBLINGS) ? TRUE : FALSE);
- VisRgn = NULL;
if ( VisBeforeJustClient != NULL &&
- (VisRgn = (PROSRGNDATA)RGNOBJAPI_Lock(VisBeforeJustClient, NULL))
&&
- REGION_Complexity(VisRgn) == NULLREGION )
+ REGION_Complexity(VisBeforeJustClient) == NULLREGION )
{
- RGNOBJAPI_Unlock(VisRgn);
- GreDeleteObject(VisBeforeJustClient);
+ REGION_Delete(VisBeforeJustClient);
VisBeforeJustClient = NULL;
}
- else if(VisRgn)
+ else if(VisBeforeJustClient)
{
- RGNOBJAPI_Unlock(VisRgn);
- NtGdiOffsetRgn(VisBeforeJustClient, -Window->rcWindow.left,
-Window->rcWindow.top);
+ IntGdiOffsetRgn(VisBeforeJustClient, -Window->rcWindow.left,
-Window->rcWindow.top);
}
}
}
@@ -1843,20 +1832,16 @@
/* Determine the new visible region */
VisAfter = VIS_ComputeVisibleRegion(Window, FALSE, FALSE,
(Window->style & WS_CLIPSIBLINGS) ? TRUE
: FALSE);
- VisRgn = NULL;
if ( VisAfter != NULL &&
- (VisRgn = (PROSRGNDATA)RGNOBJAPI_Lock(VisAfter, NULL)) &&
- REGION_Complexity(VisRgn) == NULLREGION )
- {
- RGNOBJAPI_Unlock(VisRgn);
- GreDeleteObject(VisAfter);
+ REGION_Complexity(VisAfter) == NULLREGION )
+ {
+ REGION_Delete(VisAfter);
VisAfter = NULL;
}
- else if(VisRgn)
- {
- RGNOBJAPI_Unlock(VisRgn);
- NtGdiOffsetRgn(VisAfter, -Window->rcWindow.left, -Window->rcWindow.top);
+ else if(VisAfter)
+ {
+ IntGdiOffsetRgn(VisAfter, -Window->rcWindow.left, -Window->rcWindow.top);
}
/*
@@ -1882,21 +1867,26 @@
* region...)
*/
- CopyRgn = IntSysCreateRectRgn(0, 0, 0, 0);
+ CopyRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
if (WinPos.flags & SWP_NOSIZE)
- RgnType = NtGdiCombineRgn(CopyRgn, VisAfter, VisBefore, RGN_AND);
+ RgnType = IntGdiCombineRgn(CopyRgn, VisAfter, VisBefore, RGN_AND);
else if (VisBeforeJustClient != NULL)
{
- RgnType = NtGdiCombineRgn(CopyRgn, VisAfter, VisBeforeJustClient, RGN_AND);
- GreDeleteObject(VisBeforeJustClient);
+ RgnType = IntGdiCombineRgn(CopyRgn, VisAfter, VisBeforeJustClient, RGN_AND);
+ REGION_Delete(VisBeforeJustClient);
}
/* No use in copying bits which are in the update region. */
if (Window->hrgnUpdate != NULL)
{
- NtGdiOffsetRgn(CopyRgn, NewWindowRect.left, NewWindowRect.top);
- NtGdiCombineRgn(CopyRgn, CopyRgn, Window->hrgnUpdate, RGN_DIFF);
- NtGdiOffsetRgn(CopyRgn, -NewWindowRect.left, -NewWindowRect.top);
+ PREGION RgnUpdate = RGNOBJAPI_Lock(Window->hrgnUpdate, NULL);
+ if (RgnUpdate)
+ {
+ IntGdiOffsetRgn(CopyRgn, NewWindowRect.left, NewWindowRect.top);
+ IntGdiCombineRgn(CopyRgn, CopyRgn, RgnUpdate, RGN_DIFF);
+ IntGdiOffsetRgn(CopyRgn, -NewWindowRect.left, -NewWindowRect.top);
+ RGNOBJAPI_Unlock(RgnUpdate);
+ }
}
/*
@@ -1904,21 +1894,17 @@
* there's nothing to copy. Also, it's no use copying bits onto
* themselves.
*/
- if ( (VisRgn = (PROSRGNDATA)RGNOBJAPI_Lock(CopyRgn, NULL)) &&
- REGION_GetRgnBox(VisRgn, &CopyRect) == NULLREGION)
+ if (REGION_GetRgnBox(CopyRgn, &CopyRect) == NULLREGION)
{
/* Nothing to copy, clean up */
- RGNOBJAPI_Unlock(VisRgn);
- GreDeleteObject(CopyRgn);
+ REGION_Delete(CopyRgn);
CopyRgn = NULL;
}
else if (OldWindowRect.left != NewWindowRect.left ||
OldWindowRect.top != NewWindowRect.top)
{
- if(VisRgn)
- {
- RGNOBJAPI_Unlock(VisRgn);
- }
+ HRGN DcRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
+ PREGION DcRgnObj = RGNOBJAPI_Lock(DcRgn, NULL);
/*
* Small trick here: there is no function to bitblt a region. So
@@ -1929,9 +1915,11 @@
* Since NtUserGetDCEx takes ownership of the clip region, we need
* to create a copy of CopyRgn and pass that. We need CopyRgn later
*/
- NtGdiOffsetRgn(CopyRgn, NewWindowRect.left, NewWindowRect.top);
+ IntGdiCombineRgn(DcRgnObj, CopyRgn, NULL, RGN_COPY);
+ IntGdiOffsetRgn(DcRgnObj, NewWindowRect.left, NewWindowRect.top);
+ RGNOBJAPI_Unlock(DcRgnObj);
Dc = UserGetDCEx( Window,
- CopyRgn,
+ DcRgn,
DCX_WINDOW|DCX_CACHE|DCX_INTERSECTRGN|DCX_CLIPSIBLINGS|DCX_KEEPCLIPRGN);
NtGdiBitBlt( Dc,
CopyRect.left, CopyRect.top,
@@ -1946,11 +1934,7 @@
UserReleaseDC(Window, Dc, FALSE);
IntValidateParent(Window, CopyRgn, FALSE);
- NtGdiOffsetRgn(CopyRgn, -NewWindowRect.left, -NewWindowRect.top);
- }
- else if(VisRgn)
- {
- RGNOBJAPI_Unlock(VisRgn);
+ GreDeleteObject(DcRgn);
}
}
else
@@ -1961,78 +1945,84 @@
/* We need to redraw what wasn't visible before */
if (VisAfter != NULL)
{
- DirtyRgn = IntSysCreateRectRgn(0, 0, 0, 0);
- if (CopyRgn != NULL)
+ PREGION DirtyRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (DirtyRgn)
{
- RgnType = NtGdiCombineRgn(DirtyRgn, VisAfter, CopyRgn, RGN_DIFF);
- }
- else
- {
- RgnType = NtGdiCombineRgn(DirtyRgn, VisAfter, 0, RGN_COPY);
- }
- if (RgnType != ERROR && RgnType != NULLREGION)
- {
- /* old code
- NtGdiOffsetRgn(DirtyRgn, Window->rcWindow.left, Window->rcWindow.top);
- IntInvalidateWindows( Window,
- DirtyRgn,
- RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
- }
- GreDeleteObject(DirtyRgn);
- */
-
- PWND Parent = Window->spwndParent;
-
- NtGdiOffsetRgn( DirtyRgn,
- Window->rcWindow.left,
- Window->rcWindow.top);
- if ( (Window->style & WS_CHILD) &&
- (Parent) &&
- !(Parent->style & WS_CLIPCHILDREN))
- {
- IntInvalidateWindows( Parent,
- DirtyRgn,
- RDW_ERASE | RDW_INVALIDATE);
- co_IntPaintWindows(Parent, RDW_ERASENOW, FALSE);
- }
- else
- {
+ if (CopyRgn != NULL)
+ {
+ RgnType = IntGdiCombineRgn(DirtyRgn, VisAfter, CopyRgn, RGN_DIFF);
+ }
+ else
+ {
+ RgnType = IntGdiCombineRgn(DirtyRgn, VisAfter, 0, RGN_COPY);
+ }
+ if (RgnType != ERROR && RgnType != NULLREGION)
+ {
+ /* old code
+ NtGdiOffsetRgn(DirtyRgn, Window->rcWindow.left,
Window->rcWindow.top);
IntInvalidateWindows( Window,
DirtyRgn,
- RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
- }
+ RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
+ }
+ GreDeleteObject(DirtyRgn);
+ */
+
+ PWND Parent = Window->spwndParent;
+
+ IntGdiOffsetRgn( DirtyRgn,
+ Window->rcWindow.left,
+ Window->rcWindow.top);
+ if ( (Window->style & WS_CHILD) &&
+ (Parent) &&
+ !(Parent->style & WS_CLIPCHILDREN))
+ {
+ IntInvalidateWindows( Parent,
+ DirtyRgn,
+ RDW_ERASE | RDW_INVALIDATE);
+ co_IntPaintWindows(Parent, RDW_ERASENOW, FALSE);
+ }
+ else
+ {
+ IntInvalidateWindows( Window,
+ DirtyRgn,
+ RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
+ }
+ }
+ REGION_Delete(DirtyRgn);
}
- GreDeleteObject(DirtyRgn);
}
if (CopyRgn != NULL)
{
- GreDeleteObject(CopyRgn);
+ REGION_Delete(CopyRgn);
}
/* Expose what was covered before but not covered anymore */
if (VisBefore != NULL)
{
- ExposedRgn = IntSysCreateRectRgn(0, 0, 0, 0);
- RgnType = NtGdiCombineRgn(ExposedRgn, VisBefore, NULL, RGN_COPY);
- NtGdiOffsetRgn( ExposedRgn,
- OldWindowRect.left - NewWindowRect.left,
- OldWindowRect.top - NewWindowRect.top);
-
- if (VisAfter != NULL)
- RgnType = NtGdiCombineRgn(ExposedRgn, ExposedRgn, VisAfter, RGN_DIFF);
-
- if (RgnType != ERROR && RgnType != NULLREGION)
+ PREGION ExposedRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (ExposedRgn)
{
- co_VIS_WindowLayoutChanged(Window, ExposedRgn);
+ RgnType = IntGdiCombineRgn(ExposedRgn, VisBefore, NULL, RGN_COPY);
+ IntGdiOffsetRgn( ExposedRgn,
+ OldWindowRect.left - NewWindowRect.left,
+ OldWindowRect.top - NewWindowRect.top);
+
+ if (VisAfter != NULL)
+ RgnType = IntGdiCombineRgn(ExposedRgn, ExposedRgn, VisAfter, RGN_DIFF);
+
+ if (RgnType != ERROR && RgnType != NULLREGION)
+ {
+ co_VIS_WindowLayoutChanged(Window, ExposedRgn);
+ }
+ REGION_Delete(ExposedRgn);
}
- GreDeleteObject(ExposedRgn);
- GreDeleteObject(VisBefore);
+ REGION_Delete(VisBefore);
}
if (VisAfter != NULL)
{
- GreDeleteObject(VisAfter);
+ REGION_Delete(VisAfter);
}
}
@@ -3112,7 +3102,7 @@
HRGN hRgn,
BOOL bRedraw)
{
- HRGN hrgnCopy;
+ HRGN hrgnCopy = NULL;
PWND Window;
INT flags =
(SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE);
BOOLEAN Ret = FALSE;
@@ -3132,17 +3122,13 @@
{
if (GreIsHandleValid(hRgn))
{
- hrgnCopy = IntSysCreateRectRgn(0, 0, 0, 0);
+ hrgnCopy = NtGdiCreateRectRgn(0, 0, 0, 0);
/* The coordinates of a window's window region are relative to the
upper-left corner of the window, not the client area of the window. */
NtGdiCombineRgn( hrgnCopy, hRgn, 0, RGN_COPY);
}
else
RETURN( 0);
- }
- else
- {
- hrgnCopy = NULL;
}
if (Window->hrgnClip)