ReactOS 0.4.15-dev-7889-g76290a6
graphics.c File Reference
#include <math.h>
#include "objbase.h"
#include "gdiplus.h"
#include "wine/test.h"
Include dependency graph for graphics.c:

Go to the source code of this file.

Classes

struct  node
 

Macros

#define expect(expected, got)   ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(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 BLUE_COLOR   (0xff0000ff)
 
#define is_blue_color(color)   ( ((color) & 0x00ffffff) == 0xff )
 
#define get_bitmap_pixel(x, y)   pixel[(y)*(width) + (x)]
 

Typedefs

typedef struct node node
 

Functions

static GpStatus (WINAPI *pGdipGraphicsSetAbort)(GpGraphics *
 
static void set_rect_empty (RectF *rc)
 
static REAL units_to_pixels (REAL units, GpUnit unit, REAL dpi)
 
static REAL pixels_to_units (REAL pixels, GpUnit unit, REAL dpi)
 
static REAL units_scale (GpUnit from, GpUnit to, REAL dpi)
 
static GpGraphicscreate_graphics (REAL res_x, REAL res_y, GpUnit unit, REAL scale, GpImage **image)
 
static void test_constructor_destructor (void)
 
static void log_state (GraphicsState data, node **log)
 
static void check_no_duplicates (node *log)
 
static void test_save_restore (void)
 
static void test_GdipFillClosedCurve2 (void)
 
static void test_GdipFillClosedCurve2I (void)
 
static void test_GdipDrawArc (void)
 
static void test_GdipDrawArcI (void)
 
static void test_BeginContainer2 (void)
 
static void test_GdipDrawBezierI (void)
 
static void test_GdipDrawCurve3 (void)
 
static void test_GdipDrawCurve3I (void)
 
static void test_GdipDrawCurve2 (void)
 
static void test_GdipDrawCurve2I (void)
 
static void test_GdipDrawCurve (void)
 
static void test_GdipDrawCurveI (void)
 
static void test_GdipDrawLineI (void)
 
static void test_GdipDrawImagePointsRect (void)
 
static void test_GdipDrawLinesI (void)
 
static void test_GdipFillClosedCurve (void)
 
static void test_GdipFillClosedCurveI (void)
 
static void test_GdipFillPath (void)
 
static void test_Get_Release_DC (void)
 
static void test_transformpoints (void)
 
static void test_get_set_clip (void)
 
static void test_clip_xform (void)
 
static void test_isempty (void)
 
static void test_clear (void)
 
static void test_textcontrast (void)
 
static void test_GdipDrawString (void)
 
static void test_GdipGetVisibleClipBounds_screen (void)
 
static void test_GdipGetVisibleClipBounds_window (void)
 
static void test_GdipGetVisibleClipBounds (void)
 
static void test_fromMemoryBitmap (void)
 
static void test_GdipIsVisiblePoint (void)
 
static void test_GdipIsVisibleRect (void)
 
static void test_GdipGetNearestColor (void)
 
static void test_string_functions (void)
 
static void test_get_set_interpolation (void)
 
static void test_get_set_textrenderinghint (void)
 
static void test_getdc_scaled (void)
 
static void test_GdipMeasureString (void)
 
static void test_transform (void)
 
static void test_pen_thickness (void)
 
static void test_font_height_scaling (void)
 
static void test_measure_string (void)
 
static void test_measured_extra_space (void)
 
static void test_alpha_hdc (void)
 
static void test_bitmapfromgraphics (void)
 
static void test_clipping (void)
 
static void test_clipping_2 (void)
 
static void test_GdipFillRectangles (void)
 
static void test_GdipGetVisibleClipBounds_memoryDC (void)
 
static void test_container_rects (void)
 
static void test_GdipGraphicsSetAbort (void)
 
static DWORDGetBitmapPixelBuffer (HDC hdc, HBITMAP hbmp, int width, int height)
 
static void test_GdipFillRectanglesOnMemoryDCSolidBrush (void)
 
static void test_GdipFillRectanglesOnMemoryDCTextureBrush (void)
 
static void test_GdipFillRectanglesOnBitmapTextureBrush (void)
 
static void test_GdipDrawImagePointsRectOnMemoryDC (void)
 
static void test_cliphrgn_transform (void)
 
static void test_hdc_caching (void)
 
 START_TEST (graphics)
 

Variables

static GdiplusAbort *static const REAL mm_per_inch = 25.4
 
static const REAL point_per_inch = 72.0
 
static HWND hwnd
 

Macro Definition Documentation

◆ BLUE_COLOR

#define BLUE_COLOR   (0xff0000ff)

Definition at line 6349 of file graphics.c.

◆ expect

#define expect (   expected,
  got 
)    ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))

Definition at line 28 of file graphics.c.

◆ expectf

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

Definition at line 30 of file graphics.c.

◆ expectf_

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

Definition at line 29 of file graphics.c.

◆ get_bitmap_pixel

#define get_bitmap_pixel (   x,
  y 
)    pixel[(y)*(width) + (x)]

Definition at line 6351 of file graphics.c.

◆ is_blue_color

#define is_blue_color (   color)    ( ((color) & 0x00ffffff) == 0xff )

Definition at line 6350 of file graphics.c.

Typedef Documentation

◆ node

typedef struct node node

Function Documentation

◆ check_no_duplicates()

static void check_no_duplicates ( node log)
static

Definition at line 186 of file graphics.c.

187{
188 INT dups = 0;
189 node * temp = NULL;
190 node * temp2 = NULL;
191 node * orig = log;
192
193 if(!log)
194 goto end;
195
196 do{
197 temp = log;
198 while((temp = temp->next)){
199 if(log->data == temp->data){
200 dups++;
201 break;
202 }
203 if(dups > 0)
204 break;
205 }
206 }while((log = log->next));
207
208 temp = orig;
209 do{
210 temp2 = temp->next;
212 temp = temp2;
213 }while(temp);
214
215end:
216 expect(0, dups);
217}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
GLuint GLuint end
Definition: gl.h:1545
#define expect(expected, got)
Definition: graphics.c:28
static calc_node_t temp
Definition: rpn_ieee.c:38
#define log(outFile, fmt,...)
Definition: util.h:15
struct define * next
Definition: compiler.c:65
int32_t INT
Definition: typedefs.h:58
Definition: dlist.c:348

Referenced by test_save_restore().

◆ create_graphics()

static GpGraphics * create_graphics ( REAL  res_x,
REAL  res_y,
GpUnit  unit,
REAL  scale,
GpImage **  image 
)
static

Definition at line 96 of file graphics.c.

97{
99 union
100 {
102 GpImage *image;
103 } u;
104 GpGraphics *graphics = NULL;
105 REAL res;
106
108 expect(Ok, status);
109
110 status = GdipBitmapSetResolution(u.bitmap, res_x, res_y);
111 expect(Ok, status);
113 expect(Ok, status);
114 expectf(res_x, res);
116 expect(Ok, status);
117 expectf(res_y, res);
118
119 status = GdipGetImageGraphicsContext(u.image, &graphics);
120 expect(Ok, status);
121
122 *image = u.image;
123
124 status = GdipGetDpiX(graphics, &res);
125 expect(Ok, status);
126 expectf(res_x, res);
127 status = GdipGetDpiY(graphics, &res);
128 expect(Ok, status);
129 expectf(res_y, res);
130
131 status = GdipSetPageUnit(graphics, unit);
132 expect(Ok, status);
133 status = GdipSetPageScale(graphics, scale);
134 expect(Ok, status);
135
136 return graphics;
137}
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6621
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6635
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
Definition: graphics.c:6202
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
Definition: graphics.c:6178
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
Definition: image.c:2378
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2249
GpStatus WINGDIPAPI GdipBitmapSetResolution(GpBitmap *bitmap, REAL xdpi, REAL ydpi)
Definition: image.c:1163
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2309
#define PixelFormat24bppRGB
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
GLeglImageOES image
Definition: gl.h:2204
GLuint res
Definition: glext.h:9613
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
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 * u
Definition: glfuncs.h:240
#define expectf(expected, got)
Definition: graphics.c:30
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
Definition: uimain.c:89
Definition: ps.c:97

Referenced by test_GdipMeasureString(), and test_transform().

◆ GetBitmapPixelBuffer()

static DWORD * GetBitmapPixelBuffer ( HDC  hdc,
HBITMAP  hbmp,
int  width,
int  height 
)
static

Definition at line 6352 of file graphics.c.

6353{
6355 UINT lines = 0;
6357
6358 bi.biSize = sizeof(BITMAPINFOHEADER);
6359 bi.biWidth = width;
6360 bi.biHeight = -height; /*very Important, set negative, indicating a top-down DIB*/
6361 bi.biPlanes = 1;
6362 bi.biBitCount = 32;
6363 bi.biCompression = BI_RGB;
6364 bi.biSizeImage = 0;
6365 bi.biXPelsPerMeter = 0;
6366 bi.biYPelsPerMeter = 0;
6367 bi.biClrUsed = 0;
6368 bi.biClrImportant = 0;
6369
6371 ok(lines == height, "Expected GetDIBits:%p,%d->%d,%d\n", buffer, height, lines, GetLastError());
6372
6373 return buffer;
6374}
#define ok(value,...)
Definition: atltest.h:57
HBITMAP hbmp
#define BI_RGB
Definition: precomp.h:56
unsigned long DWORD
Definition: ntddk_ex.h:95
void *WINGDIPAPI GdipAlloc(SIZE_T size)
Definition: gdiplus.c:142
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
HDC hdc
Definition: main.c:9
unsigned int UINT
Definition: ndis.h:50
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD biCompression
Definition: amvideo.idl:35
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
DWORD biSizeImage
Definition: amvideo.idl:36
eMaj lines
Definition: tritemp.h:206
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)

Referenced by test_GdipDrawImagePointsRectOnMemoryDC(), test_GdipFillRectanglesOnMemoryDCSolidBrush(), and test_GdipFillRectanglesOnMemoryDCTextureBrush().

◆ GpStatus()

static GpStatus ( WINAPI pGdipGraphicsSetAbort)
static

◆ log_state()

static void log_state ( GraphicsState  data,
node **  log 
)
static

Definition at line 176 of file graphics.c.

177{
178 node * new_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(node));
179
180 new_entry->data = data;
181 new_entry->next = *log;
182 *log = new_entry;
183}
#define HeapAlloc
Definition: compat.h:733
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLvoid * data
Definition: dlist.c:359
void * next
Definition: dlist.c:360

Referenced by test_save_restore().

◆ pixels_to_units()

static REAL pixels_to_units ( REAL  pixels,
GpUnit  unit,
REAL  dpi 
)
static

Definition at line 69 of file graphics.c.

70{
71 switch (unit)
72 {
73 case UnitPixel:
74 case UnitDisplay:
75 return pixels;
76 case UnitPoint:
77 return pixels * point_per_inch / dpi;
78 case UnitInch:
79 return pixels / dpi;
80 case UnitDocument:
81 return pixels * 300.0 / dpi;
82 case UnitMillimeter:
83 return pixels * mm_per_inch / dpi;
84 default:
85 ok(0, "Unsupported unit: %d\n", unit);
86 return 0;
87 }
88}
@ UnitDocument
Definition: gdiplusenums.h:32
@ UnitInch
Definition: gdiplusenums.h:31
@ UnitMillimeter
Definition: gdiplusenums.h:33
@ UnitDisplay
Definition: gdiplusenums.h:28
@ UnitPoint
Definition: gdiplusenums.h:30
@ UnitPixel
Definition: gdiplusenums.h:29
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
static GdiplusAbort *static const REAL mm_per_inch
Definition: graphics.c:34
static const REAL point_per_inch
Definition: graphics.c:35
#define dpi
Definition: sysparams.c:23

Referenced by test_font_height_scaling(), test_GdipMeasureString(), and units_scale().

◆ set_rect_empty()

static void set_rect_empty ( RectF rc)
static

Definition at line 38 of file graphics.c.

39{
40 rc->X = 0.0;
41 rc->Y = 0.0;
42 rc->Width = 0.0;
43 rc->Height = 0.0;
44}
REAL Height
Definition: gdiplustypes.h:664
REAL X
Definition: gdiplustypes.h:661
REAL Width
Definition: gdiplustypes.h:663
REAL Y
Definition: gdiplustypes.h:662

Referenced by test_font_height_scaling(), test_GdipMeasureString(), test_measure_string(), test_measured_extra_space(), and test_string_functions().

◆ START_TEST()

START_TEST ( graphics  )

Definition at line 6795 of file graphics.c.

