ReactOS 0.4.17-dev-116-ga4b6fe9
mapping.c File Reference
#include <stdio.h>
#include <math.h>
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
Include dependency graph for mapping.c:

Go to the source code of this file.

Macros

#define rough_match(got, expected)   (abs( MulDiv( (got) - (expected), 1000, (expected) )) <= 5)
 
#define expect_LPtoDP(_hdc, _x, _y)
 
#define expect_world_transform(_hdc, _em11, _em22)
 
#define expect_dc_ext(_func, _hdc, _cx, _cy)
 
#define expect_viewport_ext(_hdc, _cx, _cy)   expect_dc_ext(GetViewportExtEx, _hdc, _cx, _cy)
 
#define expect_window_ext(_hdc, _cx, _cy)   expect_dc_ext(GetWindowExtEx, _hdc, _cx, _cy)
 

Functions

static DWORD (WINAPI *pGetLayout)(HDC hdc)
 
static INT (WINAPI *pGetRandomRgn)(HDC hDC
 
static BOOL (WINAPI *pGetTransform)(HDC
 
static void test_world_transform (void)
 
static void test_dc_layout (void)
 
static void test_modify_world_transform (void)
 
static void test_SetWindowExt (HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
 
static void test_SetViewportExt (HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
 
static void test_isotropic_mapping (void)
 
static void test_setvirtualresolution (void)
 
static void expect_identity (int line, XFORM *xf)
 
static void xform_near_match (int line, XFORM *got, XFORM *expect)
 
static void test_gettransform (void)
 
 START_TEST (mapping)
 

Variables

static HRGN hRgn
 
static HRGN INT iCode
 
static DWORD
 

Macro Definition Documentation

◆ expect_dc_ext

#define expect_dc_ext (   _func,
  _hdc,
  _cx,
  _cy 
)
Value:
{ \
BOOL _ret; \
SIZE _size; \
SetLastError(0xdeadbeef); \
_ret = _func(_hdc, &_size); \
ok(_ret, #_func " error %lu\n", GetLastError()); \
ok(_size.cx == (_cx), "expected cx %ld, got %ld\n", (_cx), _size.cx); \
ok(_size.cy == (_cy), "expected cy %ld, got %ld\n", (_cy), _size.cy); \
}
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Definition at line 64 of file mapping.c.

◆ expect_LPtoDP

#define expect_LPtoDP (   _hdc,
  _x,
  _y 
)
Value:
{ \
POINT _pt = { 1000, 1000 }; \
LPtoDP(_hdc, &_pt, 1); \
ok(rough_match(_pt.x, _x), "expected x %d, got %ld\n", (_x), _pt.x); \
ok(rough_match(_pt.y, _y), "expected y %d, got %ld\n", (_y), _pt.y); \
}
#define _x(oid)
#define rough_match(got, expected)
Definition: mapping.c:36
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48

Definition at line 38 of file mapping.c.

◆ expect_viewport_ext

#define expect_viewport_ext (   _hdc,
  _cx,
  _cy 
)    expect_dc_ext(GetViewportExtEx, _hdc, _cx, _cy)

Definition at line 75 of file mapping.c.

◆ expect_window_ext

#define expect_window_ext (   _hdc,
  _cx,
  _cy 
)    expect_dc_ext(GetWindowExtEx, _hdc, _cx, _cy)

Definition at line 76 of file mapping.c.

◆ expect_world_transform

#define expect_world_transform (   _hdc,
  _em11,
  _em22 
)
Value:
{ \
BOOL _ret; \
XFORM _xform; \
SetLastError(0xdeadbeef); \
_ret = GetWorldTransform(_hdc, &_xform); \
{ \
ok(_ret, "GetWorldTransform error %lu\n", GetLastError()); \
ok(_xform.eM11 == (_em11), "expected %f, got %f\n", (_em11), _xform.eM11); \
ok(_xform.eM12 == 0.0, "expected 0.0, got %f\n", _xform.eM12); \
ok(_xform.eM21 == 0.0, "expected 0.0, got %f\n", _xform.eM21); \
ok(_xform.eM22 == (_em22), "expected %f, got %f\n", (_em22), _xform.eM22); \
ok(_xform.eDx == 0.0, "expected 0.0, got %f\n", _xform.eDx); \
ok(_xform.eDy == 0.0, "expected 0.0, got %f\n", _xform.eDy); \
} \
}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
FLOAT eDy
Definition: wingdi.h:2172
FLOAT eM11
Definition: wingdi.h:2167
FLOAT eM21
Definition: wingdi.h:2169
FLOAT eM22
Definition: wingdi.h:2170
FLOAT eM12
Definition: wingdi.h:2168
FLOAT eDx
Definition: wingdi.h:2171
BOOL WINAPI GetWorldTransform(_In_ HDC, _Out_ LPXFORM)
Definition: coord.c:278

Definition at line 46 of file mapping.c.

◆ rough_match

#define rough_match (   got,
  expected 
)    (abs( MulDiv( (got) - (expected), 1000, (expected) )) <= 5)

