ReactOS 0.4.17-dev-218-g5635d24
region.c File Reference
#include <math.h>
#include "objbase.h"
#include "gdiplus.h"
#include "wine/test.h"
Include dependency graph for region.c:

Go to the source code of this file.

Classes

struct  RegionDataPoint
 

Macros

#define RGNDATA_RECT   0x10000000
 
#define RGNDATA_PATH   0x10000001
 
#define RGNDATA_EMPTY_RECT   0x10000002
 
#define RGNDATA_INFINITE_RECT   0x10000003
 
#define RGNDATA_MAGIC   0xdbc01001
 
#define RGNDATA_MAGIC2   0xdbc01002
 
#define expect(expected, got)   expect_(__LINE__, expected, got)
 
#define expectf_(expected, got, precision)   ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))
 
#define expectf(expected, got)   expectf_((expected), (got), 0.001)
 
#define expect_magic(value)   ok(broken(*(value) == RGNDATA_MAGIC) || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8lx\n", *(value))
 
#define expect_dword(value, expected)   expect((expected), *(value))
 
#define expect_float(value, expected)   expectf((expected), *(FLOAT *)(value))
 

Typedefs

typedef struct RegionDataPoint RegionDataPoint
 

Functions

static void expect_ (unsigned line, DWORD expected, DWORD got)
 
static void verify_region (HRGN hrgn, const RECT *rc)
 
static void test_region_data (DWORD *data, UINT size, INT line)
 
static void test_getregiondata (void)
 
static void test_isinfinite (void)
 
static void test_isempty (void)
 
static void test_combinereplace (void)
 
static void test_fromhrgn (void)
 
static void test_gethrgn (void)
 
static void test_isequal (void)
 
static void test_translate (void)
 
static DWORD get_region_type (GpRegion *region)
 
static void test_transform (void)
 
static void test_scans (void)
 
static void test_getbounds (void)
 
static void test_isvisiblepoint (void)
 
static void test_isvisiblerect (void)
 
static void test_excludeinfinite (void)
 
static void test_GdipCreateRegionRgnData (void)
 
static void test_incombinedregion (void)
 
 START_TEST (region)
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    expect_(__LINE__, expected, got)

Definition at line 36 of file region.c.

◆ expect_dword

#define expect_dword (   value,
  expected 
)    expect((expected), *(value))

Definition at line 45 of file region.c.

◆ expect_float

#define expect_float (   value,
  expected 
)    expectf((expected), *(FLOAT *)(value))

Definition at line 46 of file region.c.

◆ expect_magic

#define expect_magic (   value)    ok(broken(*(value) == RGNDATA_MAGIC) || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8lx\n", *(value))

Definition at line 44 of file region.c.

◆ expectf

#define expectf (   expected,
  got 
)    expectf_((expected), (got), 0.001)

Definition at line 42 of file region.c.

◆ expectf_

#define expectf_ (   expected,
  got,
  precision 
)    ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))

Definition at line 41 of file region.c.

◆ RGNDATA_EMPTY_RECT

#define RGNDATA_EMPTY_RECT   0x10000002

Definition at line 30 of file region.c.

◆ RGNDATA_INFINITE_RECT

#define RGNDATA_INFINITE_RECT   0x10000003

Definition at line 31 of file region.c.

◆ RGNDATA_MAGIC

#define RGNDATA_MAGIC   0xdbc01001

Definition at line 33 of file region.c.

◆ RGNDATA_MAGIC2

#define RGNDATA_MAGIC2   0xdbc01002

Definition at line 34 of file region.c.

◆ RGNDATA_PATH

#define RGNDATA_PATH   0x10000001

Definition at line 29 of file region.c.

◆ RGNDATA_RECT

#define RGNDATA_RECT   0x10000000

Definition at line 28 of file region.c.

Typedef Documentation

◆ RegionDataPoint

Function Documentation

◆ expect_()

static void expect_ ( unsigned  line,
DWORD  expected,
DWORD  got 
)
inlinestatic

Definition at line 37 of file region.c.

38{
39 ok_(__FILE__, line)(expected == got, "Expected %ld, got %ld\n", expected, got);
40}
#define ok_(x1, x2)
Definition: atltest.h:61
BOOL expected
Definition: store.c:2000
Definition: parser.c:49

◆ get_region_type()

static DWORD get_region_type ( GpRegion region)
static

Definition at line 1449 of file region.c.

1450{
1451 DWORD *data;
1452 UINT size;
1453 DWORD result;
1454 DWORD status;
1455 status = GdipGetRegionDataSize(region, &size);
1456 expect(Ok, status);
1457 data = GdipAlloc(size);
1458 status = GdipGetRegionData(region, (BYTE*)data, size, NULL);
1459 ok(status == Ok || status == InsufficientBuffer, "unexpected status 0x%lx\n", status);
1460 result = data[4];
1461 GdipFree(data);
1462 return result;
1463}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *region, UINT *needed)
Definition: region.c:978
GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *region, BYTE *buffer, UINT size, UINT *needed)
Definition: region.c:740
unsigned long DWORD
Definition: ntddk_ex.h:95
void WINGDIPAPI GdipFree(void *ptr)
Definition: gdiplus.c:152
void *WINGDIPAPI GdipAlloc(SIZE_T size)
Definition: gdiplus.c:144
@ Ok
Definition: gdiplustypes.h:25
@ InsufficientBuffer
Definition: gdiplustypes.h:30
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint64EXT * result
Definition: glext.h:11304
#define expect(expected, got)
Definition: region.c:36
unsigned int UINT
Definition: ndis.h:50
Definition: ps.c:97
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_transform().

◆ START_TEST()

START_TEST ( region  )

Definition at line 2573 of file region.c.

2574{
2575 struct GdiplusStartupInput gdiplusStartupInput;
2576 ULONG_PTR gdiplusToken;
2577 HMODULE hmsvcrt;
2578 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
2579
2580 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
2581 hmsvcrt = LoadLibraryA("msvcrt");
2582 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
2583 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
2584
2585 gdiplusStartupInput.GdiplusVersion = 1;
2586 gdiplusStartupInput.DebugEventCallback = NULL;
2587 gdiplusStartupInput.SuppressBackgroundThread = 0;
2588 gdiplusStartupInput.SuppressExternalCodecs = 0;
2589
2590 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2591
2594 test_isempty();
2596 test_fromhrgn();
2597 test_gethrgn();
2598 test_isequal();
2601 test_scans();
2608
2609 GdiplusShutdown(gdiplusToken);
2610}
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
_ACRTIMP errno_t __cdecl _controlfp_s(unsigned int *, unsigned int, unsigned int)
Definition: math.c:1304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:83
void WINAPI GdiplusShutdown(ULONG_PTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_incombinedregion(void)
Definition: region.c:2375
static void test_isempty(void)
Definition: region.c:857
static void test_GdipCreateRegionRgnData(void)
Definition: region.c:2313
static void test_gethrgn(void)
Definition: region.c:1118
static void test_combinereplace(void)
Definition: region.c:901
static void test_translate(void)
Definition: region.c:1372
static void test_fromhrgn(void)
Definition: region.c:1001
static void test_getregiondata(void)
Definition: region.c:158
static void test_isvisiblepoint(void)
Definition: region.c:1856
static void test_getbounds(void)
Definition: region.c:1732
static void test_isvisiblerect(void)
Definition: region.c:2059
static void test_isinfinite(void)
Definition: region.c:809
static void test_isequal(void)
Definition: region.c:1280
static void test_excludeinfinite(void)
Definition: region.c:2263
static void test_scans(void)
Definition: region.c:1594
static void test_transform(void)
Definition: region.c:1465
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ test_combinereplace()

static void test_combinereplace ( void  )
static

Definition at line 901 of file region.c.

902{
904 GpRegion *region, *region2;
905 GpPath *path;
906 GpRectF rectf;
907 UINT needed;
908 DWORD buf[50];
909
910 rectf.X = rectf.Y = 0.0;
911 rectf.Width = rectf.Height = 100.0;
912
913 status = GdipCreateRegionRect(&rectf, &region);
914 expect(Ok, status);
915
916 /* replace with the same rectangle */
918 expect(Ok, status);
919
920 status = GdipGetRegionDataSize(region, &needed);
921 expect(Ok, status);
922 expect(36, needed);
923 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
924 expect(Ok, status);
925 expect(36, needed);
926 expect_dword(buf, 28);
927 trace("buf[1] = %08lx\n", buf[1]);
928 expect_magic(buf + 2);
929 expect_dword(buf + 3, 0);
931
932 /* replace with path */
934 expect(Ok, status);
935 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
936 expect(Ok, status);
938 expect(Ok, status);
939
940 status = GdipGetRegionDataSize(region, &needed);
941 expect(Ok, status);
942 expect(156, needed);
943 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
944 expect(Ok, status);
945 expect(156, needed);
946 expect_dword(buf, 148);
947 trace("buf[1] = %08lx\n", buf[1]);
948 expect_magic(buf + 2);
949 expect_dword(buf + 3, 0);
952
953 /* replace with infinite rect */
954 status = GdipCreateRegion(&region2);
955 expect(Ok, status);
957 expect(Ok, status);
958
959 status = GdipGetRegionDataSize(region, &needed);
960 expect(Ok, status);
961 expect(20, needed);
962 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
963 expect(Ok, status);
964 expect(20, needed);
965 expect_dword(buf, 12);
966 trace("buf[1] = %08lx\n", buf[1]);
967 expect_magic(buf + 2);
968 expect_dword(buf + 3, 0);
970 GdipDeleteRegion(region2);
971
972 /* more complex case : replace with a combined region */
973 status = GdipCreateRegionRect(&rectf, &region2);
974 expect(Ok, status);
976 expect(Ok, status);
977 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
978 expect(Ok, status);
980 expect(Ok, status);
983 expect(Ok, status);
984 GdipDeleteRegion(region2);
985
986 status = GdipGetRegionDataSize(region, &needed);
987 expect(Ok, status);
988 expect(180, needed);
989 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
990 expect(Ok, status);
991 expect(180, needed);
992 expect_dword(buf, 172);
993 trace("buf[1] = %08lx\n", buf[1]);
994 expect_magic(buf + 2);
995 expect_dword(buf + 3, 2);
997
998 GdipDeleteRegion(region);
999}
#define trace
Definition: atltest.h:70
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathEllipse(GpPath *path, REAL x, REAL y, REAL width, REAL height)
Definition: graphicspath.c:703
GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, CombineMode mode)
Definition: region.c:236
GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
Definition: region.c:459
GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
Definition: region.c:390
GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region, GDIPCONST GpRectF *rect, CombineMode mode)
Definition: region.c:282
GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1, GpRegion *region2, CombineMode mode)
Definition: region.c:346
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
Definition: region.c:567
@ CombineModeUnion
Definition: gdiplusenums.h:390
@ CombineModeReplace
Definition: gdiplusenums.h:388
@ FillModeAlternate
Definition: gdiplusenums.h:55
Status
Definition: gdiplustypes.h:24
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define RGNDATA_RECT
Definition: region.c:28
#define expect_dword(value, expected)
Definition: region.c:45
#define RGNDATA_INFINITE_RECT
Definition: region.c:31
#define expect_magic(value)
Definition: region.c:44
#define RGNDATA_PATH
Definition: region.c:29
REAL Height
Definition: gdiplustypes.h:659
REAL X
Definition: gdiplustypes.h:656
REAL Width
Definition: gdiplustypes.h:658
REAL Y
Definition: gdiplustypes.h:657

Referenced by START_TEST().

◆ test_excludeinfinite()

static void test_excludeinfinite ( void  )
static

Definition at line 2263 of file region.c.

