Allocate span memory for every clipping type, not only for one
[reactos.git] / reactos / subsystems / win32 / win32k / eng / clip.c
index 1fa7dac..b5453cd 100644 (file)
@@ -34,8 +34,8 @@
 
 static __inline int
 CompareRightDown(
-    const PRECT r1,
-    const PRECT r2)
+    const RECTL *r1,
+    const RECTL *r2)
 {
     int Cmp;
 
@@ -70,8 +70,8 @@ CompareRightDown(
 
 static __inline int
 CompareRightUp(
-    const PRECT r1,
-    const PRECT r2)
+    const RECTL *r1,
+    const RECTL *r2)
 {
     int Cmp;
 
@@ -106,8 +106,8 @@ CompareRightUp(
 
 static __inline int
 CompareLeftDown(
-    const PRECT r1,
-    const PRECT r2)
+    const RECTL *r1,
+    const RECTL *r2)
 {
     int Cmp;
 
@@ -142,8 +142,8 @@ CompareLeftDown(
 
 static __inline int
 CompareLeftUp(
-    const PRECT r1,
-    const PRECT r2)
+    const RECTL *r1,
+    const RECTL *r2)
 {
     int Cmp;
 
@@ -177,8 +177,8 @@ CompareLeftUp(
 
 static __inline int
 CompareSpans(
-    const PSPAN Span1,
-    const PSPAN Span2)
+    const SPAN *Span1,
+    const SPAN *Span2)
 {
     int Cmp;
 
@@ -271,7 +271,7 @@ IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
 /*
  * @implemented
  */
-CLIPOBJ * STDCALL
+CLIPOBJ * APIENTRY
 EngCreateClip(VOID)
 {
     CLIPGDI *Clip = EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPGDI), TAG_CLIPOBJ);
@@ -286,7 +286,7 @@ EngCreateClip(VOID)
 /*
  * @implemented
  */
-VOID STDCALL
+VOID APIENTRY
 EngDeleteClip(CLIPOBJ *ClipRegion)
 {
     EngFreeMem(ObjToGDI(ClipRegion, CLIP));
@@ -295,7 +295,7 @@ EngDeleteClip(CLIPOBJ *ClipRegion)
 /*
  * @implemented
  */
-ULONG STDCALL
+ULONG APIENTRY
 CLIPOBJ_cEnumStart(
     IN CLIPOBJ* ClipObj,
     IN BOOL ShouldDoAll,
@@ -356,7 +356,7 @@ CLIPOBJ_cEnumStart(
 /*
  * @implemented
  */
-BOOL STDCALL
+BOOL APIENTRY
 CLIPOBJ_bEnum(
     IN CLIPOBJ* ClipObj,
     IN ULONG ObjSize,
@@ -406,18 +406,21 @@ ClipobjToSpans(
 
     ASSERT(Boundary->top <= Boundary->bottom && Boundary->left <= Boundary->right);
 
-    *Spans = NULL;
+    *Count = Boundary->bottom - Boundary->top;
+    if (*Count > 0)
+    {
+        *Spans = ExAllocatePoolWithTag(PagedPool, *Count * sizeof(SPAN), TAG_CLIP);
+        if (NULL == *Spans)
+        {
+            *Count = 0;
+            return FALSE;
+        }
+    }
+
     if (NULL == ClipRegion || DC_TRIVIAL == ClipRegion->iDComplexity)
     {
-        *Count = Boundary->bottom - Boundary->top;
         if (0 != *Count)
         {
-            *Spans = ExAllocatePoolWithTag(PagedPool, *Count * sizeof(SPAN), TAG_CLIP);
-            if (NULL == *Spans)
-            {
-                *Count = 0;
-                return FALSE;
-            }
             for (i = 0; i < Boundary->bottom - Boundary->top; i++)
             {
                 (*Spans)[i].X = Boundary->left;