Definition at line 36 of file mapping.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGetTransform)
static

◆ DWORD()

static DWORD ( WINAPI pGetLayout)
static

◆ expect_identity()

static void expect_identity ( int  line,
XFORM xf 
)
inlinestatic

Definition at line 618 of file mapping.c.

619{
620 ok(xf->eM11 == 1.0, "%d: got %f\n", line, xf->eM11);
621 ok(xf->eM12 == 0.0, "%d: got %f\n", line, xf->eM12);
622 ok(xf->eM21 == 0.0, "%d: got %f\n", line, xf->eM21);
623 ok(xf->eM22 == 1.0, "%d: got %f\n", line, xf->eM22);
624 ok(xf->eDx == 0.0, "%d: got %f\n", line, xf->eDx);
625 ok(xf->eDy == 0.0, "%d: got %f\n", line, xf->eDy);
626}
#define ok(value,...)
Definition: atltest.h:57
Definition: parser.c:49

Referenced by test_gettransform().

◆ INT()

static INT ( WINAPI pGetRandomRgn)
static

◆ START_TEST()

START_TEST ( mapping  )

Definition at line 739 of file mapping.c.

740{
741 HMODULE mod = GetModuleHandleA("gdi32.dll");
742 pGetLayout = (void *)GetProcAddress( mod, "GetLayout" );
743 pGetRandomRgn = (void *)GetProcAddress( mod, "GetRandomRgn" );
744 pGetTransform = (void *)GetProcAddress( mod, "GetTransform" );
745 pSetVirtualResolution = (void *)GetProcAddress( mod, "SetVirtualResolution" );
746
753}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_world_transform(void)
Definition: mapping.c:78
static void test_isotropic_mapping(void)
Definition: mapping.c:490
static void test_modify_world_transform(void)
Definition: mapping.c:387
static void test_setvirtualresolution(void)
Definition: mapping.c:529
static void test_dc_layout(void)
Definition: mapping.c:240
static void test_gettransform(void)
Definition: mapping.c:639

◆ test_dc_layout()

static void test_dc_layout ( void  )
static

Definition at line 240 of file mapping.c.