2264{
2266 GpRegion *region;
2267 UINT count=0xdeadbeef;
2268 GpRectF scans[4];
2270 static const RectF rect_exclude = {0.0, 0.0, 1.0, 1.0};
2271
2273 expect(Ok, status);
2274
2275 status = GdipCreateRegion(&region);
2276 expect(Ok, status);
2277
2278 status = GdipCombineRegionRect(region, &rect_exclude, CombineModeExclude);
2279 expect(Ok, status);
2280
2282 expect(Ok, status);
2283 expect(4, count);
2284
2285 count = 4;
2286 status = GdipGetRegionScans(region, scans, (INT*)&count, identity);
2287 expect(Ok, status);
2288
2289 expectf(-4194304.0, scans[0].X);
2290 expectf(-4194304.0, scans[0].Y);
2291 expectf(8388608.0, scans[0].Width);
2292 expectf(4194304.0, scans[0].Height);
2293
2294 expectf(-4194304.0, scans[1].X);
2295 expectf(0.0, scans[1].Y);
2296 expectf(4194304.0, scans[1].Width);
2297 expectf(1.0, scans[1].Height);
2298
2299 expectf(1.0, scans[2].X);
2300 expectf(0.0, scans[2].Y);
2301 expectf(4194303.0, scans[2].Width);
2302 expectf(1.0, scans[2].Height);
2303
2304 expectf(-4194304.0, scans[3].X);
2305 expectf(1.0, scans[3].Y);
2306 expectf(8388608.0, scans[3].Width);
2307 expectf(4194303.0, scans[3].Height);
2308
2309 GdipDeleteRegion(region);
2311}
#define Y(I)
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:156
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:136
GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *region, GpRectF *scans, INT *count, GpMatrix *matrix)
Definition: region.c:1878
GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMatrix *matrix)
Definition: region.c:1823
@ CombineModeExclude
Definition: gdiplusenums.h:392
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define expectf(expected, got)
Definition: region.c:42
int32_t INT
Definition: typedefs.h:58
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88

Referenced by START_TEST().

◆ test_fromhrgn()

static void test_fromhrgn ( void  )
static

Definition at line 1001 of file region.c.

1002{
1004 GpRegion *region = (GpRegion*)0xabcdef01;
1005 HRGN hrgn;
1006 UINT needed;
1007 DWORD buf[220];
1009 GpGraphics *graphics = NULL;
1010 HDC hdc;
1011 BOOL res;
1012
1013 /* NULL */
1016 status = GdipCreateRegionHrgn(NULL, &region);
1018 status = GdipCreateRegionHrgn((HRGN)0xdeadbeef, &region);
1020 ok(region == (GpRegion*)0xabcdef01, "Expected region not to be created\n");
1021
1022 /* empty rectangle */
1023 hrgn = CreateRectRgn(0, 0, 0, 0);
1024 status = GdipCreateRegionHrgn(hrgn, &region);
1025 expect(Ok, status);
1026 if(status == Ok) {
1027
1028 hdc = GetDC(0);
1029 status = GdipCreateFromHDC(hdc, &graphics);
1030 expect(Ok, status);
1031 res = FALSE;
1032 status = GdipIsEmptyRegion(region, graphics, &res);
1033 expect(Ok, status);
1034 expect(TRUE, res);
1035 GdipDeleteGraphics(graphics);
1036 ReleaseDC(0, hdc);
1037 GdipDeleteRegion(region);
1038
1039 }
1041
1042 /* rectangle */
1043 hrgn = CreateRectRgn(0, 0, 100, 10);
1044 status = GdipCreateRegionHrgn(hrgn, &region);
1045 expect(Ok, status);
1046
1047 status = GdipGetRegionDataSize(region, &needed);
1048 expect(Ok, status);
1049 expect(56, needed);
1050
1051 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
1052 expect(Ok, status);
1053
1054 if(status == Ok){
1055
1056 expect(56, needed);
1057 expect_dword(buf, 48);
1058 expect_magic(buf + 2);
1059 expect_dword(buf + 3, 0);
1061 expect_dword(buf + 5, 0x00000020);
1062 expect_magic(buf + 6);
1063 expect_dword(buf + 7, 0x00000004);
1064 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
1065
1066 point = (RegionDataPoint*)buf + 9;
1067
1068 expect(0, point[0].X);
1069 expect(0, point[0].Y);
1070
1071 expect(100,point[1].X); /* buf + 10 */
1072 expect(0, point[1].Y);
1073 expect(100,point[2].X); /* buf + 11 */
1074 expect(10, point[2].Y);
1075
1076 expect(0, point[3].X); /* buf + 12 */
1077
1078 expect(10, point[3].Y);
1079 expect_dword(buf + 13, 0x81010100); /* closed */
1080
1081 }
1082
1083 GdipDeleteRegion(region);
1085
1086 /* ellipse */
1087 hrgn = CreateEllipticRgn(0, 0, 100, 10);
1088 status = GdipCreateRegionHrgn(hrgn, &region);
1089 expect(Ok, status);
1090
1091 status = GdipGetRegionDataSize(region, &needed);
1092 expect(Ok, status);
1093 ok(needed == 216 ||
1094 needed == 196, /* win98 */
1095 "Got %.8x\n", needed);
1096
1097 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
1098 expect(Ok, status);
1099
1100 if(status == Ok && needed == 216) /* Don't try to test win98 layout */
1101 {
1102 expect(Ok, status);
1103 expect(216, needed);
1104 expect_dword(buf, 208);
1105 expect_magic(buf + 2);
1106 expect_dword(buf + 3, 0);
1108 expect_dword(buf + 5, 0x000000C0);
1109 expect_magic(buf + 6);
1110 expect_dword(buf + 7, 0x00000024);
1111 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
1112 }
1113
1114 GdipDeleteRegion(region);
1116}
static HRGN hrgn
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2434
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2616
GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
Definition: region.c:1211
GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
Definition: region.c:502
POINTL point
Definition: edittest.c:50
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
@ InvalidParameter
Definition: gdiplustypes.h:27
GLuint res
Definition: glext.h:9613
#define todo_wine
Definition: minitest.h:80
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HRGN WINAPI CreateEllipticRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ test_GdipCreateRegionRgnData()

static void test_GdipCreateRegionRgnData ( void  )
static

Definition at line 2313 of file region.c.

2314{
2315 GpGraphics *graphics = NULL;
2316 GpRegion *region, *region2;
2317 HDC hdc = GetDC(0);
2319 BYTE buf[512];
2320 UINT needed;
2321 BOOL ret;
2322
2324 ok(status == InvalidParameter, "status %d\n", status);
2325
2326 status = GdipCreateFromHDC(hdc, &graphics);
2327 ok(status == Ok, "status %d\n", status);
2328
2329 status = GdipCreateRegion(&region);
2330 ok(status == Ok, "status %d\n", status);
2331
2332 /* infinite region */
2333 memset(buf, 0xee, sizeof(buf));
2334 needed = 0;
2335 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
2336 ok(status == Ok, "status %d\n", status);
2337 expect(20, needed);
2338
2340 ok(status == InvalidParameter, "status %d\n", status);
2341
2342 status = GdipCreateRegionRgnData(buf, needed, &region2);
2343 ok(status == Ok, "status %d\n", status);
2344
2345 ret = FALSE;
2346 status = GdipIsInfiniteRegion(region2, graphics, &ret);
2347 ok(status == Ok, "status %d\n", status);
2348 ok(ret, "got %d\n", ret);
2349 GdipDeleteRegion(region2);
2350
2351 /* empty region */
2352 status = GdipSetEmpty(region);
2353 ok(status == Ok, "status %d\n", status);
2354
2355 memset(buf, 0xee, sizeof(buf));
2356 needed = 0;
2357 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
2358 ok(status == Ok, "status %d\n", status);
2359 expect(20, needed);
2360
2361 status = GdipCreateRegionRgnData(buf, needed, &region2);
2362 ok(status == Ok, "status %d\n", status);
2363
2364 ret = FALSE;
2365 status = GdipIsEmptyRegion(region2, graphics, &ret);
2366 ok(status == Ok, "status %d\n", status);
2367 ok(ret, "got %d\n", ret);
2368 GdipDeleteRegion(region2);
2369
2370 GdipDeleteGraphics(graphics);
2371 GdipDeleteRegion(region);
2372 ReleaseDC(0, hdc);
2373}
GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
Definition: region.c:1268
GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
Definition: region.c:1581
GpStatus WINGDIPAPI GdipCreateRegionRgnData(GDIPCONST BYTE *data, INT size, GpRegion **region)
Definition: region.c:939
return ret
Definition: mutex.c:146
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_getbounds()

static void test_getbounds ( void  )
static

Definition at line 1732 of file region.c.

