2 * Unit test suite for gdiplus regions
4 * Copyright (C) 2008 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
26 static inline void expect_dword(DWORD
*value
, DWORD expected
)
28 ok(*value
== expected
, "expected %08x got %08x\n", expected
, *value
);
31 static inline void expect_float(DWORD
*value
, FLOAT expected
)
33 FLOAT valuef
= *(FLOAT
*)value
;
34 ok(valuef
== expected
, "expected %f got %f\n", expected
, valuef
);
37 static void test_create_rgn(void)
40 GpRegion
*region
, *region2
;
45 status
= GdipCreateRegion(®ion
);
47 ok(status
== Ok
, "status %08x\n", status
);
49 if(status
!= Ok
) return;
51 status
= GdipGetRegionDataSize(region
, &needed
);
52 ok(status
== Ok
, "status %08x\n", status
);
53 ok(needed
== 20, "got %d\n", needed
);
54 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
55 ok(status
== Ok
, "status %08x\n", status
);
56 ok(needed
== 20, "got %d\n", needed
);
57 expect_dword(buf
, 12);
58 trace("buf[1] = %08x\n", buf
[1]);
59 expect_dword(buf
+ 2, 0xdbc01001);
60 expect_dword(buf
+ 3, 0);
61 expect_dword(buf
+ 4, 0x10000003);
63 status
= GdipSetEmpty(region
);
64 ok(status
== Ok
, "status %08x\n", status
);
65 status
= GdipGetRegionDataSize(region
, &needed
);
66 ok(status
== Ok
, "status %08x\n", status
);
67 ok(needed
== 20, "got %d\n", needed
);
68 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
69 ok(status
== Ok
, "status %08x\n", status
);
70 ok(needed
== 20, "got %d\n", needed
);
71 expect_dword(buf
, 12);
72 trace("buf[1] = %08x\n", buf
[1]);
73 expect_dword(buf
+ 2, 0xdbc01001);
74 expect_dword(buf
+ 3, 0);
75 expect_dword(buf
+ 4, 0x10000002);
77 status
= GdipSetInfinite(region
);
78 ok(status
== Ok
, "status %08x\n", status
);
79 status
= GdipGetRegionDataSize(region
, &needed
);
80 ok(status
== Ok
, "status %08x\n", status
);
81 ok(needed
== 20, "got %d\n", needed
);
82 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
83 ok(status
== Ok
, "status %08x\n", status
);
84 ok(needed
== 20, "got %d\n", needed
);
85 expect_dword(buf
, 12);
86 trace("buf[1] = %08x\n", buf
[1]);
87 expect_dword(buf
+ 2, 0xdbc01001);
88 expect_dword(buf
+ 3, 0);
89 expect_dword(buf
+ 4, 0x10000003);
91 status
= GdipDeleteRegion(region
);
92 ok(status
== Ok
, "status %08x\n", status
);
98 status
= GdipCreateRegionRectI(&rect
, ®ion
);
99 ok(status
== Ok
, "status %08x\n", status
);
100 status
= GdipGetRegionDataSize(region
, &needed
);
101 ok(status
== Ok
, "status %08x\n", status
);
102 ok(needed
== 36, "got %d\n", needed
);
103 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
104 ok(status
== Ok
, "status %08x\n", status
);
105 ok(needed
== 36, "got %d\n", needed
);
106 expect_dword(buf
, 28);
107 trace("buf[1] = %08x\n", buf
[1]);
108 expect_dword(buf
+ 2, 0xdbc01001);
109 expect_dword(buf
+ 3, 0);
110 expect_dword(buf
+ 4, 0x10000000);
111 expect_float(buf
+ 5, 10.0);
112 expect_float(buf
+ 6, 20.0);
113 expect_float(buf
+ 7, 100.0);
114 expect_float(buf
+ 8, 200.0);
120 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeIntersect
);
121 ok(status
== Ok
, "status %08x\n", status
);
126 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeXor
);
127 ok(status
== Ok
, "status %08x\n", status
);
133 status
= GdipCreateRegionRectI(&rect
, ®ion2
);
134 ok(status
== Ok
, "status %08x\n", status
);
139 status
= GdipCombineRegionRectI(region2
, &rect
, CombineModeUnion
);
140 ok(status
== Ok
, "status %08x\n", status
);
142 status
= GdipCombineRegionRegion(region
, region2
, CombineModeComplement
);
143 ok(status
== Ok
, "status %08x\n", status
);
149 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeExclude
);
150 ok(status
== Ok
, "status %08x\n", status
);
152 status
= GdipGetRegionDataSize(region
, &needed
);
153 ok(status
== Ok
, "status %08x\n", status
);
154 ok(needed
== 156, "got %d\n", needed
);
155 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
156 ok(status
== Ok
, "status %08x\n", status
);
157 ok(needed
== 156, "got %d\n", needed
);
158 expect_dword(buf
, 148);
159 trace("buf[1] = %08x\n", buf
[1]);
160 expect_dword(buf
+ 2, 0xdbc01001);
161 expect_dword(buf
+ 3, 10);
162 expect_dword(buf
+ 4, CombineModeExclude
);
163 expect_dword(buf
+ 5, CombineModeComplement
);
164 expect_dword(buf
+ 6, CombineModeXor
);
165 expect_dword(buf
+ 7, CombineModeIntersect
);
166 expect_dword(buf
+ 8, 0x10000000);
167 expect_float(buf
+ 9, 10.0);
168 expect_float(buf
+ 10, 20.0);
169 expect_float(buf
+ 11, 100.0);
170 expect_float(buf
+ 12, 200.0);
171 expect_dword(buf
+ 13, 0x10000000);
172 expect_float(buf
+ 14, 50.0);
173 expect_float(buf
+ 15, 30.0);
174 expect_float(buf
+ 16, 10.0);
175 expect_float(buf
+ 17, 20.0);
176 expect_dword(buf
+ 18, 0x10000000);
177 expect_float(buf
+ 19, 100.0);
178 expect_float(buf
+ 20, 300.0);
179 expect_float(buf
+ 21, 30.0);
180 expect_float(buf
+ 22, 50.0);
181 expect_dword(buf
+ 23, CombineModeUnion
);
182 expect_dword(buf
+ 24, 0x10000000);
183 expect_float(buf
+ 25, 200.0);
184 expect_float(buf
+ 26, 100.0);
185 expect_float(buf
+ 27, 133.0);
186 expect_float(buf
+ 28, 266.0);
187 expect_dword(buf
+ 29, 0x10000000);
188 expect_float(buf
+ 30, 20.0);
189 expect_float(buf
+ 31, 10.0);
190 expect_float(buf
+ 32, 40.0);
191 expect_float(buf
+ 33, 66.0);
192 expect_dword(buf
+ 34, 0x10000000);
193 expect_float(buf
+ 35, 400.0);
194 expect_float(buf
+ 36, 500.0);
195 expect_float(buf
+ 37, 22.0);
196 expect_float(buf
+ 38, 55.0);
199 status
= GdipDeleteRegion(region2
);
200 ok(status
== Ok
, "status %08x\n", status
);
201 status
= GdipDeleteRegion(region
);
202 ok(status
== Ok
, "status %08x\n", status
);
208 struct GdiplusStartupInput gdiplusStartupInput
;
209 ULONG_PTR gdiplusToken
;
211 gdiplusStartupInput
.GdiplusVersion
= 1;
212 gdiplusStartupInput
.DebugEventCallback
= NULL
;
213 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
214 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
216 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
220 GdiplusShutdown(gdiplusToken
);