6796{
6797 struct GdiplusStartupInput gdiplusStartupInput;
6798 ULONG_PTR gdiplusToken;
6799 WNDCLASSA class;
6800 HMODULE gdiplus_mod = GetModuleHandleA("gdiplus.dll");
6801 HMODULE hmsvcrt;
6802 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
6803
6804 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
6805 hmsvcrt = LoadLibraryA("msvcrt");
6806 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
6807 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
6808
6809 pGdipGraphicsSetAbort = (void*)GetProcAddress(gdiplus_mod, "GdipGraphicsSetAbort");
6810
6811 memset( &class, 0, sizeof(class) );
6812 class.lpszClassName = "gdiplus_test";
6813 class.style = CS_HREDRAW | CS_VREDRAW;
6814 class.lpfnWndProc = DefWindowProcA;
6815 class.hInstance = GetModuleHandleA(0);
6816 class.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
6817 class.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
6818 class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
6819 RegisterClassA( &class );
6820 hwnd = CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6821 CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
6822 ok(hwnd != NULL, "Expected window to be created\n");
6823
6824 gdiplusStartupInput.GdiplusVersion = 1;
6825 gdiplusStartupInput.DebugEventCallback = NULL;
6826 gdiplusStartupInput.SuppressBackgroundThread = 0;
6827 gdiplusStartupInput.SuppressExternalCodecs = 0;
6828
6829 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
6830
6831 test_clipping();
6868 test_isempty();
6869 test_clear();
6888
6889 GdiplusShutdown(gdiplusToken);
6891}
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: _controlfp_s.c:19
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
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:81
void WINAPI GdiplusShutdown(ULONG_PTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_GdipDrawCurveI(void)
Definition: graphics.c:1210
static void test_clear(void)
Definition: graphics.c:2241
static void test_GdipDrawImagePointsRectOnMemoryDC(void)
Definition: graphics.c:6603
static void test_clipping(void)
Definition: graphics.c:5066
static void test_fromMemoryBitmap(void)
Definition: graphics.c:2592
static void test_isempty(void)
Definition: graphics.c:2207
static void test_GdipDrawCurve2(void)
Definition: graphics.c:1015
static void test_GdipGetVisibleClipBounds_memoryDC(void)
Definition: graphics.c:6094
static void test_GdipFillClosedCurve2I(void)
Definition: graphics.c:469
static void test_clipping_2(void)
Definition: graphics.c:5645
static void test_GdipDrawCurve3I(void)
Definition: graphics.c:935
static void test_GdipIsVisiblePoint(void)
Definition: graphics.c:2683
static void test_string_functions(void)
Definition: graphics.c:3188
static void test_GdipDrawCurve(void)
Definition: graphics.c:1149
static void test_font_height_scaling(void)
Definition: graphics.c:4260
static void test_save_restore(void)
Definition: graphics.c:219
static void test_GdipFillClosedCurveI(void)
Definition: graphics.c:1486
static void test_GdipDrawLinesI(void)
Definition: graphics.c:1363
static void test_GdipFillRectanglesOnMemoryDCSolidBrush(void)
Definition: graphics.c:6376
static void test_pen_thickness(void)
Definition: graphics.c:4054
static void test_measure_string(void)
Definition: graphics.c:4448
static void test_GdipFillClosedCurve(void)
Definition: graphics.c:1415
static void test_get_set_interpolation(void)
Definition: graphics.c:3557
static void test_bitmapfromgraphics(void)
Definition: graphics.c:5014
static void test_GdipDrawCurve2I(void)
Definition: graphics.c:1082
static void test_GdipIsVisibleRect(void)
Definition: graphics.c:2862
static void test_GdipFillRectangles(void)
Definition: graphics.c:6049
static void test_clip_xform(void)
Definition: graphics.c:2115
static void test_GdipGetNearestColor(void)
Definition: graphics.c:3024
static void test_get_set_textrenderinghint(void)
Definition: graphics.c:3626
static void test_GdipDrawArc(void)
Definition: graphics.c:531
static void test_GdipFillClosedCurve2(void)
Definition: graphics.c:398
static void test_GdipDrawArcI(void)
Definition: graphics.c:575
static void test_GdipDrawLineI(void)
Definition: graphics.c:1271
static void test_container_rects(void)
Definition: graphics.c:6149
static void test_measured_extra_space(void)
Definition: graphics.c:4871
static void test_textcontrast(void)
Definition: graphics.c:2249
static void test_cliphrgn_transform(void)
Definition: graphics.c:6681
static void test_GdipFillRectanglesOnMemoryDCTextureBrush(void)
Definition: graphics.c:6433
static void test_Get_Release_DC(void)
Definition: graphics.c:1594
static void test_GdipDrawImagePointsRect(void)
Definition: graphics.c:1309
static void test_GdipDrawBezierI(void)
Definition: graphics.c:817
static void test_GdipFillPath(void)
Definition: graphics.c:1548
static void test_get_set_clip(void)
Definition: graphics.c:2035
static void test_getdc_scaled(void)
Definition: graphics.c:3674
static void test_GdipDrawString(void)
Definition: graphics.c:2272
static void test_GdipMeasureString(void)
Definition: graphics.c:3722
static void test_transformpoints(void)
Definition: graphics.c:1906
static void test_constructor_destructor(void)
Definition: graphics.c:139
static void test_alpha_hdc(void)
Definition: graphics.c:4941
static void test_GdipGraphicsSetAbort(void)
Definition: graphics.c:6321
static void test_GdipFillRectanglesOnBitmapTextureBrush(void)
Definition: graphics.c:6518
static void test_GdipDrawCurve3(void)
Definition: graphics.c:855
static void test_GdipGetVisibleClipBounds(void)
Definition: graphics.c:2560
static void test_BeginContainer2(void)
Definition: graphics.c:619
static void test_hdc_caching(void)
Definition: graphics.c:6726
static void test_transform(void)
Definition: graphics.c:3996
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CS_VREDRAW
Definition: winuser.h:658
#define COLOR_WINDOW
Definition: winuser.h:918
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2060
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI DestroyWindow(_In_ HWND)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2090
const char * LPCSTR
Definition: xmlstorage.h:183

◆ test_alpha_hdc()

static void test_alpha_hdc ( void  )
static

Definition at line 4941 of file graphics.c.

4942{
4944 HDC hdc, gp_hdc;
4945 HBITMAP hbm, old_hbm;
4946 GpGraphics *graphics;
4947 ULONG *bits;
4948 BITMAPINFO bmi;
4949 GpRectF bounds;
4950 COLORREF colorref;
4951
4953 ok(hdc != NULL, "CreateCompatibleDC failed\n");
4954 bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
4955 bmi.bmiHeader.biHeight = 5;
4956 bmi.bmiHeader.biWidth = 5;
4957 bmi.bmiHeader.biBitCount = 32;
4958 bmi.bmiHeader.biPlanes = 1;
4960 bmi.bmiHeader.biClrUsed = 0;
4961
4962 hbm = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
4963 ok(hbm != NULL, "CreateDIBSection failed\n");
4964
4965 old_hbm = SelectObject(hdc, hbm);
4966
4967 status = GdipCreateFromHDC(hdc, &graphics);
4968 expect(Ok, status);
4969
4970 status = GdipGetVisibleClipBounds(graphics, &bounds);
4971 expect(Ok, status);
4972 expectf(0.0, bounds.X);
4973 expectf(0.0, bounds.Y);
4974 expectf(5.0, bounds.Width);
4975 expectf(5.0, bounds.Height);
4976
4977 bits[0] = 0xdeadbeef;
4978
4979 status = GdipGraphicsClear(graphics, 0xffaaaaaa);
4980 expect(Ok, status);
4981
4982 expect(0xffaaaaaa, bits[0]);
4983
4984 bits[0] = 0xdeadbeef;
4985
4986 status = GdipGetDC(graphics, &gp_hdc);
4987 expect(Ok, status);
4988
4989 colorref = GetPixel(gp_hdc, 0, 4);
4990 expect(0xefbead, colorref);
4991
4992 SetPixel(gp_hdc, 0, 4, 0xffffff);
4993
4994 expect(0xffffff, bits[0]);
4995
4996 status = GdipReleaseDC(graphics, gp_hdc);
4997 expect(Ok, status);
4998
4999 SelectObject(hdc, old_hbm);
5000
5001 bits[0] = 0xdeadbeef;
5002
5003 status = GdipGraphicsClear(graphics, 0xffbbbbbb);
5004 expect(Ok, status);
5005
5006 todo_wine expect(0xffbbbbbb, bits[0]);
5007
5008 GdipDeleteGraphics(graphics);
5009
5011 DeleteDC(hdc);
5012}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
Definition: graphics.c:6682
GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
Definition: graphics.c:5076
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics *graphics, GpRectF *rect)
Definition: graphics.c:5004
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:6758
pKey DeleteObject()
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define todo_wine
Definition: custom.c:79
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
uint32_t ULONG
Definition: typedefs.h:59
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by START_TEST().

◆ test_BeginContainer2()

static void test_BeginContainer2 ( void  )
static

Definition at line 619 of file graphics.c.

620{
622 GpRectF clip;
623 REAL defClip[] = {5, 10, 15, 20};
624 REAL elems[6], defTrans[] = {1, 2, 3, 4, 5, 6};
625 GraphicsContainer cont1, cont2, cont3, cont4;
626 CompositingQuality compqual, defCompqual = CompositingQualityHighSpeed;
627 CompositingMode compmode, defCompmode = CompositingModeSourceOver;
629 REAL scale, defScale = 17;
630 GpUnit unit, defUnit = UnitPixel;
631 PixelOffsetMode offsetmode, defOffsetmode = PixelOffsetModeHighSpeed;
632 SmoothingMode smoothmode, defSmoothmode = SmoothingModeAntiAlias;
633 UINT contrast, defContrast = 5;
634 TextRenderingHint texthint, defTexthint = TextRenderingHintAntiAlias;
635
637 GpGraphics *graphics = NULL;
638 HDC hdc = GetDC( hwnd );
639
640 ok(hdc != NULL, "Expected HDC to be initialized\n");
641
642 status = GdipCreateFromHDC(hdc, &graphics);
643 expect(Ok, status);
644 ok(graphics != NULL, "Expected graphics to be initialized\n");
645
646 /* null graphics, null container */
649
650 status = GdipBeginContainer2(graphics, NULL);
652
653 status = GdipEndContainer(NULL, cont1);
655
656 /* test all quality-related values */
657 GdipSetCompositingMode(graphics, defCompmode);
658 GdipSetCompositingQuality(graphics, defCompqual);
659 GdipSetInterpolationMode(graphics, defInterp);
660 GdipSetPageScale(graphics, defScale);
661 GdipSetPageUnit(graphics, defUnit);
662 GdipSetPixelOffsetMode(graphics, defOffsetmode);
663 GdipSetSmoothingMode(graphics, defSmoothmode);
664 GdipSetTextContrast(graphics, defContrast);
665 GdipSetTextRenderingHint(graphics, defTexthint);
666
667 status = GdipBeginContainer2(graphics, &cont1);
668 expect(Ok, status);
669
673 GdipSetPageScale(graphics, 10);
674 GdipSetPageUnit(graphics, UnitDocument);
677 GdipSetTextContrast(graphics, 7);
679
680 status = GdipEndContainer(graphics, cont1);
681 expect(Ok, status);
682
683 GdipGetCompositingMode(graphics, &compmode);
684 ok(defCompmode == compmode, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode, compmode);
685
686 GdipGetCompositingQuality(graphics, &compqual);
687 ok(defCompqual == compqual, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual, compqual);
688
690 ok(defInterp == interp, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp, interp);
691
692 GdipGetPageScale(graphics, &scale);
693 ok(fabs(defScale - scale) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale, scale);
694
695 GdipGetPageUnit(graphics, &unit);
696 ok(defUnit == unit, "Expected Page Unit to be restored to %d, got %d\n", defUnit, unit);
697
698 GdipGetPixelOffsetMode(graphics, &offsetmode);
699 ok(defOffsetmode == offsetmode, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode, offsetmode);
700
701 GdipGetSmoothingMode(graphics, &smoothmode);
702 ok(defSmoothmode == smoothmode, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode, smoothmode);
703
704 GdipGetTextContrast(graphics, &contrast);
705 ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
706
707 status = GdipGetTextRenderingHint(graphics, &texthint);
708 expect(Ok, status);
709 ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
710
711 /* test world transform */
712 status = GdipBeginContainer2(graphics, &cont1);
713 expect(Ok, status);
714
715 status = GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
716 defTrans[4], defTrans[5], &transform);
717 expect(Ok, status);
720 transform = NULL;
721
722 status = GdipBeginContainer2(graphics, &cont2);
723 expect(Ok, status);
724
725 status = GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
726 expect(Ok, status);
728 expect(Ok, status);
730 transform = NULL;
731
732 status = GdipEndContainer(graphics, cont2);
733 expect(Ok, status);
734
736 expect(Ok, status);
738 expect(Ok, status);
740 expect(Ok, status);
741 ok(fabs(defTrans[0] - elems[0]) < 0.0001 &&
742 fabs(defTrans[1] - elems[1]) < 0.0001 &&
743 fabs(defTrans[2] - elems[2]) < 0.0001 &&
744 fabs(defTrans[3] - elems[3]) < 0.0001 &&
745 fabs(defTrans[4] - elems[4]) < 0.0001 &&
746 fabs(defTrans[5] - elems[5]) < 0.0001,
747 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
748 defTrans[0], defTrans[1], defTrans[2], defTrans[3], defTrans[4], defTrans[5],
749 elems[0], elems[1], elems[2], elems[3], elems[4], elems[5]);
751 transform = NULL;
752
753 status = GdipEndContainer(graphics, cont1);
754 expect(Ok, status);
755
756 /* test clipping */
757 status = GdipBeginContainer2(graphics, &cont1);
758 expect(Ok, status);
759
760 status = GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace);
761 expect(Ok, status);
762
763 status = GdipBeginContainer2(graphics, &cont2);
764 expect(Ok, status);
765
766 status = GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
767 expect(Ok, status);
768
769 status = GdipEndContainer(graphics, cont2);
770 expect(Ok, status);
771
772 status = GdipGetClipBounds(graphics, &clip);
773 expect(Ok, status);
774
775 ok(fabs(defClip[0] - clip.X) < 0.0001 &&
776 fabs(defClip[1] - clip.Y) < 0.0001 &&
777 fabs(defClip[2] - clip.Width) < 0.0001 &&
778 fabs(defClip[3] - clip.Height) < 0.0001,
779 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
780 defClip[0], defClip[1], defClip[2], defClip[3],
781 clip.X, clip.Y, clip.Width, clip.Height);
782
783 status = GdipEndContainer(graphics, cont1);
784 expect(Ok, status);
785
786 /* nesting */
787 status = GdipBeginContainer2(graphics, &cont1);
788 expect(Ok, status);
789
790 status = GdipBeginContainer2(graphics, &cont2);
791 expect(Ok, status);
792
793 status = GdipBeginContainer2(graphics, &cont3);
794 expect(Ok, status);
795
796 status = GdipEndContainer(graphics, cont3);
797 expect(Ok, status);
798
799 status = GdipBeginContainer2(graphics, &cont4);
800 expect(Ok, status);
801
802 status = GdipEndContainer(graphics, cont4);
803 expect(Ok, status);
804
805 /* skip cont2 */
806 status = GdipEndContainer(graphics, cont1);
807 expect(Ok, status);
808
809 /* end an already-ended container */
810 status = GdipEndContainer(graphics, cont1);
811 expect(Ok, status);
812
813 GdipDeleteGraphics(graphics);
815}
GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics, TextRenderingHint *hint)
Definition: graphics.c:4988
GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics, CompositingMode mode)
Definition: graphics.c:6085
GpStatus WINGDIPAPI GdipGetSmoothingMode(GpGraphics *graphics, SmoothingMode *mode)
Definition: graphics.c:4960
GpStatus WINGDIPAPI GdipGetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode *mode)
Definition: graphics.c:4943
GpStatus WINGDIPAPI GdipGetTextContrast(GpGraphics *graphics, UINT *contrast)
Definition: graphics.c:4975
GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale)
Definition: graphics.c:4912
GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics, TextRenderingHint hint)
Definition: graphics.c:6330
GpStatus WINGDIPAPI GdipGetClipBounds(GpGraphics *graphics, GpRectF *rect)
Definition: graphics.c:4807
GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics *graphics, CompositingMode *mode)
Definition: graphics.c:4848
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:6358
GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics *graphics, CompositingQuality *quality)
Definition: graphics.c:4865
GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode mode)
Definition: graphics.c:6473
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state)
Definition: graphics.c:6039
GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics, CompositingQuality quality)
Definition: graphics.c:6114
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, InterpolationMode mode)
Definition: graphics.c:6143
GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics *graphics, InterpolationMode *mode)
Definition: graphics.c:4882
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics *graphics, GpUnit *unit)
Definition: graphics.c:4927
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
Definition: graphics.c:6289
GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:5062
GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode mode)
Definition: graphics.c:6229
GpStatus WINGDIPAPI GdipSetTextContrast(GpGraphics *graphics, UINT contrast)
Definition: graphics.c:6318
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state)
Definition: graphics.c:5917
GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
Definition: matrix.c:61
GpStatus WINGDIPAPI GdipGetMatrixElements(GDIPCONST GpMatrix *matrix, REAL *out)
Definition: matrix.c:172
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:160
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:140
SmoothingMode
Definition: gdiplusenums.h:121
@ SmoothingModeNone
Definition: gdiplusenums.h:126
@ SmoothingModeAntiAlias
Definition: gdiplusenums.h:127
CompositingMode
Definition: gdiplusenums.h:248
@ CompositingModeSourceOver
Definition: gdiplusenums.h:249
@ CompositingModeSourceCopy
Definition: gdiplusenums.h:250
@ CombineModeReplace
Definition: gdiplusenums.h:351
PixelOffsetMode
Definition: gdiplusenums.h:160
@ PixelOffsetModeHighSpeed
Definition: gdiplusenums.h:163
@ PixelOffsetModeHalf
Definition: gdiplusenums.h:166
UINT GraphicsContainer
Definition: gdiplusenums.h:23
CompositingQuality
Definition: gdiplusenums.h:131
@ CompositingQualityHighSpeed
Definition: gdiplusenums.h:134
@ CompositingQualityHighQuality
Definition: gdiplusenums.h:135
TextRenderingHint
Definition: gdiplusenums.h:254
@ TextRenderingHintAntiAlias
Definition: gdiplusenums.h:259
@ TextRenderingHintClearTypeGridFit
Definition: gdiplusenums.h:260
Unit
Definition: gdiplusenums.h:26
InterpolationMode
Definition: gdiplusenums.h:141
@ InterpolationModeHighQualityBicubic
Definition: gdiplusenums.h:150
@ InterpolationModeBilinear
Definition: gdiplusenums.h:146
@ InvalidParameter
Definition: gdiplustypes.h:28
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLuint interp
Definition: glext.h:9512
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ test_bitmapfromgraphics()