1733{
1734 GpRegion *region;
1735 GpPath *path;
1736 GpGraphics *graphics;
1738 GpRectF rectf;
1739 HDC hdc = GetDC(0);
1740
1741 status = GdipCreateFromHDC(hdc, &graphics);
1742 ok(status == Ok, "status %08x\n", status);
1743 status = GdipCreateRegion(&region);
1744 ok(status == Ok, "status %08x\n", status);
1745
1746 /* NULL */
1748 ok(status == InvalidParameter, "status %08x\n", status);
1749 status = GdipGetRegionBounds(region, NULL, NULL);
1750 ok(status == InvalidParameter, "status %08x\n", status);
1751 status = GdipGetRegionBounds(region, graphics, NULL);
1752 ok(status == InvalidParameter, "status %08x\n", status);
1753 /* infinite */
1754 rectf.X = rectf.Y = 0.0;
1755 rectf.Height = rectf.Width = 100.0;
1756 status = GdipGetRegionBounds(region, graphics, &rectf);
1757 ok(status == Ok, "status %08x\n", status);
1758 ok(rectf.X == -(REAL)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.X);
1759 ok(rectf.Y == -(REAL)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.Y);
1760 ok(rectf.Width == (REAL)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL)(1 << 23), rectf.Width);
1761 ok(rectf.Height == (REAL)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL)(1 << 23), rectf.Height);
1762 /* empty */
1763 rectf.X = rectf.Y = 0.0;
1764 rectf.Height = rectf.Width = 100.0;
1765 status = GdipSetEmpty(region);
1766 ok(status == Ok, "status %08x\n", status);
1767 status = GdipGetRegionBounds(region, graphics, &rectf);
1768 ok(status == Ok, "status %08x\n", status);
1769 ok(rectf.X == 0.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1770 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1771 ok(rectf.Width == 0.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1772 ok(rectf.Height == 0.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1773 /* rect */
1774 rectf.X = 10.0; rectf.Y = 0.0;
1775 rectf.Width = rectf.Height = 100.0;
1777 ok(status == Ok, "status %08x\n", status);
1778 rectf.X = rectf.Y = 0.0;
1779 rectf.Height = rectf.Width = 0.0;
1780 status = GdipGetRegionBounds(region, graphics, &rectf);
1781 ok(status == Ok, "status %08x\n", status);
1782 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1783 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1784 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1785 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1786
1787 /* the world and page transforms are ignored */
1788 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1789 ok(status == Ok, "status %08x\n", status);
1790 GdipSetPageUnit(graphics, UnitInch);
1791 GdipSetPageScale(graphics, 2.0);
1792 status = GdipGetRegionBounds(region, graphics, &rectf);
1793 ok(status == Ok, "status %08x\n", status);
1794 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1795 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1796 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1797
1798 rectf.X = 10.0; rectf.Y = 0.0;
1799 rectf.Width = rectf.Height = 100.0;
1801 ok(status == Ok, "status %08x\n", status);
1802 rectf.X = rectf.Y = 0.0;
1803 rectf.Height = rectf.Width = 0.0;
1804 status = GdipGetRegionBounds(region, graphics, &rectf);
1805 ok(status == Ok, "status %08x\n", status);
1806 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1807 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1808 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1809 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1810
1811 /* coordinates are not rounded */
1812 status = GdipResetWorldTransform(graphics);
1813 ok(status == Ok, "status %08x\n", status);
1814 status = GdipResetPageTransform(graphics);
1815 ok(status == Ok, "status %08x\n", status);
1816 rectf.X = 0.125;
1817 rectf.Y = 1.125;
1818 rectf.Width = 2.125;
1819 rectf.Height = 3.125;
1821 ok(status == Ok, "status %08x\n", status);
1822 rectf.X = rectf.Y = 0.0;
1823 rectf.Height = rectf.Width = 0.0;
1824 status = GdipGetRegionBounds(region, graphics, &rectf);
1825 ok(status == Ok, "status %08x\n", status);
1826 ok(rectf.X == 0.125, "Expected X = 0.0, got %.2f\n", rectf.X);
1827 ok(rectf.Y == 1.125, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1828 ok(rectf.Width == 2.125, "Expected width = 0.0, got %.2f\n", rectf.Width);
1829 ok(rectf.Height == 3.125, "Expected height = 0.0, got %.2f\n", rectf.Height);
1830
1831 /* test path */
1833 ok(status == Ok, "status %08x\n", status);
1834 status = GdipAddPathRectangle(path, 0.125, 1.125, 2.125, 3.125);
1835 ok(status == Ok, "status %08x\n", status);
1837 ok(status == Ok, "status %08x\n", status);
1839 ok(status == Ok, "status %08x\n", status);
1840 rectf.X = rectf.Y = 0.0;
1841 rectf.Height = rectf.Width = 0.0;
1842 status = GdipGetRegionBounds(region, graphics, &rectf);
1843 ok(status == Ok, "status %08x\n", status);
1844 ok(rectf.X == 0.125, "Expected X = 0.0, got %.2f\n", rectf.X);
1845 ok(rectf.Y == 1.125, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1846 ok(rectf.Width == 2.125, "Expected width = 0.0, got %.2f\n", rectf.Width);
1847 ok(rectf.Height == 3.125, "Expected height = 0.0, got %.2f\n", rectf.Height);
1848
1849 status = GdipDeleteRegion(region);
1850 ok(status == Ok, "status %08x\n", status);
1851 status = GdipDeleteGraphics(graphics);
1852 ok(status == Ok, "status %08x\n", status);
1853 ReleaseDC(0, hdc);
1854}
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipResetPageTransform(GpGraphics *graphics)
Definition: graphics.c:7940
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, REAL sy, GpMatrixOrder order)
Definition: graphics.c:6406
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
Definition: graphics.c:6560
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
Definition: graphics.c:6194
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
Definition: graphics.c:6533
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
Definition: region.c:583
@ MatrixOrderPrepend
Definition: gdiplusenums.h:187
@ UnitInch
Definition: gdiplusenums.h:31

Referenced by START_TEST().

◆ test_gethrgn()

static void test_gethrgn ( void  )
static

Definition at line 1118 of file region.c.

1119{
1121 GpRegion *region, *region2;
1122 GpPath *path;
1123 GpGraphics *graphics;
1124 HRGN hrgn;
1125 HDC hdc=GetDC(0);
1126 INT rgntype;
1127 RECT rgnbox;
1128 static const RECT empty_rect = {0,0,0,0};
1129 static const RECT test_rect = {10, 11, 20, 21};
1130 static const GpRectF test_rectF = {10.0, 11.0, 10.0, 10.0};
1131 static const RECT scaled_rect = {20, 22, 40, 42};
1132 static const RECT test_rect2 = {10, 21, 20, 31};
1133 static const GpRectF test_rect2F = {10.0, 21.0, 10.0, 10.0};
1134 static const RECT test_rect3 = {10, 11, 20, 31};
1135 static const GpRectF test_rect3F = {10.0, 11.0, 10.0, 20.0};
1136
1137 status = GdipCreateFromHDC(hdc, &graphics);
1138 ok(status == Ok, "status %08x\n", status);
1139
1140 status = GdipCreateRegion(&region);
1141 ok(status == Ok, "status %08x\n", status);
1142
1143 status = GdipGetRegionHRgn(NULL, graphics, &hrgn);
1144 ok(status == InvalidParameter, "status %08x\n", status);
1145 status = GdipGetRegionHRgn(region, graphics, NULL);
1146 ok(status == InvalidParameter, "status %08x\n", status);
1147
1148 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1149 ok(status == Ok, "status %08x\n", status);
1150 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
1151
1152 status = GdipGetRegionHRgn(region, graphics, &hrgn);
1153 ok(status == Ok, "status %08x\n", status);
1154 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
1155
1156 status = GdipSetEmpty(region);
1157 ok(status == Ok, "status %08x\n", status);
1158 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1159 ok(status == Ok, "status %08x\n", status);
1160 verify_region(hrgn, &empty_rect);
1162
1164 ok(status == Ok, "status %08x\n", status);
1165 status = GdipAddPathRectangle(path, 10.0, 11.0, 10.0, 10.0);
1166 ok(status == Ok, "status %08x\n", status);
1167
1168 status = GdipCreateRegionPath(path, &region2);
1169 ok(status == Ok, "status %08x\n", status);
1170 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
1171 ok(status == Ok, "status %08x\n", status);
1174
1175 /* resulting HRGN is in device coordinates */
1176 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1177 ok(status == Ok, "status %08x\n", status);
1178 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
1179 ok(status == Ok, "status %08x\n", status);
1180 verify_region(hrgn, &scaled_rect);
1182
1183 status = GdipCombineRegionRect(region2, &test_rectF, CombineModeReplace);
1184 ok(status == Ok, "status %08x\n", status);
1185 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
1186 ok(status == Ok, "status %08x\n", status);
1189
1190 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
1191 ok(status == Ok, "status %08x\n", status);
1192 verify_region(hrgn, &scaled_rect);
1194
1195 status = GdipSetInfinite(region);
1196 ok(status == Ok, "status %08x\n", status);
1197 status = GdipCombineRegionRect(region, &test_rectF, CombineModeIntersect);
1198 ok(status == Ok, "status %08x\n", status);
1199 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1200 ok(status == Ok, "status %08x\n", status);
1203
1204 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
1205 ok(status == Ok, "status %08x\n", status);
1206 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeUnion);
1207 ok(status == Ok, "status %08x\n", status);
1208 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1209 ok(status == Ok, "status %08x\n", status);
1212
1213 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
1214 ok(status == Ok, "status %08x\n", status);
1215 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeXor);
1216 ok(status == Ok, "status %08x\n", status);
1217 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1218 ok(status == Ok, "status %08x\n", status);
1221
1222 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
1223 ok(status == Ok, "status %08x\n", status);
1224 status = GdipCombineRegionRect(region, &test_rectF, CombineModeExclude);
1225 ok(status == Ok, "status %08x\n", status);
1226 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1227 ok(status == Ok, "status %08x\n", status);
1230
1231 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
1232 ok(status == Ok, "status %08x\n", status);
1233 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeComplement);
1234 ok(status == Ok, "status %08x\n", status);
1235 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1236 ok(status == Ok, "status %08x\n", status);
1239
1241 ok(status == Ok, "status %08x\n", status);
1242 status = GdipDeleteRegion(region);
1243 ok(status == Ok, "status %08x\n", status);
1244 status = GdipDeleteRegion(region2);
1245 ok(status == Ok, "status %08x\n", status);
1246 status = GdipDeleteGraphics(graphics);
1247 ok(status == Ok, "status %08x\n", status);
1248
1249 /* test with gdi32 transform */
1250 SetViewportOrgEx(hdc, 10, 10, NULL);
1251
1252 status = GdipCreateFromHDC(hdc, &graphics);
1253 expect(Ok, status);
1254
1255 status = GdipCreateRegionRect(&test_rectF, &region);
1256 expect(Ok, status);
1257
1258 status = GdipGetRegionHRgn(region, graphics, &hrgn);
1259 expect(Ok, status);
1260
1261 rgntype = GetRgnBox(hrgn, &rgnbox);
1263
1264 expect(SIMPLEREGION, rgntype);
1265 expect(20, rgnbox.left);
1266 expect(21, rgnbox.top);
1267 expect(30, rgnbox.right);
1268 expect(31, rgnbox.bottom);
1269
1270 status = GdipDeleteRegion(region);
1271 expect(Ok, status);
1272 status = GdipDeleteGraphics(graphics);
1273 expect(Ok, status);
1274
1275 SetViewportOrgEx(hdc, 0, 0, NULL);
1276
1277 ReleaseDC(0, hdc);
1278}
GpStatus WINGDIPAPI GdipSetInfinite(GpRegion *region)
Definition: region.c:1596
GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
Definition: region.c:1201
GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
Definition: region.c:425
@ CombineModeComplement
Definition: gdiplusenums.h:393
@ CombineModeIntersect
Definition: gdiplusenums.h:389
@ CombineModeXor
Definition: gdiplusenums.h:391
static void test_rect(void)
Definition: graphicspath.c:850
static void verify_region(HRGN hrgn, const RECT *rc)
Definition: region.c:54
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
static const RECT test_rect2
Definition: tmarshal.c:64
static const RECT test_rect3
Definition: tmarshal.c:65
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define SIMPLEREGION
Definition: wingdi.h:362
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)

Referenced by START_TEST().

◆ test_getregiondata()

static void test_getregiondata ( void  )
static

Definition at line 158 of file region.c.

