gdi: GetRandomRgn fixes
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Mon Oct 10 08:37:20 CDT 2005
Huw Davies <huw at codeweavers.com>
GetRandomRgn only returns the SYSRGN in screen co-ordinates.
Add a bunch of tests for GetRandomRgn.
--
Huw Davies
huw at codeweavers.com
Index: dlls/gdi/clipping.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/clipping.c,v
retrieving revision 1.5
diff -u -p -r1.5 clipping.c
--- dlls/gdi/clipping.c 31 Mar 2005 10:19:40 -0000 1.5
+++ dlls/gdi/clipping.c 10 Oct 2005 13:31:14 -0000
@@ -578,8 +578,8 @@ INT WINAPI GetRandomRgn(HDC hDC, HRGN hR
if (rgn) CombineRgn( hRgn, rgn, 0, RGN_COPY );
GDI_ReleaseObj( hDC );
- /* On Windows NT/2000, the region returned is in screen coordinates */
- if (!(GetVersion() & 0x80000000))
+ /* On Windows NT/2000, the SYSRGN returned is in screen coordinates */
+ if (iCode == SYSRGN && !(GetVersion() & 0x80000000))
{
POINT org;
GetDCOrgEx( hDC, &org );
Index: dlls/gdi/tests/.cvsignore
===================================================================
RCS file: /home/wine/wine/dlls/gdi/tests/.cvsignore,v
retrieving revision 1.7
diff -u -p -r1.7 .cvsignore
--- dlls/gdi/tests/.cvsignore 22 Aug 2005 09:18:02 -0000 1.7
+++ dlls/gdi/tests/.cvsignore 10 Oct 2005 13:31:14 -0000
@@ -1,6 +1,7 @@
Makefile
bitmap.ok
brush.ok
+clipping.ok
gdiobj.ok
generated.ok
metafile.ok
Index: dlls/gdi/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/gdi/tests/Makefile.in,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.in
--- dlls/gdi/tests/Makefile.in 27 Aug 2005 09:27:10 -0000 1.7
+++ dlls/gdi/tests/Makefile.in 10 Oct 2005 13:31:14 -0000
@@ -8,6 +8,7 @@ IMPORTS = user32 gdi32 kernel32
CTESTS = \
bitmap.c \
brush.c \
+ clipping.c \
gdiobj.c \
generated.c \
metafile.c \
--- /dev/null 2004-02-23 21:02:56.000000000 +0000
+++ dlls/gdi/tests/clipping.c 2005-10-10 14:29:58.517337285 +0100
@@ -0,0 +1,131 @@
+/*
+ * Unit test suite for clipping
+ *
+ * Copyright 2005 Huw Davies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "wine/test.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+
+static void test_GetRandomRgn(void)
+{
+ HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_VISIBLE|WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0);
+ HDC hdc;
+ HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
+ int ret;
+ RECT rc, rc2;
+ RECT ret_rc, window_rc;
+
+ ok( hwnd != 0, "CreateWindow failed\n" );
+
+ SetRect(&window_rc, 400, 300, 500, 400);
+ MoveWindow(hwnd, window_rc.left, window_rc.top, window_rc.right - window_rc.left, window_rc.bottom - window_rc.top, FALSE);
+ hdc = GetDC(hwnd);
+
+ ret = GetRandomRgn(hdc, hrgn, 1);
+ ok(ret == 0, "GetRandomRgn rets %d\n", ret);
+ ret = GetRandomRgn(hdc, hrgn, 2);
+ ok(ret == 0, "GetRandomRgn rets %d\n", ret);
+ ret = GetRandomRgn(hdc, hrgn, 3);
+ ok(ret == 0, "GetRandomRgn rets %d\n", ret);
+
+ /* Set a clip region */
+ SetRect(&rc, 20, 20, 80, 80);
+ IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
+
+ ret = GetRandomRgn(hdc, hrgn, 1);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ ret = GetRandomRgn(hdc, hrgn, 2);
+ ok(ret == 0, "GetRandomRgn rets %d\n", ret);
+
+ todo_wine
+ {
+ ret = GetRandomRgn(hdc, hrgn, 3);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ }
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ /* Move the clip to the meta and clear the clip */
+ SetMetaRgn(hdc);
+
+ ret = GetRandomRgn(hdc, hrgn, 1);
+ ok(ret == 0, "GetRandomRgn rets %d\n", ret);
+ ret = GetRandomRgn(hdc, hrgn, 2);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ todo_wine
+ {
+ ret = GetRandomRgn(hdc, hrgn, 3);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ }
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ /* Set a new clip (still got the meta) */
+ SetRect(&rc2, 10, 30, 70, 90);
+ IntersectClipRect(hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
+
+ ret = GetRandomRgn(hdc, hrgn, 1);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ ret = GetRandomRgn(hdc, hrgn, 2);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ IntersectRect(&rc2, &rc, &rc2);
+
+ ret = GetRandomRgn(hdc, hrgn, 3);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ GetRgnBox(hrgn, &ret_rc);
+ ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+
+ ret = GetRandomRgn(hdc, hrgn, SYSRGN);
+ ok(ret != 0, "GetRandomRgn rets %d\n", ret);
+ GetRgnBox(hrgn, &ret_rc);
+ if(GetVersion() & 0x80000000)
+ OffsetRect(&window_rc, -window_rc.left, -window_rc.top);
+ ok(EqualRect(&window_rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
+ ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
+
+ DeleteObject(hrgn);
+ ReleaseDC(hwnd, hdc);
+ DestroyWindow(hwnd);
+}
+
+START_TEST(clipping)
+{
+ test_GetRandomRgn();
+}
More information about the wine-patches
mailing list