- Set the BaseObject.hHmgr field in GDIOBJ_AllocObj

- rename RGNDATA_ functions to REGION_ to have a consistent naming.
- move REGION prototypes to region.h
- rename REGION_AllocRgn to REGION_AllocRgnWithHandle and make it return a pointer to a locked region.
- rename UnsafeIntGetRgnBox to REGION_GetRgnBox
- rename UnsafeIntRectInRegion to REGION_RectInRegion
- remove UnsafeIntUnionRectWithRgn maco
- implement REGION_SetRectRgn and call it from NtGdiSetRectRgn
- reorder some parameters
- remove REGION_CropRgn, use REGION_CropAndOffsetRegion instead
- Implement UserShowCursor based on the code from NtUserCallOneParam and call it from inside the switch statement.

svn path=/trunk/; revision=32713
This commit is contained in:
Timo Kreuzer 2008-03-17 22:17:48 +00:00
parent f7f8c1d189
commit 4e4095383f
12 changed files with 303 additions and 358 deletions

View file

@ -86,7 +86,7 @@ IntEngWndUpdateClipObj(
if (hVisRgn != NULL) if (hVisRgn != NULL)
{ {
NtGdiOffsetRgn(hVisRgn, Window->Wnd->ClientRect.left, Window->Wnd->ClientRect.top); NtGdiOffsetRgn(hVisRgn, Window->Wnd->ClientRect.left, Window->Wnd->ClientRect.top);
visRgn = RGNDATA_LockRgn(hVisRgn); visRgn = REGION_LockRgn(hVisRgn);
if (visRgn != NULL) if (visRgn != NULL)
{ {
if (visRgn->rdh.nCount > 0) if (visRgn->rdh.nCount > 0)
@ -107,7 +107,7 @@ IntEngWndUpdateClipObj(
} }
} }
} }
RGNDATA_UnlockRgn(visRgn); REGION_UnlockRgn(visRgn);
} }
else else
{ {

View file

@ -77,6 +77,8 @@ BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxW
INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags); INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags);
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon); PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon);
int NTAPI UserShowCursor(BOOL bShow);
#define IntGetSysCursorInfo(WinStaObj) \ #define IntGetSysCursorInfo(WinStaObj) \
(PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor) (PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor)

View file

@ -126,29 +126,6 @@ BOOL FASTCALL IntGdiGradientFill(DC *dc,
ULONG uVertex, ULONG uVertex,
PVOID pMesh, ULONG uMesh, ULONG ulMode); PVOID pMesh, ULONG uMesh, ULONG ulMode);
/* Rgn functions */
int FASTCALL
IntGdiGetClipBox(HDC hDC,
LPRECT rc);
INT
STDCALL
IntGdiSelectVisRgn(HDC hdc,
HRGN hrgn);
HRGN FASTCALL REGION_CropRgn(HRGN hDst, HRGN hSrc, const PRECT lpRect, PPOINT lpPt);
void FASTCALL REGION_UnionRectWithRegion(const RECT *rect, ROSRGNDATA *rgn);
INT FASTCALL UnsafeIntGetRgnBox(PROSRGNDATA Rgn, LPRECT pRect);
BOOL FASTCALL UnsafeIntRectInRegion(PROSRGNDATA Rgn, CONST LPRECT rc);
INT STDCALL IntGdiGetRgnBox(HRGN, LPRECT);
#define UnsafeIntCreateRectRgnIndirect(prc) \
NtGdiCreateRectRgn((prc)->left, (prc)->top, (prc)->right, (prc)->bottom)
#define UnsafeIntUnionRectWithRgn(rgndest, prc) \
REGION_UnionRectWithRegion((prc), (rgndest))
/* DC functions */ /* DC functions */
BOOL FASTCALL BOOL FASTCALL

View file

@ -21,13 +21,26 @@ typedef struct _ROSRGNDATA
/* Functions ******************************************************************/ /* Functions ******************************************************************/
#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION) #define REGION_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)
#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)) #define REGION_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION))
#define RGNDATA_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr((POBJ)pRgn) #define REGION_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr((POBJ)pRgn)
HRGN FASTCALL RGNDATA_AllocRgn(INT n); PROSRGNDATA FASTCALL REGION_AllocRgnWithHandle(INT n);
BOOL INTERNAL_CALL RGNDATA_Cleanup(PVOID ObjectBody); VOID FASTCALL REGION_UnionRectWithRgn(ROSRGNDATA *rgn, CONST RECT *rect);
INT FASTCALL REGION_GetRgnBox(PROSRGNDATA Rgn, LPRECT pRect);
BOOL FASTCALL REGION_RectInRegion(PROSRGNDATA Rgn, CONST LPRECT rc);
BOOL FASTCALL REGION_CropAndOffsetRegion(PROSRGNDATA rgnDst, PROSRGNDATA rgnSrc, const PRECT rect, const PPOINT off);
VOID FASTCALL REGION_SetRectRgn(PROSRGNDATA pRgn, INT LeftRect, INT TopRect, INT RightRect, INT BottomRect);
BOOL INTERNAL_CALL REGION_Cleanup(PVOID ObjectBody);
INT STDCALL IntGdiGetRgnBox(HRGN, LPRECT);
BOOL FASTCALL IntGdiPaintRgn(PDC, HRGN ); BOOL FASTCALL IntGdiPaintRgn(PDC, HRGN );
HRGN FASTCALL GdiCreatePolyPolygonRgn(CONST PPOINT, CONST PINT, INT, INT ); HRGN FASTCALL GdiCreatePolyPolygonRgn(CONST PPOINT, CONST PINT, INT, INT );
int FASTCALL IntGdiGetClipBox(HDC hDC, LPRECT rc);
INT STDCALL IntGdiSelectVisRgn(HDC hdc, HRGN hrgn);
#define UnsafeIntCreateRectRgnIndirect(prc) \
NtGdiCreateRectRgn((prc)->left, (prc)->top, (prc)->right, (prc)->bottom)
#endif /* not __WIN32K_REGION_H */ #endif /* not __WIN32K_REGION_H */

View file