static void test_bitmapfromgraphics ( void  )
static

Definition at line 5014 of file graphics.c.

5015{
5016 GpStatus stat;
5017 GpGraphics *graphics = NULL;
5018 HDC hdc = GetDC( hwnd );
5019 GpBitmap *bitmap = NULL;
5021 REAL imageres, graphicsres;
5022 UINT width, height;
5023
5024 stat = GdipCreateFromHDC(hdc, &graphics);
5025 expect(Ok, stat);
5026
5029
5030 stat = GdipCreateBitmapFromGraphics(12, 13, graphics, NULL);
5032
5033 stat = GdipCreateBitmapFromGraphics(12, 13, graphics, &bitmap);
5034 expect(Ok, stat);
5035
5037 expect(Ok, stat);
5039
5040 stat = GdipGetDpiX(graphics, &graphicsres);
5041 expect(Ok, stat);
5042
5044 expect(Ok, stat);
5045 expectf(graphicsres, imageres);
5046
5047 stat = GdipGetDpiY(graphics, &graphicsres);
5048 expect(Ok, stat);
5049
5051 expect(Ok, stat);
5052 expectf(graphicsres, imageres);
5053
5055 expect(Ok, stat);
5056 expect(12, width);
5057
5059 expect(Ok, stat);
5060 expect(13, height);
5061
5062 GdipDeleteGraphics(graphics);
5064}
#define stat
Definition: acwin.h:99
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2390
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2287
GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height, GpGraphics *target, GpBitmap **bitmap)
Definition: image.c:1542
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155
GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
Definition: image.c:2339
#define PixelFormat32bppPARGB
INT PixelFormat
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: stat.h:55

Referenced by START_TEST().

◆ test_clear()

static void test_clear ( void  )
static

Definition at line 2241 of file graphics.c.

2242{
2244
2245 status = GdipGraphicsClear(NULL, 0xdeadbeef);
2247}

Referenced by START_TEST().

◆ test_clip_xform()

static void test_clip_xform ( void  )
static

Definition at line 2115 of file graphics.c.

2116{
2118 GpGraphics *graphics = NULL;
2119 HDC hdc = GetDC( hwnd );
2120 GpRegion *clip;
2122 UINT region_data_size;
2123 struct {
2124 DWORD size;
2126 DWORD magic;
2127 DWORD num_children;
2128 DWORD element_type;
2129 REAL x;
2130 REAL y;
2131 REAL width;
2132 REAL height;
2133 } region_data;
2134
2135 status = GdipCreateFromHDC(hdc, &graphics);
2136 expect(Ok, status);
2137 status = GdipCreateRegion(&clip);
2138 expect(Ok, status);
2139
2140 status = GdipGraphicsClear(graphics, 0xff000000);
2141 expect(Ok, status);
2142
2143 status = GdipSetClipRect(graphics, 10, 10, -10, -10, CombineModeReplace);
2144 expect(Ok, status);
2145 status = GdipGetClip(graphics, clip);
2146 expect(Ok, status);
2147 status = GdipGetRegionData(clip, (BYTE*)&region_data, sizeof(region_data), &region_data_size);
2148 expect(Ok, status);
2149 expect(36, region_data_size);
2150 expect(28, region_data.size);
2151 expect(0, region_data.num_children);
2152 expect(0x10000000 /* RegionDataRect */, region_data.element_type);
2153 expectf(0.0, region_data.x);
2154 expectf(0.0, region_data.y);
2155 expectf(10.0, region_data.width);
2156 expectf(10.0, region_data.height);
2157
2158 /* No effect with negative width/height */
2159 status = GdipGraphicsClear(graphics, 0xffff0000);
2160 expect(Ok, status);
2161 color = GetPixel(hdc, 5, 5);
2162 expect(0, color);
2163
2164 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderAppend);
2165 expect(Ok, status);
2166
2167 status = GdipGraphicsClear(graphics, 0xffff0000);
2168 expect(Ok, status);
2169 color = GetPixel(hdc, 5, 5);
2170 expect(0, color);
2171
2172 status = GdipResetClip(graphics);
2173 expect(Ok, status);
2174 status = GdipResetWorldTransform(graphics);
2175 expect(Ok, status);
2176 status = GdipGraphicsClear(graphics, 0xff000000);
2177 expect(Ok, status);
2178
2179 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderAppend);
2180 expect(Ok, status);
2181
2182 status = GdipSetClipRect(graphics, 5, 5, -5, -5, CombineModeReplace);
2183 expect(Ok, status);
2184 status = GdipGetClip(graphics, clip);
2185 expect(Ok, status);
2186 status = GdipGetRegionData(clip, (BYTE*)&region_data, sizeof(region_data), &region_data_size);
2187 expect(Ok, status);
2188 expect(36, region_data_size);
2189 expect(28, region_data.size);
2190 expect(0, region_data.num_children);
2191 expect(0x10000000 /* RegionDataRect */, region_data.element_type);
2192 expectf(0.0, region_data.x);
2193 expectf(0.0, region_data.y);
2194 expectf(5.0, region_data.width);
2195 expectf(5.0, region_data.height);
2196
2197 status = GdipGraphicsClear(graphics, 0xffff0000);
2198 expect(Ok, status);
2199 color = GetPixel(hdc, 5, 5);
2200 expect(0xff, color);
2201
2202 GdipDeleteGraphics(graphics);
2203 GdipDeleteRegion(clip);
2204 ReleaseDC(hwnd, hdc);
2205}
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, REAL sy, GpMatrixOrder order)
Definition: graphics.c:6051
GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
Definition: graphics.c:6809
GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics)
Definition: graphics.c:5827
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
Definition: graphics.c:5840
GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
Definition: region.c:390
GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *region, BYTE *buffer, UINT size, UINT *needed)
Definition: region.c:747
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
Definition: region.c:571
@ MatrixOrderAppend
Definition: gdiplusenums.h:189
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
GLuint color
Definition: glext.h:6243
u32_t magic(void)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_cliphrgn_transform()

static void test_cliphrgn_transform ( void  )
static

Definition at line 6681 of file graphics.c.

6682{
6683 HDC hdc;
6685 GpGraphics *graphics;
6686 HRGN rgn;
6687 RectF rectf;
6688 BOOL res;
6689
6690 hdc = GetDC(hwnd);
6691
6692 SetViewportOrgEx(hdc, 10, 10, NULL);
6693
6694 status = GdipCreateFromHDC(hdc, &graphics);
6695 expect(Ok, status);
6696
6697 rgn = CreateRectRgn(0, 0, 100, 100);
6698
6699 status = GdipSetClipHrgn(graphics, rgn, CombineModeReplace);
6700 expect(Ok, status);
6701
6702 status = GdipGetVisibleClipBounds(graphics, &rectf);
6703 expect(Ok, status);
6704 expectf(-10.0, rectf.X);
6705 expectf(-10.0, rectf.Y);
6706 expectf(100.0, rectf.Width);
6707 expectf(100.0, rectf.Height);
6708
6709 status = GdipIsVisiblePoint(graphics, 95, 95, &res);
6710 expect(Ok, status);
6711 expect(FALSE, res);
6712
6713 status = GdipIsVisiblePoint(graphics, -5, -5, &res);
6714 expect(Ok, status);
6715 expect(TRUE, res);
6716
6717 DeleteObject(rgn);
6718
6719 GdipDeleteGraphics(graphics);
6720
6721 SetViewportOrgEx(hdc, 0, 0, NULL);
6722
6723 ReleaseDC(hwnd, hdc);
6724}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GpStatus WINGDIPAPI GdipSetClipHrgn(GpGraphics *graphics, HRGN hrgn, CombineMode mode)
Definition: graphics.c:6412
GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics *graphics, REAL x, REAL y, BOOL *result)
Definition: graphics.c:5119
unsigned int BOOL
Definition: ntddk_ex.h:94
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655

Referenced by START_TEST().

◆ test_clipping()

static void test_clipping ( void  )
static

Definition at line 5066 of file graphics.c.