159{
161 GpRegion *region, *region2;
163 UINT needed;
164 DWORD buf[256];
165 GpRect rect;
166 GpPath *path;
168
169 status = GdipCreateRegion(&region);
170 ok(status == Ok, "status %08x\n", status);
171
172 needed = 0;
173 status = GdipGetRegionDataSize(region, &needed);
174 ok(status == Ok, "status %08x\n", status);
175 expect(20, needed);
176
177 needed = 0;
178 status = GdipGetRegionData(region, (BYTE*)buf, 0, &needed);
179 ok(status == InvalidParameter, "status %08x\n", status);
180
181 memset(buf, 0xee, sizeof(buf));
182 needed = 0;
183 status = GdipGetRegionData(region, (BYTE*)buf, 4, &needed);
184 ok(status == InsufficientBuffer, "status %08x\n", status);
185 expect(4, needed);
186 expect_dword(buf, 0xeeeeeeee);
187
188 memset(buf, 0xee, sizeof(buf));
189 needed = 0;
190 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
191 ok(status == Ok, "status %08x\n", status);
192 expect(20, needed);
193 expect_dword(buf, 12);
194 trace("buf[1] = %08lx\n", buf[1]);
195 expect_magic(buf + 2);
196 expect_dword(buf + 3, 0);
198 expect_dword(buf + 6, 0xeeeeeeee);
199 test_region_data(buf, needed, __LINE__);
200
201 status = GdipSetEmpty(region);
202 ok(status == Ok, "status %08x\n", status);
203 status = GdipGetRegionDataSize(region, &needed);
204 ok(status == Ok, "status %08x\n", status);
205 expect(20, needed);
206 memset(buf, 0xee, sizeof(buf));
207 needed = 0;
208 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
209 ok(status == Ok, "status %08x\n", status);
210 expect(20, needed);
211 expect_dword(buf, 12);
212 trace("buf[1] = %08lx\n", buf[1]);
213 expect_magic(buf + 2);
214 expect_dword(buf + 3, 0);
216 expect_dword(buf + 6, 0xeeeeeeee);
217 test_region_data(buf, needed, __LINE__);
218
219 status = GdipSetInfinite(region);
220 ok(status == Ok, "status %08x\n", status);
221 status = GdipGetRegionDataSize(region, &needed);
222 ok(status == Ok, "status %08x\n", status);
223 expect(20, needed);
224 memset(buf, 0xee, sizeof(buf));
225 needed = 0;
226 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
227 ok(status == Ok, "status %08x\n", status);
228 expect(20, needed);
229 expect_dword(buf, 12);
230 trace("buf[1] = %08lx\n", buf[1]);
231 expect_magic(buf + 2);
232 expect_dword(buf + 3, 0);
234 expect_dword(buf + 6, 0xeeeeeeee);
235 test_region_data(buf, needed, __LINE__);
236
237 status = GdipDeleteRegion(region);
238 ok(status == Ok, "status %08x\n", status);
239
240 rect.X = 10;
241 rect.Y = 20;
242 rect.Width = 100;
243 rect.Height = 200;
244 status = GdipCreateRegionRectI(&rect, &region);
245 ok(status == Ok, "status %08x\n", status);
246 status = GdipGetRegionDataSize(region, &needed);
247 ok(status == Ok, "status %08x\n", status);
248 expect(36, needed);
249 memset(buf, 0xee, sizeof(buf));
250 needed = 0;
251 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
252 ok(status == Ok, "status %08x\n", status);
253 expect(36, needed);
254 expect_dword(buf, 28);
255 trace("buf[1] = %08lx\n", buf[1]);
256 expect_magic(buf + 2);
257 expect_dword(buf + 3, 0);
259 expect_float(buf + 5, 10.0);
260 expect_float(buf + 6, 20.0);
261 expect_float(buf + 7, 100.0);
262 expect_float(buf + 8, 200.0);
263 expect_dword(buf + 10, 0xeeeeeeee);
264 test_region_data(buf, needed, __LINE__);
265
266 rect.X = 50;
267 rect.Y = 30;
268 rect.Width = 10;
269 rect.Height = 20;
271 ok(status == Ok, "status %08x\n", status);
272 rect.X = 100;
273 rect.Y = 300;
274 rect.Width = 30;
275 rect.Height = 50;
277 ok(status == Ok, "status %08x\n", status);
278
279 rect.X = 200;
280 rect.Y = 100;
281 rect.Width = 133;
282 rect.Height = 266;
283 status = GdipCreateRegionRectI(&rect, &region2);
284 ok(status == Ok, "status %08x\n", status);
285 rect.X = 20;
286 rect.Y = 10;
287 rect.Width = 40;
288 rect.Height = 66;
290 ok(status == Ok, "status %08x\n", status);
291
293 ok(status == Ok, "status %08x\n", status);
294
295 rect.X = 400;
296 rect.Y = 500;
297 rect.Width = 22;
298 rect.Height = 55;
300 ok(status == Ok, "status %08x\n", status);
301
302 status = GdipGetRegionDataSize(region, &needed);
303 ok(status == Ok, "status %08x\n", status);
304 expect(156, needed);
305 memset(buf, 0xee, sizeof(buf));
306 needed = 0;
307 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
308 ok(status == Ok, "status %08x\n", status);
309 expect(156, needed);
310 expect_dword(buf, 148);
311 trace("buf[1] = %08lx\n", buf[1]);
312 expect_magic(buf + 2);
313 expect_dword(buf + 3, 10);
319 expect_float(buf + 9, 10.0);
320 expect_float(buf + 10, 20.0);
321 expect_float(buf + 11, 100.0);
322 expect_float(buf + 12, 200.0);
324 expect_float(buf + 14, 50.0);
325 expect_float(buf + 15, 30.0);
326 expect_float(buf + 16, 10.0);
327 expect_float(buf + 17, 20.0);
329 expect_float(buf + 19, 100.0);
330 expect_float(buf + 20, 300.0);
331 expect_float(buf + 21, 30.0);
332 expect_float(buf + 22, 50.0);
335 expect_float(buf + 25, 200.0);
336 expect_float(buf + 26, 100.0);
337 expect_float(buf + 27, 133.0);
338 expect_float(buf + 28, 266.0);
340 expect_float(buf + 30, 20.0);
341 expect_float(buf + 31, 10.0);
342 expect_float(buf + 32, 40.0);
343 expect_float(buf + 33, 66.0);
345 expect_float(buf + 35, 400.0);
346 expect_float(buf + 36, 500.0);
347 expect_float(buf + 37, 22.0);
348 expect_float(buf + 38, 55.0);
349 expect_dword(buf + 39, 0xeeeeeeee);
350 test_region_data(buf, needed, __LINE__);
351
352 status = GdipDeleteRegion(region2);
353 ok(status == Ok, "status %08x\n", status);
354 status = GdipDeleteRegion(region);
355 ok(status == Ok, "status %08x\n", status);
356
357 /* Try some paths */
358
360 ok(status == Ok, "status %08x\n", status);
361 GdipAddPathRectangle(path, 12.5, 13.0, 14.0, 15.0);
362
363 status = GdipCreateRegionPath(path, &region);
364 ok(status == Ok, "status %08x\n", status);
365 status = GdipGetRegionDataSize(region, &needed);
366 ok(status == Ok, "status %08x\n", status);
367 expect(72, needed);
368 memset(buf, 0xee, sizeof(buf));
369 needed = 0;
370 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
371 ok(status == Ok, "status %08x\n", status);
372 expect(72, needed);
373 expect_dword(buf, 64);
374 trace("buf[1] = %08lx\n", buf[1]);
375 expect_magic(buf + 2);
376 expect_dword(buf + 3, 0);
378 expect_dword(buf + 5, 0x00000030);
379 expect_magic(buf + 6);
380 expect_dword(buf + 7, 0x00000004);
381 expect_dword(buf + 8, 0x00000000);
382 expect_float(buf + 9, 12.5);
383 expect_float(buf + 10, 13.0);
384 expect_float(buf + 11, 26.5);
385 expect_float(buf + 12, 13.0);
386 expect_float(buf + 13, 26.5);
387 expect_float(buf + 14, 28.0);
388 expect_float(buf + 15, 12.5);
389 expect_float(buf + 16, 28.0);
390 expect_dword(buf + 17, 0x81010100);
391 expect_dword(buf + 18, 0xeeeeeeee);
392 test_region_data(buf, needed, __LINE__);
393
394 rect.X = 50;
395 rect.Y = 30;
396 rect.Width = 10;
397 rect.Height = 20;
399 ok(status == Ok, "status %08x\n", status);
400 status = GdipGetRegionDataSize(region, &needed);
401 ok(status == Ok, "status %08x\n", status);
402 expect(96, needed);
403 memset(buf, 0xee, sizeof(buf));
404 needed = 0;
405 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
406 ok(status == Ok, "status %08x\n", status);
407 expect(96, needed);
408 expect_dword(buf, 88);
409 trace("buf[1] = %08lx\n", buf[1]);
410 expect_magic(buf + 2);
411 expect_dword(buf + 3, 2);
414 expect_dword(buf + 6, 0x00000030);
415 expect_magic(buf + 7);
416 expect_dword(buf + 8, 0x00000004);
417 expect_dword(buf + 9, 0x00000000);
418 expect_float(buf + 10, 12.5);
419 expect_float(buf + 11, 13.0);
420 expect_float(buf + 12, 26.5);
421 expect_float(buf + 13, 13.0);
422 expect_float(buf + 14, 26.5);
423 expect_float(buf + 15, 28.0);
424 expect_float(buf + 16, 12.5);
425 expect_float(buf + 17, 28.0);
426 expect_dword(buf + 18, 0x81010100);
428 expect_float(buf + 20, 50.0);
429 expect_float(buf + 21, 30.0);
430 expect_float(buf + 22, 10.0);
431 expect_float(buf + 23, 20.0);
432 expect_dword(buf + 24, 0xeeeeeeee);
433 test_region_data(buf, needed, __LINE__);
434
435 status = GdipDeleteRegion(region);
436 ok(status == Ok, "status %08x\n", status);
438 ok(status == Ok, "status %08x\n", status);
439
440 /* Test an empty path */
442 expect(Ok, status);
443 status = GdipCreateRegionPath(path, &region);
444 expect(Ok, status);
445 status = GdipGetRegionDataSize(region, &needed);
446 expect(Ok, status);
447 expect(36, needed);
448 memset(buf, 0xee, sizeof(buf));
449 needed = 0;
450 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
451 expect(Ok, status);
452 expect(36, needed);
453 expect_dword(buf, 28);
454 trace("buf[1] = %08lx\n", buf[1]);
455 expect_magic(buf + 2);
456 expect_dword(buf + 3, 0);
458 /* Second signature for pathdata */
459 expect_dword(buf + 5, 12);
460 expect_magic(buf + 6);
461 expect_dword(buf + 7, 0);
462 /* flags 0 means that a path is an array of FLOATs */
463 ok(*(buf + 8) == 0x4000 /* before win7 */ || *(buf + 8) == 0,
464 "expected 0x4000 or 0, got %08lx\n", *(buf + 8));
465 expect_dword(buf + 10, 0xeeeeeeee);
466 test_region_data(buf, needed, __LINE__);
467
468 /* Transform an empty region */
470 expect(Ok, status);
472 expect(Ok, status);
474
475 status = GdipDeleteRegion(region);
476 expect(Ok, status);
477
478 /* Test a simple triangle of INTs */
479 status = GdipAddPathLine(path, 5, 6, 7, 8);
480 expect(Ok, status);
481 status = GdipAddPathLine(path, 8, 1, 5, 6);
482 expect(Ok, status);
484 expect(Ok, status);
485 status = GdipCreateRegionPath(path, &region);
486 expect(Ok, status);
487 status = GdipGetRegionDataSize(region, &needed);
488 expect(Ok, status);
489 expect(56, needed);
490 memset(buf, 0xee, sizeof(buf));
491 needed = 0;
492 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
493 expect(Ok, status);
494 expect(56, needed);
495 expect_dword(buf, 48);
496 trace("buf[1] = %08lx\n", buf[1]);
497 expect_magic(buf + 2);
498 expect_dword(buf + 3 , 0);
500 expect_dword(buf + 5, 32);
501 expect_magic(buf + 6);
502 expect_dword(buf + 7, 4);
503 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
504 expect_dword(buf + 8, 0x4000);
505
506 point = (RegionDataPoint*)(buf + 9);
507 expect(5, point[0].X);
508 expect(6, point[0].Y);
509 expect(7, point[1].X); /* buf + 10 */
510 expect(8, point[1].Y);
511 expect(8, point[2].X); /* buf + 11 */
512 expect(1, point[2].Y);
513 expect(5, point[3].X); /* buf + 12 */
514 expect(6, point[3].Y);
515 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
516 expect_dword(buf + 14, 0xeeeeeeee);
517 test_region_data(buf, needed, __LINE__);
518
519 status = GdipTranslateRegion(region, 0.6, 0.8);
520 expect(Ok, status);
521 memset(buf, 0xee, sizeof(buf));
522 needed = 0;
523 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
524 expect(Ok, status);
525 expect(72, needed);
526 expect_dword(buf, 64);
527 expect_magic(buf + 2);
528 expect_dword(buf + 3 , 0);
530 expect_dword(buf + 5, 48);
531 expect_magic(buf + 6);
532 expect_dword(buf + 7, 4);
533 /* flags 0 means that a path is an array of FLOATs */
534 expect_dword(buf + 8, 0);
535 expect_float(buf + 9, 5.6);
536 expect_float(buf + 10, 6.8);
537 expect_float(buf + 11, 7.6);
538 expect_float(buf + 12, 8.8);
539 expect_float(buf + 13, 8.6);
540 expect_float(buf + 14, 1.8);
541 expect_float(buf + 15, 5.6);
542 expect_float(buf + 16, 6.8);
543 expect_dword(buf + 17, 0x81010100); /* 0x01010100 if we don't close the path */
544 expect_dword(buf + 18, 0xeeeeeeee);
545 test_region_data(buf, needed, __LINE__);
546
548 expect(Ok, status);
549 status = GdipDeleteRegion(region);
550 expect(Ok, status);
551
552 /* Test a floating-point triangle */
554 expect(Ok, status);
555 status = GdipAddPathLine(path, 5.6, 6.2, 7.2, 8.9);
556 expect(Ok, status);
557 status = GdipAddPathLine(path, 8.1, 1.6, 5.6, 6.2);
558 expect(Ok, status);
559 status = GdipCreateRegionPath(path, &region);
560 expect(Ok, status);
561 status = GdipGetRegionDataSize(region, &needed);
562 expect(Ok, status);
563 expect(72, needed);
564 memset(buf, 0xee, sizeof(buf));
565 needed = 0;
566 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
567 expect(Ok, status);
568 expect(72, needed);
569 expect_dword(buf, 64);
570 trace("buf[1] = %08lx\n", buf[1]);
571 expect_magic(buf + 2);
572 expect_dword(buf + 3, 0);
574 expect_dword(buf + 5, 48);
575 expect_magic(buf + 6);
576 expect_dword(buf + 7, 4);
577 expect_dword(buf + 8, 0);
578 expect_float(buf + 9, 5.6);
579 expect_float(buf + 10, 6.2);
580 expect_float(buf + 11, 7.2);
581 expect_float(buf + 12, 8.9);
582 expect_float(buf + 13, 8.1);
583 expect_float(buf + 14, 1.6);
584 expect_float(buf + 15, 5.6);
585 expect_float(buf + 16, 6.2);
586 expect_dword(buf + 17, 0x01010100);
587 expect_dword(buf + 18, 0xeeeeeeee);
588 test_region_data(buf, needed, __LINE__);
589
591 expect(Ok, status);
592 status = GdipDeleteRegion(region);
593 expect(Ok, status);
594
595 /* Test for a path with > 4 points, and CombineRegionPath */
597 status = GdipAddPathLine(path, 50, 70.2, 60, 102.8);
598 expect(Ok, status);
599 status = GdipAddPathLine(path, 55.4, 122.4, 40.4, 60.2);
600 expect(Ok, status);
601 status = GdipAddPathLine(path, 45.6, 20.2, 50, 70.2);
602 expect(Ok, status);
603 rect.X = 20;
604 rect.Y = 25;
605 rect.Width = 60;
606 rect.Height = 120;
607 status = GdipCreateRegionRectI(&rect, &region);
608 expect(Ok, status);
610 expect(Ok, status);
611
612 status = GdipGetRegionDataSize(region, &needed);
613 expect(Ok, status);
614 expect(116, needed);
615 memset(buf, 0xee, sizeof(buf));
616 needed = 0;
617 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
618 expect(Ok, status);
619 expect(116, needed);
620 expect_dword(buf, 108);
621 trace("buf[1] = %08lx\n", buf[1]);
622 expect_magic(buf + 2);
623 expect_dword(buf + 3, 2);
626 expect_float(buf + 6, 20.0);
627 expect_float(buf + 7, 25.0);
628 expect_float(buf + 8, 60.0);
629 expect_float(buf + 9, 120.0);
631 expect_dword(buf + 11, 68);
632 expect_magic(buf + 12);
633 expect_dword(buf + 13, 6);
634 expect_float(buf + 14, 0.0);
635 expect_float(buf + 15, 50.0);
636 expect_float(buf + 16, 70.2);
637 expect_float(buf + 17, 60.0);
638 expect_float(buf + 18, 102.8);
639 expect_float(buf + 19, 55.4);
640 expect_float(buf + 20, 122.4);
641 expect_float(buf + 21, 40.4);
642 expect_float(buf + 22, 60.2);
643 expect_float(buf + 23, 45.6);
644 expect_float(buf + 24, 20.2);
645 expect_float(buf + 25, 50.0);
646 expect_float(buf + 26, 70.2);
647 expect_dword(buf + 27, 0x01010100);
648 ok((*(buf + 28) & 0xffff) == 0x0101,
649 "expected ????0101 got %08lx\n", *(buf + 28));
650 expect_dword(buf + 29, 0xeeeeeeee);
651 test_region_data(buf, needed, __LINE__);
652
654 expect(Ok, status);
655 status = GdipDeleteRegion(region);
656 expect(Ok, status);
657
658 /* Test how shorts are stored in the region path data */
660 ok(status == Ok, "status %08x\n", status);
661 GdipAddPathRectangleI(path, -1969, -1974, 1995, 1997);
662
663 status = GdipCreateRegionPath(path, &region);
664 ok(status == Ok, "status %08x\n", status);
665 needed = 0;
666 status = GdipGetRegionDataSize(region, &needed);
667 ok(status == Ok, "status %08x\n", status);
668 expect(56, needed);
669 memset(buf, 0xee, sizeof(buf));
670 needed = 0;
671 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
672 ok(status == Ok, "status %08x\n", status);
673 expect(56, needed);
674 expect_dword(buf, 48);
675 trace("buf[1] = %08lx\n", buf[1]);
676 expect_magic(buf + 2);
677 expect_dword(buf + 3, 0);
679 expect_dword(buf + 5, 32);
680 expect_magic(buf + 6);
681 expect_dword(buf + 7, 4);
682 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
683 expect_dword(buf + 8, 0x4000);
684 point = (RegionDataPoint*)(buf + 9);
685 expect(-1969, point[0].X);
686 expect(-1974, point[0].Y);
687 expect(26, point[1].X); /* buf + 10 */
688 expect(-1974, point[1].Y);
689 expect(26, point[2].X); /* buf + 11 */
690 expect(23, point[2].Y);
691 expect(-1969, point[3].X); /* buf + 12 */
692 expect(23, point[3].Y);
693 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
694 expect_dword(buf + 14, 0xeeeeeeee);
695 test_region_data(buf, needed, __LINE__);
696
698 expect(Ok, status);
699 status = GdipDeleteRegion(region);
700 expect(Ok, status);
701
702 /* Test with integers that can't be stored as shorts */
704 ok(status == Ok, "status %08x\n", status);
705 GdipAddPathRectangleI(path, -196900, -197400, 199500, 199700);
706
707 status = GdipCreateRegionPath(path, &region);
708 ok(status == Ok, "status %08x\n", status);
709 needed = 0;
710 status = GdipGetRegionDataSize(region, &needed);
711 ok(status == Ok, "status %08x\n", status);
712 expect(72, needed);
713 memset(buf, 0xee, sizeof(buf));
714 needed = 0;
715 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
716 ok(status == Ok, "status %08x\n", status);
717 expect(72, needed);
718 expect_dword(buf, 64);
719 trace("buf[1] = %08lx\n", buf[1]);
720 expect_magic(buf + 2);
721 expect_dword(buf + 3, 0);
723 expect_dword(buf + 5, 48);
724 expect_magic(buf + 6);
725 expect_dword(buf + 7, 4);
726 /* flags 0 means that a path is an array of FLOATs */
727 expect_dword(buf + 8, 0);
728 expect_float(buf + 9, -196900.0);
729 expect_float(buf + 10, -197400.0);
730 expect_float(buf + 11, 2600.0);
731 expect_float(buf + 12, -197400.0);
732 expect_float(buf + 13, 2600.0);
733 expect_float(buf + 14, 2300.0);
734 expect_float(buf + 15, -196900.0);
735 expect_float(buf + 16, 2300.0);
736 expect_dword(buf + 17, 0x81010100); /* 0x01010100 if we don't close the path */
737 expect_dword(buf + 18, 0xeeeeeeee);
738 test_region_data(buf, needed, __LINE__);
739
741 expect(Ok, status);
742 status = GdipDeleteRegion(region);
743 expect(Ok, status);
744
745 /* Test beziers */
747 /* Exactly 90 degrees */
748 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
749 expect(Ok, status);
750 /* Over 90 degrees */
751 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
752 expect(Ok, status);
753 status = GdipCreateRegionPath(path, &region);
754 ok(status == Ok, "status %08x\n", status);
755 needed = 0;
756 status = GdipGetRegionDataSize(region, &needed);
757 ok(status == Ok, "status %08x\n", status);
758 expect(136, needed);
759 memset(buf, 0xee, sizeof(buf));
760 needed = 0;
761 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
762 ok(status == Ok, "status %08x\n", status);
763 expect(136, needed);
764 expect_dword(buf, 128);
765 trace("buf[1] = %08lx\n", buf[1]);
766 expect_magic(buf + 2);
767 expect_dword(buf + 3, 0);
769 expect_dword(buf + 5, 112);
770 expect_magic(buf + 6);
771 expect_dword(buf + 7, 11);
772 /* flags 0 means that a path is an array of FLOATs */
773 expect_dword(buf + 8, 0);
774 expect_float(buf + 9, 600.0);
775 expect_float(buf + 10, 450.0);
776 expect_float(buf + 11, 600.0);
777 expect_float(buf + 12, 643.299561);
778 expect_float(buf + 13, 488.071198);
779 expect_float(buf + 14, 800.0);
780 expect_float(buf + 15, 350.0);
781 expect_float(buf + 16, 800.0);
782 expect_float(buf + 17, 600.0);
783 expect_float(buf + 18, 450.0);
784 expect_float(buf + 19, 600.0);
785 expect_float(buf + 20, 643.299622);
786 expect_float(buf + 21, 488.071167);
787 expect_float(buf + 22, 800.0);
788 expect_float(buf + 23, 350.0);
789 expect_float(buf + 24, 800.0);
790 expect_float(buf + 25, 329.807129);
791 expect_float(buf + 26, 800.0);
792 expect_float(buf + 27, 309.688568);
793 expect_float(buf + 28, 796.574890);
794 expect_float(buf + 29, 290.084167);
795 expect_float(buf + 30, 789.799561);
796 expect_dword(buf + 31, 0x03030300);
797 expect_dword(buf + 32, 0x03030301);
798 ok((*(buf + 33) & 0xffffff) == 0x030303,
799 "expected 0x??030303 got %08lx\n", *(buf + 33));
800 expect_dword(buf + 34, 0xeeeeeeee);
801 test_region_data(buf, needed, __LINE__);
802
804 expect(Ok, status);
805 status = GdipDeleteRegion(region);
806 expect(Ok, status);
807}
RECT rect
Definition: combotst.c:67
GpStatus WINGDIPAPI GdipAddPathRectangleI(GpPath *path, INT x, INT y, INT width, INT height)
GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphicspath.c:804
GpStatus WINGDIPAPI GdipClosePathFigure(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
Definition: graphicspath.c:353
GpStatus WINGDIPAPI GdipTransformRegion(GpRegion *region, GpMatrix *matrix)
Definition: region.c:1702
GpStatus WINGDIPAPI GdipTranslateRegion(GpRegion *region, REAL dx, REAL dy)
Definition: region.c:1742
GpStatus WINGDIPAPI GdipCombineRegionRectI(GpRegion *region, GDIPCONST GpRect *rect, CombineMode mode)
Definition: region.c:329
GpStatus WINGDIPAPI GdipCreateRegionRectI(GDIPCONST GpRect *rect, GpRegion **region)
Definition: region.c:488
GLuint GLenum matrix
Definition: glext.h:9407
static void test_region_data(DWORD *data, UINT size, INT line)
Definition: region.c:106
#define RGNDATA_EMPTY_RECT
Definition: region.c:30
#define expect_float(value, expected)
Definition: region.c:46

Referenced by START_TEST().

◆ test_incombinedregion()

static void test_incombinedregion ( void  )
static

Definition at line 2375 of file region.c.

2376{
2377 struct testrgn
2378 {
2379 const char* desc;
2380 BOOL origin_in_region;
2381 GpRegion *region;
2382 };
2383
2384 struct testrgn test_regions[] = {
2385 { "infinite region", TRUE },
2386 { "infinite region inverted", FALSE },
2387 { "empty region", FALSE },
2388 { "empty region inverted", TRUE },
2389 { "inside rectangle", TRUE },
2390 { "inside rectangle inverted", FALSE },
2391 { "outside rectangle", FALSE },
2392 { "outside rectangle inverted", TRUE },
2393 { "inside path", TRUE },
2394 { "inside path inverted", FALSE },
2395 { "outside path but in bounding rect", FALSE },
2396 { "outside path but in bounding rect inverted", TRUE },
2397 { "outside path", FALSE },
2398 { "outside path inverted", TRUE },
2399 };
2400
2401 GpStatus stat;
2402 GpRectF rect;
2403 const GpPointF inside_path_points[] = { { -1, -2 }, { 2, 1 }, { -1, 1 } };
2404 const GpPointF outside_path_bounding_points[] = { { -2, -1 }, { 1, 2 }, { -2, 2 } };
2405 const GpPointF outside_path_points[] = { { 5, 5 }, { 5, 10 }, { 10, 10 } };
2406 GpPath *path;
2407 int i, j;
2408 BOOL in_region;
2409
2410 /* Prepare test regions: */
2411
2412 /* infinite */
2413 stat = GdipCreateRegion(&test_regions[0].region);
2414 expect(Ok, stat);
2415
2416 /* empty */
2417 stat = GdipCreateRegion(&test_regions[2].region);
2418 expect(Ok, stat);
2419 stat = GdipSetEmpty(test_regions[2].region);
2420 expect(Ok, stat);
2421
2422 /* inside rectangle */
2423 rect.X = -5;
2424 rect.Y = -2;
2425 rect.Width = 10;
2426 rect.Height = 4;
2427 stat = GdipCreateRegionRect(&rect, &test_regions[4].region);
2428 expect(Ok, stat);
2429
2430 /* outside rectangle */
2431 rect.X = -10;
2432 rect.Y = -10;
2433 rect.Width = 7;
2434 rect.Height = 7;
2435 stat = GdipCreateRegionRect(&rect, &test_regions[6].region);
2436 expect(Ok, stat);
2437
2438 /* inside path */
2440 expect(Ok, stat);
2441 stat = GdipAddPathPolygon(path, inside_path_points, ARRAY_SIZE(inside_path_points));
2442 expect(Ok, stat);
2443 stat = GdipCreateRegion(&test_regions[8].region);
2444 expect(Ok, stat);
2445 stat = GdipCombineRegionPath(test_regions[8].region, path, CombineModeReplace);
2446 expect(Ok, stat);
2448 expect(Ok, stat);
2449
2450 /* outside path but in bounding rect */
2452 expect(Ok, stat);
2453 stat = GdipAddPathPolygon(path, outside_path_bounding_points, ARRAY_SIZE(outside_path_bounding_points));
2454 expect(Ok, stat);
2455 stat = GdipCreateRegion(&test_regions[10].region);
2456 expect(Ok, stat);
2457 stat = GdipCombineRegionPath(test_regions[10].region, path, CombineModeReplace);
2458 expect(Ok, stat);
2460 expect(Ok, stat);
2461
2462 /* outside path */
2464 expect(Ok, stat);
2465 stat = GdipAddPathPolygon(path, outside_path_points, ARRAY_SIZE(outside_path_points));
2466 expect(Ok, stat);
2467 stat = GdipCreateRegion(&test_regions[12].region);
2468 expect(Ok, stat);
2469 stat = GdipCombineRegionPath(test_regions[12].region, path, CombineModeReplace);
2470 expect(Ok, stat);
2472 expect(Ok, stat);
2473
2474 for (i = 1; i < ARRAY_SIZE(test_regions); i += 2)
2475 {
2476 winetest_push_context("%s", test_regions[i].desc);
2477 stat = GdipCreateRegion(&test_regions[i].region);
2478 expect(Ok, stat);
2479 stat = GdipCombineRegionRegion(test_regions[i].region, test_regions[i-1].region, CombineModeExclude);
2480 expect(Ok, stat);
2482 }
2483
2484 /* Check regions individually */
2485 for (i = 0; i < ARRAY_SIZE(test_regions); i++)
2486 {
2487 winetest_push_context("%s", test_regions[i].desc);
2488 stat = GdipIsVisibleRegionPoint(test_regions[i].region, 0, 0, NULL, &in_region);
2489 expect(Ok, stat);
2490 expect(test_regions[i].origin_in_region, in_region);
2492 }
2493
2494 /* Check combined regions */
2495 for (i = 0; i < ARRAY_SIZE(test_regions); i++)
2496 {
2497 for (j = 0; j < ARRAY_SIZE(test_regions); j++)
2498 {
2499 GpRegion *region;
2501
2502 winetest_push_context("%s + %s", test_regions[i].desc, test_regions[j].desc);
2503
2504 stat = GdipCreateRegion(&region);
2505 expect(Ok, stat);
2506
2507 /* CombineModeIntersect */
2508 stat = GdipCombineRegionRegion(region, test_regions[i].region, CombineModeReplace);
2509 expect(Ok, stat);
2510 stat = GdipCombineRegionRegion(region, test_regions[j].region, CombineModeIntersect);
2511 expect(Ok, stat);
2512
2513 expected_result = test_regions[i].origin_in_region & test_regions[j].origin_in_region;
2514 stat = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &in_region);
2515 expect(Ok, stat);
2516 ok(expected_result == in_region, "CombineModeIntersect: expected %i, got %i\n", expected_result, in_region);
2517
2518 /* CombineModeUnion */
2519 stat = GdipCombineRegionRegion(region, test_regions[i].region, CombineModeReplace);
2520 expect(Ok, stat);
2521 stat = GdipCombineRegionRegion(region, test_regions[j].region, CombineModeUnion);
2522 expect(Ok, stat);
2523
2524 expected_result = test_regions[i].origin_in_region | test_regions[j].origin_in_region;
2525 stat = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &in_region);
2526 expect(Ok, stat);
2527 ok(expected_result == in_region, "CombineModeUnion: expected %i, got %i\n", expected_result, in_region);
2528
2529 /* CombineModeXor */
2530 stat = GdipCombineRegionRegion(region, test_regions[i].region, CombineModeReplace);
2531 expect(Ok, stat);
2532 stat = GdipCombineRegionRegion(region, test_regions[j].region, CombineModeXor);
2533 expect(Ok, stat);
2534
2535 expected_result = test_regions[i].origin_in_region ^ test_regions[j].origin_in_region;
2536 stat = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &in_region);
2537 expect(Ok, stat);
2538 ok(expected_result == in_region, "CombineModeXor: expected %i, got %i\n", expected_result, in_region);
2539
2540 /* CombineModeExclude */
2541 stat = GdipCombineRegionRegion(region, test_regions[i].region, CombineModeReplace);
2542 expect(Ok, stat);
2543 stat = GdipCombineRegionRegion(region, test_regions[j].region, CombineModeExclude);
2544 expect(Ok, stat);
2545
2546 expected_result = test_regions[i].origin_in_region & !test_regions[j].origin_in_region;
2547 stat = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &in_region);
2548 expect(Ok, stat);
2549 ok(expected_result == in_region, "CombineModeExclude: expected %i, got %i\n", expected_result, in_region);
2550
2551 /* CombineModeComplement */
2552 stat = GdipCombineRegionRegion(region, test_regions[i].region, CombineModeReplace);
2553 expect(Ok, stat);
2554 stat = GdipCombineRegionRegion(region, test_regions[j].region, CombineModeComplement);
2555 expect(Ok, stat);
2556
2557 expected_result = (!test_regions[i].origin_in_region) & test_regions[j].origin_in_region;
2558 stat = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &in_region);
2559 expect(Ok, stat);
2560 ok(expected_result == in_region, "CombineModeComplement: expected %i, got %i\n", expected_result, in_region);
2561
2563 }
2564 }
2565
2566 for (i = 0; i < ARRAY_SIZE(test_regions); i++)
2567 {
2568 stat = GdipDeleteRegion(test_regions[i].region);
2569 expect(Ok, stat);
2570 }
2571}
#define stat
Definition: acwin.h:100
#define ARRAY_SIZE(A)
Definition: main.h:20
GpStatus WINGDIPAPI GdipAddPathPolygon(GpPath *path, GDIPCONST GpPointF *points, INT count)
Definition: graphicspath.c:932
GpStatus WINGDIPAPI GdipIsVisibleRegionPoint(GpRegion *region, REAL x, REAL y, GpGraphics *graphics, BOOL *res)
Definition: region.c:1529
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
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 GLint GLint j
Definition: glfuncs.h:250
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
const char * expected_result
Definition: mimeole.c:1468
Definition: stat.h:66