@ -1817,3 +1817,95 @@ NtUserDrawIconEx(
UserLeave(); UserLeave();
return Ret; return Ret;
} }
/* Called from NtUserCallOneParam with Routine ONEPARAM_ROUTINE_SHOWCURSOR
* User32 macro NtUserShowCursor */
int
NTAPI
UserShowCursor(BOOL bShow)
{
PWINSTATION_OBJECT WinSta = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation;
PSYSTEM_CURSORINFO CurInfo;
HDC Screen;
PDC dc;
HBITMAP dcbmp;
SURFOBJ *SurfObj;
BITMAPOBJ *BitmapObj;
GDIDEVICE *ppdev;
GDIPOINTER *pgp;
int showpointer=0;
if(!(Screen = IntGetScreenDC()))
{
return showpointer; /* No mouse */
}
dc = DC_LockDc(Screen);
if (!dc)
{
return showpointer; /* No mouse */
}
dcbmp = dc->w.hBitmap;
DC_UnlockDc(dc);
BitmapObj = BITMAPOBJ_LockBitmap(dcbmp);
if ( !BitmapObj )
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer; /* No Mouse */
}
SurfObj = &BitmapObj->SurfObj;
if (SurfObj == NULL)
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer; /* No mouse */
}
ppdev = GDIDEV(SurfObj);
if(ppdev == NULL)
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer; /* No mouse */
}
pgp = &ppdev->Pointer;
CurInfo = IntGetSysCursorInfo(WinSta);
if (bShow == FALSE)
{
pgp->ShowPointer--;
showpointer = pgp->ShowPointer;
if (showpointer >= 0)
{
//ppdev->SafetyRemoveCount = 1;
//ppdev->SafetyRemoveLevel = 1;
EngMovePointer(SurfObj,-1,-1,NULL);
CurInfo->ShowingCursor = 0;
}
}
else
{
pgp->ShowPointer++;
showpointer = pgp->ShowPointer;
/* Show Cursor */
if (showpointer < 0)
{
//ppdev->SafetyRemoveCount = 0;
//ppdev->SafetyRemoveLevel = 0;
EngMovePointer(SurfObj,-1,-1,NULL);
CurInfo->ShowingCursor = CURSOR_SHOWING;
}
}
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer;
}

View file