5067{
5068 HDC hdc;
5070 GpGraphics *graphics;
5071 GpRegion *region, *region100x100;
5073 GpRectF rect;
5074 GpPointF ptf[4];
5075 GpUnit unit;
5076 HRGN hrgn;
5077 int ret;
5078 RECT rc;
5079
5081 status = GdipCreateFromHDC(hdc, &graphics);
5082 expect(Ok, status);
5083
5084 status = GdipGetPageUnit(graphics, &unit);
5085 expect(Ok, status);
5087
5088 status = GdipCreateRegion(&region);
5089 expect(Ok, status);
5090 status = GdipSetEmpty(region);
5091 expect(Ok, status);
5092
5093 status = GdipCreateRegion(&region100x100);
5094 expect(Ok, status);
5095 status = GdipSetEmpty(region100x100);
5096 expect(Ok, status);
5097
5098 rect.X = rect.Y = 100.0;
5099 rect.Width = rect.Height = 100.0;
5101 expect(Ok, status);
5102 status = GdipSetClipRegion(graphics, region100x100, CombineModeReplace);
5103 expect(Ok, status);
5104
5105 status = GdipGetClipBounds(graphics, &rect);
5106 expect(Ok, status);
5107 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5108 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5109
5110 /* Clip region does not account for changes to gdi32 transform */
5111 SetViewportOrgEx(hdc, 10, 10, NULL);
5112
5113 status = GdipGetClipBounds(graphics, &rect);
5114 expect(Ok, status);
5115 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5116 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5117
5118 SetViewportOrgEx(hdc, 0, 0, NULL);
5119
5120 status = GdipSetEmpty(region);
5121 expect(Ok, status);
5122 status = GdipGetClip(graphics, region);
5123 expect(Ok, status);
5124 status = GdipGetRegionBounds(region, graphics, &rect);
5125 expect(Ok, status);
5126 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5127 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5128
5129 ptf[0].X = 100.0;
5130 ptf[0].Y = 100.0;
5131 ptf[1].X = 200.0;
5132 ptf[1].Y = 200.0;
5134 expect(Ok, status);
5135 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5136 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5137
5139 expect(Ok, status);
5141 expect(Ok, status);
5143 expect(Ok, status);
5144 status = GdipSetWorldTransform(graphics, matrix);
5145 expect(Ok, status);
5146
5147 status = GdipGetClipBounds(graphics, &rect);
5148 expect(Ok, status);
5149 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5150 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5151
5152 status = GdipSetEmpty(region);
5153 expect(Ok, status);
5154 status = GdipGetClip(graphics, region);
5155 expect(Ok, status);
5156 status = GdipGetRegionBounds(region, graphics, &rect);
5157 expect(Ok, status);
5158 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5159 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5160
5161 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5162 expect(Ok, status);
5163 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5164 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5165
5166 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5167 expect(Ok, status);
5168 ret = GetRgnBox(hrgn, &rc);
5169 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5170 ok(rc.left == 45 && rc.top == 20 && rc.right == 95 && rc.bottom == 45,
5171 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc));
5173
5174 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5175 expect(Ok, status);
5176 ret = GetRgnBox(hrgn, &rc);
5177 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5178 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5179 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5181
5182 ptf[0].X = 100.0;
5183 ptf[0].Y = 100.0;
5184 ptf[1].X = 200.0;
5185 ptf[1].Y = 200.0;
5187 expect(Ok, status);
5188 ok(ptf[0].X == 45.0 && ptf[0].Y == 20.0 && ptf[1].X == 95.0 && ptf[1].Y == 45.0,
5189 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5190
5191 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5192 expect(Ok, status);
5193 ret = GetRgnBox(hrgn, &rc);
5194 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5195 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5196 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5198
5199 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5200 expect(Ok, status);
5201 ret = GetRgnBox(hrgn, &rc);
5202 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5203 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5204 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5206
5207 ptf[0].X = 210.0;
5208 ptf[0].Y = 420.0;
5209 ptf[1].X = 410.0;
5210 ptf[1].Y = 820.0;
5212 expect(Ok, status);
5213 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5214 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5215
5216 status = GdipSetPageScale(graphics, 2.0);
5217 expect(Ok, status);
5218
5219 status = GdipGetClipBounds(graphics, &rect);
5220 expect(Ok, status);
5221 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5222 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5223
5224 status = GdipSetEmpty(region);
5225 expect(Ok, status);
5226 status = GdipGetClip(graphics, region);
5227 expect(Ok, status);
5228 status = GdipGetRegionBounds(region, graphics, &rect);
5229 expect(Ok, status);
5230 ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
5231 "expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5232
5233 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5234 expect(Ok, status);
5235 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5236 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5237
5238 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5239 expect(Ok, status);
5240 ret = GetRgnBox(hrgn, &rc);
5241 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5242 ok(rc.left == 45 && rc.top == 20 && rc.right == 95 && rc.bottom == 45,
5243 "expected 45,20-95,45, got %s\n", wine_dbgstr_rect(&rc));
5245
5246 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5247 expect(Ok, status);
5248 ret = GetRgnBox(hrgn, &rc);
5249 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5250 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5251 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5253
5254 ptf[0].X = 100.0;
5255 ptf[0].Y = 100.0;
5256 ptf[1].X = 200.0;
5257 ptf[1].Y = 200.0;
5259 expect(Ok, status);
5260 ok(ptf[0].X == 45.0 && ptf[0].Y == 20.0 && ptf[1].X == 95.0 && ptf[1].Y == 45.0,
5261 "expected 45.0,20.0-95.0,45.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5262
5263 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5264 expect(Ok, status);
5265 ret = GetRgnBox(hrgn, &rc);
5266 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5267 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5268 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5270
5271 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5272 expect(Ok, status);
5273 ret = GetRgnBox(hrgn, &rc);
5274 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5275 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5276 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5278
5279 ptf[0].X = 210.0;
5280 ptf[0].Y = 420.0;
5281 ptf[1].X = 410.0;
5282 ptf[1].Y = 820.0;
5284 expect(Ok, status);
5285 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5286 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5287
5288 GdipSetPageUnit(graphics, UnitPoint);
5289 expect(Ok, status);
5290
5291 status = GdipGetClipBounds(graphics, &rect);
5292 expect(Ok, status);
5293 ok((rect.X == 13.75 && rect.Y == 4.375 && rect.Width == 18.75 && rect.Height == 9.375) ||
5294 /* rounding under Wine is slightly different */
5295 (rect.X == 14.0 && rect.Y == 4.0 && rect.Width == 19.0 && rect.Height == 10.0) /* Wine */ ||
5296 broken(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0) /* before Win7 */,
5297 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5298
5299 status = GdipSetEmpty(region);
5300 expect(Ok, status);
5301 status = GdipGetClip(graphics, region);
5302 expect(Ok, status);
5303 status = GdipGetRegionBounds(region, graphics, &rect);
5304 expect(Ok, status);
5305 ok((rect.X == 13.75 && rect.Y == 4.375 && rect.Width == 18.75 && rect.Height == 9.375) ||
5306 /* rounding under Wine is slightly different */
5307 (rect.X == 14.0 && rect.Y == 4.0 && rect.Width == 19.0 && rect.Height == 10.0) /* Wine */ ||
5308 broken(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0) /* before Win7 */,
5309 "expected 13.75,4.375-18.75,9.375, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5310
5311 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5312 expect(Ok, status);
5313 ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
5314 "expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5315
5316 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5317 expect(Ok, status);
5318 ret = GetRgnBox(hrgn, &rc);
5319 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5320 ok((rc.left == 14 && rc.top == 5 && rc.right == 33 && rc.bottom == 14) ||
5321 /* rounding under Wine is slightly different */
5322 (rc.left == 14 && rc.top == 4 && rc.right == 33 && rc.bottom == 14) /* Wine */ ||
5323 broken(rc.left == 45 && rc.top == 20 && rc.right == 95 && rc.bottom == 45) /* before Win7 */,
5324 "expected 14,5-33,14, got %s\n", wine_dbgstr_rect(&rc));
5326
5327 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5328 expect(Ok, status);
5329 ret = GetRgnBox(hrgn, &rc);
5330 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5331 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
5332 broken(rc.left == 267 && rc.top == 267 && rc.right == 534 && rc.bottom == 534) /* before Win7 */,
5333 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5335
5336 ptf[0].X = 100.0;
5337 ptf[0].Y = 100.0;
5338 ptf[1].X = 200.0;
5339 ptf[1].Y = 200.0;
5341 expect(Ok, status);
5342 ok((ptf[0].X == 13.75 && ptf[0].Y == 4.375 && ptf[1].X == 32.5 && ptf[1].Y == 13.75) ||
5343 broken(ptf[0].X == 45.0 && ptf[0].Y == 20.0 && ptf[1].X == 95.0 && ptf[1].Y == 45.0) /* before Win7 */,
5344 "expected 13.75,4.375-32.5,13.75, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5345
5346 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5347 expect(Ok, status);
5348 ret = GetRgnBox(hrgn, &rc);
5349 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5350 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5351 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5353
5354 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5355 expect(Ok, status);
5356 ret = GetRgnBox(hrgn, &rc);
5357 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5358 ok((rc.left == 560 && rc.top == 1120 && rc.right == 1094 && rc.bottom == 2187) ||
5359 /* rounding under Wine is slightly different */
5360 (rc.left == 560 && rc.top == 1120 && rc.right == 1093 && rc.bottom == 2187) /* Wine */,
5361 "expected 560,1120-1094,2187, got %s\n", wine_dbgstr_rect(&rc));
5363
5364 ptf[0].X = 560.0;
5365 ptf[0].Y = 1120.0;
5366 ptf[1].X = 1094.0;
5367 ptf[1].Y = 2187.0;
5369 expect(Ok, status);
5370 if (fabs(ptf[0].X - 100.0) < 0.001)
5371 {
5372 expectf(100.0, ptf[0].X);
5373 expectf(100.0, ptf[0].Y);
5374 expectf(200.125, ptf[1].X);
5375 expectf(200.03125, ptf[1].Y);
5376 }
5377 else /* before Win7 */
5378 {
5379 ok(broken(fabs(ptf[0].X - 275.0) < 0.001), "expected 275.0, got %f\n", ptf[0].X);
5380 ok(broken(fabs(ptf[0].Y - 275.0) < 0.001), "expected 275.0, got %f\n", ptf[0].Y);
5381 ok(broken(fabs(ptf[1].X - 542.0) < 0.001), "expected 542.0, got %f\n", ptf[1].X);
5382 ok(broken(fabs(ptf[1].Y - 541.75) < 0.001), "expected 541.75, got %f\n", ptf[1].Y);
5383 }
5384
5385 status = GdipTransformRegion(region100x100, matrix);
5386 expect(Ok, status);
5387
5388 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5389 expect(Ok, status);
5390 ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
5391 "expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
5392
5393 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5394 expect(Ok, status);
5395 ret = GetRgnBox(hrgn, &rc);
5396 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5397 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5398 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5400
5401 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5402 expect(Ok, status);
5403 ret = GetRgnBox(hrgn, &rc);
5404 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5405 ok((rc.left == 1147 && rc.top == 4534 && rc.right == 2214 && rc.bottom == 8800) ||
5406 /* rounding under Wine is slightly different */
5407 (rc.left == 1147 && rc.top == 4533 && rc.right == 2213 && rc.bottom == 8800) /* Wine */,
5408 "expected 1147,4534-2214,8800, got %s\n", wine_dbgstr_rect(&rc));
5410
5411 ptf[0].X = 1147.0;
5412 ptf[0].Y = 4534.0;
5413 ptf[1].X = 2214.0;
5414 ptf[1].Y = 8800.0;
5416 expect(Ok, status);
5417 if (fabs(ptf[0].X - 210.0625) < 0.001)
5418 {
5419 expectf(210.0625, ptf[0].X);
5420 expectf(420.0625, ptf[0].Y);
5421 expectf(410.125, ptf[1].X);
5422 expectf(820.0, ptf[1].Y);
5423 }
5424 else /* before Win7 */
5425 {
5426 ok(broken(fabs(ptf[0].X - 568.5) < 0.001), "expected 568.5, got %f\n", ptf[0].X);
5427 ok(broken(fabs(ptf[0].Y - 1128.5) < 0.001), "expected 1128.5, got %f\n", ptf[0].Y);
5428 ok(broken(fabs(ptf[1].X - 1102.0) < 0.001), "expected 1102.0, got %f\n", ptf[1].X);
5429 ok(broken(fabs(ptf[1].Y - 2195.0) < 0.001), "expected 2195.0, got %f\n", ptf[1].Y);
5430 }
5431
5433 expect(Ok, status);
5434 status = GdipSetWorldTransform(graphics, matrix);
5435 expect(Ok, status);
5436
5437 status = GdipGetClipBounds(graphics, &rect);
5438 expect(Ok, status);
5439 expectf_(20.612978, rect.X, 1.0);
5440 expectf_(-6.256012, rect.Y, 1.5);
5441 expectf_(25.612978, rect.Width, 1.0);
5442 expectf_(12.806489, rect.Height, 1.0);
5443
5444 status = GdipSetEmpty(region);
5445 expect(Ok, status);
5446 status = GdipGetClip(graphics, region);
5447 expect(Ok, status);
5448 status = GdipGetRegionBounds(region, graphics, &rect);
5449 expect(Ok, status);
5450 /* rounding under Wine is slightly different */
5451 expectf_(20.612978, rect.X, 1.0);
5452 expectf_(-6.256012, rect.Y, 1.5);
5453 expectf_(25.612978, rect.Width, 1.0);
5454 expectf_(12.806489, rect.Height, 1.0);
5455
5456 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5457 expect(Ok, status);
5458 ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
5459 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);
5460
5461 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5462 expect(Ok, status);
5463 ret = GetRgnBox(hrgn, &rc);
5464 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5465 ok((rc.left == 22 && rc.top == -6 && rc.right == 46 && rc.bottom == 7) ||
5466 /* rounding under Wine is slightly different */
5467 (rc.left == 21 && rc.top == -5 && rc.right == 46 && rc.bottom == 7) /* Wine */,
5468 "expected (22,-6)-(46,7), got %s\n", wine_dbgstr_rect(&rc));
5470
5471 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5472 expect(Ok, status);
5473 ret = GetRgnBox(hrgn, &rc);
5474 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5475 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5476 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5478
5479 ptf[0].X = 100.0;
5480 ptf[0].Y = 100.0;
5481 ptf[1].X = 200.0;
5482 ptf[1].Y = 200.0;
5483 ptf[2].X = 200.0;
5484 ptf[2].Y = 100.0;
5485 ptf[3].X = 100.0;
5486 ptf[3].Y = 200.0;
5488 expect(Ok, status);
5489 expectf(20.612978, ptf[0].X);
5490 expectf(-1.568512, ptf[0].Y);
5491 expectf(46.225956, ptf[1].X);
5492 expectf(1.862977, ptf[1].Y);
5493 expectf(36.850956, ptf[2].X);
5494 expectf(-6.256012, ptf[2].Y);
5495 expectf(29.987980, ptf[3].X);
5496 expectf(6.550478, ptf[3].Y);
5497
5498 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5499 expect(Ok, status);
5500 ret = GetRgnBox(hrgn, &rc);
5501 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5502 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5503 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5505
5506 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5507 expect(Ok, status);
5508 ret = GetRgnBox(hrgn, &rc);
5509 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5510 ok((rc.left == -3406 && rc.top == 4500 && rc.right == -350 && rc.bottom == 8728) ||
5511 /* rounding under Wine is slightly different */
5512 (rc.left == -3407 && rc.top == 4500 && rc.right == -350 && rc.bottom == 8728) /* Wine */,
5513 "expected (-3406,4500)-(-350,8728), got %s\n", wine_dbgstr_rect(&rc));
5515
5516 ptf[0].X = -3406.0;
5517 ptf[0].Y = 4500.0;
5518 ptf[1].X = -350.0;
5519 ptf[1].Y = 8728.0;
5520 ptf[2].X = -350.0;
5521 ptf[2].Y = 4500.0;
5522 ptf[3].X = -3406.0;
5523 ptf[3].Y = 8728.0;
5525 expect(Ok, status);
5526 expectf(-136.190491, ptf[0].X);
5527 expectf(520.010742, ptf[0].Y);
5528 expectf(756.417175, ptf[1].X);
5529 expectf(720.031616, ptf[1].Y);
5530 expectf(360.042114, ptf[2].X);
5531 expectf(376.760742, ptf[2].Y);
5532 expectf(260.184570, ptf[3].X);
5533 expectf(863.281616, ptf[3].Y);
5534
5536 expect(Ok, status);
5537 status = GdipSetWorldTransform(graphics, matrix);
5538 expect(Ok, status);
5539
5540 status = GdipGetClipBounds(graphics, &rect);
5541 expect(Ok, status);
5542 expectf_(-28.100956, rect.X, 1.0);
5543 expectf_(7.806488, rect.Y, 1.5);
5544 expectf_(25.612978, rect.Width, 1.0);
5545 expectf_(12.806489, rect.Height, 1.0);
5546
5547 status = GdipSetEmpty(region);
5548 expect(Ok, status);
5549 status = GdipGetClip(graphics, region);
5550 expect(Ok, status);
5551 status = GdipGetRegionBounds(region, graphics, &rect);
5552 expect(Ok, status);
5553 /* rounding under Wine is slightly different */
5554 expectf_(-28.100956, rect.X, 1.0);
5555 expectf_(7.806488, rect.Y, 1.5);
5556 expectf_(25.612978, rect.Width, 1.0);
5557 expectf_(12.806489, rect.Height, 1.0);
5558
5559 status = GdipGetRegionBounds(region100x100, graphics, &rect);
5560 expect(Ok, status);
5561 ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
5562 "expected 210.0,420.0-200.0,400.0, got %f,%f-%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);
5563
5564 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5565 expect(Ok, status);
5566 ret = GetRgnBox(hrgn, &rc);
5567 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5568 ok((rc.left == -27 && rc.top == 8 && rc.right == -2 && rc.bottom == 21) ||
5569 /* rounding under Wine is slightly different */
5570 (rc.left == -28 && rc.top == 9 && rc.right == -2 && rc.bottom == 21) /* Wine */,
5571 "expected (-27,8)-(-2,21), got %s\n", wine_dbgstr_rect(&rc));
5573
5574 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5575 expect(Ok, status);
5576 ret = GetRgnBox(hrgn, &rc);
5577 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5578 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5579 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5581
5582 ptf[0].X = 100.0;
5583 ptf[0].Y = 100.0;
5584 ptf[1].X = 200.0;
5585 ptf[1].Y = 200.0;
5586 ptf[2].X = 200.0;
5587 ptf[2].Y = 100.0;
5588 ptf[3].X = 100.0;
5589 ptf[3].Y = 200.0;
5591 expect(Ok, status);
5592 expectf(-11.862979, ptf[0].X);
5593 expectf(7.806488, ptf[0].Y);
5594 expectf(-18.725958, ptf[1].X);
5595 expectf(20.612976, ptf[1].Y);
5596 expectf(-2.487981, ptf[2].X);
5597 expectf(15.925477, ptf[2].Y);
5598 expectf(-28.100956, ptf[3].X);
5599 expectf(12.493987, ptf[3].Y);
5600
5601 status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
5602 expect(Ok, status);
5603 ret = GetRgnBox(hrgn, &rc);
5604 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5605 ok(rc.left == 210 && rc.top == 420 && rc.right == 410 && rc.bottom == 820,
5606 "expected 210,420-410,820, got %s\n", wine_dbgstr_rect(&rc));
5608
5609 status = GdipGetRegionHRgn(region100x100, graphics, &hrgn);
5610 expect(Ok, status);
5611 ret = GetRgnBox(hrgn, &rc);
5612 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5613 ok((rc.left == 4500 && rc.top == 351 && rc.right == 8728 && rc.bottom == 3407) ||
5614 /* rounding under Wine is slightly different */
5615 (rc.left == 4499 && rc.top == 351 && rc.right == 8728 && rc.bottom == 3407) /* Wine */,
5616 "expected (4500,351)-(8728,3407), got %s\n", wine_dbgstr_rect(&rc));
5618
5619 ptf[0].X = -3406.0;
5620 ptf[0].Y = 4500.0;
5621 ptf[1].X = -350.0;
5622 ptf[1].Y = 8728.0;
5623 ptf[2].X = -350.0;
5624 ptf[2].Y = 4500.0;
5625 ptf[3].X = -3406.0;
5626 ptf[3].Y = 8728.0;
5628 expect(Ok, status);
5629 expectf(-1055.021484, ptf[0].X);
5630 expectf(-70.595329, ptf[0].Y);
5631 expectf(-1455.063232, ptf[1].X);
5632 expectf(375.708435, ptf[1].Y);
5633 expectf(-768.521484, ptf[2].X);
5634 expectf(177.520981, ptf[2].Y);
5635 expectf(-1741.563110, ptf[3].X);
5636 expectf(127.592125, ptf[3].Y);
5637
5639 GdipDeleteRegion(region);
5640 GdipDeleteRegion(region100x100);
5641 GdipDeleteGraphics(graphics);
5642 DeleteDC(hdc);
5643}
static HRGN hrgn
#define broken(x)
Definition: _sntprintf.h:21
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define Y(I)
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, CombineMode mode)
Definition: graphics.c:6533
GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace dst_space, GpCoordinateSpace src_space, GpPointF *points, INT count)
Definition: graphics.c:6960
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:289
GpStatus WINGDIPAPI GdipTranslateMatrix(GpMatrix *matrix, REAL offsetX, REAL offsetY, GpMatrixOrder order)
Definition: matrix.c:418
GpStatus WINGDIPAPI GdipRotateMatrix(GpMatrix *matrix, REAL angle, GpMatrixOrder order)
Definition: matrix.c:258
GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
Definition: region.c:1359
GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
Definition: region.c:1194
GpStatus WINGDIPAPI GdipTransformRegion(GpRegion *region, GpMatrix *matrix)
Definition: region.c:1480
GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region, GDIPCONST GpRectF *rect, CombineMode mode)
Definition: region.c:278
GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
Definition: region.c:587
@ CombineModeUnion
Definition: gdiplusenums.h:353
@ CoordinateSpaceDevice
Definition: gdiplusenums.h:369
@ CoordinateSpaceWorld
Definition: gdiplusenums.h:367
GLuint GLenum matrix
Definition: glext.h:9407
#define expectf_(expected, got, precision)
Definition: graphics.c:29
& rect
Definition: startmenu.cpp:1413
REAL Y
Definition: gdiplustypes.h:649
REAL X
Definition: gdiplustypes.h:648
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int ret
#define COMPLEXREGION
Definition: wingdi.h:363
#define SIMPLEREGION
Definition: wingdi.h:362
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)