Referenced by START_TEST().

◆ test_isempty()

static void test_isempty ( void  )
static

Definition at line 857 of file region.c.

858{
860 GpRegion *region;
861 GpGraphics *graphics = NULL;
862 HDC hdc = GetDC(0);
863 BOOL res;
864
865 status = GdipCreateFromHDC(hdc, &graphics);
866 expect(Ok, status);
867 status = GdipCreateRegion(&region);
868 expect(Ok, status);
869
870 /* NULL arguments */
873 status = GdipIsEmptyRegion(region, NULL, NULL);
875 status = GdipIsEmptyRegion(NULL, graphics, NULL);
879 status = GdipIsEmptyRegion(region, NULL, &res);
881
882 /* default is infinite */
883 res = TRUE;
884 status = GdipIsEmptyRegion(region, graphics, &res);
885 expect(Ok, status);
886 expect(FALSE, res);
887
888 status = GdipSetEmpty(region);
889 expect(Ok, status);
890
891 res = FALSE;
892 status = GdipIsEmptyRegion(region, graphics, &res);
893 expect(Ok, status);
894 expect(TRUE, res);
895
896 GdipDeleteRegion(region);
897 GdipDeleteGraphics(graphics);
898 ReleaseDC(0, hdc);
899}

Referenced by START_TEST().

