ReactOS 0.4.16-dev-91-g764881a
CombineRgn.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for ...
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
10typedef struct _RECT_TEST
11{
14 struct
15 {
18 } res[4];
20
21#define SetRectRgnIndirect(hrgn, prect) \
22 SetRectRgn(hrgn, (prect)->left, (prect)->top, (prect)->right, (prect)->bottom)
23
24PSTR apszRgnOp[6] = { "invalid", "RGN_AND", "RGN_OR", "RGN_XOR", "RGN_DIFF", "RGN_COPY" };
25
27{
28 RECT_TEST aRectTests[] = {
29
30 /* rcSrc1 rcSrc2 RGN_AND RGN_OR RGN_XOR RGN_DIFF */
31 {{0,0,0,0},{0,0,0,0}, {{NULLREGION, {0,0,0,0}}, {NULLREGION, {0,0,0,0}}, {NULLREGION, {0,0,0,0}}, {NULLREGION, {0,0,0,0}}}},
32 {{0,0,1,1},{0,0,0,0}, {{NULLREGION, {0,0,0,0}}, {SIMPLEREGION, {0,0,1,1}}, {SIMPLEREGION, {0,0,1,1}}, {SIMPLEREGION, {0,0,1,1}}}},
33 {{0,0,0,0},{0,0,1,1}, {{NULLREGION, {0,0,0,0}}, {SIMPLEREGION, {0,0,1,1}}, {SIMPLEREGION, {0,0,1,1}}, {NULLREGION, {0,0,0,0}}}},
34
35 /* Equal rgn */
36 {{0,0,4,4},{0,0,4,4}, {{SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {NULLREGION, {0,0,0,0}}, {NULLREGION, {0,0,0,0}}}},
37
38 /* rgn 2 is within rgn 1 */
39 {{0,0,4,4},{0,0,2,4}, {{SIMPLEREGION, {0,0,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{2,0,4,4}}, {SIMPLEREGION, {2,0,4,4}}}}, // left
40 {{0,0,4,4},{0,0,4,2}, {{SIMPLEREGION, {0,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,2,4,4}}, {SIMPLEREGION, {0,2,4,4}}}}, // top
41 {{0,0,4,4},{2,0,4,4}, {{SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,2,4}}, {SIMPLEREGION, {0,0,2,4}}}}, // right
42 {{0,0,4,4},{0,2,4,4}, {{SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,4,2}}, {SIMPLEREGION, {0,0,4,2}}}}, // bottom
43 {{0,0,4,4},{0,0,2,2}, {{SIMPLEREGION, {0,0,2,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // top-left
44 {{0,0,4,4},{2,0,4,2}, {{SIMPLEREGION, {2,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // top-right
45 {{0,0,4,4},{0,2,2,4}, {{SIMPLEREGION, {0,2,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // bottom-left
46 {{0,0,4,4},{2,2,4,4}, {{SIMPLEREGION, {2,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // bottom-right
47 {{0,0,4,4},{0,1,2,3}, {{SIMPLEREGION, {0,1,2,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-left
48 {{0,0,4,4},{1,0,3,2}, {{SIMPLEREGION, {1,0,3,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-top
49 {{0,0,4,4},{2,1,4,3}, {{SIMPLEREGION, {2,1,4,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-right
50 {{0,0,4,4},{1,2,3,4}, {{SIMPLEREGION, {1,2,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-bottom
51 {{0,0,4,4},{1,1,3,4}, {{SIMPLEREGION, {1,1,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center
52
53 /* rgn 1 is within rgn 2 */
54 {{0,0,2,4},{0,0,4,4}, {{SIMPLEREGION, {0,0,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{2,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // left
55 {{0,0,4,2},{0,0,4,4}, {{SIMPLEREGION, {0,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,2,4,4}}, {NULLREGION, {0,0,0,0}}}}, // top
56 {{2,0,4,4},{0,0,4,4}, {{SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,2,4}}, {NULLREGION, {0,0,0,0}}}}, // right
57 {{0,2,4,4},{0,0,4,4}, {{SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,4,2}}, {NULLREGION, {0,0,0,0}}}}, // bottom
58 {{0,0,2,2},{0,0,4,4}, {{SIMPLEREGION, {0,0,2,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // top-left
59 {{2,0,4,2},{0,0,4,4}, {{SIMPLEREGION, {2,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // top-right
60 {{0,2,2,4},{0,0,4,4}, {{SIMPLEREGION, {0,2,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // bottom-left
61 {{2,2,4,4},{0,0,4,4}, {{SIMPLEREGION, {2,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // bottom-right
62 {{0,1,2,3},{0,0,4,4}, {{SIMPLEREGION, {0,1,2,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // center-left
63 {{1,0,3,2},{0,0,4,4}, {{SIMPLEREGION, {1,0,3,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // center-top
64 {{2,1,4,3},{0,0,4,4}, {{SIMPLEREGION, {2,1,4,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // center-right
65 {{1,2,3,4},{0,0,4,4}, {{SIMPLEREGION, {1,2,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // center-bottom
66 {{1,1,3,4},{0,0,4,4}, {{SIMPLEREGION, {1,1,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION, {0,0,0,0}}}}, // center
67
68 /* rgn 2 is adjacent to rgn 1 */
69 {{2,2,4,4},{0,2,2,4}, {{NULLREGION, {0,0,0,0}}, {SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // left-fit
70 {{2,2,4,4},{0,1,2,5}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{0,1,4,5}}, {COMPLEXREGION,{0,1,4,5}}, {SIMPLEREGION, {2,2,4,4}}}}, // left-larger
71 {{2,2,4,4},{0,3,2,4}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{0,2,4,4}}, {COMPLEXREGION,{0,2,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // left-smaller
72 {{2,2,4,4},{2,0,4,2}, {{NULLREGION, {0,0,0,0}}, {SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // top-fit
73 {{2,2,4,4},{1,0,5,2}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{1,0,5,4}}, {COMPLEXREGION,{1,0,5,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // top-larger
74 {{2,2,4,4},{3,0,4,2}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{2,0,4,4}}, {COMPLEXREGION,{2,0,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // top-smaller
75 {{2,2,4,4},{4,2,6,4}, {{NULLREGION, {0,0,0,0}}, {SIMPLEREGION, {2,2,6,4}}, {SIMPLEREGION, {2,2,6,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // right-fit
76 {{2,2,4,4},{4,1,6,5}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{2,1,6,5}}, {COMPLEXREGION,{2,1,6,5}}, {SIMPLEREGION, {2,2,4,4}}}}, // right-larger
77 {{2,2,4,4},{4,3,6,4}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{2,2,6,4}}, {COMPLEXREGION,{2,2,6,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // right-smaller
78 {{2,2,4,4},{2,4,4,6}, {{NULLREGION, {0,0,0,0}}, {SIMPLEREGION, {2,2,4,6}}, {SIMPLEREGION, {2,2,4,6}}, {SIMPLEREGION, {2,2,4,4}}}}, // bottom-fit
79 {{2,2,4,4},{1,4,5,6}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{1,2,5,6}}, {COMPLEXREGION,{1,2,5,6}}, {SIMPLEREGION, {2,2,4,4}}}}, // bottom-larger
80 {{2,2,4,4},{3,4,4,6}, {{NULLREGION, {0,0,0,0}}, {COMPLEXREGION,{2,2,4,6}}, {COMPLEXREGION,{2,2,4,6}}, {SIMPLEREGION, {2,2,4,4}}}}, // bottom-smaller
81
82 /* rgn 2 overlaps rgn 1 */
83 {{2,2,4,4},{0,2,3,4}, {{SIMPLEREGION, {2,2,3,4}}, {SIMPLEREGION, {0,2,4,4}}, {COMPLEXREGION,{0,2,4,4}}, {SIMPLEREGION, {3,2,4,4}}}}, // left-fit
84 {{2,2,4,4},{0,1,3,5}, {{SIMPLEREGION, {2,2,3,4}}, {COMPLEXREGION,{0,1,4,5}}, {COMPLEXREGION,{0,1,4,5}}, {SIMPLEREGION, {3,2,4,4}}}}, // left-larger
85 {{2,2,4,4},{0,3,3,4}, {{SIMPLEREGION, {2,3,3,4}}, {COMPLEXREGION,{0,2,4,4}}, {COMPLEXREGION,{0,2,4,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // left-smaller
86 {{2,2,4,4},{2,0,4,3}, {{SIMPLEREGION, {2,2,4,3}}, {SIMPLEREGION, {2,0,4,4}}, {COMPLEXREGION,{2,0,4,4}}, {SIMPLEREGION, {2,3,4,4}}}}, // top-fit
87 {{2,2,4,4},{1,0,5,3}, {{SIMPLEREGION, {2,2,4,3}}, {COMPLEXREGION,{1,0,5,4}}, {COMPLEXREGION,{1,0,5,4}}, {SIMPLEREGION, {2,3,4,4}}}}, // top-larger
88 {{2,2,4,4},{3,0,4,3}, {{SIMPLEREGION, {3,2,4,3}}, {COMPLEXREGION,{2,0,4,4}}, {COMPLEXREGION,{2,0,4,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // top-smaller
89 {{2,2,4,4},{3,2,6,4}, {{SIMPLEREGION, {3,2,4,4}}, {SIMPLEREGION, {2,2,6,4}}, {COMPLEXREGION,{2,2,6,4}}, {SIMPLEREGION, {2,2,3,4}}}}, // right-fit
90 {{2,2,4,4},{3,1,6,5}, {{SIMPLEREGION, {3,2,4,4}}, {COMPLEXREGION,{2,1,6,5}}, {COMPLEXREGION,{2,1,6,5}}, {SIMPLEREGION, {2,2,3,4}}}}, // right-larger
91 {{2,2,4,4},{3,3,6,4}, {{SIMPLEREGION, {3,3,4,4}}, {COMPLEXREGION,{2,2,6,4}}, {COMPLEXREGION,{2,2,6,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // right-smaller
92 {{2,2,4,4},{2,3,4,6}, {{SIMPLEREGION, {2,3,4,4}}, {SIMPLEREGION, {2,2,4,6}}, {COMPLEXREGION,{2,2,4,6}}, {SIMPLEREGION, {2,2,4,3}}}}, // bottom-fit
93 {{2,2,4,4},{1,3,5,6}, {{SIMPLEREGION, {2,3,4,4}}, {COMPLEXREGION,{1,2,5,6}}, {COMPLEXREGION,{1,2,5,6}}, {SIMPLEREGION, {2,2,4,3}}}}, // bottom-larger
94 {{2,2,4,4},{3,3,4,6}, {{SIMPLEREGION, {3,3,4,4}}, {COMPLEXREGION,{2,2,4,6}}, {COMPLEXREGION,{2,2,4,6}}, {COMPLEXREGION,{2,2,4,4}}}}, // bottom-smaller
95 {{2,2,4,4},{0,0,3,3}, {{SIMPLEREGION, {2,2,3,3}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // top-left
96 {{2,2,4,4},{3,0,6,3}, {{SIMPLEREGION, {3,2,4,3}}, {COMPLEXREGION,{2,0,6,4}}, {COMPLEXREGION,{2,0,6,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // top-right
97 {{2,2,4,4},{0,3,3,6}, {{SIMPLEREGION, {2,3,3,4}}, {COMPLEXREGION,{0,2,4,6}}, {COMPLEXREGION,{0,2,4,6}}, {COMPLEXREGION,{2,2,4,4}}}}, // bottom-left
98 {{2,2,4,4},{3,3,6,6}, {{SIMPLEREGION, {3,3,4,4}}, {COMPLEXREGION,{2,2,6,6}}, {COMPLEXREGION,{2,2,6,6}}, {COMPLEXREGION,{2,2,4,4}}}}, // bottom-right
99
100 };
101
102 HRGN hrgn1, hrgn2, hrgn3, hrgnRes;
103 RECT rc;
104 INT iComplexity;
105 UINT i;
106
107 hrgn1 = CreateRectRgn(0, 0, 0, 0);
108 hrgn2 = CreateRectRgn(0, 0, 0, 0);
109 hrgn3 = CreateRectRgn(0, 0, 0, 0);
110 hrgnRes = CreateRectRgn(0, 0, 0, 0);
111
112 for (i = 0; i < sizeof(aRectTests) / sizeof(aRectTests[0]); i++)
113 {
114 INT iCombine;
115
116 SetRectRgnIndirect(hrgn1, &aRectTests[i].rcSrc1);
117 SetRectRgnIndirect(hrgn2, &aRectTests[i].rcSrc2);
118
119 for (iCombine = RGN_AND; iCombine <= RGN_DIFF; iCombine++)
120 {
121 iComplexity = CombineRgn(hrgnRes, hrgn1, hrgn2, iCombine);
122 ok(iComplexity == aRectTests[i].res[iCombine-1].iComplexity,
123 "#%u (%s), iComplexity does not match: expected %u, got %u\n",
124 i, apszRgnOp[iCombine], aRectTests[i].res[iCombine-1].iComplexity, iComplexity);
125
126 ok(GetRgnBox(hrgnRes, &rc), "GetRgnBox failed!\n");
127 ok(EqualRect(&rc, &aRectTests[i].res[iCombine-1].rcDstBounds),
128 "#%u (%s), Bounding box does not match: expected {%ld,%ld,%ld,%ld} got {%ld,%ld,%ld,%ld}\n",
129 i, apszRgnOp[iCombine],
130 aRectTests[i].res[iCombine-1].rcDstBounds.left, aRectTests[i].res[iCombine-1].rcDstBounds.top,
131 aRectTests[i].res[iCombine-1].rcDstBounds.right, aRectTests[i].res[iCombine-1].rcDstBounds.bottom,
132 rc.left, rc.top, rc.right, rc.bottom);
133
134 if (aRectTests[i].res[iCombine-1].iComplexity == SIMPLEREGION)
135 {
136 SetRectRgnIndirect(hrgn3, &aRectTests[i].res[iCombine-1].rcDstBounds);
137 ok(EqualRgn(hrgnRes, hrgn3), "#%u (%s), regions are not equal\n",
138 i, apszRgnOp[iCombine]);
139 }
140 }
141 }
142
143 DeleteObject(hrgn1);
145 DeleteObject(hrgn3);
146 DeleteObject(hrgnRes);
147}
148
149
151{
152 HRGN hrgn1, hrgn2, hrgn3;
153
154 hrgn1 = CreateRectRgn(0, 0, 0, 0);
155 hrgn2 = CreateRectRgn(0, 0, 10, 10);
156 hrgn3 = CreateRectRgn(5, 5, 20, 20);
157
158 SetLastError(0xbadbabe);
160 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, 0), ERROR);
161 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, 6), ERROR);
162 ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_PARAMETER), "wrong error: %ld\n", GetLastError());
163
164}
165
167{
168 HRGN hrgn1, hrgn2, hrgn3;
169
170 hrgn1 = CreateRectRgn(0, 0, 0, 0);
171 hrgn2 = CreateRectRgn(0, 0, 10, 10);
172 hrgn3 = CreateRectRgn(5, 5, 20, 20);
173
174 SetLastError(0xbadbabe);
179 ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
180
181 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_COPY), SIMPLEREGION);
182 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
183
184 ok_long(CombineRgn(hrgn1, hrgn1, NULL, RGN_COPY), SIMPLEREGION);
185 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
186
188 ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
189
191 ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
192
194 ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
195
197 ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
198
199 ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
200
201}
202
204{
205 HRGN hrgn1, hrgn2, hrgn3;
206
207 hrgn1 = CreateRectRgn(0, 0, 0, 0);
208 hrgn2 = CreateRectRgn(0, 0, 10, 10);
209 hrgn3 = CreateRectRgn(5, 5, 20, 20);
210
211 SetLastError(0xbadbabe);
218 ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
219
220
221 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION);
222 SetRectRgn(hrgn2, 5, 5, 10, 10);
223 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
224
225 SetRectRgn(hrgn2, 0, 0, 5, 5);
226 SetRectRgn(hrgn3, 5, 0, 10, 5);
227 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), NULLREGION);
228 SetRectRgn(hrgn2, 0, 0, 0, 0);
229 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
230
231 SetRectRgn(hrgn2, 0, 0, 20, 20);
232 SetRectRgn(hrgn3, 5, 5, 10, 10);
233 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION);
234 SetRectRgn(hrgn2, 5, 5, 10, 10);
235 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
236
237
238 SetRectRgn(hrgn2, 0, 0, 30, 10);
239 SetRectRgn(hrgn3, 10, 10, 20, 30);
240 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
241 SetRectRgn(hrgn2, 10, 0, 30, 30);
242 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), COMPLEXREGION);
243 ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), COMPLEXREGION);
244 SetRectRgn(hrgn2, 10, 10, 30, 30);
245 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), SIMPLEREGION);
246 SetRectRgn(hrgn2, 0, 0, 10, 10);
247 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), NULLREGION);
248
249 SetRectRgn(hrgn1, 0, 0, 30, 10);
250 ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), SIMPLEREGION);
251
252}
253
255{
256 HRGN hrgn1, hrgn2, hrgn3;
257
258 hrgn1 = CreateRectRgn(0, 0, 0, 0);
259 hrgn2 = CreateRectRgn(0, 0, 5, 5);
260 hrgn3 = CreateRectRgn(5, 0, 10, 5);
261 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), SIMPLEREGION);
262 SetRectRgn(hrgn2, 0, 0, 10, 5);
263 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
264
265 SetRectRgn(hrgn2, 0, 0, 10, 10);
266 SetRectRgn(hrgn3, 10, 10, 20, 20);
267 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
268 SetRectRgn(hrgn2, 10, 0, 20, 10);
269 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), COMPLEXREGION);
270 ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_OR), COMPLEXREGION);
271 SetRectRgn(hrgn2, 0, 10, 10, 20);
272 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), SIMPLEREGION);
273 SetRectRgn(hrgn2, 0, 0, 20, 20);
274 ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
275
276}
277
279{
280 HRGN hrgn1, hrgn2, hrgn3;
281
282 hrgn1 = CreateRectRgn(0, 0, 0, 0);
283 hrgn2 = CreateRectRgn(0, 0, 10, 10);
284 hrgn3 = CreateRectRgn(5, 0, 10, 5);
285
286 SetLastError(0xbadbabe);
293 ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
294
295 ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_DIFF), NULLREGION);
297 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION);
298
299 ok_long(CombineRgn(hrgn1, hrgn2, hrgn1, RGN_DIFF), SIMPLEREGION);
301 ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_DIFF), COMPLEXREGION);
302 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION);
303
304
305}
306
308{
309 HRGN hrgn1, hrgn2, hrgn3, hrgn4;
310
311 hrgn1 = CreateRectRgn(0, 0, 0, 0);
312 hrgn2 = CreateRectRgn(0, 0, 5, 5);
313 hrgn3 = CreateRectRgn(5, 5, 10, 10);
314 hrgn4 = CreateRectRgn(0, 0, 0, 0);
315
316 SetLastError(0xbadbabe);
323 ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
324
325 ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_XOR), COMPLEXREGION);
326 ok_long(CombineRgn(hrgn4, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
327 ok(EqualRgn(hrgn1, hrgn4), "Region is not correct\n");
328
329 ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), SIMPLEREGION);
330 ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
331 ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_XOR), NULLREGION);
332
333
334}
335
337{
345}
346
void Test_CombineRgn_AND()
Definition: CombineRgn.c:203
#define SetRectRgnIndirect(hrgn, prect)
Definition: CombineRgn.c:21
void Test_CombineRgn_COPY()
Definition: CombineRgn.c:166
struct _RECT_TEST RECT_TEST
void Test_CombineRgn_OR()
Definition: CombineRgn.c:254
PSTR apszRgnOp[6]
Definition: CombineRgn.c:24
void Test_RectRegions()
Definition: CombineRgn.c:26
struct _RECT_TEST * PRECT_TEST
void Test_CombineRgn_DIFF()
Definition: CombineRgn.c:278
void Test_CombineRgn_XOR()
Definition: CombineRgn.c:307
void Test_CombineRgn_Params()
Definition: CombineRgn.c:150
static HRGN hrgn2
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR(name)
Definition: error_private.h:53
pKey DeleteObject()
GLuint res
Definition: glext.h:9613
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
struct _RECT_TEST::@1595 res[4]
RECT rcSrc1
Definition: CombineRgn.c:12
RECT rcSrc2
Definition: CombineRgn.c:13
INT iComplexity
Definition: CombineRgn.c:16
RECT rcDstBounds
Definition: CombineRgn.c:17
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
char * PSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define COMPLEXREGION
Definition: wingdi.h:363
HGDIOBJ WINAPI GetStockObject(_In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define RGN_DIFF
Definition: wingdi.h:358
#define NULLREGION
Definition: wingdi.h:361
BOOL WINAPI EqualRgn(_In_ HRGN, _In_ HRGN)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_COPY
Definition: wingdi.h:357
#define RGN_AND
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:362
#define RGN_XOR
Definition: wingdi.h:360
#define BLACK_PEN
Definition: wingdi.h:903
#define RGN_OR
Definition: wingdi.h:359
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)