Referenced by START_TEST().

◆ test_clipping_2()

static void test_clipping_2 ( void  )
static

Definition at line 5645 of file graphics.c.

5646{
5647
5648 HDC hdc;
5650 GpGraphics *graphics;
5651 GpRegion *region;
5653 GpRectF rect;
5654 GpPointF ptf[4];
5655 GpUnit unit;
5656 HRGN hrgn;
5657 int ret;
5658 RECT rc;
5659
5661 status = GdipCreateFromHDC(hdc, &graphics);
5662 expect(Ok, status);
5663
5664 status = GdipGetPageUnit(graphics, &unit);
5665 expect(Ok, status);
5667
5668 GdipSetPageUnit(graphics, UnitInch);
5669
5670 status = GdipCreateRegion(&region);
5671 expect(Ok, status);
5672 status = GdipSetEmpty(region);
5673 expect(Ok, status);
5674 rect.X = rect.Y = 100.0;
5675 rect.Width = rect.Height = 100.0;
5677 expect(Ok, status);
5678 status = GdipSetClipRegion(graphics, region, CombineModeReplace);
5679 expect(Ok, status);
5680
5681 status = GdipGetClip(graphics, region);
5682 expect(Ok, status);
5683 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5684 expect(Ok, status);
5685 ret = GetRgnBox(hrgn, &rc);
5686 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5687 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5688 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5690 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5691 expect(Ok, status);
5692 ret = GetRgnBox(hrgn, &rc);
5693 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5694 ok(rc.left == 9600 && rc.top == 9600 && rc.right == 19200 && rc.bottom == 19200,
5695 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc));
5697
5698 ptf[0].X = 9600.0;
5699 ptf[0].Y = 9600.0;
5700 ptf[1].X = 19200.0;
5701 ptf[1].Y = 19200.0;
5703 expect(Ok, status);
5704 expectf(100.0, ptf[0].X);
5705 expectf(100.0, ptf[0].Y);
5706 expectf(200.0, ptf[1].X);
5707 expectf(200.0, ptf[1].X);
5708
5709 GdipSetPageUnit(graphics, UnitPoint);
5710
5711 status = GdipGetClip(graphics, region);
5712 expect(Ok, status);
5713 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5714 expect(Ok, status);
5715 ret = GetRgnBox(hrgn, &rc);
5716 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5717 ok((rc.left == 7200 && rc.top == 7200 && rc.right == 14400 && rc.bottom == 14400) ||
5718 broken(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) /* before Win7 */,
5719 "expected 7200,7200-14400,14400, got %s\n", wine_dbgstr_rect(&rc));
5721 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5722 expect(Ok, status);
5723 ret = GetRgnBox(hrgn, &rc);
5724 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5725 ok((rc.left == 9600 && rc.top == 9600 && rc.right == 19200 && rc.bottom == 19200) ||
5726 broken(rc.left == 134 && rc.top == 134 && rc.right == 267 && rc.bottom == 267) /* before Win7 */,
5727 "expected 9600,9600-19200,19200, got %s\n", wine_dbgstr_rect(&rc));
5729
5730 ptf[0].X = 9600.0;
5731 ptf[0].Y = 9600.0;
5732 ptf[1].X = 19200.0;
5733 ptf[1].Y = 19200.0;
5735 expect(Ok, status);
5736 if (fabs(ptf[0].X - 7200.0) < 0.001)
5737 ok(ptf[0].X == 7200.0 && ptf[0].Y == 7200.0 && ptf[1].X == 14400.0 && ptf[1].Y == 14400.0,
5738 "expected 7200.0,7200.0-14400.0,14400.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5739 else /* before Win7 */
5740 {
5741 ok(broken(fabs(ptf[0].X - 100.0) < 0.001), "expected 100.0, got %f\n", ptf[0].X);
5742 ok(broken(fabs(ptf[0].Y - 100.0) < 0.001), "expected 100.0, got %f\n", ptf[0].Y);
5743 ok(broken(fabs(ptf[1].X - 200.0) < 0.001), "expected 200.0, got %f\n", ptf[1].X);
5744 ok(broken(fabs(ptf[1].Y - 200.0) < 0.001), "expected 200.0, got %f\n", ptf[1].Y);
5745 }
5746
5747 GdipDeleteRegion(region);
5748
5749 GdipSetPageUnit(graphics, UnitPixel);
5750
5751 status = GdipCreateRegion(&region);
5752 expect(Ok, status);
5753 status = GdipSetEmpty(region);
5754 expect(Ok, status);
5755 rect.X = rect.Y = 100.0;
5756 rect.Width = rect.Height = 100.0;
5758 expect(Ok, status);
5759 status = GdipSetClipRegion(graphics, region, CombineModeReplace);
5760 expect(Ok, status);
5761
5762 status = GdipGetClip(graphics, region);
5763 expect(Ok, status);
5764 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5765 expect(Ok, status);
5766 ret = GetRgnBox(hrgn, &rc);
5767 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5768 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
5769 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
5770 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5772 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5773 expect(Ok, status);
5774 ret = GetRgnBox(hrgn, &rc);
5775 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5776 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
5777 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
5778 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5780
5781 ptf[0].X = 100.0;
5782 ptf[0].Y = 100.0;
5783 ptf[1].X = 200.0;
5784 ptf[1].Y = 200.0;
5786 expect(Ok, status);
5787 if (fabs(ptf[0].X - 100.0) < 0.001)
5788 ok(ptf[0].X == 100.0 && ptf[0].Y == 100.0 && ptf[1].X == 200.0 && ptf[1].Y == 200.0,
5789 "expected 100.0,100.0-200.0,200.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5790 else /* before Win7 */
5791 {
5792 ok(broken(fabs(ptf[0].X - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].X);
5793 ok(broken(fabs(ptf[0].Y - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].Y);
5794 ok(broken(fabs(ptf[1].X - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].X);
5795 ok(broken(fabs(ptf[1].Y - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].Y);
5796 }
5797
5798 GdipSetPageUnit(graphics, UnitPoint);
5799
5800 status = GdipGetClip(graphics, region);
5801 expect(Ok, status);
5802 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5803 expect(Ok, status);
5804 ret = GetRgnBox(hrgn, &rc);
5805 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5806 ok((rc.left == 75 && rc.top == 75 && rc.right == 150 && rc.bottom == 150) ||
5807 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
5808 "expected 75,75-150,150, got %s\n", wine_dbgstr_rect(&rc));
5810 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5811 expect(Ok, status);
5812 ret = GetRgnBox(hrgn, &rc);
5813 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5814 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
5815 broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
5816 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5818
5819 ptf[0].X = 100.0;
5820 ptf[0].Y = 100.0;
5821 ptf[1].X = 200.0;
5822 ptf[1].Y = 200.0;
5824 expect(Ok, status);
5825 if (fabs(ptf[0].X - 75.0) < 0.001)
5826 ok(ptf[0].X == 75.0 && ptf[0].Y == 75.0 && ptf[1].X == 150.0 && ptf[1].Y == 150.0,
5827 "expected 75.0,75.0-150.0,150.0, got %f,%f-%f,%f\n", ptf[0].X, ptf[0].Y, ptf[1].X, ptf[1].Y);
5828 else /* before Win7 */
5829 {
5830 ok(broken(fabs(ptf[0].X - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].X);
5831 ok(broken(fabs(ptf[0].Y - 1.041667) < 0.001), "expected 1.041667, got %f\n", ptf[0].Y);
5832 ok(broken(fabs(ptf[1].X - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].X);
5833 ok(broken(fabs(ptf[1].Y - 2.083333) < 0.001), "expected 2.083333, got %f\n", ptf[1].Y);
5834 }
5835
5837 expect(Ok, status);
5839 expect(Ok, status);
5840 status = GdipSetWorldTransform(graphics, matrix);
5841 expect(Ok, status);
5843
5844 status = GdipGetClip(graphics, region);
5845 expect(Ok, status);
5846 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5847 expect(Ok, status);
5848 ret = GetRgnBox(hrgn, &rc);
5849 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5850 ok(rc.left == 65 && rc.top == 65 && rc.right == 140 && rc.bottom == 140,
5851 "expected 65,65-140,140, got %s\n", wine_dbgstr_rect(&rc));
5853 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5854 expect(Ok, status);
5855 ret = GetRgnBox(hrgn, &rc);
5856 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5857 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5858 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5860
5861 ptf[0].X = 100.0;
5862 ptf[0].Y = 100.0;
5863 ptf[1].X = 200.0;
5864 ptf[1].Y = 200.0;
5866 expect(Ok, status);
5867 expectf(65.0, ptf[0].X);
5868 expectf(65.0, ptf[0].Y);
5869 expectf(140.0, ptf[1].X);
5870 expectf(140.0, ptf[1].X);
5871
5873 expect(Ok, status);
5875 expect(Ok, status);
5876 status = GdipSetWorldTransform(graphics, matrix);
5877 expect(Ok, status);
5879
5880 status = GdipGetClip(graphics, region);
5881 expect(Ok, status);
5882 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5883 expect(Ok, status);
5884 ret = GetRgnBox(hrgn, &rc);
5885 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5886 ok(rc.left == 300 && rc.top == 150 && rc.right == 600 && rc.bottom == 300,
5887 "expected 300,150-600,300, got %s\n", wine_dbgstr_rect(&rc));
5889 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5890 expect(Ok, status);
5891 ret = GetRgnBox(hrgn, &rc);
5892 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5893 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5894 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5896
5897 ptf[0].X = 100.0;
5898 ptf[0].Y = 100.0;
5899 ptf[1].X = 200.0;
5900 ptf[1].Y = 200.0;
5902 expect(Ok, status);
5903 expectf(300.0, ptf[0].X);
5904 expectf(150.0, ptf[0].Y);
5905 expectf(600.0, ptf[1].X);
5906 expectf(300.0, ptf[1].Y);
5907
5908 status = GdipSetPageScale(graphics, 2.0);
5909 expect(Ok, status);
5910
5911 status = GdipGetClip(graphics, region);
5912 expect(Ok, status);
5913 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5914 expect(Ok, status);
5915 ret = GetRgnBox(hrgn, &rc);
5916 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5917 ok((rc.left == 150 && rc.top == 75 && rc.right == 300 && rc.bottom == 150) ||
5918 broken(rc.left == 300 && rc.top == 150 && rc.right == 600 && rc.bottom == 300) /* before Win7 */,
5919 "expected 150,75-300,150, got %s\n", wine_dbgstr_rect(&rc));
5921 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5922 expect(Ok, status);
5923 ret = GetRgnBox(hrgn, &rc);
5924 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5925 ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
5926 broken(rc.left == 200 && rc.top == 200 && rc.right == 400 && rc.bottom == 400) /* before Win7 */,
5927 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5929
5930 ptf[0].X = 100.0;
5931 ptf[0].Y = 100.0;
5932 ptf[1].X = 200.0;
5933 ptf[1].Y = 200.0;
5935 expect(Ok, status);
5936 if (fabs(ptf[0].X - 150.0) < 0.001)
5937 {
5938 expectf(150.0, ptf[0].X);
5939 expectf(75.0, ptf[0].Y);
5940 expectf(300.0, ptf[1].X);
5941 expectf(150.0, ptf[1].Y);
5942 }
5943 else /* before Win7 */
5944 {
5945 ok(broken(fabs(ptf[0].X - 300.0) < 0.001), "expected 300.0, got %f\n", ptf[0].X);
5946 ok(broken(fabs(ptf[0].Y - 150.0) < 0.001), "expected 150.0, got %f\n", ptf[0].Y);
5947 ok(broken(fabs(ptf[1].X - 600.0) < 0.001), "expected 600.0, got %f\n", ptf[1].X);
5948 ok(broken(fabs(ptf[1].Y - 300.0) < 0.001), "expected 300.0, got %f\n", ptf[1].Y);
5949 }
5950
5952 expect(Ok, status);
5954 expect(Ok, status);
5955 status = GdipSetWorldTransform(graphics, matrix);
5956 expect(Ok, status);
5958
5959 status = GdipGetClip(graphics, region);
5960 expect(Ok, status);
5961 status = GdipGetRegionHRgn(region, NULL, &hrgn);
5962 expect(Ok, status);
5963 ret = GetRgnBox(hrgn, &rc);
5964 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
5965 ok((rc.left == 54 && rc.top == -26 && rc.right == 107 && rc.bottom == 27) ||
5966 /* rounding under Wine is slightly different */
5967 (rc.left == 53 && rc.top == -26 && rc.right == 106 && rc.bottom == 27) /* Wine */,
5968 "expected 54,-26-107,27, got %s\n", wine_dbgstr_rect(&rc));
5970 status = GdipGetRegionHRgn(region, graphics, &hrgn);
5971 expect(Ok, status);
5972 ret = GetRgnBox(hrgn, &rc);
5973 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
5974 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
5975 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
5977
5978 ptf[0].X = 100.0;
5979 ptf[0].Y = 100.0;
5980 ptf[1].X = 200.0;
5981 ptf[1].Y = 200.0;
5982 ptf[2].X = 200.0;
5983 ptf[2].Y = 100.0;
5984 ptf[3].X = 100.0;
5985 ptf[3].Y = 200.0;
5987 expect(Ok, status);
5988 expectf(53.033016, ptf[0].X);
5989 expectf(0.0, ptf[0].Y);
5990 expectf(106.066032, ptf[1].X);
5991 expectf(0.0, ptf[1].Y);
5992 expectf(79.549522, ptf[2].X);
5993 expectf(-26.516510, ptf[2].Y);
5994 expectf(79.549522, ptf[3].X);
5995 expectf(26.516508, ptf[3].Y);
5996
5998 expect(Ok, status);
6000 expect(Ok, status);
6001 status = GdipSetWorldTransform(graphics, matrix);
6002 expect(Ok, status);
6004
6005 status = GdipGetClip(graphics, region);
6006 expect(Ok, status);
6007 status = GdipGetRegionHRgn(region, NULL, &hrgn);
6008 expect(Ok, status);
6009 ret = GetRgnBox(hrgn, &rc);
6010 ok(ret == COMPLEXREGION, "expected COMPLEXREGION, got %d\n", ret);
6011 ok((rc.left == -26 && rc.top == 54 && rc.right == 27 && rc.bottom == 107) ||
6012 /* rounding under Wine is slightly different */
6013 (rc.left == -27 && rc.top == 54 && rc.right == 27 && rc.bottom == 106) /* Wine */,
6014 "expected -26,54-27,107, got %s\n", wine_dbgstr_rect(&rc));
6016 status = GdipGetRegionHRgn(region, graphics, &hrgn);
6017 expect(Ok, status);
6018 ret = GetRgnBox(hrgn, &rc);
6019 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
6020 ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
6021 "expected 100,100-200,200, got %s\n", wine_dbgstr_rect(&rc));
6023
6024 ptf[0].X = 100.0;
6025 ptf[0].Y = 100.0;
6026 ptf[1].X = 200.0;
6027 ptf[1].Y = 200.0;
6028 ptf[2].X = 200.0;
6029 ptf[2].Y = 100.0;
6030 ptf[3].X = 100.0;
6031 ptf[3].Y = 200.0;
6033 expect(Ok, status);
6034 expectf(0.0, ptf[0].X);
6035 expectf(53.033005, ptf[0].Y);
6036 expectf(0.0, ptf[1].X);
6037 expectf(106.066010, ptf[1].Y);
6038 expectf(26.516491, ptf[2].X);
6039 expectf(79.549507, ptf[2].Y);
6040 expectf(-26.516520, ptf[3].X);
6041 expectf(79.549500, ptf[3].Y);
6042
6043 GdipDeleteRegion(region);
6044 GdipDeleteGraphics(graphics);
6045 DeleteDC(hdc);
6046}

Referenced by START_TEST().

◆ test_constructor_destructor()

static void test_constructor_destructor ( void  )
static

Definition at line 139 of file graphics.c.

140{
142 GpGraphics *graphics = NULL;
143 HDC hdc = GetDC( hwnd );
144
145 stat = GdipCreateFromHDC(NULL, &graphics);
147 stat = GdipDeleteGraphics(graphics);
149
150 stat = GdipCreateFromHDC(hdc, &graphics);
151 expect(Ok, stat);
152 stat = GdipDeleteGraphics(graphics);
153 expect(Ok, stat);
154
155 stat = GdipCreateFromHWND(NULL, &graphics);
156 expect(Ok, stat);
157 stat = GdipDeleteGraphics(graphics);
158 expect(Ok, stat);
159
160 stat = GdipCreateFromHWNDICM(NULL, &graphics);
161 expect(Ok, stat);
162 stat = GdipDeleteGraphics(graphics);
163 expect(Ok, stat);
164
168}
GpStatus WINGDIPAPI GdipCreateFromHWNDICM(HWND hwnd, GpGraphics **graphics)
Definition: graphics.c:2551
GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
Definition: graphics.c:2529
@ OutOfMemory
Definition: gdiplustypes.h:29

Referenced by START_TEST().

◆ test_container_rects()

static void test_container_rects ( void  )
static

Definition at line 6149 of file graphics.c.

6150{
6152 GpGraphics *graphics;
6153 HDC hdc = GetDC( hwnd );
6154 GpRectF dstrect, srcrect;
6156 static const GpPointF test_points[3] = {{0.0,0.0}, {1.0,0.0}, {0.0,1.0}};
6157 GpPointF points[3];
6158 REAL dpix, dpiy;
6159
6160 status = GdipCreateFromHDC(hdc, &graphics);
6161 expect(Ok, status);
6162
6163 dstrect.X = 0.0;
6164 dstrect.Y = 0.0;
6165 dstrect.Width = 1.0;
6166 dstrect.Height = 1.0;
6167 srcrect = dstrect;
6168
6169 status = GdipGetDpiX(graphics, &dpix);
6170 expect(Ok, status);
6171
6172 status = GdipGetDpiY(graphics, &dpiy);
6173 expect(Ok, status);
6174
6175 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitWorld, &state);
6177
6178 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitDisplay, &state);
6180
6181 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitMillimeter+1, &state);
6183
6184 status = GdipBeginContainer(NULL, &dstrect, &srcrect, UnitPixel, &state);
6186
6187 status = GdipBeginContainer(graphics, NULL, &srcrect, UnitPixel, &state);
6189
6190 status = GdipBeginContainer(graphics, &dstrect, NULL, UnitPixel, &state);
6192
6193 status = GdipBeginContainer(graphics, &dstrect, &srcrect, -1, &state);
6195
6196 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, NULL);
6198
6199 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, &state);
6200 expect(Ok, status);
6201
6202 memcpy(points, test_points, sizeof(points));
6204 expect(Ok, status);
6205 expectf(0.0, points[0].X);
6206 expectf(0.0, points[0].Y);
6207 expectf(1.0, points[1].X);
6208 expectf(0.0, points[1].Y);
6209 expectf(0.0, points[2].X);
6210 expectf(1.0, points[2].Y);
6211
6212 status = GdipEndContainer(graphics, state);
6213 expect(Ok, status);
6214
6215 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state);
6216 expect(Ok, status);
6217
6218 memcpy(points, test_points, sizeof(points));
6220 expect(Ok, status);
6221 expectf(0.0, points[0].X);
6222 expectf(0.0, points[0].Y);
6223 expectf(1.0/dpix, points[1].X);
6224 expectf(0.0, points[1].Y);
6225 expectf(0.0, points[2].X);
6226 expectf(1.0/dpiy, points[2].Y);
6227
6228 status = GdipEndContainer(graphics, state);
6229 expect(Ok, status);
6230
6231 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
6232 expect(Ok, status);
6233
6234 dstrect.X = 1.0;
6235 dstrect.Height = 3.0;
6236 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, &state);
6237 expect(Ok, status);
6238
6239 memcpy(points, test_points, sizeof(points));
6241 expect(Ok, status);
6242 expectf(2.0, points[0].X);
6243 expectf(0.0, points[0].Y);
6244 expectf(4.0, points[1].X);
6245 expectf(0.0, points[1].Y);
6246 expectf(2.0, points[2].X);
6247 expectf(6.0, points[2].Y);
6248
6249 status = GdipEndContainer(graphics, state);
6250 expect(Ok, status);
6251
6252 memcpy(points, test_points, sizeof(points));
6254 expect(Ok, status);
6255 expectf(0.0, points[0].X);
6256 expectf(0.0, points[0].Y);
6257 expectf(2.0, points[1].X);
6258 expectf(0.0, points[1].Y);
6259 expectf(0.0, points[2].X);
6260 expectf(2.0, points[2].Y);
6261
6262 status = GdipResetWorldTransform(graphics);
6263 expect(Ok, status);
6264
6265 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state);
6266 expect(Ok, status);
6267
6268 memcpy(points, test_points, sizeof(points));
6270 expect(Ok, status);
6271 expectf(1.0, points[0].X);
6272 expectf(0.0, points[0].Y);
6273 expectf((dpix+1.0)/dpix, points[1].X);
6274 expectf(0.0, points[1].Y);
6275 expectf(1.0, points[2].X);
6276 expectf(3.0/dpiy, points[2].Y);
6277
6278 status = GdipEndContainer(graphics, state);
6279 expect(Ok, status);
6280
6281 status = GdipSetPageUnit(graphics, UnitInch);
6282 expect(Ok, status);
6283
6284 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitPixel, &state);
6285 expect(Ok, status);
6286
6287 memcpy(points, test_points, sizeof(points));
6289 expect(Ok, status);
6290 expectf(dpix, points[0].X);
6291 expectf(0.0, points[0].Y);
6292 expectf(dpix*2, points[1].X);
6293 expectf(0.0, points[1].Y);
6294 expectf(dpix, points[2].X);
6295 expectf(dpiy*3, points[2].Y);
6296
6297 status = GdipEndContainer(graphics, state);
6298 expect(Ok, status);
6299
6300 status = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state);
6301 expect(Ok, status);
6302
6303 memcpy(points, test_points, sizeof(points));
6305 expect(Ok, status);
6306 expectf(dpix, points[0].X);
6307 expectf(0.0, points[0].Y);
6308 expectf(dpix+1.0, points[1].X);
6309 expectf(0.0, points[1].Y);
6310 expectf(dpix, points[2].X);
6311 expectf(3.0, points[2].Y);
6312
6313 status = GdipEndContainer(graphics, state);
6314 expect(Ok, status);
6315
6316 GdipDeleteGraphics(graphics);
6317
6318 ReleaseDC(hwnd, hdc);
6319}
static int state
Definition: maze.c:121
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state)
Definition: graphics.c:5924
@ MatrixOrderPrepend
Definition: gdiplusenums.h:188
@ UnitWorld
Definition: gdiplusenums.h:27
GLsizei const GLfloat * points
Definition: glext.h:8112
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by START_TEST().