◆ test_isequal()

static void test_isequal ( void  )
static

Definition at line 1280 of file region.c.

1281{
1282 GpRegion *region1, *region2;
1283 GpGraphics *graphics;
1284 GpRectF rectf;
1286 HDC hdc = GetDC(0);
1287 BOOL res;
1288
1289 status = GdipCreateFromHDC(hdc, &graphics);
1290 ok(status == Ok, "status %08x\n", status);
1291
1292 status = GdipCreateRegion(&region1);
1293 ok(status == Ok, "status %08x\n", status);
1294 status = GdipCreateRegion(&region2);
1295 ok(status == Ok, "status %08x\n", status);
1296
1297 /* NULL */
1299 ok(status == InvalidParameter, "status %08x\n", status);
1300 status = GdipIsEqualRegion(region1, region2, NULL, NULL);
1301 ok(status == InvalidParameter, "status %08x\n", status);
1302 status = GdipIsEqualRegion(region1, region2, graphics, NULL);
1303 ok(status == InvalidParameter, "status %08x\n", status);
1304 status = GdipIsEqualRegion(region1, region2, NULL, &res);
1305 ok(status == InvalidParameter, "status %08x\n", status);
1306
1307 /* infinite regions */
1308 res = FALSE;
1309 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1310 ok(status == Ok, "status %08x\n", status);
1311 ok(res, "Expected to be equal.\n");
1312 /* empty regions */
1313 status = GdipSetEmpty(region1);
1314 ok(status == Ok, "status %08x\n", status);
1315 status = GdipSetEmpty(region2);
1316 ok(status == Ok, "status %08x\n", status);
1317 res = FALSE;
1318 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1319 ok(status == Ok, "status %08x\n", status);
1320 ok(res, "Expected to be equal.\n");
1321 /* empty & infinite */
1322 status = GdipSetInfinite(region1);
1323 ok(status == Ok, "status %08x\n", status);
1324 res = TRUE;
1325 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1326 ok(status == Ok, "status %08x\n", status);
1327 ok(!res, "Expected to be unequal.\n");
1328 /* rect & (inf/empty) */
1329 rectf.X = rectf.Y = 0.0;
1330 rectf.Width = rectf.Height = 100.0;
1332 ok(status == Ok, "status %08x\n", status);
1333 res = TRUE;
1334 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1335 ok(status == Ok, "status %08x\n", status);
1336 ok(!res, "Expected to be unequal.\n");
1337 status = GdipSetInfinite(region2);
1338 ok(status == Ok, "status %08x\n", status);
1339 res = TRUE;
1340 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1341 ok(status == Ok, "status %08x\n", status);
1342 ok(!res, "Expected to be unequal.\n");
1343 /* roughly equal rectangles */
1344 rectf.X = rectf.Y = 0.0;
1345 rectf.Width = rectf.Height = 100.001;
1347 ok(status == Ok, "status %08x\n", status);
1348 res = FALSE;
1349 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1350 ok(status == Ok, "status %08x\n", status);
1351 ok(res, "Expected to be equal.\n");
1352 /* equal rectangles */
1353 rectf.X = rectf.Y = 0.0;
1354 rectf.Width = rectf.Height = 100.0;
1356 ok(status == Ok, "status %08x\n", status);
1357 res = FALSE;
1358 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1359 ok(status == Ok, "status %08x\n", status);
1360 ok(res, "Expected to be equal.\n");
1361
1362 /* cleanup */
1363 status = GdipDeleteRegion(region1);
1364 ok(status == Ok, "status %08x\n", status);
1365 status = GdipDeleteRegion(region2);
1366 ok(status == Ok, "status %08x\n", status);
1367 status = GdipDeleteGraphics(graphics);
1368 ok(status == Ok, "status %08x\n", status);
1369 ReleaseDC(0, hdc);
1370}
GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *region, GpRegion *region2, GpGraphics *graphics, BOOL *res)
Definition: region.c:1233

Referenced by START_TEST().

◆ test_isinfinite()

static void test_isinfinite ( void  )
static

Definition at line 809 of file region.c.

810{
812 GpRegion *region;
813 GpGraphics *graphics = NULL;
814 GpMatrix *m;
815 HDC hdc = GetDC(0);
816 BOOL res;
817
818 status = GdipCreateFromHDC(hdc, &graphics);
819 expect(Ok, status);
820 status = GdipCreateRegion(&region);
821 expect(Ok, status);
822
823 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m);
824
825 /* NULL arguments */
830 status = GdipIsInfiniteRegion(NULL, graphics, NULL);
834 status = GdipIsInfiniteRegion(region, NULL, &res);
836
837 res = FALSE;
838 status = GdipIsInfiniteRegion(region, graphics, &res);
839 expect(Ok, status);
840 expect(TRUE, res);
841
842 /* after world transform */
843 status = GdipSetWorldTransform(graphics, m);
844 expect(Ok, status);
845
846 res = FALSE;
847 status = GdipIsInfiniteRegion(region, graphics, &res);
848 expect(Ok, status);
849 expect(TRUE, res);
850
852 GdipDeleteRegion(region);
853 GdipDeleteGraphics(graphics);
854 ReleaseDC(0, hdc);
855}
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:6724
GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
Definition: matrix.c:59
const GLfloat * m
Definition: glext.h:10848

Referenced by START_TEST().

◆ test_isvisiblepoint()

static void test_isvisiblepoint ( void  )
static

Definition at line 1856 of file region.c.