241{
242 INT ret;
243 LONG size_cx, size_cy, res_x, res_y, dpi_x, dpi_y;
244 SIZE size;
245 POINT pt;
247 RECT rc, ret_rc;
248 HDC hdc;
249 HRGN hrgn;
250
251 if (!pGetLayout)
252 {
253 win_skip( "Don't have GetLayout\n" );
254 return;
255 }
256
258 bitmap = CreateCompatibleBitmap( hdc, 100, 100 );
260
261 size_cx = GetDeviceCaps(hdc, HORZSIZE);
262 size_cy = GetDeviceCaps(hdc, VERTSIZE);
263 res_x = GetDeviceCaps(hdc, HORZRES);
264 res_y = GetDeviceCaps(hdc, VERTRES);
265 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
266 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
267
268 ret = GetMapMode( hdc );
269 ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
270 expect_viewport_ext(hdc, 1l, 1l);
271 expect_window_ext(hdc, 1l, 1l);
272 expect_world_transform(hdc, 1.0, 1.0);
273 expect_LPtoDP(hdc, 1000, 1000);
274
276 if (!pGetLayout( hdc ))
277 {
278 win_skip( "SetLayout not supported\n" );
279 DeleteDC(hdc);
280 return;
281 }
282
283 ret = GetMapMode( hdc );
284 ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
285 ret = pGetLayout( hdc );
286 ok(ret == LAYOUT_RTL, "got %x\n", ret);
287 expect_viewport_ext(hdc, 1l, 1l);
288 expect_window_ext(hdc, 1l, 1l);
289 expect_world_transform(hdc, 1.0, 1.0);
290 expect_LPtoDP(hdc, -1000 + 99, 1000);
292 ok( pt.x == 0 && pt.y == 0, "wrong origin %ld,%ld\n", pt.x, pt.y );
293 GetWindowOrgEx( hdc, &pt );
294 ok( pt.x == 0 && pt.y == 0, "wrong origin %ld,%ld\n", pt.x, pt.y );
295 GetDCOrgEx( hdc, &pt );
296 ok( pt.x == 0 && pt.y == 0, "wrong origin %ld,%ld\n", pt.x, pt.y );
297 if (pGetTransform)
298 {
299 XFORM xform;
300 BOOL ret = pGetTransform( hdc, 0x204, &xform ); /* World -> Device */
301 ok( ret, "got %d\n", ret );
302 ok( xform.eM11 == -1.0, "got %f\n", xform.eM11 );
303 ok( xform.eM12 == 0.0, "got %f\n", xform.eM12 );
304 ok( xform.eM21 == 0.0, "got %f\n", xform.eM21 );
305 ok( xform.eM22 == 1.0, "got %f\n", xform.eM22 );
306 ok( xform.eDx == 99.0, "got %f\n", xform.eDx );
307 ok( xform.eDy == 0.0, "got %f\n", xform.eDy );
308 }
309
310 SetRect( &rc, 10, 10, 20, 20 );
311 IntersectClipRect( hdc, 10, 10, 20, 20 );
312 hrgn = CreateRectRgn( 0, 0, 0, 0 );
313 GetClipRgn( hdc, hrgn );
314 GetRgnBox( hrgn, &ret_rc );
315 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
317 SetRect( &rc, 80, 10, 90, 20 );
318 GetClipRgn( hdc, hrgn );
319 GetRgnBox( hrgn, &ret_rc );
320 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
321 GetClipBox( hdc, &ret_rc );
322 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
323 IntersectClipRect( hdc, 80, 10, 85, 20 );
325 SetRect( &rc, 15, 10, 20, 20 );
326 GetClipRgn( hdc, hrgn );
327 GetRgnBox( hrgn, &ret_rc );
328 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
329 GetClipBox( hdc, &ret_rc );
330 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
331 SetRectRgn( hrgn, 60, 10, 80, 20 );
335 SetRect( &rc, 15, 10, 40, 20 );
336 GetClipRgn( hdc, hrgn );
337 GetRgnBox( hrgn, &ret_rc );
338 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
339 GetClipBox( hdc, &ret_rc );
340 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
341
342 /* OffsetClipRgn mirrors too */
343 OffsetClipRgn( hdc, 5, 5 );
344 OffsetRect( &rc, 5, 5 );
345 GetClipRgn( hdc, hrgn );
346 GetRgnBox( hrgn, &ret_rc );
347 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
348
349 /* GetRandomRgn returns the raw region */
350 if (pGetRandomRgn)
351 {
352 SetRect( &rc, 55, 15, 80, 25 );
353 pGetRandomRgn( hdc, hrgn, 1 );
354 GetRgnBox( hrgn, &ret_rc );
355 ok( EqualRect( &rc, &ret_rc ), "wrong clip box %s\n", wine_dbgstr_rect( &ret_rc ));
356 }
357
359 ret = GetMapMode( hdc );
360 ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
361
362 expect_viewport_ext(hdc, res_x, -res_y);
363 ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" );
364 ok( rough_match( size.cx, size_cx * 10 ) ||
365 rough_match( size.cx, MulDiv( res_x, 254, dpi_x )), /* Vista uses a more precise method */
366 "expected cx %ld or %d, got %ld\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx );
367 ok( rough_match( size.cy, size_cy * 10 ) ||
368 rough_match( size.cy, MulDiv( res_y, 254, dpi_y )), /* Vista uses a more precise method */
369 "expected cy %lxd or %d, got %ld\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy );
370 expect_world_transform(hdc, 1.0, 1.0);
371 expect_LPtoDP(hdc, -MulDiv(1000 / 10, res_x, size_cx) + 99, -MulDiv(1000 / 10, res_y, size_cy));
372
374 ret = GetMapMode( hdc );
375 ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
377 ret = GetMapMode( hdc );
378 ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret);
380 ret = GetMapMode( hdc );
381 ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
382
383 DeleteDC(hdc);
385}
static HRGN hrgn
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
pKey DeleteObject()
DWORD WINAPI SetLayout(_In_ HDC hdc, _In_ DWORD dwLayout)
Definition: coord.c:780
GLsizeiptr size
Definition: glext.h:5919
#define win_skip
Definition: minitest.h:67
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define LAYOUT_LTR
Definition: dc.c:33
#define expect_world_transform(_hdc, _em11, _em22)
Definition: mapping.c:46
#define expect_LPtoDP(_hdc, _x, _y)
Definition: mapping.c:38
#define expect_window_ext(_hdc, _cx, _cy)
Definition: mapping.c:76
#define expect_viewport_ext(_hdc, _cx, _cy)
Definition: mapping.c:75
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
long LONG
Definition: pedump.c:60
Definition: uimain.c:89
int32_t INT
Definition: typedefs.h:58
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define HORZRES
Definition: wingdi.h:716
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define VERTSIZE
Definition: wingdi.h:715
#define LOGPIXELSY
Definition: wingdi.h:719
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:439
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define HORZSIZE
Definition: wingdi.h:714
#define VERTRES
Definition: wingdi.h:717
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define MM_LOMETRIC
Definition: wingdi.h:872
int WINAPI GetMapMode(_In_ HDC)
Definition: coord.c:114
#define RGN_OR
Definition: wingdi.h:359
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
#define MM_TEXT
Definition: wingdi.h:873
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define LOGPIXELSX
Definition: wingdi.h:718
int WINAPI OffsetClipRgn(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:383
int WINAPI ExtSelectClipRgn(_In_ HDC, _In_opt_ HRGN, _In_ int)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
BOOL WINAPI GetDCOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:825
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by START_TEST().

◆ test_gettransform()

static void test_gettransform ( void  )
static

Definition at line 639 of file mapping.c.

640{
641 HDC hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
642 XFORM xform, expect;
643 BOOL r;
644 SIZE lometric_vp, lometric_wnd;
645
646 if(!pGetTransform)
647 {
648 win_skip("Don't have GetTransform\n");
649 return;
650 }
651
652 r = pGetTransform(hdc, 0x203, &xform); /* World -> Page */
653 ok(r == TRUE, "got %d\n", r);
654 expect_identity(__LINE__, &xform);
655 r = pGetTransform(hdc, 0x304, &xform); /* Page -> Device */
656 ok(r == TRUE, "got %d\n", r);
657 expect_identity(__LINE__, &xform);
658 r = pGetTransform(hdc, 0x204, &xform); /* World -> Device */
659 ok(r == TRUE, "got %d\n", r);
660 expect_identity(__LINE__, &xform);
661 r = pGetTransform(hdc, 0x402, &xform); /* Device -> World */
662 ok(r == TRUE, "got %d\n", r);
663 expect_identity(__LINE__, &xform);
664
666 GetViewportExtEx(hdc, &lometric_vp);
667 GetWindowExtEx(hdc, &lometric_wnd);
668
669 r = pGetTransform(hdc, 0x203, &xform); /* World -> Page */
670 ok(r == TRUE, "got %d\n", r);
671 expect_identity(__LINE__, &xform);
672
673 r = pGetTransform(hdc, 0x304, &xform); /* Page -> Device */
674 ok(r == TRUE, "got %d\n", r);
675 expect.eM11 = (FLOAT) lometric_vp.cx / lometric_wnd.cx;
676 expect.eM12 = expect.eM21 = 0.0;
677 expect.eM22 = (FLOAT) lometric_vp.cy / lometric_wnd.cy;
678 expect.eDx = expect.eDy = 0.0;
679 xform_near_match(__LINE__, &xform, &expect);
680
681 r = pGetTransform(hdc, 0x204, &xform); /* World -> Device */
682 ok(r == TRUE, "got %d\n", r);
683 xform_near_match(__LINE__, &xform, &expect);
684
685 r = pGetTransform(hdc, 0x402, &xform); /* Device -> World */
686 ok(r == TRUE, "got %d\n", r);
687 expect.eM11 = (FLOAT) lometric_wnd.cx / lometric_vp.cx;
688 expect.eM22 = (FLOAT) lometric_wnd.cy / lometric_vp.cy;
689 xform_near_match(__LINE__, &xform, &expect);
690
691
693
694 expect.eM11 = 10.0;
695 expect.eM22 = 20.0;
697 r = pGetTransform(hdc, 0x203, &xform); /* World -> Page */
698 ok(r == TRUE, "got %d\n", r);
699 xform_near_match(__LINE__, &xform, &expect);
700
701 r = pGetTransform(hdc, 0x304, &xform); /* Page -> Device */
702 ok(r == TRUE, "got %d\n", r);
703 expect.eM11 = (FLOAT) lometric_vp.cx / lometric_wnd.cx;
704 expect.eM22 = (FLOAT) lometric_vp.cy / lometric_wnd.cy;
705 xform_near_match(__LINE__, &xform, &expect);
706
707 r = pGetTransform(hdc, 0x204, &xform); /* World -> Device */
708 ok(r == TRUE, "got %d\n", r);
709 expect.eM11 *= 10.0;
710 expect.eM22 *= 20.0;
711 xform_near_match(__LINE__, &xform, &expect);
712
713 r = pGetTransform(hdc, 0x402, &xform); /* Device -> World */
714 ok(r == TRUE, "got %d\n", r);
715 expect.eM11 = 1 / expect.eM11;
716 expect.eM22 = 1 / expect.eM22;
717 xform_near_match(__LINE__, &xform, &expect);
718
719 r = pGetTransform(hdc, 0x102, &xform);
720 ok(r == FALSE, "got %d\n", r);
721 r = pGetTransform(hdc, 0x103, &xform);
722 ok(r == FALSE, "got %d\n", r);
723 r = pGetTransform(hdc, 0x104, &xform);
724 ok(r == FALSE, "got %d\n", r);
725 r = pGetTransform(hdc, 0x202, &xform);
726 ok(r == FALSE, "got %d\n", r);
727 r = pGetTransform(hdc, 0x302, &xform);
728 ok(r == FALSE, "got %d\n", r);
729 r = pGetTransform(hdc, 0x303, &xform);
730 ok(r == FALSE, "got %d\n", r);
731 r = pGetTransform(hdc, 0x403, &xform);
732 ok(r == FALSE, "got %d\n", r);
733 r = pGetTransform(hdc, 0x404, &xform);
734 ok(r == FALSE, "got %d\n", r);
735 r = pGetTransform(hdc, 0xffff, &xform);
736 ok(r == FALSE, "got %d\n", r);
737}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define FLOAT
Definition: i386-dis.c:525
static void xform_near_match(int line, XFORM *got, XFORM *expect)
Definition: mapping.c:628
static void expect_identity(int line, XFORM *xf)
Definition: mapping.c:618
float FLOAT
Definition: typedefs.h:69
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1233
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
#define GM_ADVANCED
Definition: wingdi.h:865
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351

Referenced by START_TEST().

◆ test_isotropic_mapping()

static void test_isotropic_mapping ( void  )
static

Definition at line 490 of file mapping.c.

491{
492 SIZE win, vp;
493 HDC hdc = GetDC(0);
494
496
497 /* MM_ISOTROPIC is set up like MM_LOMETRIC.
498 Initial values after SetMapMode():
499 (1 inch = 25.4 mm)
500
501 Windows 9x: Windows NT:
502 Window Ext: 254 x -254 HORZSIZE*10 x VERTSIZE*10
503 Viewport Ext: LOGPIXELSX x LOGPIXELSY HORZRES x -VERTRES
504
505 To test without rounding errors, we have to use multiples of
506 these values!
507 */
508
510 GetViewportExtEx(hdc, &vp);
511
512 test_SetViewportExt(hdc, 10 * vp.cx, 10 * vp.cy, 10 * vp.cx, 10 * vp.cy);
513 test_SetWindowExt(hdc, win.cx, win.cy, 10 * vp.cx, 10 * vp.cy);
514 test_SetWindowExt(hdc, 2 * win.cx, win.cy, 10 * vp.cx, 5 * vp.cy);
515 test_SetWindowExt(hdc, win.cx, win.cy, 5 * vp.cx, 5 * vp.cy);
516 test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
517 test_SetViewportExt(hdc, vp.cx, 2 * vp.cy, vp.cx, vp.cy);
518 test_SetViewportExt(hdc, 2 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
519 test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
520 test_SetWindowExt(hdc, 4 * win.cx, 2 * win.cy, 2 * vp.cx, vp.cy);
521 test_SetViewportExt(hdc, -2 * vp.cx, -4 * vp.cy, -2 * vp.cx, -vp.cy);
522 test_SetViewportExt(hdc, -2 * vp.cx, -1 * vp.cy, -2 * vp.cx, -vp.cy);
523 test_SetWindowExt(hdc, -4 * win.cx, -2 * win.cy, -2 * vp.cx, -vp.cy);
524 test_SetWindowExt(hdc, 4 * win.cx, -4 * win.cy, -vp.cx, -vp.cy);
525
526 ReleaseDC(0, hdc);
527}
static real win[4][36]
static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
Definition: mapping.c:459
static void test_SetWindowExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
Definition: mapping.c:429
#define MM_ISOTROPIC
Definition: wingdi.h:870
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ test_modify_world_transform()

static void test_modify_world_transform ( void  )
static

Definition at line 387 of file mapping.c.

388{
389 HDC hdc = GetDC(0);
390 XFORM xform, xform2;
391 int ret;
392
394 ok(ret, "ret = %d\n", ret);
395
397 ok(ret, "ret = %d\n", ret);
398
400 ok(!ret, "ret = %d\n", ret);
401
403 ok(!ret, "ret = %d\n", ret);
404
405 xform.eM11 = 2;
406 xform.eM12 = 0;
407 xform.eM21 = 0;
408 xform.eM22 = 1;
409 xform.eDx = xform.eDy = 0;
410 ret = ModifyWorldTransform(hdc, &xform, 4);
411 ok(ret, "ModifyWorldTransform failed\n");
412
413 memset(&xform2, 0xcc, sizeof(xform2));
414 ret = GetWorldTransform(hdc, &xform2);
415 ok(ret, "GetWorldTransform failed\n");
416 ok(!memcmp(&xform, &xform2, sizeof(xform)), "unexpected xform\n");
417
418 xform.eM11 = 1;
419 xform.eM12 = 1;
420 xform.eM21 = 1;
421 xform.eM22 = 1;
422 xform.eDx = xform.eDy = 0;
423 ret = ModifyWorldTransform(hdc, &xform, 4);
424 ok(!ret, "ModifyWorldTransform succeeded\n");
425
426 ReleaseDC(0, hdc);
427}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
#define memset(x, y, z)
Definition: compat.h:39
#define MWT_LEFTMULTIPLY
Definition: wingdi.h:945
#define MWT_RIGHTMULTIPLY
Definition: wingdi.h:946
#define MWT_IDENTITY
Definition: wingdi.h:944
BOOL WINAPI ModifyWorldTransform(_In_ HDC, _In_opt_ const XFORM *, _In_ DWORD)

Referenced by START_TEST().

◆ test_SetViewportExt()

static void test_SetViewportExt ( HDC  hdc,
LONG  cx,
LONG  cy,
LONG  expected_vp_cx,
LONG  expected_vp_cy 
)
static

Definition at line 459 of file mapping.c.

460{
461 SIZE windowExt, windowExtAfter, viewportExt;
462 POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
463
464 GetWindowOrgEx(hdc, &windowOrg);
465 GetViewportOrgEx(hdc, &viewportOrg);
466 GetWindowExtEx(hdc, &windowExt);
467
469 GetViewportExtEx(hdc, &viewportExt);
470 ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
471 "Viewport extents have not been properly adjusted: Expected %ldx%ld, got %ldx%ld\n",
472 expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
473
474 GetWindowExtEx(hdc, &windowExtAfter);
475 ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy,
476 "Window extension changed from %ldx%ld to %ldx%ld\n",
477 windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy);
478
479 GetWindowOrgEx(hdc, &windowOrgAfter);
480 ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
481 "Window origin changed from (%ld,%ld) to (%ld,%ld)\n",
482 windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
483
484 GetViewportOrgEx(hdc, &viewportOrgAfter);
485 ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
486 "Viewport origin changed from (%ld,%ld) to (%ld,%ld)\n",
487 viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
488}
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465

Referenced by test_isotropic_mapping().

◆ test_setvirtualresolution()

static void test_setvirtualresolution ( void  )
static

Definition at line 529 of file mapping.c.

530{
531 HDC hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
532 BOOL r;
533 INT horz_res = GetDeviceCaps(hdc, HORZRES);
534 INT horz_size = GetDeviceCaps(hdc, HORZSIZE);
535 INT log_pixels_x = GetDeviceCaps(hdc, LOGPIXELSX);
536 SIZE orig_lometric_vp, orig_lometric_wnd;
537
538 if(!pSetVirtualResolution)
539 {
540 win_skip("Don't have SetVirtualResolution\n");
541 return;
542 }
543
544 /* Get the true resolution limits */
546 GetViewportExtEx(hdc, &orig_lometric_vp);
547 GetWindowExtEx(hdc, &orig_lometric_wnd);
549
550 r = pSetVirtualResolution(hdc, 4000, 1000, 400, 200); /* 10 pix/mm x 5 pix/mm */
551 ok(r == TRUE, "got %d\n", r);
552 expect_LPtoDP(hdc, 1000, 1000);
553 expect_viewport_ext(hdc, 1l, 1l);
554 expect_window_ext(hdc, 1l, 1l);
555
557 expect_LPtoDP(hdc, 1000, -500);
558 expect_viewport_ext(hdc, 4000l, -1000l);
559 expect_window_ext(hdc, 4000l, 2000l);
560
561 /* Doesn't change the device caps */
562 ok(horz_res == GetDeviceCaps(hdc, HORZRES), "horz_res changed\n");
563 ok(horz_size == GetDeviceCaps(hdc, HORZSIZE), "horz_size changed\n");
564 ok(log_pixels_x == GetDeviceCaps(hdc, LOGPIXELSX), "log_pixels_x changed\n");
565
566 r = pSetVirtualResolution(hdc, 8000, 1000, 400, 200); /* 20 pix/mm x 5 pix/mm */
567 ok(r == TRUE, "got %d\n", r);
568 expect_LPtoDP(hdc, 1000, -500); /* No change, need to re-set the mapping mode */
571 expect_LPtoDP(hdc, 2000, -500);
572 expect_viewport_ext(hdc, 8000l, -1000l);
573 expect_window_ext(hdc, 4000l, 2000l);
574
575 r = pSetVirtualResolution(hdc, 8000, 1000, 200, 200); /* 40 pix/mm x 5 pix/mm */
576 ok(r == TRUE, "got %d\n", r);
579 expect_LPtoDP(hdc, 4000, -500);
580 expect_viewport_ext(hdc, 8000l, -1000l);
581 expect_window_ext(hdc, 2000l, 2000l);
582
583 r = pSetVirtualResolution(hdc, 8000, 1000, 200, 200); /* 40 pix/mm x 5 pix/mm */
584 ok(r == TRUE, "got %d\n", r);
587 expect_LPtoDP(hdc, 4000, -500);
588 expect_viewport_ext(hdc, 8000l, -1000l);
589 expect_window_ext(hdc, 2000l, 2000l);
590
591 r = pSetVirtualResolution(hdc, 8000, 2000, 200, 200); /* 40 pix/mm x 10 pix/mm */
592 ok(r == TRUE, "got %d\n", r);
595 expect_LPtoDP(hdc, 4000, -1000);
596 expect_viewport_ext(hdc, 8000l, -2000l);
597 expect_window_ext(hdc, 2000l, 2000l);
598
599 r = pSetVirtualResolution(hdc, 0, 0, 10, 0); /* Error */
600 ok(r == FALSE, "got %d\n", r);
603 expect_LPtoDP(hdc, 4000, -1000);
604 expect_viewport_ext(hdc, 8000l, -2000l);
605 expect_window_ext(hdc, 2000l, 2000l);
606
607 r = pSetVirtualResolution(hdc, 0, 0, 0, 0); /* Reset to true resolution */
608 ok(r == TRUE, "got %d\n", r);
611 expect_viewport_ext(hdc, orig_lometric_vp.cx, orig_lometric_vp.cy);
612 expect_window_ext(hdc, orig_lometric_wnd.cx, orig_lometric_wnd.cy);
613
614 DeleteDC(hdc);
615}

Referenced by START_TEST().

◆ test_SetWindowExt()

static void test_SetWindowExt ( HDC  hdc,
LONG  cx,
LONG  cy,
LONG  expected_vp_cx,
LONG  expected_vp_cy 
)
static

Definition at line 429 of file mapping.c.

430{
431 SIZE windowExt, viewportExt;
432 POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
433
434 GetWindowOrgEx(hdc, &windowOrg);
435 GetViewportOrgEx(hdc, &viewportOrg);
436
438 GetWindowExtEx(hdc, &windowExt);
439 ok(windowExt.cx == cx && windowExt.cy == cy,
440 "Window extension: Expected %ldx%ld, got %ldx%ld\n",
441 cx, cy, windowExt.cx, windowExt.cy);
442
443 GetViewportExtEx(hdc, &viewportExt);
444 ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
445 "Viewport extents have not been properly adjusted: Expected %ldx%ld, got %ldx%ld\n",
446 expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
447
448 GetWindowOrgEx(hdc, &windowOrgAfter);
449 ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
450 "Window origin changed from (%ld,%ld) to (%ld,%ld)\n",
451 windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
452
453 GetViewportOrgEx(hdc, &viewportOrgAfter);
454 ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
455 "Viewport origin changed from (%ld,%ld) to (%ld,%ld)\n",
456 viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
457}
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)

Referenced by test_isotropic_mapping().

◆ test_world_transform()

static void test_world_transform ( void  )
static

Definition at line 78 of file mapping.c.

79{
80 HDC hdc;
81 int ret;
82 LONG size_cx, size_cy, res_x, res_y, dpi_x, dpi_y;
83 XFORM xform;
84 SIZE size;
85
87
88 xform.eM11 = 1.0f;
89 xform.eM12 = 0.0f;
90 xform.eM21 = 0.0f;
91 xform.eM22 = 1.0f;
92 xform.eDx = 0.0f;
93 xform.eDy = 0.0f;
94 ret = SetWorldTransform(hdc, &xform);
95 ok(!ret, "SetWorldTransform should fail in GM_COMPATIBLE mode\n");
96
97 size_cx = GetDeviceCaps(hdc, HORZSIZE);
98 size_cy = GetDeviceCaps(hdc, VERTSIZE);
99 res_x = GetDeviceCaps(hdc, HORZRES);
100 res_y = GetDeviceCaps(hdc, VERTRES);
101 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
102 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
103 trace("dc size %ld x %ld, resolution %ld x %ld dpi %ld x %ld\n",
104 size_cx, size_cy, res_x, res_y, dpi_x, dpi_y );
105
106 expect_viewport_ext(hdc, 1l, 1l);
107 expect_window_ext(hdc, 1l, 1l);
108 expect_world_transform(hdc, 1.0, 1.0);
109 expect_LPtoDP(hdc, 1000, 1000);
110
111 SetLastError(0xdeadbeef);
113 ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
114
115 expect_viewport_ext(hdc, res_x, -res_y);
116 ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" );
117 ok( rough_match( size.cx, size_cx * 10 ) ||
118 rough_match( size.cx, MulDiv( res_x, 254, dpi_x )), /* Vista uses a more precise method */
119 "expected cx %ld or %d, got %ld\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx );
120 ok( rough_match( size.cy, size_cy * 10 ) ||
121 rough_match( size.cy, MulDiv( res_y, 254, dpi_y )), /* Vista uses a more precise method */
122 "expected cy %ld or %d, got %ld\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy );
123 expect_world_transform(hdc, 1.0, 1.0);
124 expect_LPtoDP(hdc, MulDiv(1000 / 10, res_x, size_cx), -MulDiv(1000 / 10, res_y, size_cy));
125
126 SetLastError(0xdeadbeef);
128 ok(ret == MM_LOMETRIC, "expected MM_LOMETRIC, got %d\n", ret);
129
130 expect_viewport_ext(hdc, 1l, 1l);
131 expect_window_ext(hdc, 1l, 1l);
132 expect_world_transform(hdc, 1.0, 1.0);
133 expect_LPtoDP(hdc, 1000, 1000);
134
136 if (!ret)
137 {
138 DeleteDC(hdc);
139 skip("GM_ADVANCED is not supported on this platform\n");
140 return;
141 }
142
143 expect_viewport_ext(hdc, 1l, 1l);
144 expect_window_ext(hdc, 1l, 1l);
145 expect_world_transform(hdc, 1.0, 1.0);
146 expect_LPtoDP(hdc, 1000, 1000);
147
148 /* The transform must conform to (eM11 * eM22 != eM12 * eM21) requirement */
149 xform.eM11 = 1.0f;
150 xform.eM12 = 2.0f;
151 xform.eM21 = 1.0f;
152 xform.eM22 = 2.0f;
153 xform.eDx = 0.0f;
154 xform.eDy = 0.0f;
155 ret = SetWorldTransform(hdc, &xform);
156 ok(!ret ||
157 broken(ret), /* NT4 */
158 "SetWorldTransform should fail with an invalid xform\n");
159
160 xform.eM11 = 20.0f;
161 xform.eM12 = 0.0f;
162 xform.eM21 = 0.0f;
163 xform.eM22 = 20.0f;
164 xform.eDx = 0.0f;
165 xform.eDy = 0.0f;
166 SetLastError(0xdeadbeef);
167 ret = SetWorldTransform(hdc, &xform);
168 ok(ret, "SetWorldTransform error %lu\n", GetLastError());
169
170 expect_viewport_ext(hdc, 1l, 1l);
171 expect_window_ext(hdc, 1l, 1l);
172 expect_world_transform(hdc, 20.0, 20.0);
173 expect_LPtoDP(hdc, 20000, 20000);
174
175 SetLastError(0xdeadbeef);
177 ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
178
179 expect_viewport_ext(hdc, res_x, -res_y);
180 ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" );
181 ok( rough_match( size.cx, size_cx * 10 ) ||
182 rough_match( size.cx, MulDiv( res_x, 254, dpi_x )), /* Vista uses a more precise method */
183 "expected cx %ld or %d, got %ld\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx );
184 ok( rough_match( size.cy, size_cy * 10 ) ||
185 rough_match( size.cy, MulDiv( res_y, 254, dpi_y )), /* Vista uses a more precise method */
186 "expected cy %ld or %d, got %ld\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy );
187 expect_world_transform(hdc, 20.0, 20.0);
188 expect_LPtoDP(hdc, MulDiv(20000, res_x, size.cx), -MulDiv(20000, res_y, size.cy));
189
190 SetLastError(0xdeadbeef);
192 ok(ret == MM_LOMETRIC, "expected MM_LOMETRIC, got %d\n", ret);
193
194 expect_viewport_ext(hdc, 1l, 1l);
195 expect_window_ext(hdc, 1l, 1l);
196 expect_world_transform(hdc, 20.0, 20.0);
197 expect_LPtoDP(hdc, 20000, 20000);
198
199 size.cx = 0xdeadbeef;
200 size.cy = 0xdeadbeef;
201 ret = SetViewportExtEx(hdc, -1, -1, &size);
202 ok(ret, "SetViewportExtEx(-1, -1) failed\n");
203 ok(size.cx == 1 && size.cy == 1, "expected 1,1 got %ld,%ld\n", size.cx, size.cy);
204 expect_viewport_ext(hdc, 1l, 1l);
205 expect_window_ext(hdc, 1l, 1l);
206 expect_world_transform(hdc, 20.0, 20.0);
207 expect_LPtoDP(hdc, 20000, 20000);
208
210 ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
211
212 expect_viewport_ext(hdc, 1l, 1l);
213 expect_window_ext(hdc, 1l, 1l);
214 expect_world_transform(hdc, 20.0, 20.0);
215 expect_LPtoDP(hdc, 20000, 20000);
216
217 size.cx = 0xdeadbeef;
218 size.cy = 0xdeadbeef;
219 ret = SetViewportExtEx(hdc, -1, -1, &size);
220 ok(ret, "SetViewportExtEx(-1, -1) failed\n");
221 ok(size.cx == 1 && size.cy == 1, "expected 1,1 got %ld,%ld\n", size.cx, size.cy);
222 expect_viewport_ext(hdc, -1l, -1l);
223 expect_window_ext(hdc, 1l, 1l);
224 expect_world_transform(hdc, 20.0, 20.0);
225 expect_LPtoDP(hdc, -20000, -20000);
226
228 ok(ret, "SetGraphicsMode(GM_COMPATIBLE) should not fail if DC has't an identity transform\n");
230 ok(ret == GM_COMPATIBLE, "expected GM_COMPATIBLE, got %d\n", ret);
231
232 expect_viewport_ext(hdc, -1l, -1l);
233 expect_window_ext(hdc, 1l, 1l);
234 expect_world_transform(hdc, 20.0, 20.0);
235 expect_LPtoDP(hdc, -20000, -20000);
236
237 DeleteDC(hdc);
238}
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define SetLastError(x)
Definition: compat.h:752
#define GM_COMPATIBLE
Definition: wingdi.h:864
int WINAPI GetGraphicsMode(_In_ HDC)

Referenced by START_TEST().

◆ xform_near_match()

static void xform_near_match ( int  line,
XFORM got,
XFORM expect 
)
inlinestatic

Definition at line 628 of file mapping.c.

629{
630 ok(fabs(got->eM11 - expect->eM11) < 0.001, "%d: got %f expect %f\n", line, got->eM11, expect->eM11);
631 ok(fabs(got->eM12 - expect->eM12) < 0.001, "%d: got %f expect %f\n", line, got->eM12, expect->eM12);
632 ok(fabs(got->eM21 - expect->eM21) < 0.001, "%d: got %f expect %f\n", line, got->eM21, expect->eM21);
633 ok(fabs(got->eM22 - expect->eM22) < 0.001, "%d: got %f expect %f\n", line, got->eM22, expect->eM22);
634 ok(fabs(got->eDx - expect->eDx) < 0.001, "%d: got %f expect %f\n", line, got->eDx, expect->eDx);
635 ok(fabs(got->eDy - expect->eDy) < 0.001, "%d: got %f expect %f\n", line, got->eDy, expect->eDy);
636}
_ACRTIMP double __cdecl fabs(double)

Referenced by test_gettransform().

Variable Documentation

◆ DWORD

XFORM *static DWORD

Definition at line 33 of file mapping.c.

◆ hRgn

◆ iCode

HRGN INT iCode