◆ test_font_height_scaling()

static void test_font_height_scaling ( void  )
static

Definition at line 4260 of file graphics.c.

4261{
4262 static const WCHAR tahomaW[] = { 'T','a','h','o','m','a',0 };
4263 static const WCHAR string[] = { '1','2','3','4','5','6','7',0 };
4264 HDC hdc;
4266 CharacterRange range = { 0, 7 };
4267 GpRegion *region;
4268 GpGraphics *graphics;
4269 GpFontFamily *family;
4270 GpFont *font;
4272 RectF bounds, rect;
4273 REAL height, dpi, scale;
4274 PointF ptf;
4275 GpUnit gfx_unit, font_unit;
4276
4278 expect(Ok, status);
4280 expect(Ok, status);
4281 status = GdipCreateRegion(&region);
4282 expect(Ok, status);
4283
4284 status = GdipCreateFontFamilyFromName(tahomaW, NULL, &family);
4285 expect(Ok, status);
4286
4288 status = GdipCreateFromHDC(hdc, &graphics);
4289 expect(Ok, status);
4290
4291 status = GdipGetDpiY(graphics, &dpi);
4292 expect(Ok, status);
4293
4294 /* First check if tested functionality works:
4295 * under XP if font and graphics units differ then GdipTransformPoints
4296 * followed by GdipSetPageUnit to change the graphics units breaks region
4297 * scaling in GdipMeasureCharacterRanges called later.
4298 */
4299 status = GdipSetPageUnit(graphics, UnitDocument);
4300 expect(Ok, status);
4301
4302 ptf.X = 0.0;
4303 ptf.Y = 0.0;
4305 expect(Ok, status);
4306
4307 status = GdipSetPageUnit(graphics, UnitInch);
4308 expect(Ok, status);
4309
4311 expect(Ok, status);
4312
4314 set_rect_empty(&bounds);
4315 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
4316 expect(Ok, status);
4317 trace("test bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);
4318
4320 rect.Width = 32000.0;
4321 rect.Height = 32000.0;
4322 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4323 expect(Ok, status);
4324
4326 status = GdipGetRegionBounds(region, graphics, &rect);
4327 expect(Ok, status);
4328 trace("test region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);
4329
4331
4332 scale = rect.Height / bounds.Height;
4333 if (fabs(scale - 1.0) > 0.1)
4334 {
4335 win_skip("GdipGetRegionBounds is broken, scale %f (should be near 1.0)\n", scale);
4336 goto cleanup;
4337 }
4338
4339 status = GdipScaleWorldTransform(graphics, 0.01, 0.01, MatrixOrderAppend);
4340 expect(Ok, status);
4341
4342 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4343 /* UnitPixel as a font base unit is not tested because it drastically
4344 differs in behaviour */
4345 for (font_unit = 3; font_unit <= 6; font_unit++)
4346 {
4347 /* create a font for the final text height of 100 pixels */
4348 /* height + 2 * (height/6) = 100 => height = 100 * 3 / 4 => 75 */
4349 status = GdipSetPageUnit(graphics, font_unit);
4350 expect(Ok, status);
4351 ptf.X = 0;
4352 ptf.Y = 75.0;
4354 expect(Ok, status);
4355 height = ptf.Y;
4356 /*trace("height %f units\n", height);*/
4357 status = GdipCreateFont(family, height, FontStyleRegular, font_unit, &font);
4358 expect(Ok, status);
4359
4360 /* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
4361 for (gfx_unit = 2; gfx_unit <= 6; gfx_unit++)
4362 {
4363 static const WCHAR doubleW[2] = { 'W','W' };
4364 RectF bounds_1, bounds_2;
4365 REAL margin, margin_y, font_height;
4366 int match;
4367
4368 status = GdipSetPageUnit(graphics, gfx_unit);
4369 expect(Ok, status);
4370
4371 margin_y = units_to_pixels(height / 8.0, font_unit, dpi);
4372 margin_y = pixels_to_units(margin_y, gfx_unit, dpi);
4373
4375 expect(Ok, status);
4376
4378 set_rect_empty(&bounds);
4379 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
4380 expect(Ok, status);
4381 /*trace("bounds: %f,%f,%f,%f\n", bounds.X, bounds.Y, bounds.Width, bounds.Height);*/
4383 expectf_(font_height + margin_y, bounds.Height, 0.005);
4384
4385 ptf.X = 0;
4386 ptf.Y = bounds.Height;
4388 expect(Ok, status);
4389 match = fabs(100.0 - ptf.Y) <= 1.0;
4391 ok(match, "Expected 100.0, got %f\n", ptf.Y);
4392
4393 /* verify the result */
4394 ptf.Y = units_to_pixels(bounds.Height, gfx_unit, dpi);
4395 ptf.Y /= 100.0;
4396 match = fabs(100.0 - ptf.Y) <= 1.0;
4398 ok(match, "Expected 100.0, got %f\n", ptf.Y);
4399
4400 /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
4402 set_rect_empty(&bounds_1);
4403 status = GdipMeasureString(graphics, doubleW, 1, font, &rect, format, &bounds_1, NULL, NULL);
4404 expect(Ok, status);
4405 /* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
4407 set_rect_empty(&bounds_2);
4408 status = GdipMeasureString(graphics, doubleW, 2, font, &rect, format, &bounds_2, NULL, NULL);
4409 expect(Ok, status);
4410
4411 /* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
4412 margin = bounds_1.Width - bounds_2.Width / 2.0;
4413 /*trace("margin %f\n", margin);*/
4414 ok(margin > 0.0, "wrong margin %f\n", margin);
4415
4417 rect.Width = 320000.0;
4418 rect.Height = 320000.0;
4419 status = GdipMeasureCharacterRanges(graphics, string, -1, font, &rect, format, 1, &region);
4420 expect(Ok, status);
4422 status = GdipGetRegionBounds(region, graphics, &rect);
4423 expect(Ok, status);
4424 /*trace("region: %f,%f,%f,%f\n", rect.X, rect.Y, rect.Width, rect.Height);*/
4425 ok(rect.X > 0.0, "wrong rect.X %f\n", rect.X);
4426 expectf(0.0, rect.Y);
4427 match = fabs(1.0 - margin / rect.X) <= 0.05;
4428 ok(match, "Expected %f, got %f\n", margin, rect.X);
4429 match = fabs(1.0 - font_height / rect.Height) <= 0.1;
4430 ok(match, "Expected %f, got %f\n", font_height, rect.Height);
4431 match = fabs(1.0 - bounds.Width / (rect.Width + margin * 2.0)) <= 0.05;
4432 ok(match, "Expected %f, got %f\n", bounds.Width, rect.Width + margin * 2.0);
4433 }
4434
4436 }
4437
4438cleanup:
4439 status = GdipDeleteGraphics(graphics);
4440 expect(Ok, status);
4441 DeleteDC(hdc);
4442
4443 GdipDeleteFontFamily(family);
4444 GdipDeleteRegion(region);
4446}
#define trace
Definition: atltest.h:70
GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height)
Definition: font.c:552
GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
Definition: font.c:869
GpStatus WINGDIPAPI GdipDeleteFont(GpFont *font)
Definition: font.c:270
GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, GpFontCollection *fontCollection, GpFontFamily **FontFamily)
Definition: font.c:746
GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font)
Definition: font.c:144
GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, RectF *bounds, INT *codepointsfitted, INT *linesfilled)
Definition: graphics.c:5546
GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *stringFormat, INT regionCount, GpRegion **regions)
Definition: graphics.c:5423
GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, GpStringFormat **format)
Definition: stringformat.c:76
GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges)
Definition: stringformat.c:290
GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
Definition: stringformat.c:105
static void cleanup(void)
Definition: main.c:1335
REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi)
Definition: gdiplus.c:327
@ FontStyleRegular
Definition: gdiplusenums.h:303
@ StringFormatFlagsNoWrap
Definition: gdiplusenums.h:286
GLenum GLint * range
Definition: glext.h:7539
static int font_height(HFONT hFont)
Definition: combo.c:612
static REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi)
Definition: graphics.c:69
static void set_rect_empty(RectF *rc)
Definition: graphics.c:38
Definition: mk_font.cpp:20
#define LANG_NEUTRAL
Definition: nls.h:22
#define win_skip
Definition: test.h:160
Definition: match.c:28
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_fromMemoryBitmap()

