[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 4 Jan 2011 12:36:19 +0000 (12:36 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 4 Jan 2011 12:36:19 +0000 (12:36 +0000)
Implement NtGdiGetBoundsRect and NtGdiSetBoundsRect. Patch by Samuel Serapion with modifications by me.

svn path=/trunk/; revision=50280

reactos/subsystems/win32/win32k/objects/coord.c
reactos/subsystems/win32/win32k/objects/dcutil.c

index 6e9ceaf..7f229a5 100644 (file)
@@ -1057,7 +1057,7 @@ NtGdiSetVirtualResolution(
         cxVirtualDeviceMm = NtGdiGetDeviceCaps(hdc, HORZSIZE);
         cyVirtualDeviceMm = NtGdiGetDeviceCaps(hdc, VERTSIZE);
     }
-    else if (cxVirtualDevicePixel == 0 || cyVirtualDevicePixel == 0 || 
+    else if (cxVirtualDevicePixel == 0 || cyVirtualDevicePixel == 0 ||
              cxVirtualDeviceMm == 0 || cyVirtualDeviceMm == 0)
     {
         return FALSE;
@@ -1322,28 +1322,4 @@ NtGdiGetDCPoint(
     return Ret;
 }
 
-
-DWORD
-APIENTRY
-NtGdiGetBoundsRect(
-    IN HDC hdc,
-    OUT LPRECT prc,
-    IN DWORD f)
-{
-    DPRINT1("stub\n");
-    return  DCB_RESET;   /* bounding rectangle always empty */
-}
-
-DWORD
-APIENTRY
-NtGdiSetBoundsRect(
-    IN HDC hdc,
-    IN LPRECT prc,
-    IN DWORD f)
-{
-    DPRINT1("stub\n");
-    return  DCB_DISABLE;   /* bounding rectangle always empty */
-}
-
-
 /* EOF */
index 83a490b..4b172c0 100644 (file)
@@ -464,3 +464,92 @@ NtGdiGetAndSetDCDword(
     DC_UnlockDc(pdc);
     return Ret;
 }
+
+DWORD
+APIENTRY
+NtGdiGetBoundsRect(
+    IN HDC hdc,
+    OUT LPRECT prc,
+    IN DWORD flags)
+{
+    DWORD ret;
+    PDC pdc;
+
+    /* Lock the DC */
+    if (!(pdc = DC_LockDc(hdc))) return 0;
+
+    /* Get the return value */
+    ret = pdc->fs & DC_ACCUM_APP ? DCB_ENABLE : DCB_DISABLE;
+    ret |= RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? DCB_RESET : DCB_SET;
+
+    /* Copy the rect to the caller */
+    _SEH2_TRY
+    {
+        ProbeForWrite(prc, sizeof(RECT), 1);
+        *prc = pdc->erclBoundsApp;
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        ret = 0;
+    }
+    _SEH2_END;
+
+    if (flags & DCB_RESET)
+    {
+        RECTL_vSetEmptyRect(&pdc->erclBoundsApp);
+    }
+
+    DC_UnlockDc(pdc);
+    return ret;
+}
+
+
+DWORD
+APIENTRY
+NtGdiSetBoundsRect(
+    IN HDC hdc,
+    IN LPRECT prc,
+    IN DWORD flags)
+{
+    DWORD ret;
+    PDC pdc;
+    RECTL rcl;
+
+    /* Verify arguments */
+    if ((flags & DCB_ENABLE) && (flags & DCB_DISABLE)) return 0;
+
+    /* Lock the DC */
+    if (!(pdc = DC_LockDc(hdc))) return 0;
+
+    /* Get the return value */
+    ret = pdc->fs & DC_ACCUM_APP ? DCB_ENABLE : DCB_DISABLE;
+    ret |= RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? DCB_RESET : DCB_SET;
+
+    if (flags & DCB_RESET)
+    {
+        RECTL_vSetEmptyRect(&pdc->erclBoundsApp);
+    }
+
+    if (flags & DCB_ACCUMULATE)
+    {
+        /* Capture the rect */
+        _SEH2_TRY
+        {
+            ProbeForRead(prc, sizeof(RECT), 1);
+            rcl = *prc;
+        }
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+        {
+            _SEH2_YIELD(return 0;)
+        }
+        _SEH2_END;
+
+        RECTL_vMakeWellOrdered(&rcl);
+        RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, &rcl);
+    }
+
+    if (flags & DCB_ENABLE) pdc->fs |= DC_ACCUM_APP;
+    if (flags & DCB_DISABLE) pdc->fs &= ~DC_ACCUM_APP;
+    DC_UnlockDc( pdc );
+    return ret;
+}