Author: tkreuzer
Date: Thu Dec 18 08:11:19 2014
New Revision: 65720

URL: http://svn.reactos.org/svn/reactos?rev=65720&view=rev
Log:
[WIN32K]
More improvements to region.c:
- PROSRGNDATA -> REGION, void -> VOID, int -> INT, uppercase struct names
- do not put assignments into if statements
- !x -> x == NULL for pointers
- Add additional parentheses / curly braces
- rename RGN_ATTR::Flags to iComplexity

Modified:
    trunk/reactos/win32ss/gdi/eng/engwindow.c
    trunk/reactos/win32ss/gdi/gdi32/objects/region.c
    trunk/reactos/win32ss/gdi/ntgdi/dcutil.c
    trunk/reactos/win32ss/gdi/ntgdi/region.c
    trunk/reactos/win32ss/gdi/ntgdi/region.h
    trunk/reactos/win32ss/include/ntgdihdl.h
    trunk/reactos/win32ss/user/ntuser/painting.c

Modified: trunk/reactos/win32ss/gdi/eng/engwindow.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/engwindow.c?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/engwindow.c   [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/engwindow.c   [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -52,7 +52,7 @@
     XCLIPOBJ* Clip,
     PWND Window)
 {
-    PROSRGNDATA visRgn;
+    PREGION visRgn;
 
     TRACE("IntEngWndUpdateClipObj\n");
 

Modified: trunk/reactos/win32ss/gdi/gdi32/objects/region.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/region.c?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/objects/region.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/region.c    [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -212,13 +212,13 @@
     if ( !Ret ||
             !pRgn_Attr_Dest ||
             !pRgn_Attr_Src1 ||
-            pRgn_Attr_Src1->Flags > SIMPLEREGION )
+            pRgn_Attr_Src1->iComplexity > SIMPLEREGION )
         return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
 
     /* Handle COPY and use only src1. */
     if ( CombineMode == RGN_COPY )
     {
-        switch (pRgn_Attr_Src1->Flags)
+        switch (pRgn_Attr_Src1->iComplexity)
         {
         case NULLREGION:
             Ret = SetRectRgn( hDest, 0, 0, 0, 0);
@@ -245,7 +245,7 @@
     Ret = GdiGetHandleUserData((HGDIOBJ) hSrc2, GDI_OBJECT_TYPE_REGION, 
(PVOID) &pRgn_Attr_Src2);
     if ( !Ret ||
             !pRgn_Attr_Src2 ||
-            pRgn_Attr_Src2->Flags > SIMPLEREGION )
+            pRgn_Attr_Src2->iComplexity > SIMPLEREGION )
         return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
 
     /* All but AND. */
@@ -270,14 +270,14 @@
                 return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
             }
             /* Now handle DIFF. */
-            if ( pRgn_Attr_Src1->Flags == NULLREGION )
+            if ( pRgn_Attr_Src1->iComplexity == NULLREGION )
             {
                 if (SetRectRgn( hDest, 0, 0, 0, 0))
                     return NULLREGION;
                 goto ERROR_Exit;
             }
 
-            if ( pRgn_Attr_Src2->Flags != NULLREGION )
+            if ( pRgn_Attr_Src2->iComplexity != NULLREGION )
             {
                 Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, 
&pRgn_Attr_Src2->Rect);
 
@@ -295,9 +295,9 @@
         }
         else /* Handle OR or XOR. */
         {
-            if ( pRgn_Attr_Src1->Flags == NULLREGION )
-            {
-                if ( pRgn_Attr_Src2->Flags != NULLREGION )
+            if ( pRgn_Attr_Src1->iComplexity == NULLREGION )
+            {
+                if ( pRgn_Attr_Src2->iComplexity != NULLREGION )
                 {
                     /* Src1 null and not NULL, set from src2. */
                     Ret = SetRectRgn( hDest,
@@ -315,7 +315,7 @@
                 goto ERROR_Exit;
             }
             /* Src1 is not NULL. */
-            if ( pRgn_Attr_Src2->Flags != NULLREGION )
+            if ( pRgn_Attr_Src2->iComplexity != NULLREGION )
             {
                 if ( CombineMode != RGN_OR ) /* Filter XOR, so go K. */
                     return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
@@ -350,8 +350,8 @@
     }
 
     /* Handle AND.  */
-    if ( pRgn_Attr_Src1->Flags != NULLREGION &&
-            pRgn_Attr_Src2->Flags != NULLREGION )
+    if ( pRgn_Attr_Src1->iComplexity != NULLREGION &&
+            pRgn_Attr_Src2->iComplexity != NULLREGION )
     {
         Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, 
&pRgn_Attr_Src2->Rect);
 
@@ -491,13 +491,13 @@
 
     if (( x1 == x2) || (y1 == y2))
     {
-        pRgn_Attr->Flags = NULLREGION;
+        pRgn_Attr->iComplexity = NULLREGION;
         pRgn_Attr->Rect.left = pRgn_Attr->Rect.top =
                                    pRgn_Attr->Rect.right = 
pRgn_Attr->Rect.bottom = 0;
     }
     else
     {
-        pRgn_Attr->Flags = SIMPLEREGION;
+        pRgn_Attr->iComplexity = SIMPLEREGION;
         pRgn_Attr->Rect.left   = x1;
         pRgn_Attr->Rect.top    = y1;
         pRgn_Attr->Rect.right  = x2;
@@ -642,7 +642,7 @@
                     !(pEntry->Flags & GDI_ENTRY_VALIDATE_VIS) )
             {
                 if (!hrgn ||
-                        (hrgn && pRgn_Attr && pRgn_Attr->Flags <= 
SIMPLEREGION) )
+                        (hrgn && pRgn_Attr && pRgn_Attr->iComplexity <= 
SIMPLEREGION) )
                 {
                     if ((pTeb->GdiTebBatch.Offset + sizeof(GDIBSEXTSELCLPRGN)) 
<= GDIBATCHBUFSIZE)
                     {
@@ -655,7 +655,7 @@
 
                         if ( hrgn && pRgn_Attr )
                         {
-                            Ret = pRgn_Attr->Flags;
+                            Ret = pRgn_Attr->iComplexity;
 
                             if ( pDc_Attr->VisRectRegion.Rect.left   >= 
pRgn_Attr->Rect.right  ||
                                     pDc_Attr->VisRectRegion.Rect.top    >= 
pRgn_Attr->Rect.bottom ||
@@ -670,7 +670,7 @@
                         }
                         else
                         {
-                            Ret = pDc_Attr->VisRectRegion.Flags;
+                            Ret = pDc_Attr->VisRectRegion.iComplexity;
                             pgO->fnMode |= 0x80000000; // Set no hrgn mode.
                         }
                         pTeb->GdiTebBatch.Offset += sizeof(GDIBSEXTSELCLPRGN);
@@ -763,7 +763,7 @@
     //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, 
(PVOID) &Rgn_Attr))
     return NtGdiGetRgnBox(hrgn, prcOut);
 
-    if (Rgn_Attr->Flags == NULLREGION)
+    if (Rgn_Attr->iComplexity == NULLREGION)
     {
         prcOut->left   = 0;
         prcOut->top    = 0;
@@ -772,12 +772,12 @@
     }
     else
     {
-        if (Rgn_Attr->Flags != SIMPLEREGION)
+        if (Rgn_Attr->iComplexity != SIMPLEREGION)
             return NtGdiGetRgnBox(hrgn, prcOut);
         /* WARNING! prcOut is never checked newbies! */
         RtlCopyMemory( prcOut, &Rgn_Attr->Rect, sizeof(RECT));
     }
-    return Rgn_Attr->Flags;
+    return Rgn_Attr->iComplexity;
 }
 
 /*
@@ -875,10 +875,10 @@
 //  if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) 
&pRgn_Attr))
     return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset);
 
-    if ( pRgn_Attr->Flags == NULLREGION)
-        return pRgn_Attr->Flags;
-
-    if ( pRgn_Attr->Flags != SIMPLEREGION)
+    if ( pRgn_Attr->iComplexity == NULLREGION)
+        return pRgn_Attr->iComplexity;
+
+    if ( pRgn_Attr->iComplexity != SIMPLEREGION)
         return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset);
 
     nLeftRect   = pRgn_Attr->Rect.left;
@@ -911,7 +911,7 @@
             pRgn_Attr->AttrFlags |= ATTR_RGN_DIRTY;
         }
     }
-    return pRgn_Attr->Flags;
+    return pRgn_Attr->iComplexity;
 }
 
 /*
@@ -929,10 +929,10 @@
     //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, 
(PVOID) &pRgn_Attr))
     return NtGdiPtInRegion(hrgn,x,y);
 
-    if ( pRgn_Attr->Flags == NULLREGION)
+    if ( pRgn_Attr->iComplexity == NULLREGION)
         return FALSE;
 
-    if ( pRgn_Attr->Flags != SIMPLEREGION)
+    if ( pRgn_Attr->iComplexity != SIMPLEREGION)
         return NtGdiPtInRegion(hrgn,x,y);
 
     return INRECT( pRgn_Attr->Rect, x, y);
@@ -953,10 +953,10 @@
     //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, 
(PVOID) &pRgn_Attr))
     return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
 
-    if ( pRgn_Attr->Flags == NULLREGION)
+    if ( pRgn_Attr->iComplexity == NULLREGION)
         return FALSE;
 
-    if ( pRgn_Attr->Flags != SIMPLEREGION)
+    if ( pRgn_Attr->iComplexity != SIMPLEREGION)
         return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
 
     /* swap the coordinates to make right >= left and bottom >= top */
@@ -1019,7 +1019,7 @@
     if ((nLeftRect == nRightRect) || (nTopRect == nBottomRect))
     {
         Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY;
-        Rgn_Attr->Flags = NULLREGION;
+        Rgn_Attr->iComplexity = NULLREGION;
         Rgn_Attr->Rect.left = Rgn_Attr->Rect.top =
                                   Rgn_Attr->Rect.right = Rgn_Attr->Rect.bottom 
= 0;
         return TRUE;
@@ -1042,7 +1042,7 @@
     }
 
     Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY ;
-    Rgn_Attr->Flags = SIMPLEREGION;
+    Rgn_Attr->iComplexity = SIMPLEREGION;
     return TRUE;
 }
 

Modified: trunk/reactos/win32ss/gdi/ntgdi/dcutil.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcutil.c?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dcutil.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dcutil.c    [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -274,7 +274,7 @@
 IntSetDefaultRegion(PDC pdc)
 {
     PSURFACE pSurface;
-    PROSRGNDATA prgn;
+    PREGION prgn;
     RECTL rclWnd, rclClip;
 
     IntGdiReleaseRaoRgn(pdc);

Modified: trunk/reactos/win32ss/gdi/ntgdi/region.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/region.c?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/region.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/region.c    [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -119,21 +119,21 @@
 #define NDEBUG
 #include <debug.h>
 
-PROSRGNDATA prgnDefault = NULL;
-HRGN        hrgnDefault = NULL;
+PREGION prgnDefault = NULL;
+HRGN    hrgnDefault = NULL;
 
 // Internal Functions
 
 #if 1
 #define COPY_RECTS(dest, src, nRects) \
   do {                                \
-    PRECTL xDest = (dest);             \
-    PRECTL xSrc = (src);               \
+    PRECTL xDest = (dest);            \
+    PRECTL xSrc = (src);              \
     UINT xRects = (nRects);           \
-    while(xRects-- > 0) {             \
+    while (xRects-- > 0) {            \
       *(xDest++) = *(xSrc++);         \
     }                                 \
-  } while(0)
+  } while (0)
 #else
 #define COPY_RECTS(dest, src, nRects) RtlCopyMemory(dest, src, (nRects) * 
sizeof(RECTL))
 #endif
@@ -230,11 +230,11 @@
 }
 
 /*
- *     This structure contains all of the information needed
- *     to run the bresenham algorithm.
- *     The variables may be hardcoded into the declarations
- *     instead of using this structure to make use of
- *     register declarations.
+ * This structure contains all of the information needed
+ * to run the bresenham algorithm.
+ * The variables may be hardcoded into the declarations
+ * instead of using this structure to make use of
+ * register declarations.
  */
 typedef struct
 {
@@ -284,16 +284,16 @@
  *     We also keep a data structure known as the Edge Table (ET),
  *     which keeps track of all the edges which the current
  *     scanline has not yet reached.  The ET is basically a
- *     list of ScanLineList structures containing a list of
+ *     list of SCANLINE_LIST structures containing a list of
  *     edges which are entered at a given scanline.  There is one
- *     ScanLineList per scanline at which an edge is entered.
+ *     SCANLINE_LIST per scanline at which an edge is entered.
  *     When we enter a new edge, we move it from the ET to the AET.
  *
  *     From the AET, we can implement the even-odd rule as in
  *     (Foley/Van Dam).
  *     The winding number rule is a little trickier.  We also
- *     keep the EdgeTableEntries in the AET linked by the
- *     nextWETE (winding EdgeTableEntry) link.  This allows
+ *     keep the EDGE_TABLEEntries in the AET linked by the
+ *     nextWETE (winding EDGE_TABLE_ENTRY) link.  This allows
  *     the edges to be linked just as before for updating
  *     purposes, but only uses the edges linked by the nextWETE
  *     link as edges representing spans of the polygon to
@@ -306,31 +306,31 @@
 #define CLOCKWISE          1
 #define COUNTERCLOCKWISE  -1
 
-typedef struct _EdgeTableEntry
+typedef struct _EDGE_TABLE_ENTRY
 {
     INT ymax;             /* ycoord at which we exit this edge. */
     BRESINFO bres;        /* Bresenham info to run the edge     */
-    struct _EdgeTableEntry *next;       /* Next in the list     */
-    struct _EdgeTableEntry *back;       /* For insertion sort   */
-    struct _EdgeTableEntry *nextWETE;   /* For winding num rule */
-    int ClockWise;        /* Flag for winding number rule       */
-} EdgeTableEntry;
-
-
-typedef struct _ScanLineList
+    struct _EDGE_TABLE_ENTRY *next;       /* Next in the list     */
+    struct _EDGE_TABLE_ENTRY *back;       /* For insertion sort   */
+    struct _EDGE_TABLE_ENTRY *nextWETE;   /* For winding num rule */
+    INT ClockWise;        /* Flag for winding number rule       */
+} EDGE_TABLE_ENTRY;
+
+
+typedef struct _SCANLINE_LIST
 {
     INT scanline;                /* The scanline represented */
-    EdgeTableEntry *edgelist;    /* Header node              */
-    struct _ScanLineList *next;  /* Next in the list       */
-} ScanLineList;
+    EDGE_TABLE_ENTRY *edgelist;    /* Header node              */
+    struct _SCANLINE_LIST *next;  /* Next in the list       */
+} SCANLINE_LIST;
 
 
 typedef struct
 {
     INT ymax;                 /* ymax for the polygon     */
     INT ymin;                 /* ymin for the polygon     */
-    ScanLineList scanlines;   /* Header node              */
-} EdgeTable;
+    SCANLINE_LIST scanlines;   /* Header node              */
+} EDGE_TABLE;
 
 
 /*
@@ -340,11 +340,11 @@
  */
 #define SLLSPERBLOCK 25
 
-typedef struct _ScanLineListBlock
-{
-    ScanLineList SLLs[SLLSPERBLOCK];
-    struct _ScanLineListBlock *next;
-} ScanLineListBlock;
+typedef struct _SCANLINE_LISTBLOCK
+{
+    SCANLINE_LIST SLLs[SLLSPERBLOCK];
+    struct _SCANLINE_LISTBLOCK *next;
+} SCANLINE_LISTBLOCK;
 
 
 /*
@@ -408,18 +408,19 @@
 /*
  *   Check to see if there is enough memory in the present region.
  */
-static __inline int xmemcheck(ROSRGNDATA *reg, PRECTL *rect, PRECTL *firstrect)
-{
-    if ( (reg->rdh.nCount+1) * sizeof(RECT) >= reg->rdh.nRgnSize )
+static __inline INT xmemcheck(PREGION reg, PRECTL *rect, PRECTL *firstrect)
+{
+    if ((reg->rdh.nCount+1) * sizeof(RECT) >= reg->rdh.nRgnSize)
     {
         PRECTL temp;
         DWORD NewSize = 2 * reg->rdh.nRgnSize;
+
         if (NewSize < (reg->rdh.nCount + 1) * sizeof(RECT))
         {
             NewSize = (reg->rdh.nCount + 1) * sizeof(RECT);
         }
+
         temp = ExAllocatePoolWithTag(PagedPool, NewSize, TAG_REGION);
-
         if (temp == NULL)
         {
             return 0;
@@ -433,16 +434,17 @@
         {
             ExFreePoolWithTag(*firstrect, TAG_REGION);
         }
+
         *firstrect = temp;
-        *rect = (*firstrect)+reg->rdh.nCount;
+        *rect = (*firstrect) + reg->rdh.nCount;
     }
     return 1;
 }
 
 #define MEMCHECK(reg, rect, firstrect) xmemcheck(reg,&(rect),(PRECTL 
*)&(firstrect))
 
-typedef void (FASTCALL *overlapProcp)(PROSRGNDATA, PRECT, PRECT, PRECT, PRECT, 
INT, INT);
-typedef void (FASTCALL *nonOverlapProcp)(PROSRGNDATA, PRECT, PRECT, INT, INT);
+typedef VOID (FASTCALL *overlapProcp)(PREGION, PRECT, PRECT, PRECT, PRECT, 
INT, INT);
+typedef VOID (FASTCALL *nonOverlapProcp)(PREGION, PRECT, PRECT, INT, INT);
 
 // Number of points to buffer before sending them off to scanlines() :  Must 
be an even number
 #define NUMPTSTOBUFFER 200
@@ -464,7 +466,7 @@
 FASTCALL
 IntDumpRegion(HRGN hRgn)
 {
-    ROSRGNDATA *Data;
+    PREGION Data;
 
     Data = RGNOBJAPI_Lock(hRgn, NULL);
     if (Data == NULL)
@@ -490,12 +492,12 @@
 FASTCALL
 REGION_Complexity(PREGION prgn)
 {
-    if (!prgn)
+    if (prgn == NULL)
         return NULLREGION;
 
+    DPRINT("Region Complexity -> %lu", prgn->rdh.nCount);
     switch (prgn->rdh.nCount)
     {
-        DPRINT("Region Complexity -> %lu", prgn->rdh.nCount);
         case 0:
             return NULLREGION;
         case 1:
@@ -509,26 +511,34 @@
 BOOL
 FASTCALL
 REGION_CopyRegion(
-    PROSRGNDATA dst,
-    PROSRGNDATA src)
-{
-    if (dst != src) // Don't want to copy to itself
-    {
+    PREGION dst,
+    PREGION src)
+{
+    /* Only copy if source and dest are equal */
+    if (dst != src)
+    {
+        /* Check if we need to increase our buffer */
         if (dst->rdh.nRgnSize < src->rdh.nCount * sizeof(RECT))
         {
             PRECTL temp;
 
-            temp = ExAllocatePoolWithTag(PagedPool, src->rdh.nCount * 
sizeof(RECT), TAG_REGION );
-            if (!temp)
+            /* Allocate a new buffer */
+            temp = ExAllocatePoolWithTag(PagedPool,
+                                         src->rdh.nCount * sizeof(RECT),
+                                         TAG_REGION);
+            if (temp == NULL)
                 return FALSE;
 
-            if (dst->Buffer && dst->Buffer != &dst->rdh.rcBound)
-                ExFreePoolWithTag(dst->Buffer, TAG_REGION);     // Free the 
old buffer
+            /* Free the old buffer */
+            if ((dst->Buffer != NULL) && (dst->Buffer != &dst->rdh.rcBound))
+                ExFreePoolWithTag(dst->Buffer, TAG_REGION);
+
+            /* Set the new buffer and the size */
             dst->Buffer = temp;
-            dst->rdh.nRgnSize = src->rdh.nCount * sizeof(RECT); // Size of 
region buffer
-        }
-
-        dst->rdh.nCount = src->rdh.nCount;                      // Number of 
rectangles present in Buffer
+            dst->rdh.nRgnSize = src->rdh.nCount * sizeof(RECT);
+        }
+
+        dst->rdh.nCount = src->rdh.nCount;
         dst->rdh.rcBound.left = src->rdh.rcBound.left;
         dst->rdh.rcBound.top = src->rdh.rcBound.top;
         dst->rdh.rcBound.right = src->rdh.rcBound.right;
@@ -541,13 +551,14 @@
 }
 
 static
-void
+VOID
 FASTCALL
 REGION_SetExtents(
-    ROSRGNDATA *pReg)
+    PREGION pReg)
 {
     RECTL *pRect, *pRectEnd, *pExtents;
 
+    /* Quick check for NULLREGION */
     if (pReg->rdh.nCount == 0)
     {
         pReg->rdh.rcBound.left = 0;
@@ -599,12 +610,14 @@
     POINT pt = {0,0};
     const POINT *off = offset;
 
-    if (!off) off = &pt;
+    if (off == NULL)
+        off = &pt;
 
     /* Just copy and offset */
-    if (!rect)
+    if (rect == NULL)
     {
         PRECTL xrect;
+
         if (rgnDst == rgnSrc)
         {
             if (off->x || off->y)
@@ -617,7 +630,7 @@
             xrect = ExAllocatePoolWithTag(PagedPool,
                                           rgnSrc->rdh.nCount * sizeof(RECT),
                                           TAG_REGION);
-            if(!xrect)
+            if (xrect == NULL)
                 return ERROR;
 
             /* Free the old buffer. Will be assigned to xrect below. */
@@ -633,6 +646,7 @@
         if (off->x || off->y)
         {
             ULONG i;
+
             for (i = 0; i < rgnDst->rdh.nCount; i++)
             {
                 xrect[i].left = (rgnSrc->Buffer + i)->left + off->x;
@@ -655,7 +669,7 @@
     }
     else if ((rect->left >= rect->right) ||
              (rect->top >= rect->bottom) ||
-             !EXTENTCHECK(rect, &rgnSrc->rdh.rcBound))
+             (EXTENTCHECK(rect, &rgnSrc->rdh.rcBound) == 0))
     {
         goto empty;
     }
@@ -698,7 +712,7 @@
         {
             PRECTL temp;
             temp = ExAllocatePoolWithTag(PagedPool, nRgnSize, TAG_REGION);
-            if (!temp)
+            if (temp == NULL)
                 return ERROR;
 
             /* Free the old buffer */
@@ -767,7 +781,7 @@
     return REGION_Complexity(rgnDst);
 
 empty:
-    if (!rgnDst->Buffer)
+    if (rgnDst->Buffer == NULL)
     {
         rgnDst->Buffer = &rgnDst->rdh.rcBound;
     }
@@ -795,16 +809,16 @@
 INT
 FASTCALL
 REGION_Coalesce(
-    PROSRGNDATA pReg, /* Region to coalesce */
-    INT prevStart,  /* Index of start of previous band */
-    INT curStart)    /* Index of start of current band */
-{
-    RECTL *pPrevRect;          /* Current rect in previous band */
-    RECTL *pCurRect;           /* Current rect in current band */
-    RECTL *pRegEnd;            /* End of region */
-    INT curNumRects;          /* Number of rectangles in current band */
-    INT prevNumRects;         /* Number of rectangles in previous band */
-    INT bandtop;               /* Top coordinate for current band */
+    PREGION pReg,  /* Region to coalesce */
+    INT prevStart, /* Index of start of previous band */
+    INT curStart)  /* Index of start of current band */
+{
+    RECTL *pPrevRect;  /* Current rect in previous band */
+    RECTL *pCurRect;   /* Current rect in current band */
+    RECTL *pRegEnd;    /* End of region */
+    INT curNumRects;   /* Number of rectangles in current band */
+    INT prevNumRects;  /* Number of rectangles in previous band */
+    INT bandtop;       /* Top coordinate for current band */
 
     pRegEnd = pReg->Buffer + pReg->rdh.nCount;
     pPrevRect = pReg->Buffer + prevStart;
@@ -833,6 +847,7 @@
         {
             pRegEnd--;
         }
+
         curStart = pRegEnd - pReg->Buffer;
         pRegEnd = pReg->Buffer + pReg->rdh.nCount;
     }
@@ -840,6 +855,7 @@
     if ((curNumRects == prevNumRects) && (curNumRects != 0))
     {
         pCurRect -= curNumRects;
+
         /* The bands may only be coalesced if the bottom of the previous
          * matches the top scanline of the current. */
         if (pPrevRect->bottom == pCurRect->top)
@@ -928,12 +944,12 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_RegionOp(
-    ROSRGNDATA *newReg, /* Place to store result */
-    ROSRGNDATA *reg1,   /* First region in operation */
-    ROSRGNDATA *reg2,   /* 2nd region in operation */
+    PREGION newReg, /* Place to store result */
+    PREGION reg1,   /* First region in operation */
+    PREGION reg2,   /* 2nd region in operation */
     overlapProcp overlapFunc,     /* Function to call for over-lapping bands */
     nonOverlapProcp nonOverlap1Func, /* Function to call for non-overlapping 
bands in region 1 */
     nonOverlapProcp nonOverlap2Func)  /* Function to call for non-overlapping 
bands in region 2 */
@@ -963,7 +979,6 @@
     r1End = r1 + reg1->rdh.nCount;
     r2End = r2 + reg2->rdh.nCount;
 
-
     /* newReg may be one of the src regions so we can't empty it. We keep a
      * note of its rects pointer (so that we can free them later), preserve its
      * extents and simply set numRects to zero. */
@@ -980,7 +995,7 @@
     newReg->Buffer = ExAllocatePoolWithTag(PagedPool,
                                            newReg->rdh.nRgnSize,
                                            TAG_REGION);
-    if (!newReg->Buffer)
+    if (newReg->Buffer == NULL)
     {
         newReg->rdh.nRgnSize = 0;
         return;
@@ -1010,7 +1025,6 @@
      * the possible expansion, and resultant moving, of the new region's
      * array of rectangles. */
     prevBand = 0;
-
     do
     {
         curBand = newReg->rdh.nCount;
@@ -1149,7 +1163,7 @@
 
     if (newReg->rdh.nCount != curBand)
     {
-        (void) REGION_Coalesce(newReg, prevBand, curBand);
+        (VOID)REGION_Coalesce(newReg, prevBand, curBand);
     }
 
     /* A bit of cleanup. To keep regions from growing without bound,
@@ -1158,7 +1172,8 @@
      *
      * Only do this stuff if the number of rectangles allocated is more than
      * twice the number of rectangles in the region (a simple 
optimization...). */
-    if ((2 * newReg->rdh.nCount * sizeof(RECT) < newReg->rdh.nRgnSize) && 
(newReg->rdh.nCount > 2))
+    if ((newReg->rdh.nRgnSize > (2 * newReg->rdh.nCount * sizeof(RECT))) &&
+        (newReg->rdh.nCount > 2))
     {
         if (REGION_NOT_EMPTY(newReg))
         {
@@ -1167,8 +1182,10 @@
                                                    newReg->rdh.nCount * 
sizeof(RECT),
                                                    TAG_REGION);
 
-            if (!newReg->Buffer)
+            if (newReg->Buffer == NULL)
+            {
                 newReg->Buffer = prev_rects;
+            }
             else
             {
                 newReg->rdh.nRgnSize = newReg->rdh.nCount*sizeof(RECT);
@@ -1185,7 +1202,9 @@
             if (newReg->Buffer != &newReg->rdh.rcBound)
                 ExFreePoolWithTag(newReg->Buffer, TAG_REGION);
 
-            newReg->Buffer = ExAllocatePoolWithTag(PagedPool, sizeof(RECT), 
TAG_REGION);
+            newReg->Buffer = ExAllocatePoolWithTag(PagedPool,
+                                                   sizeof(RECT),
+                                                   TAG_REGION);
             ASSERT(newReg->Buffer);
         }
     }
@@ -1213,16 +1232,16 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_IntersectO(
-    PROSRGNDATA pReg,
-    PRECTL      r1,
-    PRECTL      r1End,
-    PRECTL      r2,
-    PRECTL      r2End,
-    INT         top,
-    INT         bottom)
+    PREGION pReg,
+    PRECTL  r1,
+    PRECTL  r1End,
+    PRECTL  r2,
+    PRECTL  r2End,
+    INT     top,
+    INT     bottom)
 {
     INT       left, right;
     RECTL     *pNextRect;
@@ -1275,24 +1294,29 @@
  * REGION_IntersectRegion
  */
 static
-void
+VOID
 FASTCALL
 REGION_IntersectRegion(
-    ROSRGNDATA *newReg,
-    ROSRGNDATA *reg1,
-    ROSRGNDATA *reg2)
+    PREGION newReg,
+    PREGION reg1,
+    PREGION reg2)
 {
     /* Check for trivial reject */
-    if ( (!(reg1->rdh.nCount)) || (!(reg2->rdh.nCount))  ||
-            (!EXTENTCHECK(&reg1->rdh.rcBound, &reg2->rdh.rcBound)) )
+    if ((reg1->rdh.nCount == 0) ||
+        (reg2->rdh.nCount == 0) ||
+        (EXTENTCHECK(&reg1->rdh.rcBound, &reg2->rdh.rcBound) == 0))
+    {
         newReg->rdh.nCount = 0;
+    }
     else
+    {
         REGION_RegionOp(newReg,
                         reg1,
                         reg2,
                         REGION_IntersectO,
                         NULL,
                         NULL);
+    }
 
     /* Can't alter newReg's extents before we call miRegionOp because
      * it might be one of the source regions and miRegionOp depends
@@ -1320,14 +1344,14 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_UnionNonO(
-    PROSRGNDATA pReg,
-    PRECTL      r,
-    PRECTL      rEnd,
-    INT         top,
-    INT         bottom)
+    PREGION pReg,
+    PRECTL  r,
+    PRECTL  rEnd,
+    INT     top,
+    INT     bottom)
 {
     RECTL *pNextRect;
 
@@ -1361,16 +1385,16 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_UnionO (
-    PROSRGNDATA pReg,
-    PRECTL      r1,
-    PRECTL      r1End,
-    PRECTL      r2,
-    PRECTL      r2End,
-    INT         top,
-    INT         bottom)
+    PREGION pReg,
+    PRECTL  r1,
+    PRECTL  r1End,
+    PRECTL  r2,
+    PRECTL  r2End,
+    INT     top,
+    INT     bottom)
 {
     RECTL *pNextRect;
 
@@ -1420,10 +1444,12 @@
         while (r1 != r1End);
     }
     else
+    {
         while (r2 != r2End)
         {
             MERGERECT(r2);
         }
+    }
 
     return;
 }
@@ -1431,17 +1457,19 @@
 /***********************************************************************
  * REGION_UnionRegion
  */
-static void FASTCALL
+static
+VOID
+FASTCALL
 REGION_UnionRegion(
-    ROSRGNDATA *newReg,
-    ROSRGNDATA *reg1,
-    ROSRGNDATA *reg2)
+    PREGION newReg,
+    PREGION reg1,
+    PREGION reg2)
 {
     /* Checks all the simple cases
      * Region 1 and 2 are the same or region 1 is empty */
-    if (reg1 == reg2 || 0 == reg1->rdh.nCount ||
-        reg1->rdh.rcBound.right <= reg1->rdh.rcBound.left ||
-        reg1->rdh.rcBound.bottom <= reg1->rdh.rcBound.top)
+    if ((reg1 == reg2) || (reg1->rdh.nCount == 0) ||
+        (reg1->rdh.rcBound.right <= reg1->rdh.rcBound.left) ||
+        (reg1->rdh.rcBound.bottom <= reg1->rdh.rcBound.top))
     {
         if (newReg != reg2)
         {
@@ -1452,23 +1480,24 @@
     }
 
     /* If nothing to union (region 2 empty) */
-    if (0 == reg2->rdh.nCount ||
-        reg2->rdh.rcBound.right <= reg2->rdh.rcBound.left ||
-        reg2->rdh.rcBound.bottom <= reg2->rdh.rcBound.top)
+    if ((reg2->rdh.nCount == 0) ||
+        (reg2->rdh.rcBound.right <= reg2->rdh.rcBound.left) ||
+        (reg2->rdh.rcBound.bottom <= reg2->rdh.rcBound.top))
     {
         if (newReg != reg1)
         {
             REGION_CopyRegion(newReg, reg1);
         }
+
         return;
     }
 
     /* Region 1 completely subsumes region 2 */
-    if (1 == reg1->rdh.nCount &&
-        reg1->rdh.rcBound.left <= reg2->rdh.rcBound.left &&
-        reg1->rdh.rcBound.top <= reg2->rdh.rcBound.top &&
-        reg2->rdh.rcBound.right <= reg1->rdh.rcBound.right &&
-        reg2->rdh.rcBound.bottom <= reg1->rdh.rcBound.bottom)
+    if ((reg1->rdh.nCount == 1) &&
+        (reg1->rdh.rcBound.left <= reg2->rdh.rcBound.left) &&
+        (reg1->rdh.rcBound.top <= reg2->rdh.rcBound.top) &&
+        (reg2->rdh.rcBound.right <= reg1->rdh.rcBound.right) &&
+        (reg2->rdh.rcBound.bottom <= reg1->rdh.rcBound.bottom))
     {
         if (newReg != reg1)
         {
@@ -1479,11 +1508,11 @@
     }
 
     /* Region 2 completely subsumes region 1 */
-    if (1 == reg2->rdh.nCount &&
-        reg2->rdh.rcBound.left <= reg1->rdh.rcBound.left &&
-        reg2->rdh.rcBound.top <= reg1->rdh.rcBound.top &&
-        reg1->rdh.rcBound.right <= reg2->rdh.rcBound.right &&
-        reg1->rdh.rcBound.bottom <= reg2->rdh.rcBound.bottom)
+    if ((reg2->rdh.nCount == 1) &&
+        (reg2->rdh.rcBound.left <= reg1->rdh.rcBound.left) &&
+        (reg2->rdh.rcBound.top <= reg1->rdh.rcBound.top) &&
+        (reg1->rdh.rcBound.right <= reg2->rdh.rcBound.right) &&
+        (reg1->rdh.rcBound.bottom <= reg2->rdh.rcBound.bottom))
     {
         if (newReg != reg2)
         {
@@ -1493,12 +1522,12 @@
         return;
     }
 
-    REGION_RegionOp (newReg,
-                     reg1,
-                     reg2,
-                     REGION_UnionO,
-                     REGION_UnionNonO,
-                     REGION_UnionNonO);
+    REGION_RegionOp(newReg,
+                    reg1,
+                    reg2,
+                    REGION_UnionO,
+                    REGION_UnionNonO,
+                    REGION_UnionNonO);
 
     newReg->rdh.rcBound.left = min(reg1->rdh.rcBound.left, 
reg2->rdh.rcBound.left);
     newReg->rdh.rcBound.top = min(reg1->rdh.rcBound.top, 
reg2->rdh.rcBound.top);
@@ -1522,14 +1551,14 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_SubtractNonO1(
-    PROSRGNDATA pReg,
-    PRECTL      r,
-    PRECTL      rEnd,
-    INT         top,
-    INT         bottom)
+    PREGION pReg,
+    PRECTL  r,
+    PRECTL  rEnd,
+    INT     top,
+    INT     bottom)
 {
     RECTL *pNextRect;
 
@@ -1563,16 +1592,16 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_SubtractO(
-    PROSRGNDATA pReg,
-    PRECTL      r1,
-    PRECTL      r1End,
-    PRECTL      r2,
-    PRECTL      r2End,
-    INT         top,
-    INT         bottom)
+    PREGION pReg,
+    PRECTL  r1,
+    PRECTL  r1End,
+    PRECTL  r2,
+    PRECTL  r2End,
+    INT     top,
+    INT     bottom)
 {
     RECTL *pNextRect;
     INT left;
@@ -1644,6 +1673,7 @@
                 pReg->rdh.nCount += 1;
                 pNextRect++;
             }
+
             r1++;
             if (r1 != r1End)
                 left = r1->left;
@@ -1682,17 +1712,17 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_SubtractRegion(
-    ROSRGNDATA *regD,
-    ROSRGNDATA *regM,
-    ROSRGNDATA *regS)
+    PREGION regD,
+    PREGION regM,
+    PREGION regS)
 {
     /* Check for trivial reject */
-    if ((!(regM->rdh.nCount)) ||
-        (!(regS->rdh.nCount)) ||
-        (!EXTENTCHECK(&regM->rdh.rcBound, &regS->rdh.rcBound)) )
+    if ((regM->rdh.nCount == 0) ||
+        (regS->rdh.nCount == 0) ||
+        (EXTENTCHECK(&regM->rdh.rcBound, &regS->rdh.rcBound) == 0))
     {
         REGION_CopyRegion(regD, regM);
         return;
@@ -1717,19 +1747,19 @@
  * REGION_XorRegion
  */
 static
-void
+VOID
 FASTCALL
 REGION_XorRegion(
-    ROSRGNDATA *dr,
-    ROSRGNDATA *sra,
-    ROSRGNDATA *srb)
+    PREGION dr,
+    PREGION sra,
+    PREGION srb)
 {
     HRGN htra, htrb;
-    ROSRGNDATA *tra, *trb;
+    PREGION tra, trb;
 
     // FIXME: Don't use a handle
     tra = REGION_AllocRgnWithHandle(sra->rdh.nCount + 1);
-    if (!tra )
+    if (tra == NULL)
     {
         return;
     }
@@ -1737,7 +1767,7 @@
 
     // FIXME: Don't use a handle
     trb = REGION_AllocRgnWithHandle(srb->rdh.nCount + 1);
-    if (!trb)
+    if (trb == NULL)
     {
         RGNOBJAPI_Unlock(tra);
         GreDeleteObject(htra);
@@ -1763,10 +1793,10 @@
 VOID
 FASTCALL
 REGION_UnionRectWithRgn(
-    ROSRGNDATA *rgn,
+    PREGION rgn,
     const RECTL *rect)
 {
-    ROSRGNDATA region;
+    REGION region;
 
     region.Buffer = &region.rdh.rcBound;
     region.rdh.nCount = 1;
@@ -1795,7 +1825,7 @@
 BOOL
 FASTCALL
 REGION_CreateSimpleFrameRgn(
-    PROSRGNDATA rgn,
+    PREGION rgn,
     INT x,
     INT y)
 {
@@ -1806,8 +1836,8 @@
     {
         prc = rc;
 
-        if (rgn->rdh.rcBound.bottom - rgn->rdh.rcBound.top > y * 2 &&
-            rgn->rdh.rcBound.right - rgn->rdh.rcBound.left > x * 2)
+        if ((rgn->rdh.rcBound.bottom - rgn->rdh.rcBound.top > y * 2) &&
+            (rgn->rdh.rcBound.right - rgn->rdh.rcBound.left > x * 2))
         {
             if (y != 0)
             {
@@ -1854,8 +1884,10 @@
             rgn->rdh.nCount = (DWORD)(prc - rc);
             ASSERT(rgn->rdh.nCount > 1);
             rgn->rdh.nRgnSize = rgn->rdh.nCount * sizeof(RECT);
-            rgn->Buffer = ExAllocatePoolWithTag(PagedPool, rgn->rdh.nRgnSize, 
TAG_REGION);
-            if (!rgn->Buffer)
+            rgn->Buffer = ExAllocatePoolWithTag(PagedPool,
+                                                rgn->rdh.nRgnSize,
+                                                TAG_REGION);
+            if (rgn->Buffer == NULL)
             {
                 rgn->rdh.nRgnSize = 0;
                 return FALSE;
@@ -1869,18 +1901,20 @@
     return TRUE;
 }
 
-BOOL FASTCALL
+BOOL
+FASTCALL
 REGION_CreateFrameRgn(
     HRGN hDest,
     HRGN hSrc,
     INT x,
     INT y)
 {
-    PROSRGNDATA srcObj, destObj;
+    PREGION srcObj, destObj;
     PRECTL rc;
     ULONG i;
 
-    if (!(srcObj = RGNOBJAPI_Lock(hSrc, NULL)))
+    srcObj = RGNOBJAPI_Lock(hSrc, NULL);
+    if (srcObj == NULL)
     {
         return FALSE;
     }
@@ -1891,7 +1925,8 @@
         return FALSE;
     }
 
-    if (!(destObj = RGNOBJAPI_Lock(hDest, NULL)))
+    destObj = RGNOBJAPI_Lock(hDest, NULL);
+    if (destObj == NULL)
     {
         RGNOBJAPI_Unlock(srcObj);
         return FALSE;
@@ -1936,6 +1971,7 @@
             rc->right -= 2 * x;
             rc++;
         }
+
         REGION_IntersectRegion(destObj, destObj, srcObj);
 
         /* Original region moved down */
@@ -1959,6 +1995,7 @@
             rc->bottom -= 2 * y;
             rc++;
         }
+
         REGION_IntersectRegion(destObj, destObj, srcObj);
 
         /* Restore the original region */
@@ -1969,6 +2006,7 @@
             rc->bottom += y;
             rc++;
         }
+
         REGION_SubtractRegion(destObj, srcObj, destObj);
     }
 
@@ -1990,7 +2028,7 @@
     RECTL tmpRect;
     PDC_ATTR pdcattr;
 
-    if (!dc)
+    if (dc == NULL)
         return FALSE;
     pdcattr = dc->pdcattr;
 
@@ -2036,18 +2074,18 @@
     return TRUE;
 }
 
-PROSRGNDATA
+PREGION
 FASTCALL
 REGION_AllocRgnWithHandle(
     INT nReg)
 {
     //HRGN hReg;
-    PROSRGNDATA pReg;
-
-    pReg = (PROSRGNDATA)GDIOBJ_AllocateObject(GDIObjType_RGN_TYPE,
-                                              sizeof(REGION),
-                                              BASEFLAG_LOOKASIDE);
-    if (!pReg)
+    PREGION pReg;
+
+    pReg = (PREGION)GDIOBJ_AllocateObject(GDIObjType_RGN_TYPE,
+                                          sizeof(REGION),
+                                          BASEFLAG_LOOKASIDE);
+    if (pReg == NULL)
     {
         DPRINT1("Could not allocate a palette.\n");
         return NULL;
@@ -2062,7 +2100,7 @@
 
     //hReg = pReg->BaseObject.hHmgr;
 
-    if (nReg == 0 || nReg == 1)
+    if ((nReg == 0) || (nReg == 1))
     {
         /* Testing shows that > 95% of all regions have only 1 rect.
            Including that here saves us from having to do another allocation */
@@ -2070,8 +2108,10 @@
     }
     else
     {
-        pReg->Buffer = ExAllocatePoolWithTag(PagedPool, nReg * sizeof(RECT), 
TAG_REGION);
-        if (!pReg->Buffer)
+        pReg->Buffer = ExAllocatePoolWithTag(PagedPool,
+                                             nReg * sizeof(RECT),
+                                             TAG_REGION);
+        if (pReg->Buffer == NULL)
         {
             DPRINT1("Could not allocate region buffer\n");
             GDIOBJ_vDeleteObject(&pReg->BaseObject);
@@ -2100,7 +2140,7 @@
     ASSERT(ppi);
 
     prgnattr = GdiPoolAllocate(ppi->pPoolRgnAttr);
-    if (!prgnattr)
+    if (prgnattr == NULL)
     {
         DPRINT1("Could not allocate RGN attr\n");
         return FALSE;
@@ -2117,7 +2157,7 @@
 //
 // Allocate User Space Region Handle.
 //
-PROSRGNDATA
+PREGION
 FASTCALL
 REGION_AllocUserRgnWithHandle(
     INT nRgn)
@@ -2125,7 +2165,7 @@
     PREGION prgn;
 
     prgn = REGION_AllocRgnWithHandle(nRgn);
-    if (!prgn)
+    if (prgn == NULL)
     {
         return NULL;
     }
@@ -2157,19 +2197,19 @@
                 {
                     if ( pRgn_Attr->AttrFlags & 
(ATTR_RGN_VALID|ATTR_RGN_DIRTY) )
                     {
-                        switch (pRgn_Attr->Flags)
+                        switch (pRgn_Attr->iComplexity)
                         {
-                        case NULLREGION:
-                            EMPTY_REGION( pRgn );
-                            break;
-
-                        case SIMPLEREGION:
-                            REGION_SetRectRgn( pRgn,
-                            pRgn_Attr->Rect.left,
-                            pRgn_Attr->Rect.top,
-                            pRgn_Attr->Rect.right,
-                            pRgn_Attr->Rect.bottom );
-                            break;
+                            case NULLREGION:
+                                EMPTY_REGION( pRgn );
+                                break;
+
+                            case SIMPLEREGION:
+                                REGION_SetRectRgn( pRgn,
+                                pRgn_Attr->Rect.left,
+                                pRgn_Attr->Rect.top,
+                                pRgn_Attr->Rect.right,
+                                pRgn_Attr->Rect.bottom );
+                                break;
                         }
                         pRgn_Attr->AttrFlags &= ~ATTR_RGN_DIRTY;
                     }
@@ -2177,7 +2217,7 @@
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
             {
-                (void)0;
+                (VOID)0;
             }
             _SEH2_END;
         }
@@ -2185,15 +2225,17 @@
 
 }
 
-PROSRGNDATA
+PREGION
 FASTCALL
 RGNOBJAPI_Lock(
     HRGN hRgn,
     PRGN_ATTR *ppRgn_Attr)
 {
-    PROSRGNDATA pRgn = NULL;
+    PREGION pRgn;
 
     pRgn = REGION_LockRgn(hRgn);
+    if (pRgn == NULL)
+        return NULL;
 
     REGION_vSyncRegion(pRgn);
 
@@ -2206,7 +2248,7 @@
 VOID
 FASTCALL
 RGNOBJAPI_Unlock(
-    PROSRGNDATA pRgn)
+    PREGION pRgn)
 {
     PRGN_ATTR pRgn_Attr;
 
@@ -2220,7 +2262,7 @@
             {
                 if ( pRgn_Attr->AttrFlags & ATTR_RGN_VALID )
                 {
-                    pRgn_Attr->Flags = REGION_Complexity( pRgn );
+                    pRgn_Attr->iComplexity = 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;
@@ -2229,7 +2271,7 @@
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
             {
-                (void)0;
+                (VOID)0;
             }
             _SEH2_END;
         }
@@ -2245,7 +2287,7 @@
 //
 // System Region Functions
 //
-PROSRGNDATA
+PREGION
 FASTCALL
 IntSysCreateRectpRgn(
     INT LeftRect,
@@ -2257,7 +2299,7 @@
 
     /* Allocate a region, witout a handle */
     prgn = (PREGION)GDIOBJ_AllocateObject(GDIObjType_RGN_TYPE, sizeof(REGION), 
BASEFLAG_LOOKASIDE);
-    if (!prgn)
+    if (prgn == NULL)
     {
         return NULL;
     }
@@ -2274,7 +2316,7 @@
 NTAPI
 REGION_vCleanup(PVOID ObjectBody)
 {
-    PROSRGNDATA pRgn = (PROSRGNDATA)ObjectBody;
+    PREGION pRgn = (PREGION)ObjectBody;
     PPROCESSINFO ppi = PsGetCurrentProcessWin32Process();
     ASSERT(ppi);
 
@@ -2288,9 +2330,11 @@
 
 VOID
 FASTCALL
-REGION_Delete(PROSRGNDATA pRgn)
-{
-    if ( pRgn == prgnDefault) return;
+REGION_Delete(PREGION pRgn)
+{
+    if (pRgn == prgnDefault)
+        return;
+
     GDIOBJ_vDeleteObject(&pRgn->BaseObject);
 }
 
@@ -2322,7 +2366,7 @@
 
 VOID
 FASTCALL
-IntUpdateVisRectRgn(PDC pDC, PROSRGNDATA pRgn)
+IntUpdateVisRectRgn(PDC pDC, PREGION pRgn)
 {
     INT Index = GDI_HANDLE_GET_INDEX(pDC->BaseObject.hHmgr);
     PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index];
@@ -2333,9 +2377,9 @@
     {
         pdcattr = pDC->pdcattr;
 
-        pdcattr->VisRectRegion.Flags = REGION_Complexity(pRgn);
-
-        if (pRgn && pdcattr->VisRectRegion.Flags != NULLREGION)
+        pdcattr->VisRectRegion.iComplexity = REGION_Complexity(pRgn);
+
+        if (pRgn && pdcattr->VisRectRegion.iComplexity != NULLREGION)
         {
             rcl.left   = pRgn->rdh.rcBound.left;
             rcl.top    = pRgn->rdh.rcBound.top;
@@ -2348,7 +2392,9 @@
             rcl.bottom -= pDC->erclWindow.top;
         }
         else
+        {
             RECTL_vSetEmptyRect(&rcl);
+        }
 
         pdcattr->VisRectRegion.Rect = rcl;
 
@@ -2365,7 +2411,7 @@
     PPROCESSINFO ppi;
 
     prgn = RGNOBJAPI_Lock(hRgn, &prgnattr);
-    if (!prgn)
+    if (prgn == NULL)
     {
         return FALSE;
     }
@@ -2377,6 +2423,7 @@
         ppi = PsGetCurrentProcessWin32Process();
         GdiPoolFree(ppi->pPoolRgnAttr, prgnattr);
     }
+
     RGNOBJAPI_Unlock(prgn);
 
     return GreSetObjectOwner(hRgn, OwnerMask);
@@ -2385,19 +2432,19 @@
 INT
 FASTCALL
 IntGdiCombineRgn(
-    PROSRGNDATA prgnDest,
-    PROSRGNDATA prgnSrc1,
-    PROSRGNDATA prgnSrc2,
+    PREGION prgnDest,
+    PREGION prgnSrc1,
+    PREGION prgnSrc2,
     INT iCombineMode)
 {
 
-    if (!prgnDest)
+    if (prgnDest == NULL)
     {
         DPRINT("IntGdiCombineRgn: hDest unavailable\n");
         return ERROR;
     }
 
-    if (!prgnSrc1)
+    if (prgnSrc1 == NULL)
     {
         DPRINT("IntGdiCombineRgn: hSrc1 unavailable\n");
         return ERROR;
@@ -2407,10 +2454,11 @@
     {
         if (!REGION_CopyRegion(prgnDest, prgnSrc1))
             return ERROR;
+
         return REGION_Complexity(prgnDest);
     }
 
-    if (!prgnSrc2)
+    if (prgnSrc2 == NULL)
     {
         DPRINT1("IntGdiCombineRgn requires hSrc2 != NULL for combine mode 
%d!\n", iCombineMode);
         ASSERT(FALSE);
@@ -2439,12 +2487,12 @@
 INT
 FASTCALL
 REGION_GetRgnBox(
-    PROSRGNDATA Rgn,
+    PREGION Rgn,
     PRECTL pRect)
 {
     DWORD ret;
 
-    if (Rgn)
+    if (Rgn != NULL)
     {
         *pRect = Rgn->rdh.rcBound;
         ret = REGION_Complexity(Rgn);
@@ -2460,10 +2508,11 @@
     HRGN hRgn,
     PRECTL pRect)
 {
-    PROSRGNDATA Rgn;
+    PREGION Rgn;
     DWORD ret;
 
-    if (!(Rgn = RGNOBJAPI_Lock(hRgn, NULL)))
+    Rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (Rgn == NULL)
     {
         return ERROR;
     }
@@ -2480,14 +2529,14 @@
     PDC dc,
     PREGION Rgn)
 {
-    PROSRGNDATA VisRgn;
+    PREGION VisRgn;
     XCLIPOBJ ClipRegion;
     BOOL bRet = FALSE;
     POINTL BrushOrigin;
     SURFACE *psurf;
     PDC_ATTR pdcattr;
 
-    if (!dc || !Rgn)
+    if ((dc == NULL) || (Rgn == NULL))
         return FALSE;
 
     pdcattr = dc->pdcattr;
@@ -2495,7 +2544,7 @@
     ASSERT(!(pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)));
 
     VisRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
-    if (!VisRgn)
+    if (VisRgn == NULL)
     {
         return FALSE;
     }
@@ -2512,7 +2561,10 @@
         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;
@@ -2558,7 +2610,7 @@
 BOOL
 FASTCALL
 REGION_RectInRegion(
-    PROSRGNDATA Rgn,
+    PREGION Rgn,
     const RECTL *rect)
 {
     PRECTL pCurRect, pRectEnd;
@@ -2566,7 +2618,7 @@
 
     /* Swap the coordinates to make right >= left and bottom >= top */
     /* (region building rectangles are normalized the same way) */
-    if( rect->top > rect->bottom)
+    if (rect->top > rect->bottom)
     {
         rc.top = rect->bottom;
         rc.bottom = rect->top;
@@ -2577,7 +2629,7 @@
         rc.bottom = rect->bottom;
     }
 
-    if( rect->right < rect->left)
+    if (rect->right < rect->left)
     {
         rc.right = rect->left;
         rc.left = rect->right;
@@ -2611,13 +2663,14 @@
             return TRUE;
         }
     }
+
     return FALSE;
 }
 
 VOID
 FASTCALL
 REGION_SetRectRgn(
-    PROSRGNDATA rgn,
+    PREGION rgn,
     INT LeftRect,
     INT TopRect,
     INT RightRect,
@@ -2659,7 +2712,7 @@
 INT
 FASTCALL
 IntGdiOffsetRgn(
-    PROSRGNDATA rgn,
+    PREGION rgn,
     INT XOffset,
     INT YOffset)
 {
@@ -2702,18 +2755,18 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_InsertEdgeInET(
-    EdgeTable *ET,
-    EdgeTableEntry *ETE,
+    EDGE_TABLE *ET,
+    EDGE_TABLE_ENTRY *ETE,
     INT scanline,
-    ScanLineListBlock **SLLBlock,
+    SCANLINE_LISTBLOCK **SLLBlock,
     INT *iSLLBlock)
 {
-    EdgeTableEntry *start, *prev;
-    ScanLineList *pSLL, *pPrevSLL;
-    ScanLineListBlock *tmpSLLBlock;
+    EDGE_TABLE_ENTRY *start, *prev;
+    SCANLINE_LIST *pSLL, *pPrevSLL;
+    SCANLINE_LISTBLOCK *tmpSLLBlock;
 
     /* Find the right bucket to put the edge into */
     pPrevSLL = &ET->scanlines;
@@ -2724,13 +2777,15 @@
         pSLL = pSLL->next;
     }
 
-    /* Reassign pSLL (pointer to ScanLineList) if necessary */
+    /* Reassign pSLL (pointer to SCANLINE_LIST) if necessary */
     if ((!pSLL) || (pSLL->scanline > scanline))
     {
         if (*iSLLBlock > SLLSPERBLOCK-1)
         {
-            tmpSLLBlock = ExAllocatePoolWithTag(PagedPool, 
sizeof(ScanLineListBlock), TAG_REGION);
-            if (!tmpSLLBlock)
+            tmpSLLBlock = ExAllocatePoolWithTag(PagedPool,
+                                                sizeof(SCANLINE_LISTBLOCK),
+                                                TAG_REGION);
+            if (tmpSLLBlock == NULL)
             {
                 DPRINT1("REGION_InsertEdgeInETL(): Can't alloc SLLB\n");
                 /* FIXME: Free resources? */
@@ -2738,7 +2793,7 @@
             }
 
             (*SLLBlock)->next = tmpSLLBlock;
-            tmpSLLBlock->next = (ScanLineListBlock *)NULL;
+            tmpSLLBlock->next = (SCANLINE_LISTBLOCK *)NULL;
             *SLLBlock = tmpSLLBlock;
             *iSLLBlock = 0;
         }
@@ -2746,14 +2801,14 @@
         pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
 
         pSLL->next = pPrevSLL->next;
-        pSLL->edgelist = (EdgeTableEntry *)NULL;
+        pSLL->edgelist = (EDGE_TABLE_ENTRY *)NULL;
         pPrevSLL->next = pSLL;
     }
 
     pSLL->scanline = scanline;
 
     /* Now insert the edge in the right bucket */
-    prev = (EdgeTableEntry *)NULL;
+    prev = (EDGE_TABLE_ENTRY *)NULL;
     start = pSLL->edgelist;
     while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
     {
@@ -2772,20 +2827,20 @@
 /***********************************************************************
  *     REGION_loadAET
  *
- *     This routine moves EdgeTableEntries from the
- *     EdgeTable into the Active Edge Table,
+ *     This routine moves EDGE_TABLEEntries from the
+ *     EDGE_TABLE into the Active Edge Table,
  *     leaving them sorted by smaller x coordinate.
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_loadAET(
-    EdgeTableEntry *AET,
-    EdgeTableEntry *ETEs)
-{
-    EdgeTableEntry *pPrevAET;
-    EdgeTableEntry *tmp;
+    EDGE_TABLE_ENTRY *AET,
+    EDGE_TABLE_ENTRY *ETEs)
+{
+    EDGE_TABLE_ENTRY *pPrevAET;
+    EDGE_TABLE_ENTRY *tmp;
 
     pPrevAET = AET;
     AET = AET->next;
@@ -2814,7 +2869,7 @@
  *     REGION_computeWAET
  *
  *     This routine links the AET by the
- *     nextWETE (winding EdgeTableEntry) link for
+ *     nextWETE (winding EDGE_TABLE_ENTRY) link for
  *     use by the winding number rule.  The final
  *     Active Edge Table (AET) might look something
  *     like:
@@ -2831,16 +2886,16 @@
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_computeWAET(
-    EdgeTableEntry *AET)
-{
-    register EdgeTableEntry *pWETE;
-    register int inside = 1;
-    register int isInside = 0;
-
-    AET->nextWETE = (EdgeTableEntry *)NULL;
+    EDGE_TABLE_ENTRY *AET)
+{
+    register EDGE_TABLE_ENTRY *pWETE;
+    register INT inside = 1;
+    register INT isInside = 0;
+
+    AET->nextWETE = (EDGE_TABLE_ENTRY *)NULL;
     pWETE = AET;
     AET = AET->next;
     while (AET)
@@ -2860,7 +2915,7 @@
         AET = AET->next;
     }
 
-    pWETE->nextWETE = (EdgeTableEntry *)NULL;
+    pWETE->nextWETE = (EDGE_TABLE_ENTRY *)NULL;
 }
 
 /***********************************************************************
@@ -2875,11 +2930,11 @@
 BOOL
 FASTCALL
 REGION_InsertionSort(
-    EdgeTableEntry *AET)
-{
-    EdgeTableEntry *pETEchase;
-    EdgeTableEntry *pETEinsert;
-    EdgeTableEntry *pETEchaseBackTMP;
+    EDGE_TABLE_ENTRY *AET)
+{
+    EDGE_TABLE_ENTRY *pETEchase;
+    EDGE_TABLE_ENTRY *pETEinsert;
+    EDGE_TABLE_ENTRY *pETEchaseBackTMP;
     BOOL changed = FALSE;
 
     AET = AET->next;
@@ -2915,12 +2970,12 @@
  *     Clean up our act.
  */
 static
-void
+VOID
 FASTCALL
 REGION_FreeStorage(
-    ScanLineListBlock *pSLLBlock)
-{
-    ScanLineListBlock   *tmpSLLBlock;
+    SCANLINE_LISTBLOCK *pSLLBlock)
+{
+    SCANLINE_LISTBLOCK   *tmpSLLBlock;
 
     while (pSLLBlock)
     {
@@ -2940,15 +2995,15 @@
 INT
 FASTCALL
 REGION_PtsToRegion(
-    int numFullPtBlocks,
-    int iCurPtBlock,
+    INT numFullPtBlocks,
+    INT iCurPtBlock,
     POINTBLOCK *FirstPtBlock,
-    ROSRGNDATA *reg)
+    PREGION reg)
 {
     RECTL *rects;
     POINT *pts;
     POINTBLOCK *CurPtBlock;
-    int i;
+    INT i;
     RECTL *extents, *temp;
     INT numRects;
 
@@ -2962,10 +3017,12 @@
         numRects = 1;
     }
 
-    if (!(temp = ExAllocatePoolWithTag(PagedPool, numRects * sizeof(RECT), 
TAG_REGION)))
+    temp = ExAllocatePoolWithTag(PagedPool, numRects * sizeof(RECT), 
TAG_REGION);
+    if (temp == NULL)
     {
         return 0;
     }
+
     if (reg->Buffer != NULL)
     {
         COPY_RECTS(temp, reg->Buffer, reg->rdh.nCount);
@@ -2984,17 +3041,19 @@
     {
         /* The loop uses 2 points per iteration */
         i = NUMPTSTOBUFFER >> 1;
-        if (!numFullPtBlocks)
+        if (numFullPtBlocks == 0)
             i = iCurPtBlock >> 1;
 
         for (pts = CurPtBlock->pts; i--; pts += 2)
         {
             if (pts->x == pts[1].x)
                 continue;
-            if (numRects && pts->x == rects->left && pts->y == rects->bottom &&
-                    pts[1].x == rects->right &&
-                    (numRects == 1 || rects[-1].top != rects->top) &&
-                    (i && pts[2].y > pts[1].y))
+
+            if ((numRects && pts->x == rects->left) &&
+                (pts->y == rects->bottom) &&
+                (pts[1].x == rects->right) &&
+                ((numRects == 1) || (rects[-1].top != rects->top)) &&
+                (i && pts[2].y > pts[1].y))
             {
                 rects->bottom = pts[1].y + 1;
                 continue;
@@ -3006,6 +3065,7 @@
             rects->top = pts->y;
             rects->right = pts[1].x;
             rects->bottom = pts[1].y + 1;
+
             if (rects->left < extents->left)
                 extents->left = rects->left;
             if (rects->right > extents->right)
@@ -3034,15 +3094,15 @@
 }
 
 /***********************************************************************
- *     REGION_CreateEdgeTable
+ *     REGION_CreateEDGE_TABLE
  *
  *     This routine creates the edge table for
  *     scan converting polygons.
  *     The Edge Table (ET) looks like:
  *
- *    EdgeTable
+ *    EDGE_TABLE
  *     --------
- *    |  ymax  |        ScanLineLists
+ *    |  ymax  |        SCANLINE_LISTs
  *    |scanline|-->------------>-------------->...
  *     --------   |scanline|   |scanline|
  *                |edgelist|   |edgelist|
@@ -3052,41 +3112,40 @@
  *                    V             V
  *              list of ETEs   list of ETEs
  *
- *     where ETE is an EdgeTableEntry data structure,
- *     and there is one ScanLineList per scanline at
+ *     where ETE is an EDGE_TABLE_ENTRY data structure,
+ *     and there is one SCANLINE_LIST per scanline at
  *     which an edge is initially entered.
  *
  */
 static
-void
+VOID
 FASTCALL
 REGION_CreateETandAET(
     const ULONG *Count,
     INT nbpolygons,
     const POINT *pts,
-    EdgeTable *ET,
-    EdgeTableEntry *AET,
-    EdgeTableEntry *pETEs,
-    ScanLineListBlock *pSLLBlock)
+    EDGE_TABLE *ET,
+    EDGE_TABLE_ENTRY *AET,
+    EDGE_TABLE_ENTRY *pETEs,
+    SCANLINE_LISTBLOCK *pSLLBlock)
 {
     const POINT *top, *bottom;
     const POINT *PrevPt, *CurrPt, *EndPt;
     INT poly, count;
-    int iSLLBlock = 0;
-    int dy;
-
+    INT iSLLBlock = 0;
+    INT dy;
 
     /*  Initialize the Active Edge Table */
-    AET->next = (EdgeTableEntry *)NULL;
-    AET->back = (EdgeTableEntry *)NULL;
-    AET->nextWETE = (EdgeTableEntry *)NULL;
+    AET->next = (EDGE_TABLE_ENTRY *)NULL;
+    AET->back = (EDGE_TABLE_ENTRY *)NULL;
+    AET->nextWETE = (EDGE_TABLE_ENTRY *)NULL;
     AET->bres.minor_axis = SMALL_COORDINATE;
 
     /* Initialize the Edge Table. */
-    ET->scanlines.next = (ScanLineList *)NULL;
+    ET->scanlines.next = (SCANLINE_LIST *)NULL;
     ET->ymax = SMALL_COORDINATE;
     ET->ymin = LARGE_COORDINATE;
-    pSLLBlock->next = (ScanLineListBlock *)NULL;
+    pSLLBlock->next = (SCANLINE_LISTBLOCK *)NULL;
 
     EndPt = pts - 1;
     for (poly = 0; poly < nbpolygons; poly++)
@@ -3154,21 +3213,21 @@
     INT mode,
     PREGION Rgn)
 {
-    EdgeTableEntry *pAET;                       /* Active Edge Table        */
-    INT y;                                      /* Current scanline         */
-    int iPts = 0;                               /* Number of pts in buffer  */
-    EdgeTableEntry *pWETE;                      /* Winding Edge Table Entry */
-    ScanLineList *pSLL;                         /* Current scanLineList     */
-    POINT *pts;                                 /* Output buffer            */
-    EdgeTableEntry *pPrevAET;                   /* Pointer to previous AET  */
-    EdgeTable ET;                               /* Header node for ET       */
-    EdgeTableEntry AET;                         /* Header node for AET      */
-    EdgeTableEntry *pETEs;                      /* EdgeTableEntries pool    */
-    ScanLineListBlock SLLBlock;                 /* Header for scanlinelist  */
-    int fixWAET = FALSE;
-    POINTBLOCK FirstPtBlock, *curPtBlock;       /* PtBlock buffers          */
+    EDGE_TABLE_ENTRY *pAET;               /* Active Edge Table        */
+    INT y;                                /* Current scanline         */
+    INT iPts = 0;                         /* Number of pts in buffer  */
+    EDGE_TABLE_ENTRY *pWETE;              /* Winding Edge Table Entry */
+    SCANLINE_LIST *pSLL;                  /* Current SCANLINE_LIST    */
+    POINT *pts;                           /* Output buffer            */
+    EDGE_TABLE_ENTRY *pPrevAET;           /* Pointer to previous AET  */
+    EDGE_TABLE ET;                        /* Header node for ET       */
+    EDGE_TABLE_ENTRY AET;                 /* Header node for AET      */
+    EDGE_TABLE_ENTRY *pETEs;              /* EDGE_TABLEEntries pool   */
+    SCANLINE_LISTBLOCK SLLBlock;          /* Header for SCANLINE_LIST */
+    INT fixWAET = FALSE;
+    POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers          */
     POINTBLOCK *tmpPtBlock;
-    int numFullPtBlocks = 0;
+    INT numFullPtBlocks = 0;
     INT poly, total;
 
     if (mode == 0 || mode > 2) return 0;
@@ -3196,7 +3255,10 @@
     for (poly = total = 0; poly < nbpolygons; poly++)
         total += Count[poly];
 
-    if (!(pETEs = ExAllocatePoolWithTag(PagedPool, sizeof(EdgeTableEntry) * 
total, TAG_REGION)) )
+    pETEs = ExAllocatePoolWithTag(PagedPool,
+                                  sizeof(EDGE_TABLE_ENTRY) * total,
+                                  TAG_REGION);
+    if (pETEs == NULL)
     {
         return FALSE;
     }
@@ -3230,8 +3292,10 @@
                 /* Send out the buffer */
                 if (iPts == NUMPTSTOBUFFER)
                 {
-                    tmpPtBlock = ExAllocatePoolWithTag(PagedPool, 
sizeof(POINTBLOCK), TAG_REGION);
-                    if (!tmpPtBlock)
+                    tmpPtBlock = ExAllocatePoolWithTag(PagedPool,
+                                                       sizeof(POINTBLOCK),
+                                                       TAG_REGION);
+                    if (tmpPtBlock == NULL)
                     {
                         DPRINT1("Can't alloc tPB\n");
                         ExFreePoolWithTag(pETEs, TAG_REGION);
@@ -3264,6 +3328,7 @@
                 REGION_computeWAET(&AET);
                 pSLL = pSLL->next;
             }
+
             pPrevAET = &AET;
             pAET = AET.next;
             pWETE = pAET;
@@ -3282,8 +3347,9 @@
                     if (iPts == NUMPTSTOBUFFER)
                     {
                         tmpPtBlock = ExAllocatePoolWithTag(PagedPool,
-                                                           sizeof(POINTBLOCK), 
TAG_REGION);
-                        if (!tmpPtBlock)
+                                                           sizeof(POINTBLOCK),
+                                                           TAG_REGION);
+                        if (tmpPtBlock == NULL)
                         {
                             DPRINT1("Can't alloc tPB\n");
                             ExFreePoolWithTag(pETEs, TAG_REGION);
@@ -3332,10 +3398,11 @@
     HRGN  hRgn,
     LPRECTL rc)
 {
-    PROSRGNDATA Rgn;
+    PREGION Rgn;
     BOOL Ret;
 
-    if (!(Rgn = RGNOBJAPI_Lock(hRgn, NULL)))
+    Rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (Rgn == NULL)
     {
         return ERROR;
     }
@@ -3361,12 +3428,16 @@
     PREGION aprgn[3];
     INT iResult;
 
-    if (iMode < RGN_AND || iMode > RGN_COPY)
+    /* Validate the combine mode */
+    if ((iMode < RGN_AND) || (iMode > RGN_COPY))
     {
         return ERROR;
     }
 
-    if (!hrgnDst || !hrgnSrc1 || (iMode != RGN_COPY && !hrgnSrc2))
+    /* Validate that we have the required regions */
+    if ((hrgnDst == NULL) ||
+        (hrgnSrc1 == NULL) ||
+        ((iMode != RGN_COPY) && (hrgnSrc2 == NULL)))
     {
         DPRINT1("NtGdiCombineRgn: %p, %p, %p, %d\n",
                 hrgnDst, hrgnSrc1, hrgnSrc2, iMode);
@@ -3392,10 +3463,14 @@
     /* Call the internal function */
     iResult = IntGdiCombineRgn(aprgn[0], aprgn[1], aprgn[2], iMode);
 
+    /// FIXME: need to sync user attr back
+
     /* Cleanup and return */
     REGION_UnlockRgn(aprgn[0]);
     REGION_UnlockRgn(aprgn[1]);
-    if (aprgn[2]) REGION_UnlockRgn(aprgn[2]);
+    if (aprgn[2])
+        REGION_UnlockRgn(aprgn[2]);
+
     return iResult;
 }
 
@@ -3422,15 +3497,17 @@
     INT RightRect,
     INT BottomRect)
 {
-    PROSRGNDATA pRgn;
+    PREGION pRgn;
     HRGN hRgn;
 
     /* Allocate region data structure with space for 1 RECTL */
-    if (!(pRgn = REGION_AllocUserRgnWithHandle(1)))
+    pRgn = REGION_AllocUserRgnWithHandle(1);
+    if (pRgn == NULL)
     {
         EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
         return NULL;
     }
+
     hRgn = pRgn->BaseObject.hHmgr;
 
     REGION_SetRectRgn(pRgn, LeftRect, TopRect, RightRect, BottomRect);
@@ -3451,9 +3528,9 @@
     INT ellipse_width,
     INT ellipse_height)
 {
-    PROSRGNDATA obj;
+    PREGION obj;
     HRGN hrgn;
-    int asq, bsq, d, xd, yd;
+    INT asq, bsq, d, xd, yd;
     RECTL rect;
 
     /* Make the dimensions sensible */
@@ -3486,8 +3563,10 @@
 
     /* Create region */
     d = (ellipse_height < 128) ? ((3 * ellipse_height) >> 2) : 64;
-    if (!(obj = REGION_AllocUserRgnWithHandle(d)))
+    obj = REGION_AllocUserRgnWithHandle(d);
+    if (obj == NULL)
         return 0;
+
     hrgn = obj->BaseObject.hHmgr;
 
     /* Ellipse algorithm, based on an article by K. Porter
@@ -3569,15 +3648,17 @@
     HRGN  hSrcRgn1,
     HRGN  hSrcRgn2)
 {
-    PROSRGNDATA rgn1, rgn2;
+    PREGION rgn1, rgn2;
     PRECTL tRect1, tRect2;
     ULONG i;
     BOOL bRet = FALSE;
 
-    if (!(rgn1 = RGNOBJAPI_Lock(hSrcRgn1, NULL)))
+    rgn1 = RGNOBJAPI_Lock(hSrcRgn1, NULL);
+    if (rgn1 == NULL)
         return ERROR;
 
-    if (!(rgn2 = RGNOBJAPI_Lock(hSrcRgn2, NULL)))
+    rgn2 = RGNOBJAPI_Lock(hSrcRgn2, NULL);
+    if (rgn2 == NULL)
     {
         RGNOBJAPI_Unlock(rgn1);
         return ERROR;
@@ -3592,24 +3673,24 @@
         goto exit;
     }
 
-    if (rgn1->rdh.rcBound.left   != rgn2->rdh.rcBound.left  ||
-        rgn1->rdh.rcBound.right  != rgn2->rdh.rcBound.right ||
-        rgn1->rdh.rcBound.top    != rgn2->rdh.rcBound.top   ||
-        rgn1->rdh.rcBound.bottom != rgn2->rdh.rcBound.bottom )
+    if ((rgn1->rdh.rcBound.left   != rgn2->rdh.rcBound.left)  ||
+        (rgn1->rdh.rcBound.right  != rgn2->rdh.rcBound.right) ||
+        (rgn1->rdh.rcBound.top    != rgn2->rdh.rcBound.top)   ||
+        (rgn1->rdh.rcBound.bottom != rgn2->rdh.rcBound.bottom))
         goto exit;
 
     tRect1 = rgn1->Buffer;
     tRect2 = rgn2->Buffer;
 
-    if (!tRect1 || !tRect2)
+    if ((tRect1 == NULL) || (tRect2 == NULL))
         goto exit;
 
     for (i=0; i < rgn1->rdh.nCount; i++)
     {
-        if (tRect1[i].left   != tRect2[i].left  ||
-            tRect1[i].right  != tRect2[i].right ||
-            tRect1[i].top    != tRect2[i].top   ||
-            tRect1[i].bottom != tRect2[i].bottom )
+        if ((tRect1[i].left   != tRect2[i].left)  ||
+            (tRect1[i].right  != tRect2[i].right) ||
+            (tRect1[i].top    != tRect2[i].top)   ||
+            (tRect1[i].bottom != tRect2[i].bottom))
             goto exit;
     }
 
@@ -3629,7 +3710,7 @@
     LPRGNDATA RgnData)
 {
     HRGN hRgn;
-    PROSRGNDATA Region;
+    PREGION Region;
     DWORD nCount = 0;
     DWORD iType = 0;
     DWORD dwSize = 0;
@@ -3661,9 +3742,9 @@
     }
 
     /* Check parameters, but don't set last error here */
-    if (Count < sizeof(RGNDATAHEADER) + nCount * sizeof(RECT) ||
-        iType != RDH_RECTANGLES ||
-        dwSize != sizeof(RGNDATAHEADER))
+    if ((Count < sizeof(RGNDATAHEADER) + nCount * sizeof(RECT)) ||
+        (iType != RDH_RECTANGLES) ||
+        (dwSize != sizeof(RGNDATAHEADER)))
     {
         return NULL;
     }
@@ -3684,7 +3765,8 @@
         {
             REGION_UnionRectWithRgn(Region, &rects[i]);
         }
-        if (Xform)
+
+        if (Xform != NULL)
         {
             ULONG ret;
 
@@ -3734,15 +3816,17 @@
     HBRUSH hBrush)
 {
     HBRUSH oldhBrush;
-    PROSRGNDATA rgn;
+    PREGION rgn;
     PRECTL r;
 
-    if (NULL == (rgn = RGNOBJAPI_Lock(hRgn, NULL)))
+    rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (rgn == NULL)
     {
         return FALSE;
     }
 
-    if (NULL == (oldhBrush = NtGdiSelectBrush(hDC, hBrush)))
+    oldhBrush = NtGdiSelectBrush(hDC, hBrush);
+    if (oldhBrush == NULL)
     {
         RGNOBJAPI_Unlock(rgn);
         return FALSE;
@@ -3771,7 +3855,8 @@
     HRGN FrameRgn;
     BOOL Ret;
 
-    if (!(FrameRgn = NtGdiCreateRectRgn(0, 0, 0, 0)))
+    FrameRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
+    if (FrameRgn == NULL)
     {
         return FALSE;
     }
@@ -3795,19 +3880,20 @@
     HRGN hRgn,
     PRECTL pRect)
 {
-    PROSRGNDATA  Rgn;
+    PREGION Rgn;
     RECTL SafeRect;
     DWORD ret;
     NTSTATUS Status = STATUS_SUCCESS;
 
-    if (!(Rgn = RGNOBJAPI_Lock(hRgn, NULL)))
+    Rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (Rgn == NULL)
     {
         return ERROR;
     }
 
     ret = REGION_GetRgnBox(Rgn, &SafeRect);
     RGNOBJAPI_Unlock(Rgn);
-    if (ERROR == ret)
+    if (ret == ERROR)
     {
         return ret;
     }
@@ -3836,11 +3922,12 @@
     HDC hDC,
     HRGN hRgn)
 {
-    PROSRGNDATA RgnData;
+    PREGION RgnData;
     ULONG i;
     PRECTL rc;
 
-    if (!(RgnData = RGNOBJAPI_Lock(hRgn, NULL)))
+    RgnData = RGNOBJAPI_Lock(hRgn, NULL);
+    if (RgnData == NULL)
     {
         EngSetLastError(ERROR_INVALID_HANDLE);
         return FALSE;
@@ -3869,12 +3956,13 @@
     INT XOffset,
     INT YOffset)
 {
-    PROSRGNDATA rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    PREGION rgn;
     INT ret;
 
     DPRINT("NtGdiOffsetRgn: hRgn %p Xoffs %d Yoffs %d rgn %p\n", hRgn, 
XOffset, YOffset, rgn );
 
-    if (!rgn)
+    rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (rgn == NULL)
     {
         DPRINT("NtGdiOffsetRgn: hRgn error\n");
         return ERROR;
@@ -3896,7 +3984,8 @@
     PREGION prgn;
     BOOL ret;
 
-    if (!(prgn = RGNOBJAPI_Lock(hRgn, NULL)))
+    prgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (prgn == NULL)
         return FALSE;
 
     ret = REGION_PtInRegion(prgn, X, Y);
@@ -3944,9 +4033,10 @@
     INT RightRect,
     INT BottomRect)
 {
-    PROSRGNDATA rgn;
-
-    if (!(rgn = RGNOBJAPI_Lock(hRgn, NULL)))
+    PREGION rgn;
+
+    rgn = RGNOBJAPI_Lock(hRgn, NULL);
+    if (rgn == NULL)
     {
         return 0; // Per documentation
     }
@@ -3964,10 +4054,11 @@
     const RECTL *UnsafeRect)
 {
     RECTL SafeRect = { 0 };
-    PROSRGNDATA Rgn;
+    PREGION Rgn;
     NTSTATUS Status = STATUS_SUCCESS;
 
-    if (!(Rgn = RGNOBJAPI_Lock(hDest, NULL)))
+    Rgn = RGNOBJAPI_Lock(hDest, NULL);
+    if (Rgn == NULL)
     {
         EngSetLastError(ERROR_INVALID_HANDLE);
         return NULL;
@@ -3984,7 +4075,7 @@
     }
     _SEH2_END;
 
-    if (! NT_SUCCESS(Status))
+    if (!NT_SUCCESS(Status))
     {
         RGNOBJAPI_Unlock(Rgn);
         SetLastNtError(Status);
@@ -4019,7 +4110,7 @@
 
     /* Lock the region */
     prgn = RGNOBJAPI_Lock(hrgn, NULL);
-    if (!prgn)
+    if (prgn == NULL)
     {
         EngSetLastError(ERROR_INVALID_HANDLE);
         return 0;

Modified: trunk/reactos/win32ss/gdi/ntgdi/region.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/region.h?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/region.h    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/region.h    [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -4,7 +4,7 @@
 
 /* Internal region data.
    Can't use RGNDATA structure because buffer is allocated statically */
-typedef struct _ROSRGNDATA
+typedef struct _REGION
 {
   /* Header for all gdi objects in the handle table.
      Do not (re)move this. */
@@ -14,7 +14,7 @@
 
   RGNDATAHEADER rdh;
   RECTL        *Buffer;
-} ROSRGNDATA, *PROSRGNDATA, *LPROSRGNDATA, REGION, *PREGION;
+} REGION, *PREGION;
 
 
 /* Functions 
******************************************************************/
@@ -22,41 +22,41 @@
 #define  REGION_FreeRgn(pRgn)  GDIOBJ_FreeObj((POBJ)pRgn, GDIObjType_RGN_TYPE)
 #define  REGION_FreeRgnByHandle(hRgn)  GDIOBJ_FreeObjByHandle((HGDIOBJ)hRgn, 
GDI_OBJECT_TYPE_REGION)
 
-PROSRGNDATA FASTCALL REGION_AllocRgnWithHandle(INT n);
-PROSRGNDATA FASTCALL REGION_AllocUserRgnWithHandle(INT n);
-VOID FASTCALL REGION_UnionRectWithRgn(ROSRGNDATA *rgn, const RECTL *rect);
+PREGION FASTCALL REGION_AllocRgnWithHandle(INT n);
+PREGION FASTCALL REGION_AllocUserRgnWithHandle(INT n);
+VOID FASTCALL REGION_UnionRectWithRgn(PREGION rgn, const RECTL *rect);
 INT FASTCALL REGION_SubtractRectFromRgn(PREGION prgnDest, PREGION prgnSrc, 
const RECTL *prcl);
-INT FASTCALL REGION_GetRgnBox(PROSRGNDATA Rgn, RECTL *pRect);
-BOOL FASTCALL REGION_RectInRegion(PROSRGNDATA Rgn, const RECTL *rc);
+INT FASTCALL REGION_GetRgnBox(PREGION Rgn, RECTL *pRect);
+BOOL FASTCALL REGION_RectInRegion(PREGION Rgn, const RECTL *rc);
 BOOL FASTCALL REGION_PtInRegion(PREGION, INT, INT);
-INT FASTCALL REGION_CropAndOffsetRegion(PROSRGNDATA rgnDst, PROSRGNDATA 
rgnSrc, const RECTL *rect, const POINT *off);
-VOID FASTCALL REGION_SetRectRgn(PROSRGNDATA pRgn, INT LeftRect, INT TopRect, 
INT RightRect, INT BottomRect);
+INT FASTCALL REGION_CropAndOffsetRegion(PREGION rgnDst, PREGION rgnSrc, const 
RECTL *rect, const POINT *off);
+VOID FASTCALL REGION_SetRectRgn(PREGION pRgn, INT LeftRect, INT TopRect, INT 
RightRect, INT BottomRect);
 VOID NTAPI REGION_vCleanup(PVOID ObjectBody);
 
-extern PROSRGNDATA prgnDefault;
+extern PREGION prgnDefault;
 extern HRGN        hrgnDefault;
 
-VOID FASTCALL REGION_Delete(PROSRGNDATA);
+VOID FASTCALL REGION_Delete(PREGION);
 VOID FASTCALL IntGdiReleaseRaoRgn(PDC);
 VOID FASTCALL IntGdiReleaseVisRgn(PDC);
 
 INT APIENTRY IntGdiGetRgnBox(HRGN, RECTL*);
 BOOL FASTCALL IntGdiPaintRgn(PDC, PREGION );
 BOOL FASTCALL IntSetPolyPolygonRgn(PPOINT, PULONG, INT, INT, PREGION);
-INT FASTCALL IntGdiOffsetRgn(PROSRGNDATA,INT,INT);
+INT FASTCALL IntGdiOffsetRgn(PREGION,INT,INT);
 BOOL FASTCALL IntRectInRegion(HRGN,LPRECTL);
 
-INT FASTCALL IntGdiCombineRgn(PROSRGNDATA, PROSRGNDATA, PROSRGNDATA, INT);
-INT FASTCALL REGION_Complexity(PROSRGNDATA);
-PROSRGNDATA FASTCALL RGNOBJAPI_Lock(HRGN,PRGN_ATTR *);
-VOID FASTCALL RGNOBJAPI_Unlock(PROSRGNDATA);
-PROSRGNDATA FASTCALL IntSysCreateRectpRgn(INT,INT,INT,INT);
+INT FASTCALL IntGdiCombineRgn(PREGION, PREGION, PREGION, INT);
+INT FASTCALL REGION_Complexity(PREGION);
+PREGION FASTCALL RGNOBJAPI_Lock(HRGN,PRGN_ATTR *);
+VOID FASTCALL RGNOBJAPI_Unlock(PREGION);
+PREGION FASTCALL IntSysCreateRectpRgn(INT,INT,INT,INT);
 BOOL FASTCALL IntGdiSetRegionOwner(HRGN,DWORD);
 
 #define IntSysCreateRectpRgnIndirect(prc) \
   IntSysCreateRectpRgn((prc)->left, (prc)->top, (prc)->right, (prc)->bottom)
 
-PROSRGNDATA
+PREGION
 FASTCALL
 IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect);
 

Modified: trunk/reactos/win32ss/include/ntgdihdl.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/include/ntgdihdl.h?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/include/ntgdihdl.h    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/include/ntgdihdl.h    [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -273,7 +273,7 @@
 typedef struct _RGN_ATTR
 {
     ULONG AttrFlags;
-    ULONG Flags;     /* Clipping region's complexity. NULL, SIMPLE & 
COMPLEXREGION */
+    ULONG iComplexity;     /* Clipping region's complexity. NULL, SIMPLE & 
COMPLEXREGION */
     RECTL Rect;
 } RGN_ATTR,*PRGN_ATTR;
 

Modified: trunk/reactos/win32ss/user/ntuser/painting.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/painting.c?rev=65720&r1=65719&r2=65720&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/painting.c        [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/painting.c        [iso-8859-1] Thu Dec 18 
08:11:19 2014
@@ -1309,7 +1309,7 @@
    PWND Window;
    RECTL Rect;
    INT RegionType;
-   PROSRGNDATA RgnData;
+   PREGION RgnData;
    NTSTATUS Status;
    DECLARE_RETURN(BOOL);
 


Reply via email to