static void test_fromMemoryBitmap ( void  )
static

Definition at line 2592 of file graphics.c.

2593{
2595 GpGraphics *graphics = NULL;
2596 GpBitmap *bitmap = NULL;
2597 BYTE bits[48] = {0};
2598 HDC hdc=NULL;
2600
2602 expect(Ok, status);
2603
2605 expect(Ok, status);
2606
2607 status = GdipGraphicsClear(graphics, 0xff686868);
2608 expect(Ok, status);
2609
2610 GdipDeleteGraphics(graphics);
2611
2612 /* drawing writes to the memory provided */
2613 expect(0x68, bits[10]);
2614
2616 expect(Ok, status);
2617
2618 status = GdipGetDC(graphics, &hdc);
2619 expect(Ok, status);
2620 ok(hdc != NULL, "got NULL hdc\n");
2621
2622 color = GetPixel(hdc, 0, 0);
2623 /* The HDC is write-only, and native fills with a solid color to figure out
2624 * which pixels have changed. */
2625 todo_wine expect(0x0c0b0d, color);
2626
2627 SetPixel(hdc, 0, 0, 0x797979);
2628 SetPixel(hdc, 1, 0, 0x0c0b0d);
2629
2630 status = GdipReleaseDC(graphics, hdc);
2631 expect(Ok, status);
2632
2633 GdipDeleteGraphics(graphics);
2634
2635 expect(0x79, bits[0]);
2636 todo_wine expect(0x68, bits[3]);
2637
2639
2640 /* We get the same kind of write-only HDC for a "normal" bitmap */
2642 expect(Ok, status);
2643
2645 expect(Ok, status);
2646
2647 status = GdipGetDC(graphics, &hdc);
2648 expect(Ok, status);
2649 ok(hdc != NULL, "got NULL hdc\n");
2650
2651 color = GetPixel(hdc, 0, 0);
2652 todo_wine expect(0x0c0b0d, color);
2653
2654 status = GdipReleaseDC(graphics, hdc);
2655 expect(Ok, status);
2656
2657 GdipDeleteGraphics(graphics);
2658
2660
2661 /* If we don't draw to the HDC, the bits are never accessed */
2663 expect(Ok, status);
2664
2666 expect(Ok, status);
2667
2668 status = GdipGetDC(graphics, &hdc);
2669 expect(Ok, status);
2670 ok(hdc != NULL, "got NULL hdc\n");
2671
2672 color = GetPixel(hdc, 0, 0);
2673 todo_wine expect(0x0c0b0d, color);
2674
2675 status = GdipReleaseDC(graphics, hdc);
2676 expect(Ok, status);
2677
2678 GdipDeleteGraphics(graphics);
2679
2681}

