Author: jimtabor
Date: Sat Dec 26 20:19:33 2009
New Revision: 44765
URL:
http://svn.reactos.org/svn/reactos?rev=44765&view=rev
Log:
[Win32k]
- Rewritten NtGdiCombineRgn.
- Add two function's to support locking and Rgn attributes. These function's will
replace all the normal Rgn locking ones.
Modified:
trunk/reactos/subsystems/win32/win32k/objects/region.c
Modified: trunk/reactos/subsystems/win32/win32k/objects/region.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/region.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/region.c [iso-8859-1] Sat Dec 26
20:19:33 2009
@@ -2068,6 +2068,85 @@
return pReg;
}
+PROSRGNDATA
+FASTCALL
+RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr)
+{
+ INT Index;
+ PGDI_TABLE_ENTRY Entry;
+ PROSRGNDATA pRgn;
+ PRGN_ATTR pRgn_Attr;
+
+ pRgn = REGION_LockRgn(hRgn);
+
+ if (pRgn)
+ {
+ Index = GDI_HANDLE_GET_INDEX(hRgn);
+ Entry = &GdiHandleTable->Entries[Index];
+
+ pRgn_Attr = Entry->UserData;
+ if (pRgn_Attr)
+ {
+ if ( pRgn_Attr->AttrFlags & (ATTR_RGN_VALID|ATTR_RGN_DIRTY) )
+ {
+ switch (pRgn_Attr->Flags)
+ {
+ case NULLREGION:
+ EMPTY_REGION( pRgn );
+ pRgn_Attr->AttrFlags &= ~ATTR_RGN_DIRTY; // Clear flag in these
cases,
+ break;
+
+ case SIMPLEREGION:
+ REGION_SetRectRgn( pRgn,
+ pRgn_Attr->Rect.left,
+ pRgn_Attr->Rect.top,
+ pRgn_Attr->Rect.right,
+ pRgn_Attr->Rect.bottom );
+ pRgn_Attr->AttrFlags &= ~ATTR_RGN_DIRTY; // just incase, force a
redraw.
+ break;
+ }
+ }
+ if (ppRgn_Attr)
+ *ppRgn_Attr = pRgn_Attr;
+ }
+ else
+ {
+ if (ppRgn_Attr)
+ *ppRgn_Attr = NULL;
+ }
+ }
+ return pRgn;
+}
+
+VOID
+FASTCALL
+RGNOBJAPI_Unlock(PROSRGNDATA pRgn)
+{
+ INT Index;
+ PGDI_TABLE_ENTRY Entry;
+ PRGN_ATTR pRgn_Attr;
+
+ if (pRgn)
+ {
+ Index = GDI_HANDLE_GET_INDEX(pRgn->BaseObject.hHmgr);
+ Entry = &GdiHandleTable->Entries[Index];
+
+ pRgn_Attr = Entry->UserData;
+ if ( pRgn_Attr )
+ {
+ if ( pRgn_Attr->AttrFlags & ATTR_RGN_VALID )
+ {
+ pRgn_Attr->Flags = REGION_Complexity( pRgn );
+ pRgn_Attr->Rect.left = pRgn->rdh.rcBound.left;
+ pRgn_Attr->Rect.top = pRgn->rdh.rcBound.top;
+ pRgn_Attr->Rect.right = pRgn->rdh.rcBound.right;
+ pRgn_Attr->Rect.bottom = pRgn->rdh.rcBound.bottom;
+ }
+ }
+ }
+ REGION_UnlockRgn(pRgn);
+}
+
BOOL INTERNAL_CALL
REGION_Cleanup(PVOID ObjectBody)
{
@@ -2209,64 +2288,41 @@
HRGN hSrc2,
INT CombineMode)
{
- INT result = ERROR;
- PROSRGNDATA destRgn, src1Rgn, src2Rgn;
-
- destRgn = REGION_LockRgn(hDest);
- if (destRgn)
- {
- src1Rgn = REGION_LockRgn(hSrc1);
- if (src1Rgn)
- {
- if (CombineMode == RGN_COPY)
- {
- if ( !REGION_CopyRegion(destRgn, src1Rgn) )
- return ERROR;
- result = REGION_Complexity(destRgn);
- }
- else
- {
- src2Rgn = REGION_LockRgn(hSrc2);
- if (src2Rgn)
- {
- switch (CombineMode)
- {
- case RGN_AND:
- REGION_IntersectRegion(destRgn, src1Rgn, src2Rgn);
- break;
- case RGN_OR:
- REGION_UnionRegion(destRgn, src1Rgn, src2Rgn);
- break;
- case RGN_XOR:
- REGION_XorRegion(destRgn, src1Rgn, src2Rgn);
- break;
- case RGN_DIFF:
- REGION_SubtractRegion(destRgn, src1Rgn, src2Rgn);
- break;
- }
- REGION_UnlockRgn(src2Rgn);
- result = REGION_Complexity(destRgn);
- }
- else if (hSrc2 == NULL)
- {
- DPRINT1("NtGdiCombineRgn requires hSrc2 != NULL for combine mode
%d!\n", CombineMode);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- }
- }
-
- REGION_UnlockRgn(src1Rgn);
- }
-
- REGION_UnlockRgn(destRgn);
- }
- else
- {
- DPRINT("NtGdiCombineRgn: hDest unavailable\n");
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- result = ERROR;
- }
-
- return result;
+ INT result = ERROR;
+ PROSRGNDATA destRgn, src1Rgn, src2Rgn = NULL;
+
+ if ( CombineMode > RGN_COPY && CombineMode < RGN_AND)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return ERROR;
+ }
+
+ destRgn = REGION_LockRgn(hDest);
+ if (!destRgn)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return ERROR;
+ }
+
+ src1Rgn = REGION_LockRgn(hSrc1);
+ if (!src1Rgn)
+ {
+ REGION_UnlockRgn(destRgn);
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return ERROR;
+ }
+
+ if (hSrc2)
+ src2Rgn = REGION_LockRgn(hSrc2);
+
+ result = IntGdiCombineRgn( destRgn, src1Rgn, src2Rgn, CombineMode);
+
+ if (src2Rgn)
+ REGION_UnlockRgn(src2Rgn);
+ REGION_UnlockRgn(src1Rgn);
+ REGION_UnlockRgn(destRgn);
+
+ return result;
}
HRGN