@ -145,103 +145,16 @@ NtUserCallOneParam(
DWORD Routine) DWORD Routine)
{ {
DECLARE_RETURN(DWORD); DECLARE_RETURN(DWORD);
PDC dc;
DPRINT("Enter NtUserCallOneParam\n"); DPRINT("Enter NtUserCallOneParam\n");
if (Routine == ONEPARAM_ROUTINE_SHOWCURSOR)
{
PWINSTATION_OBJECT WinSta = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation;
PSYSTEM_CURSORINFO CurInfo;
HDC Screen;
HBITMAP dcbmp;
SURFOBJ *SurfObj;
BITMAPOBJ *BitmapObj;
GDIDEVICE *ppdev;
GDIPOINTER *pgp;
int showpointer=0;
if(!(Screen = IntGetScreenDC()))
{
return showpointer; /* No mouse */
}
dc = DC_LockDc(Screen);
if (!dc)
{
return showpointer; /* No mouse */
}
dcbmp = dc->w.hBitmap;
DC_UnlockDc(dc);
BitmapObj = BITMAPOBJ_LockBitmap(dcbmp);
if ( !BitmapObj )
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer; /* No Mouse */
}
SurfObj = &BitmapObj->SurfObj;
if (SurfObj == NULL)
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer; /* No mouse */
}
ppdev = GDIDEV(SurfObj);
if(ppdev == NULL)
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer; /* No mouse */
}
pgp = &ppdev->Pointer;
CurInfo = IntGetSysCursorInfo(WinSta);
if (Param == FALSE)
{
pgp->ShowPointer--;
showpointer = pgp->ShowPointer;
if (showpointer >= 0)
{
//ppdev->SafetyRemoveCount = 1;
//ppdev->SafetyRemoveLevel = 1;
EngMovePointer(SurfObj,-1,-1,NULL);
CurInfo->ShowingCursor = 0;
}
}
else
{
pgp->ShowPointer++;
showpointer = pgp->ShowPointer;
/* Show Cursor */
if (showpointer < 0)
{
//ppdev->SafetyRemoveCount = 0;
//ppdev->SafetyRemoveLevel = 0;
EngMovePointer(SurfObj,-1,-1,NULL);
CurInfo->ShowingCursor = CURSOR_SHOWING;
}
}
BITMAPOBJ_UnlockBitmap(BitmapObj);
return showpointer;
}
UserEnterExclusive(); UserEnterExclusive();
switch(Routine) switch(Routine)
{ {
case ONEPARAM_ROUTINE_SHOWCURSOR:
RETURN( (DWORD)UserShowCursor((BOOL)Param) );
case ONEPARAM_ROUTINE_GETDESKTOPMAPPING: case ONEPARAM_ROUTINE_GETDESKTOPMAPPING:
{ {
PW32THREADINFO ti; PW32THREADINFO ti;

View file

@ -816,11 +816,11 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
if (Window->UpdateRegion != NULL) if (Window->UpdateRegion != NULL)
{ {
MsqDecPaintCountQueue(Window->MessageQueue); MsqDecPaintCountQueue(Window->MessageQueue);
Rgn = RGNDATA_LockRgn(Window->UpdateRegion); Rgn = REGION_LockRgn(Window->UpdateRegion);
if (NULL != Rgn) if (NULL != Rgn)
{ {
UnsafeIntGetRgnBox(Rgn, &Ps.rcPaint); REGION_GetRgnBox(Rgn, &Ps.rcPaint);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
IntGdiIntersectRect(&Ps.rcPaint, &Ps.rcPaint, &Window->Wnd->ClientRect); IntGdiIntersectRect(&Ps.rcPaint, &Ps.rcPaint, &Window->Wnd->ClientRect);
if (! IntGdiIsEmptyRect(&Ps.rcPaint)) if (! IntGdiIsEmptyRect(&Ps.rcPaint))
{ {
@ -1042,10 +1042,10 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase)
} }
else else
{ {
RgnData = RGNDATA_LockRgn(Window->UpdateRegion); RgnData = REGION_LockRgn(Window->UpdateRegion);
ASSERT(RgnData != NULL); ASSERT(RgnData != NULL);
RegionType = UnsafeIntGetRgnBox(RgnData, &Rect); RegionType = REGION_GetRgnBox(RgnData, &Rect);
RGNDATA_UnlockRgn(RgnData); REGION_UnlockRgn(RgnData);
if (RegionType != ERROR && RegionType != NULLREGION) if (RegionType != ERROR && RegionType != NULLREGION)
IntGdiIntersectRect(&Rect, &Rect, &Window->Wnd->ClientRect); IntGdiIntersectRect(&Rect, &Rect, &Window->Wnd->ClientRect);

View file

@ -4392,10 +4392,10 @@ IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn)
/* Copy the region into hRgn */ /* Copy the region into hRgn */
NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY); NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY);
if((pRgn = RGNDATA_LockRgn(hRgn))) if((pRgn = REGION_LockRgn(hRgn)))
{ {
Ret = pRgn->rdh.iType; Ret = pRgn->rdh.iType;
RGNDATA_UnlockRgn(pRgn); REGION_UnlockRgn(pRgn);
} }
else else
Ret = ERROR; Ret = ERROR;
@ -4431,11 +4431,11 @@ IntGetWindowRgnBox(PWINDOW_OBJECT Window, RECT *Rect)
if(Window->WindowRegion && !(Wnd->Style & WS_MINIMIZE)) if(Window->WindowRegion && !(Wnd->Style & WS_MINIMIZE))
NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND); NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
if((pRgn = RGNDATA_LockRgn(VisRgn))) if((pRgn = REGION_LockRgn(VisRgn)))
{ {
Ret = pRgn->rdh.iType; Ret = pRgn->rdh.iType;
*Rect = pRgn->rdh.rcBound; *Rect = pRgn->rdh.rcBound;
RGNDATA_UnlockRgn(pRgn); REGION_UnlockRgn(pRgn);
} }
else else
Ret = ERROR; Ret = ERROR;

View file

@ -961,16 +961,16 @@ co_WinPosSetWindowPos(
VisBefore = VIS_ComputeVisibleRegion(Window, FALSE, FALSE, TRUE); VisBefore = VIS_ComputeVisibleRegion(Window, FALSE, FALSE, TRUE);
VisRgn = NULL; VisRgn = NULL;
if (VisBefore != NULL && (VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(VisBefore)) && if (VisBefore != NULL && (VisRgn = (PROSRGNDATA)REGION_LockRgn(VisBefore)) &&
UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION) REGION_GetRgnBox(VisRgn, &TempRect) == NULLREGION)
{ {
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
NtGdiDeleteObject(VisBefore); NtGdiDeleteObject(VisBefore);
VisBefore = NULL; VisBefore = NULL;
} }
else if(VisRgn) else if(VisRgn)
{ {
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
NtGdiOffsetRgn(VisBefore, -Window->Wnd->WindowRect.left, -Window->Wnd->WindowRect.top); NtGdiOffsetRgn(VisBefore, -Window->Wnd->WindowRect.left, -Window->Wnd->WindowRect.top);
} }
} }
@ -1111,16 +1111,16 @@ co_WinPosSetWindowPos(
VisAfter = VIS_ComputeVisibleRegion(Window, FALSE, FALSE, TRUE); VisAfter = VIS_ComputeVisibleRegion(Window, FALSE, FALSE, TRUE);
VisRgn = NULL; VisRgn = NULL;
if (VisAfter != NULL && (VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(VisAfter)) && if (VisAfter != NULL && (VisRgn = (PROSRGNDATA)REGION_LockRgn(VisAfter)) &&
UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION) REGION_GetRgnBox(VisRgn, &TempRect) == NULLREGION)
{ {
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
NtGdiDeleteObject(VisAfter); NtGdiDeleteObject(VisAfter);
VisAfter = NULL; VisAfter = NULL;
} }
else if(VisRgn) else if(VisRgn)
{ {
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
NtGdiOffsetRgn(VisAfter, -Window->Wnd->WindowRect.left, -Window->Wnd->WindowRect.top); NtGdiOffsetRgn(VisAfter, -Window->Wnd->WindowRect.left, -Window->Wnd->WindowRect.top);
} }
@ -1149,12 +1149,15 @@ co_WinPosSetWindowPos(
if (!(WinPos.flags & SWP_NOSIZE) && RgnType != ERROR && if (!(WinPos.flags & SWP_NOSIZE) && RgnType != ERROR &&
RgnType != NULLREGION) RgnType != NULLREGION)
{ {
PROSRGNDATA pCopyRgn;
RECT ORect = OldClientRect; RECT ORect = OldClientRect;
RECT NRect = NewClientRect; RECT NRect = NewClientRect;
IntGdiOffsetRect(&ORect, - OldWindowRect.left, - OldWindowRect.top); IntGdiOffsetRect(&ORect, - OldWindowRect.left, - OldWindowRect.top);
IntGdiOffsetRect(&NRect, - NewWindowRect.left, - NewWindowRect.top); IntGdiOffsetRect(&NRect, - NewWindowRect.left, - NewWindowRect.top);
IntGdiIntersectRect(&CopyRect, &ORect, &NRect); IntGdiIntersectRect(&CopyRect, &ORect, &NRect);
REGION_CropRgn(CopyRgn, CopyRgn, &CopyRect, NULL); pCopyRgn = REGION_LockRgn(CopyRgn);
REGION_CropAndOffsetRegion(pCopyRgn, pCopyRgn, &CopyRect, NULL);
REGION_UnlockRgn(pCopyRgn);
} }
/* No use in copying bits which are in the update region. */ /* No use in copying bits which are in the update region. */
@ -1170,11 +1173,11 @@ co_WinPosSetWindowPos(
* there's nothing to copy. Also, it's no use copying bits onto * there's nothing to copy. Also, it's no use copying bits onto
* themselves. * themselves.
*/ */
if ((VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(CopyRgn)) && if ((VisRgn = (PROSRGNDATA)REGION_LockRgn(CopyRgn)) &&
UnsafeIntGetRgnBox(VisRgn, &CopyRect) == NULLREGION) REGION_GetRgnBox(VisRgn, &CopyRect) == NULLREGION)
{ {
/* Nothing to copy, clean up */ /* Nothing to copy, clean up */
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
NtGdiDeleteObject(CopyRgn); NtGdiDeleteObject(CopyRgn);
CopyRgn = NULL; CopyRgn = NULL;
} }
@ -1183,7 +1186,7 @@ co_WinPosSetWindowPos(
{ {
if(VisRgn) if(VisRgn)
{ {
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
} }
/* /*
@ -1210,7 +1213,7 @@ co_WinPosSetWindowPos(
} }
else if(VisRgn) else if(VisRgn)
{ {
RGNDATA_UnlockRgn(VisRgn); REGION_UnlockRgn(VisRgn);
} }
} }
else else

View file

@ -37,7 +37,7 @@ CLIPPING_UpdateGCRegion(DC* Dc)
NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, RGN_AND); NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, RGN_AND);
NtGdiOffsetRgn(Dc->w.hGCClipRgn, Dc->w.DCOrgX, Dc->w.DCOrgY); NtGdiOffsetRgn(Dc->w.hGCClipRgn, Dc->w.DCOrgX, Dc->w.DCOrgY);
if((CombinedRegion = RGNDATA_LockRgn(Dc->w.hGCClipRgn))) if((CombinedRegion = REGION_LockRgn(Dc->w.hGCClipRgn)))
{ {
if (Dc->CombinedClip != NULL) if (Dc->CombinedClip != NULL)
IntEngDeleteClipRegion(Dc->CombinedClip); IntEngDeleteClipRegion(Dc->CombinedClip);
@ -47,13 +47,13 @@ CLIPPING_UpdateGCRegion(DC* Dc)
(PRECTL)CombinedRegion->Buffer, (PRECTL)CombinedRegion->Buffer,
(PRECTL)&CombinedRegion->rdh.rcBound); (PRECTL)&CombinedRegion->rdh.rcBound);
RGNDATA_UnlockRgn(CombinedRegion); REGION_UnlockRgn(CombinedRegion);
} }
if ( NULL == Dc->CombinedClip ) if ( NULL == Dc->CombinedClip )
{ {
DPRINT1("IntEngCreateClipRegion() failed\n"); DPRINT1("IntEngCreateClipRegion() failed\n");
return ERROR; return ERROR;
} }
return NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY); return NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY);
@ -126,10 +126,10 @@ int STDCALL IntGdiExtSelectClipRgn(PDC dc,
{ {
PROSRGNDATA Rgn; PROSRGNDATA Rgn;
RECT rect; RECT rect;
if((Rgn = RGNDATA_LockRgn(dc->w.hVisRgn))) if((Rgn = REGION_LockRgn(dc->w.hVisRgn)))
{ {
UnsafeIntGetRgnBox(Rgn, &rect); REGION_GetRgnBox(Rgn, &rect);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
dc->w.hClipRgn = UnsafeIntCreateRectRgnIndirect(&rect); dc->w.hClipRgn = UnsafeIntCreateRectRgnIndirect(&rect);
} }
else else
@ -181,13 +181,13 @@ IntGdiGetClipBox(HDC hDC, LPRECT rc)
return ERROR; return ERROR;
} }
if (!(Rgn = RGNDATA_LockRgn(dc->w.hGCClipRgn))) if (!(Rgn = REGION_LockRgn(dc->w.hGCClipRgn)))
{ {
DC_UnlockDc(dc); DC_UnlockDc(dc);
return ERROR; return ERROR;
} }
retval = UnsafeIntGetRgnBox(Rgn, rc); retval = REGION_GetRgnBox(Rgn, rc);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
IntDPtoLP(dc, (LPPOINT)rc, 2); IntDPtoLP(dc, (LPPOINT)rc, 2);
DC_UnlockDc(dc); DC_UnlockDc(dc);
@ -418,11 +418,11 @@ BOOL STDCALL NtGdiRectVisible(HDC hDC,
if (dc->w.hGCClipRgn) if (dc->w.hGCClipRgn)
{ {
if((Rgn = (PROSRGNDATA)RGNDATA_LockRgn(dc->w.hGCClipRgn))) if((Rgn = (PROSRGNDATA)REGION_LockRgn(dc->w.hGCClipRgn)))
{ {
IntLPtoDP(dc, (LPPOINT)&Rect, 2); IntLPtoDP(dc, (LPPOINT)&Rect, 2);
Result = UnsafeIntRectInRegion(Rgn, &Rect); Result = REGION_RectInRegion(Rgn, &Rect);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
} }
} }
DC_UnlockDc(dc); DC_UnlockDc(dc);

View file

@ -72,7 +72,7 @@ OBJ_TYPE_INFO ObjTypeInfo[] =
{1, sizeof(DC), TAG_DC, DC_Cleanup}, /* 01 DC */ {1, sizeof(DC), TAG_DC, DC_Cleanup}, /* 01 DC */
{1, 0, 0, NULL}, /* 02 UNUSED1 */ {1, 0, 0, NULL}, /* 02 UNUSED1 */
{1, 0, 0, NULL}, /* 03 UNUSED2 */ {1, 0, 0, NULL}, /* 03 UNUSED2 */
{1, sizeof(ROSRGNDATA), TAG_REGION, RGNDATA_Cleanup}, /* 04 RGN */ {1, sizeof(ROSRGNDATA), TAG_REGION, REGION_Cleanup}, /* 04 RGN */
{1, sizeof(BITMAPOBJ), TAG_SURFACE, BITMAP_Cleanup}, /* 05 SURFACE */ {1, sizeof(BITMAPOBJ), TAG_SURFACE, BITMAP_Cleanup}, /* 05 SURFACE */
{0, sizeof(DC), TAG_CLIENTOBJ, GDI_CleanupDummy}, /* 06 CLIENTOBJ: METADC,... FIXME: don't use DC struct */ {0, sizeof(DC), TAG_CLIENTOBJ, GDI_CleanupDummy}, /* 06 CLIENTOBJ: METADC,... FIXME: don't use DC struct */
{0, 0, TAG_PATH, NULL}, /* 07 PATH, unused */ {0, 0, TAG_PATH, NULL}, /* 07 PATH, unused */
@ -537,6 +537,7 @@ LockHandle:
_InterlockedIncrement(&W32Process->GDIObjects); _InterlockedIncrement(&W32Process->GDIObjects);
} }
Handle = (HGDIOBJ)((Index & 0xFFFF) | (TypeInfo << GDI_ENTRY_UPPER_SHIFT)); Handle = (HGDIOBJ)((Index & 0xFFFF) | (TypeInfo << GDI_ENTRY_UPPER_SHIFT));
newObject->hHmgr = Handle;
DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, newObject); DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, newObject);
return Handle; return Handle;

View file

@ -465,7 +465,7 @@ IntDumpRegion(HRGN hRgn)
{ {
ROSRGNDATA *Data; ROSRGNDATA *Data;
Data = RGNDATA_LockRgn(hRgn); Data = REGION_LockRgn(hRgn);
if (Data == NULL) if (Data == NULL)
{ {
DbgPrint("IntDumpRegion called with invalid region!\n"); DbgPrint("IntDumpRegion called with invalid region!\n");
@ -480,7 +480,7 @@ IntDumpRegion(HRGN hRgn)
Data->rdh.rcBound.bottom, Data->rdh.rcBound.bottom,
Data->rdh.iType); Data->rdh.iType);
RGNDATA_UnlockRgn(Data); REGION_UnlockRgn(Data);
} }
#endif /* not NDEBUG */ #endif /* not NDEBUG */
@ -564,14 +564,19 @@ REGION_SetExtents(ROSRGNDATA *pReg)
/*********************************************************************** /***********************************************************************
* REGION_CropAndOffsetRegion * REGION_CropAndOffsetRegion
*/ */
static BOOL FASTCALL BOOL FASTCALL
REGION_CropAndOffsetRegion( REGION_CropAndOffsetRegion(
const PPOINT off, PROSRGNDATA rgnDst,
const PRECT rect,
PROSRGNDATA rgnSrc, PROSRGNDATA rgnSrc,
PROSRGNDATA rgnDst const PRECT rect,
const PPOINT offset
) )
{ {
POINT pt = {0,0};
PPOINT off = offset;
if (!off) off = &pt;
if (!rect) // just copy and offset if (!rect) // just copy and offset
{ {
PRECT xrect; PRECT xrect;
@ -727,69 +732,6 @@ empty:
return TRUE; return TRUE;
} }
/*!
* \param
* hSrc: Region to crop and offset.
* lpRect: Clipping rectangle. Can be NULL (no clipping).
* lpPt: Points to offset the cropped region. Can be NULL (no offset).
*
* hDst: Region to hold the result (a new region is created if it's 0).
* Allowed to be the same region as hSrc in which case everything
* will be done in place, with no memory reallocations.
*
* \return hDst if success, 0 otherwise.
*/
HRGN FASTCALL
REGION_CropRgn(
HRGN hDst,
HRGN hSrc,
const PRECT lpRect,
PPOINT lpPt
)
{
PROSRGNDATA objSrc, rgnDst;
HRGN hRet = NULL;
POINT pt = { 0, 0 };
if (!hDst)
{
if ( !(hDst = RGNDATA_AllocRgn(1)) )
{
return 0;
}
}
rgnDst = RGNDATA_LockRgn(hDst);
if (rgnDst == NULL)
{
return NULL;
}
objSrc = RGNDATA_LockRgn(hSrc);
if (objSrc == NULL)
{
RGNDATA_UnlockRgn(rgnDst);
return NULL;
}
if (!lpPt)
lpPt = &pt;
if (REGION_CropAndOffsetRegion(lpPt, lpRect, objSrc, rgnDst) == FALSE)
{
// ve failed cleanup and return
hRet = NULL;
}
else // ve are fine. unlock the correct pointer and return correct handle
{
hRet = hDst;
}
RGNDATA_UnlockRgn(objSrc);
RGNDATA_UnlockRgn(rgnDst);
return hRet;
}
/*! /*!
* Attempt to merge the rects in the current band with those in the * Attempt to merge the rects in the current band with those in the
@ -1772,35 +1714,29 @@ REGION_XorRegion(
HRGN htra, htrb; HRGN htra, htrb;
ROSRGNDATA *tra, *trb; ROSRGNDATA *tra, *trb;
if (!(htra = RGNDATA_AllocRgn(sra->rdh.nCount + 1))) // FIXME: don't use a handle
return; tra = REGION_AllocRgnWithHandle(sra->rdh.nCount + 1);
if (!(htrb = RGNDATA_AllocRgn(srb->rdh.nCount + 1)))
{
NtGdiDeleteObject(htra);
return;
}
tra = RGNDATA_LockRgn(htra);
if (!tra ) if (!tra )
{ {
NtGdiDeleteObject(htra);
NtGdiDeleteObject(htrb);
return; return;
} }
htra = tra->BaseObject.hHmgr;
trb = RGNDATA_LockRgn(htrb); // FIXME: don't use a handle
trb = REGION_AllocRgnWithHandle(srb->rdh.nCount + 1);
if (!trb) if (!trb)
{ {
RGNDATA_UnlockRgn(tra); REGION_UnlockRgn(tra);
NtGdiDeleteObject(htra); NtGdiDeleteObject(htra);
NtGdiDeleteObject(htrb);
return; return;
} }
htrb = trb->BaseObject.hHmgr;
REGION_SubtractRegion(tra, sra, srb); REGION_SubtractRegion(tra, sra, srb);
REGION_SubtractRegion(trb, srb, sra); REGION_SubtractRegion(trb, srb, sra);
REGION_UnionRegion(dr, tra, trb); REGION_UnionRegion(dr, tra, trb);
RGNDATA_UnlockRgn(tra); REGION_UnlockRgn(tra);
RGNDATA_UnlockRgn(trb); REGION_UnlockRgn(trb);
NtGdiDeleteObject(htra); NtGdiDeleteObject(htra);
NtGdiDeleteObject(htrb); NtGdiDeleteObject(htrb);
@ -1811,10 +1747,10 @@ REGION_XorRegion(
/*! /*!
* Adds a rectangle to a REGION * Adds a rectangle to a REGION
*/ */
void FASTCALL VOID FASTCALL
REGION_UnionRectWithRegion( REGION_UnionRectWithRgn(
const RECT *rect, ROSRGNDATA *rgn,
ROSRGNDATA *rgn const RECT *rect
) )
{ {
ROSRGNDATA region; ROSRGNDATA region;
@ -1914,26 +1850,26 @@ REGION_CreateFrameRgn(
PRECT rc; PRECT rc;
ULONG i; ULONG i;
if (!(srcObj = (PROSRGNDATA)RGNDATA_LockRgn(hSrc))) if (!(srcObj = REGION_LockRgn(hSrc)))
{ {
return FALSE; return FALSE;
} }
if (!REGION_NOT_EMPTY(srcObj)) if (!REGION_NOT_EMPTY(srcObj))
{ {
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
return FALSE; return FALSE;
} }
if (!(destObj = (PROSRGNDATA)RGNDATA_LockRgn(hDest))) if (!(destObj = REGION_LockRgn(hDest)))
{ {
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
return FALSE; return FALSE;
} }
EMPTY_REGION(destObj); EMPTY_REGION(destObj);
if (!REGION_CopyRegion(destObj, srcObj)) if (!REGION_CopyRegion(destObj, srcObj))
{ {
RGNDATA_UnlockRgn(destObj); REGION_UnlockRgn(destObj);
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
return FALSE; return FALSE;
} }
@ -1942,8 +1878,8 @@ REGION_CreateFrameRgn(
if (!REGION_CreateSimpleFrameRgn(destObj, x, y)) if (!REGION_CreateSimpleFrameRgn(destObj, x, y))
{ {
EMPTY_REGION(destObj); EMPTY_REGION(destObj);
RGNDATA_UnlockRgn(destObj); REGION_UnlockRgn(destObj);
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
return FALSE; return FALSE;
} }
} }
@ -2002,8 +1938,8 @@ REGION_CreateFrameRgn(
REGION_SubtractRegion(destObj, srcObj, destObj); REGION_SubtractRegion(destObj, srcObj, destObj);
} }
RGNDATA_UnlockRgn(destObj); REGION_UnlockRgn(destObj);
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
return TRUE; return TRUE;
} }
@ -2039,11 +1975,11 @@ REGION_LPTODP(
goto done; goto done;
} }
if ( !(srcObj = (PROSRGNDATA) RGNDATA_LockRgn(hSrc)) ) if ( !(srcObj = REGION_LockRgn(hSrc)) )
goto done; goto done;
if ( !(destObj = (PROSRGNDATA) RGNDATA_LockRgn(hDest)) ) if ( !(destObj = REGION_LockRgn(hDest)) )
{ {
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
goto done; goto done;
} }
EMPTY_REGION(destObj); EMPTY_REGION(destObj);
@ -2070,27 +2006,27 @@ REGION_LPTODP(
tmpRect.bottom = tmp; tmpRect.bottom = tmp;
} }
REGION_UnionRectWithRegion(&tmpRect, destObj); REGION_UnionRectWithRgn(destObj, &tmpRect);
} }
ret = TRUE; ret = TRUE;
RGNDATA_UnlockRgn(srcObj); REGION_UnlockRgn(srcObj);
RGNDATA_UnlockRgn(destObj); REGION_UnlockRgn(destObj);
done: done:
DC_UnlockDc(dc); DC_UnlockDc(dc);
return ret; return ret;
} }
HRGN FASTCALL PROSRGNDATA FASTCALL
RGNDATA_AllocRgn(INT n) REGION_AllocRgnWithHandle(INT n)
{ {
HRGN hReg; HRGN hReg;
PROSRGNDATA pReg; PROSRGNDATA pReg;
if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION))) if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
{ {
if (NULL != (pReg = RGNDATA_LockRgn(hReg))) if (NULL != (pReg = REGION_LockRgn(hReg)))
{ {
if (1 == n) if (1 == n)
{ {
@ -2110,14 +2046,12 @@ RGNDATA_AllocRgn(INT n)
pReg->rdh.nCount = n; pReg->rdh.nCount = n;
pReg->rdh.nRgnSize = n*sizeof(RECT); pReg->rdh.nRgnSize = n*sizeof(RECT);
RGNDATA_UnlockRgn(pReg); return pReg;
return hReg;
} }
} }
else else
{ {
RGNDATA_FreeRgn(hReg); REGION_FreeRgn(hReg);
} }
} }
@ -2125,7 +2059,7 @@ RGNDATA_AllocRgn(INT n)
} }
BOOL INTERNAL_CALL BOOL INTERNAL_CALL
RGNDATA_Cleanup(PVOID ObjectBody) REGION_Cleanup(PVOID ObjectBody)
{ {
PROSRGNDATA pRgn = (PROSRGNDATA)ObjectBody; PROSRGNDATA pRgn = (PROSRGNDATA)ObjectBody;
if (pRgn->Buffer && pRgn->Buffer != &pRgn->rdh.rcBound) if (pRgn->Buffer && pRgn->Buffer != &pRgn->rdh.rcBound)
@ -2144,10 +2078,10 @@ NtGdiCombineRgn(HRGN hDest,
INT result = ERROR; INT result = ERROR;
PROSRGNDATA destRgn, src1Rgn, src2Rgn; PROSRGNDATA destRgn, src1Rgn, src2Rgn;
destRgn = RGNDATA_LockRgn(hDest); destRgn = REGION_LockRgn(hDest);
if (destRgn) if (destRgn)
{ {
src1Rgn = RGNDATA_LockRgn(hSrc1); src1Rgn = REGION_LockRgn(hSrc1);
if (src1Rgn) if (src1Rgn)
{ {
if (CombineMode == RGN_COPY) if (CombineMode == RGN_COPY)
@ -2158,7 +2092,7 @@ NtGdiCombineRgn(HRGN hDest,
} }
else else
{ {
src2Rgn = RGNDATA_LockRgn(hSrc2); src2Rgn = REGION_LockRgn(hSrc2);
if (src2Rgn) if (src2Rgn)
{ {
switch (CombineMode) switch (CombineMode)
@ -2176,7 +2110,7 @@ NtGdiCombineRgn(HRGN hDest,
REGION_SubtractRegion(destRgn, src1Rgn, src2Rgn); REGION_SubtractRegion(destRgn, src1Rgn, src2Rgn);
break; break;
} }
RGNDATA_UnlockRgn(src2Rgn); REGION_UnlockRgn(src2Rgn);
result = destRgn->rdh.iType; result = destRgn->rdh.iType;
} }
else if (hSrc2 == NULL) else if (hSrc2 == NULL)
@ -2185,10 +2119,10 @@ NtGdiCombineRgn(HRGN hDest,
} }
} }
RGNDATA_UnlockRgn(src1Rgn); REGION_UnlockRgn(src1Rgn);
} }
RGNDATA_UnlockRgn(destRgn); REGION_UnlockRgn(destRgn);
} }
else else
{ {
@ -2215,18 +2149,22 @@ NtGdiCreateEllipticRgn(
HRGN STDCALL HRGN STDCALL
NtGdiCreateRectRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect) NtGdiCreateRectRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
{ {
PROSRGNDATA pRgn;
HRGN hRgn; HRGN hRgn;
/* Allocate region data structure with space for 1 RECT */ /* Allocate region data structure with space for 1 RECT */
if ((hRgn = RGNDATA_AllocRgn(1))) if (!(pRgn = REGION_AllocRgnWithHandle(1)))
{ {
if (NtGdiSetRectRgn(hRgn, LeftRect, TopRect, RightRect, BottomRect)) SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return hRgn; return NULL;
NtGdiDeleteObject(hRgn);
} }
hRgn = pRgn->BaseObject.hHmgr;
REGION_SetRectRgn(pRgn, LeftRect, TopRect, RightRect, BottomRect);
REGION_UnlockRgn(pRgn);
return hRgn;
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
} }
HRGN HRGN
@ -2276,8 +2214,8 @@ NtGdiCreateRoundRectRgn(
/* Create region */ /* Create region */
d = (ellipse_height < 128) ? ((3 * ellipse_height) >> 2) : 64; d = (ellipse_height < 128) ? ((3 * ellipse_height) >> 2) : 64;
if (!(hrgn = RGNDATA_AllocRgn(d))) return 0; if (!(obj = REGION_AllocRgnWithHandle(d))) return 0;
if (!(obj = RGNDATA_LockRgn(hrgn))) return 0; hrgn = obj->BaseObject.hHmgr;
/* Ellipse algorithm, based on an article by K. Porter */ /* Ellipse algorithm, based on an article by K. Porter */
/* in DDJ Graphics Programming Column, 8/89 */ /* in DDJ Graphics Programming Column, 8/89 */
@ -2300,10 +2238,10 @@ NtGdiCreateRoundRectRgn(
/* move toward center */ /* move toward center */
rect.top = top++; rect.top = top++;
rect.bottom = rect.top + 1; rect.bottom = rect.top + 1;
UnsafeIntUnionRectWithRgn(obj, &rect); REGION_UnionRectWithRgn(obj, &rect);
rect.top = --bottom; rect.top = --bottom;
rect.bottom = rect.top + 1; rect.bottom = rect.top + 1;
UnsafeIntUnionRectWithRgn(obj, &rect); REGION_UnionRectWithRgn(obj, &rect);
yd -= 2*asq; yd -= 2*asq;
d -= yd; d -= yd;
} }
@ -2320,10 +2258,10 @@ NtGdiCreateRoundRectRgn(
/* next vertical point */ /* next vertical point */
rect.top = top++; rect.top = top++;
rect.bottom = rect.top + 1; rect.bottom = rect.top + 1;
UnsafeIntUnionRectWithRgn(obj, &rect); REGION_UnionRectWithRgn(obj, &rect);
rect.top = --bottom; rect.top = --bottom;
rect.bottom = rect.top + 1; rect.bottom = rect.top + 1;
UnsafeIntUnionRectWithRgn(obj, &rect); REGION_UnionRectWithRgn(obj, &rect);
if (d < 0) /* if nearest pixel is outside ellipse */ if (d < 0) /* if nearest pixel is outside ellipse */
{ {
rect.left--; /* move away from center */ rect.left--; /* move away from center */
@ -2340,9 +2278,10 @@ NtGdiCreateRoundRectRgn(
{ {
rect.top = top; rect.top = top;
rect.bottom = bottom; rect.bottom = bottom;
UnsafeIntUnionRectWithRgn(obj, &rect); REGION_UnionRectWithRgn(obj, &rect);
} }
RGNDATA_UnlockRgn(obj);
REGION_UnlockRgn(obj);
return hrgn; return hrgn;
} }
@ -2358,12 +2297,12 @@ NtGdiEqualRgn(
ULONG i; ULONG i;
BOOL bRet = FALSE; BOOL bRet = FALSE;
if ( !(rgn1 = RGNDATA_LockRgn(hSrcRgn1)) ) if ( !(rgn1 = REGION_LockRgn(hSrcRgn1)) )
return ERROR; return ERROR;
if ( !(rgn2 = RGNDATA_LockRgn(hSrcRgn2)) ) if ( !(rgn2 = REGION_LockRgn(hSrcRgn2)) )
{ {
RGNDATA_UnlockRgn(rgn1); REGION_UnlockRgn(rgn1);
return ERROR; return ERROR;
} }
@ -2392,8 +2331,8 @@ NtGdiEqualRgn(
bRet = TRUE; bRet = TRUE;
exit: exit:
RGNDATA_UnlockRgn(rgn1); REGION_UnlockRgn(rgn1);
RGNDATA_UnlockRgn(rgn2); REGION_UnlockRgn(rgn2);
return bRet; return bRet;
} }
@ -2437,19 +2376,14 @@ NtGdiExtCreateRegion(
return NULL; return NULL;
} }
hRgn = RGNDATA_AllocRgn(nCount); Region = REGION_AllocRgnWithHandle(nCount);
if (hRgn == NULL)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
Region = RGNDATA_LockRgn(hRgn);
if (Region == NULL) if (Region == NULL)
{ {
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
} }
hRgn = Region->BaseObject.hHmgr;
_SEH_TRY _SEH_TRY
{ {
@ -2468,12 +2402,12 @@ NtGdiExtCreateRegion(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastWin32Error(ERROR_INVALID_PARAMETER); SetLastWin32Error(ERROR_INVALID_PARAMETER);
RGNDATA_UnlockRgn(Region); REGION_UnlockRgn(Region);
NtGdiDeleteObject(hRgn); NtGdiDeleteObject(hRgn);
return NULL; return NULL;
} }
RGNDATA_UnlockRgn(Region); REGION_UnlockRgn(Region);
return hRgn; return hRgn;
} }
@ -2490,14 +2424,14 @@ NtGdiFillRgn(
PROSRGNDATA rgn; PROSRGNDATA rgn;
PRECT r; PRECT r;
if (NULL == (rgn = RGNDATA_LockRgn(hRgn))) if (NULL == (rgn = REGION_LockRgn(hRgn)))
{ {
return FALSE; return FALSE;
} }
if (NULL == (oldhBrush = NtGdiSelectBrush(hDC, hBrush))) if (NULL == (oldhBrush = NtGdiSelectBrush(hDC, hBrush)))
{ {
RGNDATA_UnlockRgn(rgn); REGION_UnlockRgn(rgn);
return FALSE; return FALSE;
} }
@ -2506,7 +2440,7 @@ NtGdiFillRgn(
NtGdiPatBlt(hDC, r->left, r->top, r->right - r->left, r->bottom - r->top, PATCOPY); NtGdiPatBlt(hDC, r->left, r->top, r->right - r->left, r->bottom - r->top, PATCOPY);
} }
RGNDATA_UnlockRgn(rgn); REGION_UnlockRgn(rgn);
NtGdiSelectBrush(hDC, oldhBrush); NtGdiSelectBrush(hDC, oldhBrush);
return TRUE; return TRUE;
@ -2542,7 +2476,7 @@ NtGdiFrameRgn(
} }
INT FASTCALL INT FASTCALL
UnsafeIntGetRgnBox( REGION_GetRgnBox(
PROSRGNDATA Rgn, PROSRGNDATA Rgn,
LPRECT pRect LPRECT pRect
) )
@ -2637,13 +2571,13 @@ IntGdiGetRgnBox(
PROSRGNDATA Rgn; PROSRGNDATA Rgn;
DWORD ret; DWORD ret;
if (!(Rgn = RGNDATA_LockRgn(hRgn))) if (!(Rgn = REGION_LockRgn(hRgn)))
{ {
return ERROR; return ERROR;
} }
ret = UnsafeIntGetRgnBox(Rgn, pRect); ret = REGION_GetRgnBox(Rgn, pRect);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
return ret; return ret;
} }
@ -2660,13 +2594,13 @@ NtGdiGetRgnBox(
DWORD ret; DWORD ret;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (!(Rgn = RGNDATA_LockRgn(hRgn))) if (!(Rgn = REGION_LockRgn(hRgn)))
{ {
return ERROR; return ERROR;
} }
ret = UnsafeIntGetRgnBox(Rgn, &SafeRect); ret = REGION_GetRgnBox(Rgn, &SafeRect);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
if (ERROR == ret) if (ERROR == ret)
{ {
return ret; return ret;
@ -2701,7 +2635,7 @@ NtGdiInvertRgn(
ULONG i; ULONG i;
PRECT rc; PRECT rc;
if (!(RgnData = RGNDATA_LockRgn(hRgn))) if (!(RgnData = REGION_LockRgn(hRgn)))
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
@ -2713,13 +2647,13 @@ NtGdiInvertRgn(
if (!NtGdiPatBlt(hDC, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, DSTINVERT)) if (!NtGdiPatBlt(hDC, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, DSTINVERT))
{ {
RGNDATA_UnlockRgn(RgnData); REGION_UnlockRgn(RgnData);
return FALSE; return FALSE;
} }
rc++; rc++;
} }
RGNDATA_UnlockRgn(RgnData); REGION_UnlockRgn(RgnData);
return TRUE; return TRUE;
} }
@ -2731,7 +2665,7 @@ NtGdiOffsetRgn(
INT YOffset INT YOffset
) )
{ {
PROSRGNDATA rgn = RGNDATA_LockRgn(hRgn); PROSRGNDATA rgn = REGION_LockRgn(hRgn);
INT ret; INT ret;
DPRINT("NtGdiOffsetRgn: hRgn %d Xoffs %d Yoffs %d rgn %x\n", hRgn, XOffset, YOffset, rgn ); DPRINT("NtGdiOffsetRgn: hRgn %d Xoffs %d Yoffs %d rgn %x\n", hRgn, XOffset, YOffset, rgn );
@ -2767,7 +2701,7 @@ NtGdiOffsetRgn(
} }
} }
ret = rgn->rdh.iType; ret = rgn->rdh.iType;
RGNDATA_UnlockRgn(rgn); REGION_UnlockRgn(rgn);
return ret; return ret;
} }
@ -2813,8 +2747,8 @@ IntGdiPaintRgn(
NtGdiCombineRgn(tmpVisRgn, tmpVisRgn, dc->w.hGCClipRgn, RGN_AND); NtGdiCombineRgn(tmpVisRgn, tmpVisRgn, dc->w.hGCClipRgn, RGN_AND);
*/ */
//visrgn = RGNDATA_LockRgn(tmpVisRgn); //visrgn = REGION_LockRgn(tmpVisRgn);
visrgn = RGNDATA_LockRgn(hRgn); visrgn = REGION_LockRgn(hRgn);
if (visrgn == NULL) if (visrgn == NULL)
{ {
NtGdiDeleteObject(tmpVisRgn); NtGdiDeleteObject(tmpVisRgn);
@ -2843,7 +2777,7 @@ IntGdiPaintRgn(
BITMAPOBJ_UnlockBitmap(BitmapObj); BITMAPOBJ_UnlockBitmap(BitmapObj);
BRUSHOBJ_UnlockBrush(pBrush); BRUSHOBJ_UnlockBrush(pBrush);
RGNDATA_UnlockRgn(visrgn); REGION_UnlockRgn(visrgn);
NtGdiDeleteObject(tmpVisRgn); NtGdiDeleteObject(tmpVisRgn);
// Fill the region // Fill the region
@ -2862,7 +2796,7 @@ NtGdiPtInRegion(
ULONG i; ULONG i;
PRECT r; PRECT r;
if (!(rgn = RGNDATA_LockRgn(hRgn) ) ) if (!(rgn = REGION_LockRgn(hRgn) ) )
return FALSE; return FALSE;
if (rgn->rdh.nCount > 0 && INRECT(rgn->rdh.rcBound, X, Y)) if (rgn->rdh.nCount > 0 && INRECT(rgn->rdh.rcBound, X, Y))
@ -2872,19 +2806,19 @@ NtGdiPtInRegion(
{ {
if (INRECT(*r, X, Y)) if (INRECT(*r, X, Y))
{ {
RGNDATA_UnlockRgn(rgn); REGION_UnlockRgn(rgn);
return TRUE; return TRUE;
} }
r++; r++;
} }
} }
RGNDATA_UnlockRgn(rgn); REGION_UnlockRgn(rgn);
return FALSE; return FALSE;
} }
BOOL BOOL
FASTCALL FASTCALL
UnsafeIntRectInRegion( REGION_RectInRegion(
PROSRGNDATA Rgn, PROSRGNDATA Rgn,
CONST LPRECT rc CONST LPRECT rc
) )
@ -2919,7 +2853,7 @@ NtGdiRectInRegion(
BOOL Ret; BOOL Ret;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (!(Rgn = RGNDATA_LockRgn(hRgn))) if (!(Rgn = REGION_LockRgn(hRgn)))
{ {
return ERROR; return ERROR;
} }
@ -2937,35 +2871,29 @@ NtGdiRectInRegion(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
SetLastNtError(Status); SetLastNtError(Status);
DPRINT1("NtGdiRectInRegion: bogus rc\n"); DPRINT1("NtGdiRectInRegion: bogus rc\n");
return ERROR; return ERROR;
} }
Ret = UnsafeIntRectInRegion(Rgn, &rc); Ret = REGION_RectInRegion(Rgn, &rc);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
return Ret; return Ret;
} }
BOOL VOID
STDCALL FASTCALL
NtGdiSetRectRgn( REGION_SetRectRgn(
HRGN hRgn, PROSRGNDATA rgn,
INT LeftRect, INT LeftRect,
INT TopRect, INT TopRect,
INT RightRect, INT RightRect,
INT BottomRect INT BottomRect
) )
{ {
PROSRGNDATA rgn;
PRECT firstRect; PRECT firstRect;
if ( !(rgn = RGNDATA_LockRgn(hRgn)) )
return 0; //per documentation
if (LeftRect > RightRect) if (LeftRect > RightRect)
{ {
INT tmp = LeftRect; INT tmp = LeftRect;
@ -2992,8 +2920,28 @@ NtGdiSetRectRgn(
} }
else else
EMPTY_REGION(rgn); EMPTY_REGION(rgn);
}
RGNDATA_UnlockRgn(rgn); BOOL
STDCALL
NtGdiSetRectRgn(
HRGN hRgn,
INT LeftRect,
INT TopRect,
INT RightRect,
INT BottomRect
)
{
PROSRGNDATA rgn;
if ( !(rgn = REGION_LockRgn(hRgn)) )
{
return 0; //per documentation
}
REGION_SetRectRgn(rgn, LeftRect, TopRect, RightRect, BottomRect);
REGION_UnlockRgn(rgn);
return TRUE; return TRUE;
} }
@ -3007,7 +2955,7 @@ NtGdiUnionRectWithRgn(
PROSRGNDATA Rgn; PROSRGNDATA Rgn;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (!(Rgn = (PROSRGNDATA)RGNDATA_LockRgn(hDest))) if (!(Rgn = REGION_LockRgn(hDest)))
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return NULL; return NULL;
@ -3026,13 +2974,13 @@ NtGdiUnionRectWithRgn(
if (! NT_SUCCESS(Status)) if (! NT_SUCCESS(Status))
{ {
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
SetLastNtError(Status); SetLastNtError(Status);
return NULL; return NULL;
} }
UnsafeIntUnionRectWithRgn(Rgn, &SafeRect); REGION_UnionRectWithRgn(Rgn, &SafeRect);
RGNDATA_UnlockRgn(Rgn); REGION_UnlockRgn(Rgn);
return hDest; return hDest;
} }
@ -3054,7 +3002,7 @@ NtGdiGetRegionData(
) )
{ {
DWORD size; DWORD size;
PROSRGNDATA obj = RGNDATA_LockRgn(hrgn); PROSRGNDATA obj = REGION_LockRgn(hrgn);
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (!obj) if (!obj)
@ -3063,10 +3011,10 @@ NtGdiGetRegionData(
size = obj->rdh.nCount * sizeof(RECT); size = obj->rdh.nCount * sizeof(RECT);
if (count < (size + sizeof(RGNDATAHEADER)) || rgndata == NULL) if (count < (size + sizeof(RGNDATAHEADER)) || rgndata == NULL)
{ {
RGNDATA_UnlockRgn(obj); REGION_UnlockRgn(obj);
if (rgndata) /* buffer is too small, signal it by return 0 */ if (rgndata) /* buffer is too small, signal it by return 0 */
return 0; return 0;
else /* user requested buffer size with rgndata NULL */ else /* user requested buffer size with rgndata NULL */
return size + sizeof(RGNDATAHEADER); return size + sizeof(RGNDATAHEADER);
} }
@ -3089,11 +3037,11 @@ NtGdiGetRegionData(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
RGNDATA_UnlockRgn(obj); REGION_UnlockRgn(obj);
return 0; return 0;
} }
RGNDATA_UnlockRgn(obj); REGION_UnlockRgn(obj);
return size + sizeof(RGNDATAHEADER); return size + sizeof(RGNDATAHEADER);
} }
@ -3560,13 +3508,9 @@ IntCreatePolyPolgonRgn(
int numFullPtBlocks = 0; int numFullPtBlocks = 0;
INT poly, total; INT poly, total;
if (!(hrgn = RGNDATA_AllocRgn(nbpolygons))) if (!(region = REGION_AllocRgnWithHandle(nbpolygons)))
return 0; return 0;
if (!(region = RGNDATA_LockRgn(hrgn))) hrgn = region->BaseObject.hHmgr;
{
NtGdiDeleteObject(hrgn);
return 0;
}
/* special case a rectangle */ /* special case a rectangle */
@ -3581,7 +3525,7 @@ IntCreatePolyPolgonRgn(
(Pts[2].x == Pts[3].x) && (Pts[2].x == Pts[3].x) &&
(Pts[3].y == Pts[0].y)))) (Pts[3].y == Pts[0].y))))
{ {
RGNDATA_UnlockRgn(region); REGION_UnlockRgn(region);
NtGdiSetRectRgn(hrgn, min(Pts[0].x, Pts[2].x), min(Pts[0].y, Pts[2].y), 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)); max(Pts[0].x, Pts[2].x), max(Pts[0].y, Pts[2].y));
return hrgn; return hrgn;
@ -3730,7 +3674,7 @@ IntCreatePolyPolgonRgn(
curPtBlock = tmpPtBlock; curPtBlock = tmpPtBlock;
} }
ExFreePool(pETEs); ExFreePool(pETEs);
RGNDATA_UnlockRgn(region); REGION_UnlockRgn(region);
return hrgn; return hrgn;
} }