Referenced by START_TEST().

◆ test_GdipDrawArc()

static void test_GdipDrawArc ( void  )
static

Definition at line 531 of file graphics.c.

532{
534 GpGraphics *graphics = NULL;
535 GpPen *pen = NULL;
536 HDC hdc = GetDC( hwnd );
537
538 /* make a graphics object and pen object */
539 ok(hdc != NULL, "Expected HDC to be initialized\n");
540
541 status = GdipCreateFromHDC(hdc, &graphics);
542 expect(Ok, status);
543 ok(graphics != NULL, "Expected graphics to be initialized\n");
544
545 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
546 expect(Ok, status);
547 ok(pen != NULL, "Expected pen to be initialized\n");
548
549 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
550 status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
552
553 status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
555
556 status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
558
559 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
561
562 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
564
565 /* successful case */
566 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
567 expect(Ok, status);
568
569 GdipDeletePen(pen);
570 GdipDeleteGraphics(graphics);
571
573}
GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:2619
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen)
Definition: pen.c:136
GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
Definition: pen.c:192
DWORD ARGB

Referenced by START_TEST().

◆ test_GdipDrawArcI()

static void test_GdipDrawArcI ( void  )
static

Definition at line 575 of file graphics.c.

576{
578 GpGraphics *graphics = NULL;
579 GpPen *pen = NULL;
580 HDC hdc = GetDC( hwnd );
581
582 /* make a graphics object and pen object */
583 ok(hdc != NULL, "Expected HDC to be initialized\n");
584
585 status = GdipCreateFromHDC(hdc, &graphics);
586 expect(Ok, status);
587 ok(graphics != NULL, "Expected graphics to be initialized\n");
588
589 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
590 expect(Ok, status);
591 ok(pen != NULL, "Expected pen to be initialized\n");
592
593 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
594 status = GdipDrawArcI(NULL, NULL, 0, 0, 0, 0, 0, 0);
596
597 status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
599
600 status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
602
603 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
605
606 status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
608
609 /* successful case */
610 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
611 expect(Ok, status);
612
613 GdipDeletePen(pen);
614 GdipDeleteGraphics(graphics);
615
617}
GpStatus WINGDIPAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
Definition: graphics.c:2645

Referenced by START_TEST().

◆ test_GdipDrawBezierI()

static void test_GdipDrawBezierI ( void  )
static

Definition at line 817 of file graphics.c.

818{
820 GpGraphics *graphics = NULL;
821 GpPen *pen = NULL;
822 HDC hdc = GetDC( hwnd );
823
824 /* make a graphics object and pen object */
825 ok(hdc != NULL, "Expected HDC to be initialized\n");
826
827 status = GdipCreateFromHDC(hdc, &graphics);
828 expect(Ok, status);
829 ok(graphics != NULL, "Expected graphics to be initialized\n");
830
831 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
832 expect(Ok, status);
833 ok(pen != NULL, "Expected pen to be initialized\n");
834
835 /* InvalidParameter cases: null graphics, null pen */
836 status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
838
839 status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
841
842 status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
844
845 /* successful case */
846 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
847 expect(Ok, status);
848
849 GdipDeletePen(pen);
850 GdipDeleteGraphics(graphics);
851
853}
GpStatus WINGDIPAPI GdipDrawBezierI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4)
Definition: graphics.c:2679

Referenced by START_TEST().

◆ test_GdipDrawCurve()

static void test_GdipDrawCurve ( void  )
static

Definition at line 1149 of file graphics.c.

1150{
1152 GpGraphics *graphics = NULL;
1153 GpPen *pen = NULL;
1154 HDC hdc = GetDC( hwnd );
1155 GpPointF points[3];
1156
1157 points[0].X = 0;
1158 points[0].Y = 0;
1159
1160 points[1].X = 40;
1161 points[1].Y = 20;
1162
1163 points[2].X = 10;
1164 points[2].Y = 40;
1165
1166 /* make a graphics object and pen object */
1167 ok(hdc != NULL, "Expected HDC to be initialized\n");
1168
1169 status = GdipCreateFromHDC(hdc, &graphics);
1170 expect(Ok, status);
1171 ok(graphics != NULL, "Expected graphics to be initialized\n");
1172
1173 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1174 expect(Ok, status);
1175 ok(pen != NULL, "Expected pen to be initialized\n");
1176
1177 /* InvalidParameter cases: null graphics, null pen */
1180
1181 status = GdipDrawCurve(graphics, NULL, points, 3);
1183
1184 status = GdipDrawCurve(NULL, pen, points, 3);
1186
1187 /* InvalidParameter cases: invalid count */
1188 status = GdipDrawCurve(graphics, pen, points, -1);
1190
1191 status = GdipDrawCurve(graphics, pen, points, 0);
1193
1194 status = GdipDrawCurve(graphics, pen, points, 1);
1196
1197 /* Valid test cases */
1198 status = GdipDrawCurve(graphics, pen, points, 2);
1199 expect(Ok, status);
1200
1201 status = GdipDrawCurve(graphics, pen, points, 3);
1202 expect(Ok, status);
1203
1204 GdipDeletePen(pen);
1205 GdipDeleteGraphics(graphics);
1206
1207 ReleaseDC(hwnd, hdc);
1208}
GpStatus WINGDIPAPI GdipDrawCurve(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count)
Definition: graphics.c:2814

Referenced by START_TEST().

◆ test_GdipDrawCurve2()

static void test_GdipDrawCurve2 ( void  )
static

Definition at line 1015 of file graphics.c.

1016{
1018 GpGraphics *graphics = NULL;
1019 GpPen *pen = NULL;
1020 HDC hdc = GetDC( hwnd );
1021 GpPointF points[3];
1022
1023 points[0].X = 0;
1024 points[0].Y = 0;
1025
1026 points[1].X = 40;
1027 points[1].Y = 20;
1028
1029 points[2].X = 10;
1030 points[2].Y = 40;
1031
1032 /* make a graphics object and pen object */
1033 ok(hdc != NULL, "Expected HDC to be initialized\n");
1034
1035 status = GdipCreateFromHDC(hdc, &graphics);
1036 expect(Ok, status);
1037 ok(graphics != NULL, "Expected graphics to be initialized\n");
1038
1039 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1040 expect(Ok, status);
1041 ok(pen != NULL, "Expected pen to be initialized\n");
1042
1043 /* InvalidParameter cases: null graphics, null pen */
1046
1047 status = GdipDrawCurve2(graphics, NULL, points, 3, 1);
1049
1050 status = GdipDrawCurve2(NULL, pen, points, 3, 1);
1052
1053 /* InvalidParameter cases: invalid count */
1054 status = GdipDrawCurve2(graphics, pen, points, -1, 1);
1056
1057 status = GdipDrawCurve2(graphics, pen, points, 0, 1);
1059
1060 status = GdipDrawCurve2(graphics, pen, points, 1, 1);
1062
1063 /* Valid test cases */
1064 status = GdipDrawCurve2(graphics, pen, points, 2, 1);
1065 expect(Ok, status);
1066
1067 status = GdipDrawCurve2(graphics, pen, points, 3, 2);
1068 expect(Ok, status);
1069
1070 status = GdipDrawCurve2(graphics, pen, points, 3, -2);
1071 expect(Ok, status);
1072
1073 status = GdipDrawCurve2(graphics, pen, points, 3, 0);
1074 expect(Ok, status);
1075
1076 GdipDeletePen(pen);
1077 GdipDeleteGraphics(graphics);
1078
1079 ReleaseDC(hwnd, hdc);
1080}
GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, REAL tension)
Definition: graphics.c:2850

Referenced by START_TEST().

◆ test_GdipDrawCurve2I()

static void test_GdipDrawCurve2I ( void  )
static

Definition at line 1082 of file graphics.c.

1083{
1085 GpGraphics *graphics = NULL;
1086 GpPen *pen = NULL;
1087 HDC hdc = GetDC( hwnd );
1088 GpPoint points[3];
1089
1090 points[0].X = 0;
1091 points[0].Y = 0;
1092
1093 points[1].X = 40;
1094 points[1].Y = 20;
1095
1096 points[2].X = 10;
1097 points[2].Y = 40;
1098
1099 /* make a graphics object and pen object */
1100 ok(hdc != NULL, "Expected HDC to be initialized\n");
1101
1102 status = GdipCreateFromHDC(hdc, &graphics);
1103 expect(Ok, status);
1104 ok(graphics != NULL, "Expected graphics to be initialized\n");
1105
1106 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1107 expect(Ok, status);
1108 ok(pen != NULL, "Expected pen to be initialized\n");
1109
1110 /* InvalidParameter cases: null graphics, null pen */
1113
1114 status = GdipDrawCurve2I(graphics, NULL, points, 3, 1);
1116
1117 status = GdipDrawCurve2I(NULL, pen, points, 3, 1);
1119
1120 /* InvalidParameter cases: invalid count */
1121 status = GdipDrawCurve2I(graphics, pen, points, -1, 1);
1123
1124 status = GdipDrawCurve2I(graphics, pen, points, 0, 1);
1126
1127 status = GdipDrawCurve2I(graphics, pen, points, 1, 1);
1129
1130 /* Valid test cases */
1131 status = GdipDrawCurve2I(graphics, pen, points, 2, 1);
1132 expect(Ok, status);
1133
1134 status = GdipDrawCurve2I(graphics, pen, points, 3, 2);
1135 expect(Ok, status);
1136
1137 status = GdipDrawCurve2I(graphics, pen, points, 3, -2);
1138 expect(Ok, status);
1139
1140 status = GdipDrawCurve2I(graphics, pen, points, 3, 0);
1141 expect(Ok, status);
1142
1143 GdipDeletePen(pen);
1144 GdipDeleteGraphics(graphics);
1145
1146 ReleaseDC(hwnd, hdc);
1147}
GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, REAL tension)
Definition: graphics.c:2878

Referenced by START_TEST().

◆ test_GdipDrawCurve3()

static void test_GdipDrawCurve3 ( void  )
static

Definition at line 855 of file graphics.c.

856{
858 GpGraphics *graphics = NULL;
859 GpPen *pen = NULL;
860 HDC hdc = GetDC( hwnd );
861 GpPointF points[3];
862
863 points[0].X = 0;
864 points[0].Y = 0;
865
866 points[1].X = 40;
867 points[1].Y = 20;
868
869 points[2].X = 10;
870 points[2].Y = 40;
871
872 /* make a graphics object and pen object */
873 ok(hdc != NULL, "Expected HDC to be initialized\n");
874
875 status = GdipCreateFromHDC(hdc, &graphics);
876 expect(Ok, status);
877 ok(graphics != NULL, "Expected graphics to be initialized\n");
878
879 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
880 expect(Ok, status);
881 ok(pen != NULL, "Expected pen to be initialized\n");
882
883 /* InvalidParameter cases: null graphics, null pen */
884 status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1);
886
887 status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1);
889
890 status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1);
892
893 /* InvalidParameter cases: invalid count */
894 status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1);
896
897 status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1);
899
900 status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1);
902
903 status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1);
904