1857{
1858 HDC hdc = GetDC(0);
1859 GpGraphics* graphics;
1860 GpRegion* region;
1861 GpPath* path;
1862 GpRectF rectf;
1864 BOOL res;
1865 REAL x, y;
1866
1867 status = GdipCreateFromHDC(hdc, &graphics);
1868 expect(Ok, status);
1869
1870 status = GdipCreateRegion(&region);
1871 expect(Ok, status);
1872
1873 /* null parameters */
1874 status = GdipIsVisibleRegionPoint(NULL, 0, 0, graphics, &res);
1876 status = GdipIsVisibleRegionPointI(NULL, 0, 0, graphics, &res);
1878
1879 status = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &res);
1880 expect(Ok, status);
1881 status = GdipIsVisibleRegionPointI(region, 0, 0, NULL, &res);
1882 expect(Ok, status);
1883
1884 status = GdipIsVisibleRegionPoint(region, 0, 0, graphics, NULL);
1886 status = GdipIsVisibleRegionPointI(region, 0, 0, graphics, NULL);
1888
1889 /* infinite region */
1890 status = GdipIsInfiniteRegion(region, graphics, &res);
1891 expect(Ok, status);
1892 ok(res == TRUE, "Region should be infinite\n");
1893
1894 x = 10;
1895 y = 10;
1896 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1897 expect(Ok, status);
1898 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1899 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1900 expect(Ok, status);
1901 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1902
1903 x = -10;
1904 y = -10;
1905 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1906 expect(Ok, status);
1907 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1908 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1909 expect(Ok, status);
1910 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1911
1912 /* rectangular region */
1913 rectf.X = 10;
1914 rectf.Y = 20;
1915 rectf.Width = 30;
1916 rectf.Height = 40;
1917
1919 expect(Ok, status);
1920
1921 x = 0;
1922 y = 0;
1923 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1924 expect(Ok, status);
1925 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1926 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1927 expect(Ok, status);
1928 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1929
1930 x = 9;
1931 y = 19;
1932 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1933 expect(Ok, status);
1934 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1935
1936 x = 9.25;
1937 y = 19.25;
1938 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1939 expect(Ok, status);
1940 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1941
1942 x = 9.5;
1943 y = 19.5;
1944 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1945 expect(Ok, status);
1946 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1947
1948 x = 9.75;
1949 y = 19.75;
1950 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1951 expect(Ok, status);
1952 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1953
1954 x = 10;
1955 y = 20;
1956 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1957 expect(Ok, status);
1958 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1959
1960 x = 25;
1961 y = 40;
1962 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1963 expect(Ok, status);
1964 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1965 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1966 expect(Ok, status);
1967 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1968
1969 x = 40;
1970 y = 60;
1971 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1972 expect(Ok, status);
1973 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1974 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1975 expect(Ok, status);
1976 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1977
1978 /* translate into the center of the rectangle */
1980 expect(Ok, status);
1981
1982 /* native ignores the world transform, so treat these as if
1983 * no transform exists */
1984 x = -20;
1985 y = -30;
1986 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1987 expect(Ok, status);
1988 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1989 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1990 expect(Ok, status);
1991 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1992
1993 x = 0;
1994 y = 0;
1995 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1996 expect(Ok, status);
1997 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1998 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1999 expect(Ok, status);
2000 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
2001
2002 x = 25;
2003 y = 40;
2004 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
2005 expect(Ok, status);
2006 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2007 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
2008 expect(Ok, status);
2009 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
2010
2011 /* translate back to origin */
2013 expect(Ok, status);
2014
2015 /* region from path */
2017 expect(Ok, status);
2018
2019 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
2020 expect(Ok, status);
2021
2023 expect(Ok, status);
2024
2025 x = 11;
2026 y = 21;
2027 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
2028 expect(Ok, status);
2029 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2030 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
2031 expect(Ok, status);
2032 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
2033
2034 x = 25;
2035 y = 40;
2036 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
2037 expect(Ok, status);
2038 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2039 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
2040 expect(Ok, status);
2041 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
2042
2043 x = 40;
2044 y = 60;
2045 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
2046 expect(Ok, status);
2047 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2048 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
2049 expect(Ok, status);
2050 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
2051
2053
2054 GdipDeleteRegion(region);
2055 GdipDeleteGraphics(graphics);
2056 ReleaseDC(0, hdc);
2057}
GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx, REAL dy, GpMatrixOrder order)
Definition: graphics.c:6748
GpStatus WINGDIPAPI GdipIsVisibleRegionPointI(GpRegion *region, INT x, INT y, GpGraphics *graphics, BOOL *res)
Definition: region.c:1571
@ MatrixOrderAppend
Definition: gdiplusenums.h:188
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by START_TEST().

◆ test_isvisiblerect()

static void test_isvisiblerect ( void  )
static

Definition at line 2059 of file region.c.

2060{
2061 HDC hdc = GetDC(0);
2062 GpGraphics* graphics;
2063 GpRegion* region;
2064 GpPath* path;
2065 GpRectF rectf;
2067 BOOL res;
2068 REAL x, y, w, h;
2069
2070 status = GdipCreateFromHDC(hdc, &graphics);
2071 expect(Ok, status);
2072
2073 status = GdipCreateRegion(&region);
2074 expect(Ok, status);
2075
2076 /* null parameters */
2077 status = GdipIsVisibleRegionRect(NULL, 0, 0, 0, 0, graphics, &res);
2079 status = GdipIsVisibleRegionRectI(NULL, 0, 0, 0, 0, graphics, &res);
2081
2082 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, NULL, &res);
2083 expect(Ok, status);
2084 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, NULL, &res);
2085 expect(Ok, status);
2086
2087 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, graphics, NULL);
2089 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, graphics, NULL);
2091
2092 /* infinite region */
2093 status = GdipIsInfiniteRegion(region, graphics, &res);
2094 expect(Ok, status);
2095 ok(res == TRUE, "Region should be infinite\n");
2096
2097 x = 10; w = 10;
2098 y = 10; h = 10;
2099 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2100 expect(Ok, status);
2101 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2102
2103 x = -10; w = 5;
2104 y = -10; h = 5;
2105 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2106 expect(Ok, status);
2107 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2108
2109 /* rectangular region */
2110 rectf.X = 10;
2111 rectf.Y = 20;
2112 rectf.Width = 30;
2113 rectf.Height = 40;
2114
2116 expect(Ok, status);
2117
2118 /* entirely within the region */
2119 x = 11; w = 10;
2120 y = 12; h = 10;
2121 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2122 expect(Ok, status);
2123 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2124 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2125 expect(Ok, status);
2126 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2127
2128 /* entirely outside of the region */
2129 x = 0; w = 5;
2130 y = 0; h = 5;
2131 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2132 expect(Ok, status);
2133 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2134 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2135 expect(Ok, status);
2136 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2137
2138 /* corner cases */
2139 x = 0; w = 10;
2140 y = 0; h = 20;
2141 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2142 expect(Ok, status);
2143 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2144
2145 x = 0; w = 10.25;
2146 y = 0; h = 20.25;
2147 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2148 expect(Ok, status);
2149 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2150
2151 x = 39; w = 10;
2152 y = 59; h = 10;
2153 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2154 expect(Ok, status);
2155 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2156
2157 x = 39.25; w = 10;
2158 y = 59.25; h = 10;
2159 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2160 expect(Ok, status);
2161 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2162
2163 /* corners outside, but some intersection */
2164 x = 0; w = 100;
2165 y = 0; h = 100;
2166 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2167 expect(Ok, status);
2168 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2169
2170 x = 0; w = 100;
2171 y = 0; h = 40;
2172 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2173 expect(Ok, status);
2174 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2175
2176 x = 0; w = 25;
2177 y = 0; h = 100;
2178 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2179 expect(Ok, status);
2180 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2181
2182 /* translate into the center of the rectangle */
2184 expect(Ok, status);
2185
2186 /* native ignores the world transform, so treat these as if
2187 * no transform exists */
2188 x = 0; w = 5;
2189 y = 0; h = 5;
2190 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2191 expect(Ok, status);
2192 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2193 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2194 expect(Ok, status);
2195 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2196
2197 x = 11; w = 10;
2198 y = 12; h = 10;
2199 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2200 expect(Ok, status);
2201 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2202 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2203 expect(Ok, status);
2204 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2205
2206 /* translate back to origin */
2208 expect(Ok, status);
2209
2210 /* region from path */
2212 expect(Ok, status);
2213
2214 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
2215 expect(Ok, status);
2216
2218 expect(Ok, status);
2219
2220 x = 0; w = 12;
2221 y = 0; h = 22;
2222 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2223 expect(Ok, status);
2224 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2225 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2226 expect(Ok, status);
2227 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2228
2229 x = 0; w = 25;
2230 y = 0; h = 40;
2231 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2232 expect(Ok, status);
2233 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2234 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2235 expect(Ok, status);
2236 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2237
2238 x = 38; w = 10;
2239 y = 55; h = 10;
2240 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2241 expect(Ok, status);
2242 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2243 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2244 expect(Ok, status);
2245 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2246
2247 x = 0; w = 100;
2248 y = 0; h = 100;
2249 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2250 expect(Ok, status);
2251 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2252 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2253 expect(Ok, status);
2254 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2255
2257
2258 GdipDeleteRegion(region);
2259 GdipDeleteGraphics(graphics);
2260 ReleaseDC(0, hdc);
2261}
GpStatus WINGDIPAPI GdipIsVisibleRegionRect(GpRegion *region, REAL x, REAL y, REAL w, REAL h, GpGraphics *graphics, BOOL *res)
Definition: region.c:1284
GpStatus WINGDIPAPI GdipIsVisibleRegionRectI(GpRegion *region, INT x, INT y, INT w, INT h, GpGraphics *graphics, BOOL *res)
Definition: region.c:1315
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

Referenced by START_TEST().

◆ test_region_data()

static void test_region_data ( DWORD data,
UINT  size,
INT  line 
)
static

Definition at line 106 of file region.c.

107{
109 GpRegion *region;
110 DWORD buf[256];
111 UINT needed, i;
112
114 /* Windows always fails to create an empty path in a region */
115 if (data[4] == RGNDATA_PATH)
116 {
117 struct path_header
118 {
119 DWORD size;
120 DWORD magic;
121 DWORD count;
122 DWORD flags;
123 } *path_header = (struct path_header *)(data + 5);
124 if (!path_header->count)
125 {
126 ok_(__FILE__, line)(status == GenericError, "expected GenericError, got %d\n", status);
127 return;
128 }
129 }
130
131 ok_(__FILE__, line)(status == Ok, "GdipCreateRegionRgnData error %d\n", status);
132 if (status != Ok) return;
133
134 needed = 0;
135 status = GdipGetRegionDataSize(region, &needed);
136 ok_(__FILE__, line)(status == Ok, "status %d\n", status);
137 ok_(__FILE__, line)(needed == size, "data size mismatch: %u != %u\n", needed, size);
138
139 memset(buf, 0xee, sizeof(buf));
140 needed = 0;
141 status = GdipGetRegionData(region, (BYTE *)buf, sizeof(buf), &needed);
142 ok_(__FILE__, line)(status == Ok, "status %08x\n", status);
143 ok_(__FILE__, line)(needed == size, "data size mismatch: %u != %u\n", needed, size);
144
145 size /= sizeof(DWORD);
146 for (i = 0; i < size - 1; i++)
147 {
148 if (i == 1) continue; /* data[1] never matches */
149 ok_(__FILE__, line)(data[i] == buf[i], "off %u: %#lx != %#lx\n", i, data[i], buf[i]);
150 }
151 /* some Windows versions fail to properly clear the aligned DWORD */
152 ok_(__FILE__, line)(data[size - 1] == buf[size - 1] || broken(data[size - 1] != buf[size - 1]),
153 "off %u: %#lx != %#lx\n", size - 1, data[size - 1], buf[size - 1]);
154
155 GdipDeleteRegion(region);
156}
#define broken(x)
Definition: atltest.h:178
@ GenericError
Definition: gdiplustypes.h:26
#define DWORD
Definition: nt_native.h:44
DWORD size
Definition: region.c:95
DWORD magic
Definition: region.c:96

Referenced by test_getregiondata().

◆ test_scans()

static void test_scans ( void  )
static

Definition at line 1594 of file region.c.

