2 * Unit test suite for clipping
4 * Copyright 2005 Huw Davies
5 * Copyright 2008,2011,2013 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
27 static void test_GetRandomRgn(void)
29 HWND hwnd
= CreateWindowExA(0,"BUTTON","test",WS_VISIBLE
|WS_POPUP
,0,0,100,100,GetDesktopWindow(),0,0,0);
31 HRGN hrgn
= CreateRectRgn(0, 0, 0, 0);
34 RECT ret_rc
, window_rc
;
36 ok( hwnd
!= 0, "CreateWindow failed\n" );
38 SetRect(&window_rc
, 400, 300, 500, 400);
39 SetWindowPos(hwnd
, HWND_TOPMOST
, window_rc
.left
, window_rc
.top
,
40 window_rc
.right
- window_rc
.left
, window_rc
.bottom
- window_rc
.top
, 0 );
43 ret
= GetRandomRgn(hdc
, hrgn
, 1);
44 ok(ret
== 0, "GetRandomRgn rets %d\n", ret
);
45 ret
= GetRandomRgn(hdc
, hrgn
, 2);
46 ok(ret
== 0, "GetRandomRgn rets %d\n", ret
);
47 ret
= GetRandomRgn(hdc
, hrgn
, 3);
48 ok(ret
== 0, "GetRandomRgn rets %d\n", ret
);
50 /* Set a clip region */
51 SetRect(&rc
, 20, 20, 80, 80);
52 IntersectClipRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
54 ret
= GetRandomRgn(hdc
, hrgn
, 1);
55 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
56 GetRgnBox(hrgn
, &ret_rc
);
57 ok(EqualRect(&rc
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
58 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
60 ret
= GetRandomRgn(hdc
, hrgn
, 2);
61 ok(ret
== 0, "GetRandomRgn rets %d\n", ret
);
63 ret
= GetRandomRgn(hdc
, hrgn
, 3);
64 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
65 GetRgnBox(hrgn
, &ret_rc
);
66 ok(EqualRect(&rc
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
67 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
69 /* Move the clip to the meta and clear the clip */
72 ret
= GetRandomRgn(hdc
, hrgn
, 1);
73 ok(ret
== 0, "GetRandomRgn rets %d\n", ret
);
74 ret
= GetRandomRgn(hdc
, hrgn
, 2);
75 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
76 GetRgnBox(hrgn
, &ret_rc
);
77 ok(EqualRect(&rc
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
78 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
80 ret
= GetRandomRgn(hdc
, hrgn
, 3);
81 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
82 GetRgnBox(hrgn
, &ret_rc
);
83 ok(EqualRect(&rc
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
84 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
86 /* Set a new clip (still got the meta) */
87 SetRect(&rc2
, 10, 30, 70, 90);
88 IntersectClipRect(hdc
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
90 ret
= GetRandomRgn(hdc
, hrgn
, 1);
91 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
92 GetRgnBox(hrgn
, &ret_rc
);
93 ok(EqualRect(&rc2
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
94 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
96 ret
= GetRandomRgn(hdc
, hrgn
, 2);
97 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
98 GetRgnBox(hrgn
, &ret_rc
);
99 ok(EqualRect(&rc
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
100 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
102 IntersectRect(&rc2
, &rc
, &rc2
);
104 ret
= GetRandomRgn(hdc
, hrgn
, 3);
105 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
106 GetRgnBox(hrgn
, &ret_rc
);
107 ok(EqualRect(&rc2
, &ret_rc
), "GetRandomRgn %d,%d - %d,%d\n",
108 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
111 ret
= GetRandomRgn(hdc
, hrgn
, SYSRGN
);
112 ok(ret
!= 0, "GetRandomRgn rets %d\n", ret
);
113 GetRgnBox(hrgn
, &ret_rc
);
114 if(GetVersion() & 0x80000000)
115 OffsetRect(&window_rc
, -window_rc
.left
, -window_rc
.top
);
116 /* the window may be partially obscured so the region may be smaller */
117 IntersectRect( &window_rc
, &ret_rc
, &ret_rc
);
118 ok(EqualRect(&window_rc
, &ret_rc
) ||
119 broken(IsRectEmpty(&ret_rc
)), /* win95 */
120 "GetRandomRgn %d,%d - %d,%d\n",
121 ret_rc
.left
, ret_rc
.top
, ret_rc
.right
, ret_rc
.bottom
);
124 ReleaseDC(hwnd
, hdc
);
128 static void verify_region(HRGN hrgn
, const RECT
*rc
)
133 char buf
[sizeof(RGNDATAHEADER
) + sizeof(RECT
)];
138 ret
= GetRegionData(hrgn
, 0, NULL
);
140 ok(ret
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", ret
);
142 ok(ret
== sizeof(rgn
.data
.rdh
) + sizeof(RECT
), "expected sizeof(rgn), got %u\n", ret
);
146 ret
= GetRegionData(hrgn
, sizeof(rgn
), &rgn
.data
);
148 ok(ret
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", ret
);
150 ok(ret
== sizeof(rgn
.data
.rdh
) + sizeof(RECT
), "expected sizeof(rgn), got %u\n", ret
);
152 trace("size %u, type %u, count %u, rgn size %u, bound (%d,%d-%d,%d)\n",
153 rgn
.data
.rdh
.dwSize
, rgn
.data
.rdh
.iType
,
154 rgn
.data
.rdh
.nCount
, rgn
.data
.rdh
.nRgnSize
,
155 rgn
.data
.rdh
.rcBound
.left
, rgn
.data
.rdh
.rcBound
.top
,
156 rgn
.data
.rdh
.rcBound
.right
, rgn
.data
.rdh
.rcBound
.bottom
);
157 if (rgn
.data
.rdh
.nCount
!= 0)
159 rect
= (const RECT
*)rgn
.data
.Buffer
;
160 trace("rect (%d,%d-%d,%d)\n", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
161 ok(EqualRect(rect
, rc
), "rects don't match\n");
164 ok(rgn
.data
.rdh
.dwSize
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", rgn
.data
.rdh
.dwSize
);
165 ok(rgn
.data
.rdh
.iType
== RDH_RECTANGLES
, "expected RDH_RECTANGLES, got %u\n", rgn
.data
.rdh
.iType
);
168 ok(rgn
.data
.rdh
.nCount
== 0, "expected 0, got %u\n", rgn
.data
.rdh
.nCount
);
169 ok(rgn
.data
.rdh
.nRgnSize
== 0 ||
170 broken(rgn
.data
.rdh
.nRgnSize
== 168), /* NT4 */
171 "expected 0, got %u\n", rgn
.data
.rdh
.nRgnSize
);
175 ok(rgn
.data
.rdh
.nCount
== 1, "expected 1, got %u\n", rgn
.data
.rdh
.nCount
);
176 ok(rgn
.data
.rdh
.nRgnSize
== sizeof(RECT
) ||
177 broken(rgn
.data
.rdh
.nRgnSize
== 168), /* NT4 */
178 "expected sizeof(RECT), got %u\n", rgn
.data
.rdh
.nRgnSize
);
180 ok(EqualRect(&rgn
.data
.rdh
.rcBound
, rc
), "rects don't match\n");
183 static void test_ExtCreateRegion(void)
185 static const RECT empty_rect
;
186 static const RECT rc
= { 111, 222, 333, 444 };
187 static const RECT arc
[2] = { {0, 0, 10, 10}, {10, 10, 20, 20}};
188 static const RECT rc_xformed
= { 76, 151, 187, 262 };
192 char buf
[sizeof(RGNDATAHEADER
) + 2 * sizeof(RECT
)];
197 if (0) /* crashes under Win9x */
199 SetLastError(0xdeadbeef);
200 hrgn
= ExtCreateRegion(NULL
, 0, NULL
);
201 ok(!hrgn
, "ExtCreateRegion should fail\n");
202 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
205 rgn
.data
.rdh
.dwSize
= 0;
206 rgn
.data
.rdh
.iType
= 0;
207 rgn
.data
.rdh
.nCount
= 0;
208 rgn
.data
.rdh
.nRgnSize
= 0;
209 SetRectEmpty(&rgn
.data
.rdh
.rcBound
);
210 memcpy(rgn
.data
.Buffer
, &rc
, sizeof(rc
));
212 SetLastError(0xdeadbeef);
213 hrgn
= ExtCreateRegion(NULL
, sizeof(rgn
), &rgn
.data
);
214 ok(!hrgn
, "ExtCreateRegion should fail\n");
215 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
217 rgn
.data
.rdh
.dwSize
= sizeof(rgn
.data
.rdh
) - 1;
219 SetLastError(0xdeadbeef);
220 hrgn
= ExtCreateRegion(NULL
, sizeof(rgn
), &rgn
.data
);
221 ok(!hrgn
, "ExtCreateRegion should fail\n");
222 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
224 /* although XP doesn't care about the type Win9x does */
225 rgn
.data
.rdh
.iType
= RDH_RECTANGLES
;
226 rgn
.data
.rdh
.dwSize
= sizeof(rgn
.data
.rdh
);
228 /* sizeof(RGNDATAHEADER) is large enough */
229 SetLastError(0xdeadbeef);
230 hrgn
= ExtCreateRegion(NULL
, sizeof(RGNDATAHEADER
), &rgn
.data
);
231 ok(hrgn
!= 0, "ExtCreateRegion error %u\n", GetLastError());
232 verify_region(hrgn
, &empty_rect
);
235 /* Cannot be smaller than sizeof(RGNDATAHEADER) */
236 SetLastError(0xdeadbeef);
237 hrgn
= ExtCreateRegion(NULL
, sizeof(RGNDATAHEADER
) - 1, &rgn
.data
);
239 ok(!hrgn
, "ExtCreateRegion should fail\n");
240 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
242 SetLastError(0xdeadbeef);
243 hrgn
= ExtCreateRegion(NULL
, sizeof(rgn
), &rgn
.data
);
244 ok(hrgn
!= 0, "ExtCreateRegion error %u\n", GetLastError());
245 verify_region(hrgn
, &empty_rect
);
248 rgn
.data
.rdh
.nCount
= 1;
249 SetRectEmpty(&rgn
.data
.rdh
.rcBound
);
250 memcpy(rgn
.data
.Buffer
, &rc
, sizeof(rc
));
252 /* With a single rect this seems to work... */
253 SetLastError(0xdeadbeef);
254 hrgn
= ExtCreateRegion(NULL
, sizeof(RGNDATAHEADER
) + sizeof(RECT
) - 1, &rgn
.data
);
255 ok(hrgn
!= 0, "ExtCreateRegion error %u\n", GetLastError());
256 verify_region(hrgn
, &rc
);
259 SetLastError(0xdeadbeef);
260 hrgn
= ExtCreateRegion(NULL
, sizeof(rgn
), &rgn
.data
);
261 ok(hrgn
!= 0, "ExtCreateRegion error %u\n", GetLastError());
262 verify_region(hrgn
, &rc
);
265 rgn
.data
.rdh
.dwSize
= sizeof(rgn
.data
.rdh
) + 1;
267 SetLastError(0xdeadbeef);
268 hrgn
= ExtCreateRegion(NULL
, 1, &rgn
.data
);
270 broken(GetLastError() == 0xdeadbeef), /* NT4 */
271 "ExtCreateRegion error %u\n", GetLastError());
274 verify_region(hrgn
, &rc
);
278 xform
.eM11
= 0.5; /* 50% width */
281 xform
.eM22
= 0.5; /* 50% height */
285 rgn
.data
.rdh
.dwSize
= sizeof(rgn
.data
.rdh
);
287 SetLastError(0xdeadbeef);
288 hrgn
= ExtCreateRegion(&xform
, sizeof(rgn
), &rgn
.data
);
289 ok(hrgn
!= 0, "ExtCreateRegion error %u/%x\n", GetLastError(), GetLastError());
290 verify_region(hrgn
, &rc_xformed
);
293 rgn
.data
.rdh
.nCount
= 2;
294 SetRectEmpty(&rgn
.data
.rdh
.rcBound
);
295 memcpy(rgn
.data
.Buffer
, arc
, sizeof(arc
));
297 /* Buffer cannot be smaller than sizeof(RGNDATAHEADER) + 2 * sizeof(RECT) */
298 SetLastError(0xdeadbeef);
299 hrgn
= ExtCreateRegion(NULL
, sizeof(RGNDATAHEADER
) + 2 * sizeof(RECT
) - 1, &rgn
.data
);
301 ok(!hrgn
, "ExtCreateRegion should fail\n");
302 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
306 static void test_GetClipRgn(void)
309 HRGN hrgn
, hrgn2
, hrgn3
, hrgn4
;
312 /* Test calling GetClipRgn with NULL device context and region handles. */
313 ret
= GetClipRgn(NULL
, NULL
);
314 ok(ret
== -1, "Expected GetClipRgn to return -1, got %d\n", ret
);
317 ok(hdc
!= NULL
, "Expected GetDC to return a valid device context handle\n");
319 /* Test calling GetClipRgn with a valid device context and NULL region. */
320 ret
= GetClipRgn(hdc
, NULL
);
322 ret
== -1 /* Win9x */,
323 "Expected GetClipRgn to return 0, got %d\n", ret
);
325 /* Initialize the test regions. */
326 hrgn
= CreateRectRgn(100, 100, 100, 100);
328 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
330 hrgn2
= CreateRectRgn(1, 2, 3, 4);
332 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
334 hrgn3
= CreateRectRgn(1, 2, 3, 4);
336 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
338 hrgn4
= CreateRectRgn(1, 2, 3, 4);
340 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
342 /* Try getting a clipping region from the device context
343 * when the device context's clipping region isn't set. */
344 ret
= GetClipRgn(hdc
, hrgn2
);
345 ok(ret
== 0, "Expected GetClipRgn to return 0, got %d\n", ret
);
347 /* The region passed to GetClipRgn should be unchanged. */
348 ret
= EqualRgn(hrgn2
, hrgn3
);
350 "Expected EqualRgn to compare the two regions as equal, got %d\n", ret
);
352 /* Try setting and getting back a clipping region. */
353 ret
= SelectClipRgn(hdc
, hrgn
);
354 ok(ret
== NULLREGION
,
355 "Expected SelectClipRgn to return NULLREGION, got %d\n", ret
);
357 /* Passing a NULL region handle when the device context
358 * has a clipping region results in an error. */
359 ret
= GetClipRgn(hdc
, NULL
);
360 ok(ret
== -1, "Expected GetClipRgn to return -1, got %d\n", ret
);
362 ret
= GetClipRgn(hdc
, hrgn2
);
363 ok(ret
== 1, "Expected GetClipRgn to return 1, got %d\n", ret
);
365 ret
= EqualRgn(hrgn
, hrgn2
);
367 "Expected EqualRgn to compare the two regions as equal, got %d\n", ret
);
369 /* Try unsetting and then query the clipping region. */
370 ret
= SelectClipRgn(hdc
, NULL
);
371 ok(ret
== SIMPLEREGION
|| (ret
== COMPLEXREGION
&& GetSystemMetrics(SM_CMONITORS
) > 1),
372 "Expected SelectClipRgn to return SIMPLEREGION, got %d\n", ret
);
374 ret
= GetClipRgn(hdc
, NULL
);
376 ret
== -1 /* Win9x */,
377 "Expected GetClipRgn to return 0, got %d\n", ret
);
379 ret
= GetClipRgn(hdc
, hrgn3
);
380 ok(ret
== 0, "Expected GetClipRgn to return 0, got %d\n", ret
);
382 ret
= EqualRgn(hrgn3
, hrgn4
);
384 "Expected EqualRgn to compare the two regions as equal, got %d\n", ret
);
390 ReleaseDC(NULL
, hdc
);
393 static void test_memory_dc_clipping(void)
396 HRGN hrgn
, hrgn_empty
;
401 hdc
= CreateCompatibleDC(0);
402 hrgn_empty
= CreateRectRgn(0, 0, 0, 0);
403 hrgn
= CreateRectRgn(0, 0, 0, 0);
404 hbmp
= CreateCompatibleBitmap(hdc
, 100, 100);
406 ret
= GetClipRgn(hdc
, hrgn
);
407 ok(ret
== 0, "expected 0, got %d\n", ret
);
409 ret
= ExtSelectClipRgn(hdc
, hrgn_empty
, RGN_DIFF
);
410 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
412 ret
= GetClipRgn(hdc
, hrgn
);
413 ok(ret
== 1, "expected 1, got %d\n", ret
);
415 ret
= GetRgnBox(hrgn
, &rc
);
416 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
417 ok(rc
.left
== 0 && rc
.top
== 0 && rc
.right
== 1 && rc
.bottom
== 1,
418 "expected 0,0-1,1, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
420 ret
= ExtSelectClipRgn(hdc
, 0, RGN_COPY
);
421 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
423 ret
= GetClipRgn(hdc
, hrgn
);
424 ok(ret
== 0, "expected 0, got %d\n", ret
);
426 ret
= ExtSelectClipRgn(hdc
, 0, RGN_DIFF
);
427 ok(ret
== 0, "expected 0, got %d\n", ret
);
429 ret
= GetClipRgn(hdc
, hrgn
);
430 ok(ret
== 0, "expected 0, got %d\n", ret
);
432 SelectObject(hdc
, hbmp
);
434 ret
= ExtSelectClipRgn(hdc
, hrgn_empty
, RGN_DIFF
);
435 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
437 ret
= GetClipRgn(hdc
, hrgn
);
438 ok(ret
== 1, "expected 1, got %d\n", ret
);
440 ret
= GetRgnBox(hrgn
, &rc
);
441 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
442 ok(rc
.left
== 0 && rc
.top
== 0 && rc
.right
== 100 && rc
.bottom
== 100,
443 "expected 0,0-100,100, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
445 SetRect( &rc
, 10, 10, 20, 20 );
446 ret
= RectVisible( hdc
, &rc
);
447 ok( ret
, "RectVisible failed for %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
449 SetRect( &rc
, 20, 20, 10, 10 );
450 ret
= RectVisible( hdc
, &rc
);
451 ok( ret
, "RectVisible failed for %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
453 ret
= ExtSelectClipRgn(hdc
, 0, RGN_DIFF
);
454 ok(ret
== 0, "expected 0, got %d\n", ret
);
456 ret
= GetClipRgn(hdc
, hrgn
);
457 ok(ret
== 1, "expected 1, got %d\n", ret
);
459 ret
= GetRgnBox(hrgn
, &rc
);
460 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
461 ok(rc
.left
== 0 && rc
.top
== 0 && rc
.right
== 100 && rc
.bottom
== 100,
462 "expected 0,0-100,100, got %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
466 DeleteObject(hrgn_empty
);
470 static void test_window_dc_clipping(void)
473 HRGN hrgn
, hrgn_empty
;
475 RECT rc
, virtual_rect
;
476 int ret
, screen_width
, screen_height
;
478 /* Windows versions earlier than Win2k do not support the virtual screen metrics,
479 * so we fall back to the primary screen metrics. */
480 screen_width
= GetSystemMetrics(SM_CXVIRTUALSCREEN
);
481 if(!screen_width
) screen_width
= GetSystemMetrics(SM_CXSCREEN
);
482 screen_height
= GetSystemMetrics(SM_CYVIRTUALSCREEN
);
483 if(!screen_height
) screen_height
= GetSystemMetrics(SM_CYSCREEN
);
484 SetRect(&virtual_rect
, GetSystemMetrics(SM_XVIRTUALSCREEN
), GetSystemMetrics(SM_YVIRTUALSCREEN
),
485 GetSystemMetrics(SM_XVIRTUALSCREEN
) + screen_width
, GetSystemMetrics(SM_YVIRTUALSCREEN
) + screen_height
);
487 trace("screen resolution %d x %d\n", screen_width
, screen_height
);
489 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
490 -100, -100, screen_width
* 2, screen_height
* 2, 0, 0, 0, NULL
);
491 hdc
= GetWindowDC(0);
492 hrgn_empty
= CreateRectRgn(0, 0, 0, 0);
493 hrgn
= CreateRectRgn(0, 0, 0, 0);
495 ret
= GetClipRgn(hdc
, hrgn
);
496 ok(ret
== 0, "expected 0, got %d\n", ret
);
498 ret
= ExtSelectClipRgn(hdc
, 0, RGN_DIFF
);
499 ok(ret
== 0, "expected 0, got %d\n", ret
);
501 ret
= GetClipRgn(hdc
, hrgn
);
502 ok(ret
== 0, "expected 0, got %d\n", ret
);
504 ret
= ExtSelectClipRgn(hdc
, hrgn_empty
, RGN_DIFF
);
505 ok(ret
== SIMPLEREGION
|| (ret
== COMPLEXREGION
&& GetSystemMetrics(SM_CMONITORS
) > 1),
506 "expected SIMPLEREGION, got %d\n", ret
);
508 ret
= GetClipRgn(hdc
, hrgn
);
509 ok(ret
== 1, "expected 1, got %d\n", ret
);
511 ret
= GetRgnBox(hrgn
, &rc
);
512 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
513 ok(EqualRect(&rc
, &virtual_rect
), "expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
514 virtual_rect
.left
, virtual_rect
.top
, virtual_rect
.right
, virtual_rect
.bottom
,
515 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
517 SetRect( &rc
, 10, 10, 20, 20 );
518 ret
= RectVisible( hdc
, &rc
);
519 ok( ret
, "RectVisible failed for %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
521 SetRect( &rc
, 20, 20, 10, 10 );
522 ret
= RectVisible( hdc
, &rc
);
523 ok( ret
, "RectVisible failed for %d,%d-%d,%d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
525 ret
= ExtSelectClipRgn(hdc
, 0, RGN_DIFF
);
526 ok(ret
== 0, "expected 0, got %d\n", ret
);
528 ret
= GetClipRgn(hdc
, hrgn
);
529 ok(ret
== 1, "expected 1, got %d\n", ret
);
531 ret
= GetRgnBox(hrgn
, &rc
);
532 ok(ret
== SIMPLEREGION
, "expected SIMPLEREGION, got %d\n", ret
);
533 ok(EqualRect(&rc
, &virtual_rect
), "expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
534 virtual_rect
.left
, virtual_rect
.top
, virtual_rect
.right
, virtual_rect
.bottom
,
535 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
537 ret
= ExtSelectClipRgn(hdc
, 0, RGN_COPY
);
538 ok(ret
== SIMPLEREGION
|| (ret
== COMPLEXREGION
&& GetSystemMetrics(SM_CMONITORS
) > 1),
539 "expected SIMPLEREGION, got %d\n", ret
);
541 ret
= GetClipRgn(hdc
, hrgn
);
542 ok(ret
== 0, "expected 0, got %d\n", ret
);
546 DeleteObject(hrgn_empty
);
554 test_ExtCreateRegion();
556 test_memory_dc_clipping();
557 test_window_dc_clipping();