1595{
1596 GpRegion *region;
1598 GpRectF rectf;
1600 UINT count=80085;
1601 INT icount;
1602 GpRectF scans[2];
1603 GpRect scansi[2];
1604
1605 status = GdipCreateRegion(&region);
1606 expect(Ok, status);
1607
1609 expect(Ok, status);
1610
1611 /* test NULL values */
1614
1617
1620
1621 status = GdipGetRegionScans(NULL, scans, &icount, matrix);
1623
1624 status = GdipGetRegionScans(region, scans, NULL, matrix);
1626
1627 status = GdipGetRegionScans(region, scans, &icount, NULL);
1629
1630 /* infinite */
1632 expect(Ok, status);
1633 expect(1, count);
1634
1635 status = GdipGetRegionScans(region, NULL, &icount, matrix);
1636 expect(Ok, status);
1637 expect(1, icount);
1638
1639 status = GdipGetRegionScans(region, scans, &icount, matrix);
1640 expect(Ok, status);
1641 expect(1, icount);
1642
1643 status = GdipGetRegionScansI(region, scansi, &icount, matrix);
1644 expect(Ok, status);
1645 expect(1, icount);
1646 expect(-0x400000, scansi[0].X);
1647 expect(-0x400000, scansi[0].Y);
1648 expect(0x800000, scansi[0].Width);
1649 expect(0x800000, scansi[0].Height);
1650
1651 status = GdipGetRegionScans(region, scans, &icount, matrix);
1652 expect(Ok, status);
1653 expect(1, icount);
1654 expectf((double)-0x400000, scans[0].X);
1655 expectf((double)-0x400000, scans[0].Y);
1656 expectf((double)0x800000, scans[0].Width);
1657 expectf((double)0x800000, scans[0].Height);
1658
1659 /* empty */
1660 status = GdipSetEmpty(region);
1661 expect(Ok, status);
1662
1664 expect(Ok, status);
1665 expect(0, count);
1666
1667 status = GdipGetRegionScans(region, scans, &icount, matrix);
1668 expect(Ok, status);
1669 expect(0, icount);
1670
1671 /* single rectangle */
1672 rectf.X = rectf.Y = 0.0;
1673 rectf.Width = rectf.Height = 5.0;
1675 expect(Ok, status);
1676
1678 expect(Ok, status);
1679 expect(1, count);
1680
1681 status = GdipGetRegionScans(region, scans, &icount, matrix);
1682 expect(Ok, status);
1683 expect(1, icount);
1684 expectf(0.0, scans[0].X);
1685 expectf(0.0, scans[0].Y);
1686 expectf(5.0, scans[0].Width);
1687 expectf(5.0, scans[0].Height);
1688
1689 /* two rectangles */
1690 rectf.X = rectf.Y = 5.0;
1691 rectf.Width = rectf.Height = 5.0;
1693 expect(Ok, status);
1694
1696 expect(Ok, status);
1697 expect(2, count);
1698
1699 /* Native ignores the initial value of count */
1700 scans[1].X = scans[1].Y = scans[1].Width = scans[1].Height = 8.0;
1701 icount = 1;
1702 status = GdipGetRegionScans(region, scans, &icount, matrix);
1703 expect(Ok, status);
1704 expect(2, icount);
1705 expectf(0.0, scans[0].X);
1706 expectf(0.0, scans[0].Y);
1707 expectf(5.0, scans[0].Width);
1708 expectf(5.0, scans[0].Height);
1709 expectf(5.0, scans[1].X);
1710 expectf(5.0, scans[1].Y);
1711 expectf(5.0, scans[1].Width);
1712 expectf(5.0, scans[1].Height);
1713
1714 status = GdipGetRegionScansI(region, scansi, &icount, matrix);
1715 expect(Ok, status);
1716 expect(2, icount);
1717 expect(0, scansi[0].X);
1718 expect(0, scansi[0].Y);
1719 expect(5, scansi[0].Width);
1720 expect(5, scansi[0].Height);
1721 expect(5, scansi[1].X);
1722 expect(5, scansi[1].Y);
1723 expect(5, scansi[1].Width);
1724 expect(5, scansi[1].Height);
1725
1726 status = GdipDeleteRegion(region);
1727 expect(Ok, status);
1729 expect(Ok, status);
1730}
GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *region, GpRect *scans, INT *count, GpMatrix *matrix)
Definition: region.c:1844

Referenced by START_TEST().

◆ test_transform()

static void test_transform ( void  )
static

Definition at line 1465 of file region.c.

1466{
1467 GpRegion *region, *region2;
1469 GpGraphics *graphics;
1470 GpPath *path;
1471 GpRectF rectf;
1473 HDC hdc = GetDC(0);
1474 BOOL res;
1475 DWORD type;
1476
1477 status = GdipCreateFromHDC(hdc, &graphics);
1478 expect(Ok, status);
1479
1481 expect(Ok, status);
1482
1483 status = GdipCreateRegion(&region);
1484 expect(Ok, status);
1485 status = GdipCreateRegion(&region2);
1486 expect(Ok, status);
1487
1489 expect(Ok, status);
1491 expect(Ok, status);
1492
1493 /* NULL */
1496
1497 status = GdipTransformRegion(region, NULL);
1499
1500 /* infinite */
1502 expect(Ok, status);
1503
1504 res = FALSE;
1505 status = GdipIsEqualRegion(region, region2, graphics, &res);
1506 expect(Ok, status);
1507 ok(res, "Expected to be equal.\n");
1508 type = get_region_type(region);
1509 expect(0x10000003 /* RegionDataInfiniteRect */, type);
1510
1511 /* empty */
1512 status = GdipSetEmpty(region);
1513 expect(Ok, status);
1515 expect(Ok, status);
1516
1517 status = GdipSetEmpty(region2);
1518 expect(Ok, status);
1519
1520 res = FALSE;
1521 status = GdipIsEqualRegion(region, region2, graphics, &res);
1522 expect(Ok, status);
1523 ok(res, "Expected to be equal.\n");
1524 type = get_region_type(region);
1525 expect(0x10000002 /* RegionDataEmptyRect */, type);
1526
1527 /* rect */
1528 rectf.X = 10.0;
1529 rectf.Y = 0.0;
1530 rectf.Width = rectf.Height = 100.0;
1532 expect(Ok, status);
1533 rectf.X = 20.0;
1534 rectf.Y = 0.0;
1535 rectf.Width = 200.0;
1536 rectf.Height = 300.0;
1538 expect(Ok, status);
1540 expect(Ok, status);
1541 res = FALSE;
1542 status = GdipIsEqualRegion(region, region2, graphics, &res);
1543 expect(Ok, status);
1544 ok(res, "Expected to be equal.\n");
1545 type = get_region_type(region);
1546 expect(0x10000000 /* RegionDataRect */, type);
1547
1548 /* path */
1549 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1550 expect(Ok, status);
1552 expect(Ok, status);
1554 expect(Ok, status);
1555 status = GdipAddPathEllipse(path, 0.0, 30.0, 200.0, 450.0);
1556 expect(Ok, status);
1558 expect(Ok, status);
1560 expect(Ok, status);
1561 res = FALSE;
1562 status = GdipIsEqualRegion(region, region2, graphics, &res);
1563 expect(Ok, status);
1564 ok(res, "Expected to be equal.\n");
1565 type = get_region_type(region);
1566 expect(0x10000001 /* RegionDataPath */, type);
1567
1568 /* rotated rect -> path */
1569 rectf.X = 10.0;
1570 rectf.Y = 0.0;
1571 rectf.Width = rectf.Height = 100.0;
1573 expect(Ok, status);
1575 expect(Ok, status);
1577 expect(Ok, status);
1578 type = get_region_type(region);
1579 expect(0x10000001 /* RegionDataPath */, type);
1580
1581 status = GdipDeleteRegion(region);
1582 expect(Ok, status);
1583 status = GdipDeleteRegion(region2);
1584 expect(Ok, status);
1585 status = GdipDeleteGraphics(graphics);
1586 expect(Ok, status);
1588 expect(Ok, status);
1590 expect(Ok, status);
1591 ReleaseDC(0, hdc);
1592}
GpStatus WINGDIPAPI GdipResetPath(GpPath *path)
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:288
GpStatus WINGDIPAPI GdipRotateMatrix(GpMatrix *matrix, REAL angle, GpMatrixOrder order)
Definition: matrix.c:257
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static DWORD get_region_type(GpRegion *region)
Definition: region.c:1449

Referenced by START_TEST().

◆ test_translate()

static void test_translate ( void  )
static

Definition at line 1372 of file region.c.

1373{
1374 GpRegion *region, *region2;
1375 GpGraphics *graphics;
1376 GpPath *path;
1377 GpRectF rectf;
1379 HDC hdc = GetDC(0);
1380 BOOL res;
1381
1382 status = GdipCreateFromHDC(hdc, &graphics);
1383 ok(status == Ok, "status %08x\n", status);
1384
1386 ok(status == Ok, "status %08x\n", status);
1387
1388 status = GdipCreateRegion(&region);
1389 ok(status == Ok, "status %08x\n", status);
1390 status = GdipCreateRegion(&region2);
1391 ok(status == Ok, "status %08x\n", status);
1392
1393 /* NULL */
1394 status = GdipTranslateRegion(NULL, 0.0, 0.0);
1395 ok(status == InvalidParameter, "status %08x\n", status);
1396
1397 /* infinite */
1398 status = GdipTranslateRegion(region, 10.0, 10.0);
1399 ok(status == Ok, "status %08x\n", status);
1400 /* empty */
1401 status = GdipSetEmpty(region);
1402 ok(status == Ok, "status %08x\n", status);
1403 status = GdipTranslateRegion(region, 10.0, 10.0);
1404 ok(status == Ok, "status %08x\n", status);
1405 /* rect */
1406 rectf.X = 10.0; rectf.Y = 0.0;
1407 rectf.Width = rectf.Height = 100.0;
1409 ok(status == Ok, "status %08x\n", status);
1410 rectf.X = 15.0; rectf.Y = -2.0;
1411 rectf.Width = rectf.Height = 100.0;
1413 ok(status == Ok, "status %08x\n", status);
1414 status = GdipTranslateRegion(region, 5.0, -2.0);
1415 ok(status == Ok, "status %08x\n", status);
1416 res = FALSE;
1417 status = GdipIsEqualRegion(region, region2, graphics, &res);
1418 ok(status == Ok, "status %08x\n", status);
1419 ok(res, "Expected to be equal.\n");
1420 /* path */
1421 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1422 ok(status == Ok, "status %08x\n", status);
1424 ok(status == Ok, "status %08x\n", status);
1426 ok(status == Ok, "status %08x\n", status);
1427 status = GdipAddPathEllipse(path, 10.0, 21.0, 100.0, 150.0);
1428 ok(status == Ok, "status %08x\n", status);
1430 ok(status == Ok, "status %08x\n", status);
1431 status = GdipTranslateRegion(region, 10.0, 11.0);
1432 ok(status == Ok, "status %08x\n", status);
1433 res = FALSE;
1434 status = GdipIsEqualRegion(region, region2, graphics, &res);
1435 ok(status == Ok, "status %08x\n", status);
1436 ok(res, "Expected to be equal.\n");
1437
1438 status = GdipDeleteRegion(region);
1439 ok(status == Ok, "status %08x\n", status);
1440 status = GdipDeleteRegion(region2);
1441 ok(status == Ok, "status %08x\n", status);
1442 status = GdipDeleteGraphics(graphics);
1443 ok(status == Ok, "status %08x\n", status);
1445 ok(status == Ok, "status %08x\n", status);
1446 ReleaseDC(0, hdc);
1447}

Referenced by START_TEST().

◆ verify_region()

static void verify_region ( HRGN  hrgn,
const RECT rc 
)
static

Definition at line 54 of file region.c.

55{
56 union
57 {
59 char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
60 } rgn;
61 const RECT *rect;
62 DWORD ret;
63
65 if (IsRectEmpty(rc))
66 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %lu\n", ret);
67 else
68 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %lu\n", ret);
69
70 if (!ret) return;
71
72 ret = GetRegionData(hrgn, sizeof(rgn), &rgn.data);
73 if (IsRectEmpty(rc))
74 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %lu\n", ret);
75 else
76 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %lu\n", ret);
77
78 trace("size %lu, type %lu, count %lu, rgn size %lu, bound %s\n",
79 rgn.data.rdh.dwSize, rgn.data.rdh.iType,
80 rgn.data.rdh.nCount, rgn.data.rdh.nRgnSize,
81 wine_dbgstr_rect(&rgn.data.rdh.rcBound));
82 if (rgn.data.rdh.nCount != 0)
83 {
84 rect = (const RECT *)rgn.data.Buffer;
85 trace("rect %s\n", wine_dbgstr_rect(rect));
86 ok(EqualRect(rect, rc), "expected %s, got %s\n",
88 }
89
90 ok(rgn.data.rdh.dwSize == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %lu\n", rgn.data.rdh.dwSize);
91 ok(rgn.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %lu\n", rgn.data.rdh.iType);
92 if (IsRectEmpty(rc))
93 {
94 ok(rgn.data.rdh.nCount == 0, "expected 0, got %lu\n", rgn.data.rdh.nCount);
95 ok(rgn.data.rdh.nRgnSize == 0, "expected 0, got %lu\n", rgn.data.rdh.nRgnSize);
96 }
97 else
98 {
99 ok(rgn.data.rdh.nCount == 1, "expected 1, got %lu\n", rgn.data.rdh.nCount);
100 ok(rgn.data.rdh.nRgnSize == sizeof(RECT), "expected sizeof(RECT), got %lu\n", rgn.data.rdh.nRgnSize);
101 }
102 ok(EqualRect(&rgn.data.rdh.rcBound, rc), "expected %s, got %s\n",
103 wine_dbgstr_rect(rc), wine_dbgstr_rect(&rgn.data.rdh.rcBound));
104}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
struct _RGNDATAHEADER RGNDATAHEADER
#define RDH_RECTANGLES
Definition: wingdi.h:669
DWORD WINAPI GetRegionData(_In_ HRGN hrgn, _In_ DWORD nCount, _Out_writes_bytes_to_opt_(nCount, return) LPRGNDATA lpRgnData)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by test_gethrgn().