ReactOS  0.4.14-dev-614-gbfd8a84
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 *pSetLayout)(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 DWORD layout
 
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 %u\n", GetLastError()); \
ok(_size.cx == (_cx), "expected cx %d, got %d\n", (_cx), _size.cx); \
ok(_size.cy == (_cy), "expected cy %d, got %d\n", (_cy), _size.cy); \
}
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define _ret

Definition at line 65 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 %d\n", (_x), _pt.x); \
ok(rough_match(_pt.y, _y), "expected y %d, got %d\n", (_y), _pt.y); \
}
#define rough_match(got, expected)
Definition: mapping.c:37
#define _x(oid)

Definition at line 39 of file mapping.c.

◆ expect_viewport_ext

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

Definition at line 76 of file mapping.c.

◆ expect_window_ext

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

Definition at line 77 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 %u\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); \
} \
}
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetWorldTransform(_In_ HDC, _Out_ LPXFORM)
Definition: coord.c:278
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define _ret

Definition at line 47 of file mapping.c.

◆ rough_match

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

Definition at line 37 of file mapping.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGetTransform)
static

◆ DWORD()

static DWORD ( WINAPI pSetLayout)
static

◆ expect_identity()

static void expect_identity ( int  line,
XFORM xf 
)
inlinestatic

Definition at line 593 of file mapping.c.

594 {
595  ok(xf->eM11 == 1.0, "%d: got %f\n", line, xf->eM11);
596  ok(xf->eM12 == 0.0, "%d: got %f\n", line, xf->eM12);
597  ok(xf->eM21 == 0.0, "%d: got %f\n", line, xf->eM21);
598  ok(xf->eM22 == 1.0, "%d: got %f\n", line, xf->eM22);
599  ok(xf->eDx == 0.0, "%d: got %f\n", line, xf->eDx);
600  ok(xf->eDy == 0.0, "%d: got %f\n", line, xf->eDy);
601 }
FLOAT eDx
Definition: wingdi.h:1724
FLOAT eM21
Definition: wingdi.h:1722
FLOAT eM12
Definition: wingdi.h:1721
Definition: parser.c:48
FLOAT eM11
Definition: wingdi.h:1720
#define ok(value,...)
Definition: atltest.h:57
FLOAT eM22
Definition: wingdi.h:1723
FLOAT eDy
Definition: wingdi.h:1725

Referenced by test_gettransform().

◆ INT()

static INT ( WINAPI pGetRandomRgn)
static

◆ START_TEST()

START_TEST ( mapping  )

Definition at line 714 of file mapping.c.

715 {
716  HMODULE mod = GetModuleHandleA("gdi32.dll");
717  pGetLayout = (void *)GetProcAddress( mod, "GetLayout" );
718  pSetLayout = (void *)GetProcAddress( mod, "SetLayout" );
719  pGetRandomRgn = (void *)GetProcAddress( mod, "GetRandomRgn" );
720  pGetTransform = (void *)GetProcAddress( mod, "GetTransform" );
721  pSetVirtualResolution = (void *)GetProcAddress( mod, "SetVirtualResolution" );
722 
725  test_dc_layout();
729 }
static void test_setvirtualresolution(void)
Definition: mapping.c:504
static void test_dc_layout(void)
Definition: mapping.c:240
static void test_gettransform(void)
Definition: mapping.c:614
static void test_modify_world_transform(void)
Definition: mapping.c:384
static void test_world_transform(void)
Definition: mapping.c:79
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define GetProcAddress(x, y)
Definition: compat.h:418
static void test_isotropic_mapping(void)
Definition: mapping.c:465
static int mod
Definition: i386-dis.c:1273

◆ test_dc_layout()

static void test_dc_layout ( void  )
static

Definition at line 240 of file mapping.c.

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

Referenced by START_TEST().

◆ test_gettransform()

static void test_gettransform ( void  )
static

Definition at line 614 of file mapping.c.

615 {
616  HDC hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
617  XFORM xform, expect;
618  BOOL r;
619  SIZE lometric_vp, lometric_wnd;
620 
621  if(!pGetTransform)
622  {
623  win_skip("Don't have GetTransform\n");
624  return;
625  }
626 
627  r = pGetTransform(hdc, 0x203, &xform); /* World -> Page */
628  ok(r == TRUE, "got %d\n", r);
629  expect_identity(__LINE__, &xform);
630  r = pGetTransform(hdc, 0x304, &xform); /* Page -> Device */
631  ok(r == TRUE, "got %d\n", r);
632  expect_identity(__LINE__, &xform);
633  r = pGetTransform(hdc, 0x204, &xform); /* World -> Device */
634  ok(r == TRUE, "got %d\n", r);
635  expect_identity(__LINE__, &xform);
636  r = pGetTransform(hdc, 0x402, &xform); /* Device -> World */
637  ok(r == TRUE, "got %d\n", r);
638  expect_identity(__LINE__, &xform);
639 
641  GetViewportExtEx(hdc, &lometric_vp);
642  GetWindowExtEx(hdc, &lometric_wnd);
643 
644  r = pGetTransform(hdc, 0x203, &xform); /* World -> Page */
645  ok(r == TRUE, "got %d\n", r);
646  expect_identity(__LINE__, &xform);
647 
648  r = pGetTransform(hdc, 0x304, &xform); /* Page -> Device */
649  ok(r == TRUE, "got %d\n", r);
650  expect.eM11 = (FLOAT) lometric_vp.cx / lometric_wnd.cx;
651  expect.eM12 = expect.eM21 = 0.0;
652  expect.eM22 = (FLOAT) lometric_vp.cy / lometric_wnd.cy;
653  expect.eDx = expect.eDy = 0.0;
654  xform_near_match(__LINE__, &xform, &expect);
655 
656  r = pGetTransform(hdc, 0x204, &xform); /* World -> Device */
657  ok(r == TRUE, "got %d\n", r);
658  xform_near_match(__LINE__, &xform, &expect);
659 
660  r = pGetTransform(hdc, 0x402, &xform); /* Device -> World */
661  ok(r == TRUE, "got %d\n", r);
662  expect.eM11 = (FLOAT) lometric_wnd.cx / lometric_vp.cx;
663  expect.eM22 = (FLOAT) lometric_wnd.cy / lometric_vp.cy;
664  xform_near_match(__LINE__, &xform, &expect);
665 
666 
668 
669  expect.eM11 = 10.0;
670  expect.eM22 = 20.0;
672  r = pGetTransform(hdc, 0x203, &xform); /* World -> Page */
673  ok(r == TRUE, "got %d\n", r);
674  xform_near_match(__LINE__, &xform, &expect);
675 
676  r = pGetTransform(hdc, 0x304, &xform); /* Page -> Device */
677  ok(r == TRUE, "got %d\n", r);
678  expect.eM11 = (FLOAT) lometric_vp.cx / lometric_wnd.cx;
679  expect.eM22 = (FLOAT) lometric_vp.cy / lometric_wnd.cy;
680  xform_near_match(__LINE__, &xform, &expect);
681 
682  r = pGetTransform(hdc, 0x204, &xform); /* World -> Device */
683  ok(r == TRUE, "got %d\n", r);
684  expect.eM11 *= 10.0;
685  expect.eM22 *= 20.0;
686  xform_near_match(__LINE__, &xform, &expect);
687 
688  r = pGetTransform(hdc, 0x402, &xform); /* Device -> World */
689  ok(r == TRUE, "got %d\n", r);
690  expect.eM11 = 1 / expect.eM11;
691  expect.eM22 = 1 / expect.eM22;
692  xform_near_match(__LINE__, &xform, &expect);
693 
694  r = pGetTransform(hdc, 0x102, &xform);
695  ok(r == FALSE, "got %d\n", r);
696  r = pGetTransform(hdc, 0x103, &xform);
697  ok(r == FALSE, "got %d\n", r);
698  r = pGetTransform(hdc, 0x104, &xform);
699  ok(r == FALSE, "got %d\n", r);
700  r = pGetTransform(hdc, 0x202, &xform);
701  ok(r == FALSE, "got %d\n", r);
702  r = pGetTransform(hdc, 0x302, &xform);
703  ok(r == FALSE, "got %d\n", r);
704  r = pGetTransform(hdc, 0x303, &xform);
705  ok(r == FALSE, "got %d\n", r);
706  r = pGetTransform(hdc, 0x403, &xform);
707  ok(r == FALSE, "got %d\n", r);
708  r = pGetTransform(hdc, 0x404, &xform);
709  ok(r == FALSE, "got %d\n", r);
710  r = pGetTransform(hdc, 0xffff, &xform);
711  ok(r == FALSE, "got %d\n", r);
712 }
#define TRUE
Definition: types.h:120
#define FLOAT
Definition: i386-dis.c:516
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void expect_identity(int line, XFORM *xf)
Definition: mapping.c:593
static HDC
Definition: imagelist.c:92
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
static void xform_near_match(int line, XFORM *got, XFORM *expect)
Definition: mapping.c:603
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI SetMapMode(_In_ HDC, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
#define MM_LOMETRIC
Definition: wingdi.h:871
HDC hdc
Definition: main.c:9
#define ok(value,...)
Definition: atltest.h:57
#define expect(expected, got)
Definition: combo.c:36
float FLOAT
Definition: typedefs.h:67
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
LONG cy
Definition: windef.h:335
#define win_skip
Definition: test.h:150
#define GM_ADVANCED
Definition: wingdi.h:864

Referenced by START_TEST().

◆ test_isotropic_mapping()

static void test_isotropic_mapping ( void  )
static

Definition at line 465 of file mapping.c.

466 {
467  SIZE win, vp;
468  HDC hdc = GetDC(0);
469 
471 
472  /* MM_ISOTROPIC is set up like MM_LOMETRIC.
473  Initial values after SetMapMode():
474  (1 inch = 25.4 mm)
475 
476  Windows 9x: Windows NT:
477  Window Ext: 254 x -254 HORZSIZE*10 x VERTSIZE*10
478  Viewport Ext: LOGPIXELSX x LOGPIXELSY HORZRES x -VERTRES
479 
480  To test without rounding errors, we have to use multiples of
481  these values!
482  */
483 
485  GetViewportExtEx(hdc, &vp);
486 
487  test_SetViewportExt(hdc, 10 * vp.cx, 10 * vp.cy, 10 * vp.cx, 10 * vp.cy);
488  test_SetWindowExt(hdc, win.cx, win.cy, 10 * vp.cx, 10 * vp.cy);
489  test_SetWindowExt(hdc, 2 * win.cx, win.cy, 10 * vp.cx, 5 * vp.cy);
490  test_SetWindowExt(hdc, win.cx, win.cy, 5 * vp.cx, 5 * vp.cy);
491  test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
492  test_SetViewportExt(hdc, vp.cx, 2 * vp.cy, vp.cx, vp.cy);
493  test_SetViewportExt(hdc, 2 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
494  test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
495  test_SetWindowExt(hdc, 4 * win.cx, 2 * win.cy, 2 * vp.cx, vp.cy);
496  test_SetViewportExt(hdc, -2 * vp.cx, -4 * vp.cy, -2 * vp.cx, -vp.cy);
497  test_SetViewportExt(hdc, -2 * vp.cx, -1 * vp.cy, -2 * vp.cx, -vp.cy);
498  test_SetWindowExt(hdc, -4 * win.cx, -2 * win.cy, -2 * vp.cx, -vp.cy);
499  test_SetWindowExt(hdc, 4 * win.cx, -4 * win.cy, -vp.cx, -vp.cy);
500 
501  ReleaseDC(0, hdc);
502 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
HDC WINAPI GetDC(_In_opt_ HWND)
static void test_SetWindowExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
Definition: mapping.c:404
static HDC
Definition: imagelist.c:92
static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
Definition: mapping.c:434
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG cx
Definition: windef.h:334
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
HDC hdc
Definition: main.c:9
static real win[4][36]
LONG cy
Definition: windef.h:335

Referenced by START_TEST().

◆ test_modify_world_transform()

static void test_modify_world_transform ( void  )
static

Definition at line 384 of file mapping.c.

385 {
386  HDC hdc = GetDC(0);
387  int ret;
388 
390  ok(ret, "ret = %d\n", ret);
391 
393  ok(ret, "ret = %d\n", ret);
394 
396  ok(!ret, "ret = %d\n", ret);
397 
399  ok(!ret, "ret = %d\n", ret);
400 
401  ReleaseDC(0, hdc);
402 }
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
#define MWT_LEFTMULTIPLY
Definition: wingdi.h:944
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI ModifyWorldTransform(_In_ HDC, _In_opt_ const XFORM *, _In_ DWORD)
int ret
HDC hdc
Definition: main.c:9
#define ok(value,...)
Definition: atltest.h:57
#define MWT_IDENTITY
Definition: wingdi.h:943
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
#define GM_ADVANCED
Definition: wingdi.h:864
#define MWT_RIGHTMULTIPLY
Definition: wingdi.h:945

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 434 of file mapping.c.

435 {
436  SIZE windowExt, windowExtAfter, viewportExt;
437  POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
438 
439  GetWindowOrgEx(hdc, &windowOrg);
440  GetViewportOrgEx(hdc, &viewportOrg);
441  GetWindowExtEx(hdc, &windowExt);
442 
444  GetViewportExtEx(hdc, &viewportExt);
445  ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
446  "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n",
447  expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
448 
449  GetWindowExtEx(hdc, &windowExtAfter);
450  ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy,
451  "Window extension changed from %dx%d to %dx%d\n",
452  windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy);
453 
454  GetWindowOrgEx(hdc, &windowOrgAfter);
455  ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
456  "Window origin changed from (%d,%d) to (%d,%d)\n",
457  windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
458 
459  GetViewportOrgEx(hdc, &viewportOrgAfter);
460  ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
461  "Viewport origin changed from (%d,%d) to (%d,%d)\n",
462  viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
463 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:439
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:383
#define rough_match(got, expected)
Definition: mapping.c:37
HDC hdc
Definition: main.c:9
#define ok(value,...)
Definition: atltest.h:57
_Out_opt_ int * cx
Definition: commctrl.h:581
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
LONG cy
Definition: windef.h:335

Referenced by test_isotropic_mapping().

◆ test_setvirtualresolution()

static void test_setvirtualresolution ( void  )
static

Definition at line 504 of file mapping.c.

505 {
506  HDC hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
507  BOOL r;
508  INT horz_res = GetDeviceCaps(hdc, HORZRES);
509  INT horz_size = GetDeviceCaps(hdc, HORZSIZE);
510  INT log_pixels_x = GetDeviceCaps(hdc, LOGPIXELSX);
511  SIZE orig_lometric_vp, orig_lometric_wnd;
512 
513  if(!pSetVirtualResolution)
514  {
515  win_skip("Don't have SetVirtualResolution\n");
516  return;
517  }
518 
519  /* Get the true resolution limits */
521  GetViewportExtEx(hdc, &orig_lometric_vp);
522  GetWindowExtEx(hdc, &orig_lometric_wnd);
524 
525  r = pSetVirtualResolution(hdc, 4000, 1000, 400, 200); /* 10 pix/mm x 5 pix/mm */
526  ok(r == TRUE, "got %d\n", r);
527  expect_LPtoDP(hdc, 1000, 1000);
528  expect_viewport_ext(hdc, 1, 1);
529  expect_window_ext(hdc, 1, 1);
530 
532  expect_LPtoDP(hdc, 1000, -500);
533  expect_viewport_ext(hdc, 4000, -1000);
534  expect_window_ext(hdc, 4000, 2000);
535 
536  /* Doesn't change the device caps */
537  ok(horz_res == GetDeviceCaps(hdc, HORZRES), "horz_res changed\n");
538  ok(horz_size == GetDeviceCaps(hdc, HORZSIZE), "horz_size changed\n");
539  ok(log_pixels_x == GetDeviceCaps(hdc, LOGPIXELSX), "log_pixels_x changed\n");
540 
541  r = pSetVirtualResolution(hdc, 8000, 1000, 400, 200); /* 20 pix/mm x 5 pix/mm */
542  ok(r == TRUE, "got %d\n", r);
543  expect_LPtoDP(hdc, 1000, -500); /* No change, need to re-set the mapping mode */
546  expect_LPtoDP(hdc, 2000, -500);
547  expect_viewport_ext(hdc, 8000, -1000);
548  expect_window_ext(hdc, 4000, 2000);
549 
550  r = pSetVirtualResolution(hdc, 8000, 1000, 200, 200); /* 40 pix/mm x 5 pix/mm */
551  ok(r == TRUE, "got %d\n", r);
554  expect_LPtoDP(hdc, 4000, -500);
555  expect_viewport_ext(hdc, 8000, -1000);
556  expect_window_ext(hdc, 2000, 2000);
557 
558  r = pSetVirtualResolution(hdc, 8000, 1000, 200, 200); /* 40 pix/mm x 5 pix/mm */
559  ok(r == TRUE, "got %d\n", r);
562  expect_LPtoDP(hdc, 4000, -500);
563  expect_viewport_ext(hdc, 8000, -1000);
564  expect_window_ext(hdc, 2000, 2000);
565 
566  r = pSetVirtualResolution(hdc, 8000, 2000, 200, 200); /* 40 pix/mm x 10 pix/mm */
567  ok(r == TRUE, "got %d\n", r);
570  expect_LPtoDP(hdc, 4000, -1000);
571  expect_viewport_ext(hdc, 8000, -2000);
572  expect_window_ext(hdc, 2000, 2000);
573 
574  r = pSetVirtualResolution(hdc, 0, 0, 10, 0); /* Error */
575  ok(r == FALSE, "got %d\n", r);
578  expect_LPtoDP(hdc, 4000, -1000);
579  expect_viewport_ext(hdc, 8000, -2000);
580  expect_window_ext(hdc, 2000, 2000);
581 
582  r = pSetVirtualResolution(hdc, 0, 0, 0, 0); /* Reset to true resolution */
583  ok(r == TRUE, "got %d\n", r);
586  expect_viewport_ext(hdc, orig_lometric_vp.cx, orig_lometric_vp.cy);
587  expect_window_ext(hdc, orig_lometric_wnd.cx, orig_lometric_wnd.cy);
588 
589  DeleteDC(hdc);
590 }
#define HORZRES
Definition: wingdi.h:715
#define LOGPIXELSX
Definition: wingdi.h:717
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HDC
Definition: imagelist.c:92
int32_t INT
Definition: typedefs.h:56
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI SetMapMode(_In_ HDC, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
#define MM_LOMETRIC
Definition: wingdi.h:871
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define expect_window_ext(_hdc, _cx, _cy)
Definition: mapping.c:77
#define HORZSIZE
Definition: wingdi.h:713
#define expect_viewport_ext(_hdc, _cx, _cy)
Definition: mapping.c:76
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57
#define MM_TEXT
Definition: wingdi.h:872
#define expect_LPtoDP(_hdc, _x, _y)
Definition: mapping.c:39
LONG cy
Definition: windef.h:335
#define win_skip
Definition: test.h:150

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 404 of file mapping.c.

405 {
406  SIZE windowExt, viewportExt;
407  POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
408 
409  GetWindowOrgEx(hdc, &windowOrg);
410  GetViewportOrgEx(hdc, &viewportOrg);
411 
413  GetWindowExtEx(hdc, &windowExt);
414  ok(windowExt.cx == cx && windowExt.cy == cy,
415  "Window extension: Expected %dx%d, got %dx%d\n",
416  cx, cy, windowExt.cx, windowExt.cy);
417 
418  GetViewportExtEx(hdc, &viewportExt);
419  ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
420  "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n",
421  expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
422 
423  GetWindowOrgEx(hdc, &windowOrgAfter);
424  ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
425  "Window origin changed from (%d,%d) to (%d,%d)\n",
426  windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
427 
428  GetViewportOrgEx(hdc, &viewportOrgAfter);
429  ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
430  "Viewport origin changed from (%d,%d) to (%d,%d)\n",
431  viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
432 }
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:439
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:383
#define rough_match(got, expected)
Definition: mapping.c:37
HDC hdc
Definition: main.c:9
#define ok(value,...)
Definition: atltest.h:57
_Out_opt_ int * cx
Definition: commctrl.h:581
LONG cy
Definition: windef.h:335

Referenced by test_isotropic_mapping().

◆ test_world_transform()

static void test_world_transform ( void  )
static

Definition at line 79 of file mapping.c.

80 {
81  HDC hdc;
82  INT ret, 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 %d x %d, resolution %d x %d dpi %d x %d\n",
104  size_cx, size_cy, res_x, res_y, dpi_x, dpi_y );
105 
106  expect_viewport_ext(hdc, 1, 1);
107  expect_window_ext(hdc, 1, 1);
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 %d or %d, got %d\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 %d or %d, got %d\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, 1, 1);
131  expect_window_ext(hdc, 1, 1);
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, 1, 1);
144  expect_window_ext(hdc, 1, 1);
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 %u\n", GetLastError());
169 
170  expect_viewport_ext(hdc, 1, 1);
171  expect_window_ext(hdc, 1, 1);
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 %d or %d, got %d\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 %d or %d, got %d\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, 1, 1);
195  expect_window_ext(hdc, 1, 1);
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 %d,%d\n", size.cx, size.cy);
204  expect_viewport_ext(hdc, 1, 1);
205  expect_window_ext(hdc, 1, 1);
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, 1, 1);
213  expect_window_ext(hdc, 1, 1);
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 %d,%d\n", size.cx, size.cy);
222  expect_viewport_ext(hdc, -1, -1);
223  expect_window_ext(hdc, 1, 1);
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, -1, -1);
233  expect_window_ext(hdc, 1, 1);
234  expect_world_transform(hdc, 20.0, 20.0);
235  expect_LPtoDP(hdc, -20000, -20000);
236 
237  DeleteDC(hdc);
238 }
#define HORZRES
Definition: wingdi.h:715
#define LOGPIXELSX
Definition: wingdi.h:717
static HDC
Definition: imagelist.c:92
#define expect_world_transform(_hdc, _em11, _em22)
Definition: mapping.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
int WINAPI SetMapMode(_In_ HDC, _In_ int)
FLOAT eDx
Definition: wingdi.h:1724
FLOAT eM21
Definition: wingdi.h:1722
FLOAT eM12
Definition: wingdi.h:1721
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
int WINAPI GetGraphicsMode(_In_ HDC)
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
#define MM_LOMETRIC
Definition: wingdi.h:871
#define rough_match(got, expected)
Definition: mapping.c:37
#define SetLastError(x)
Definition: compat.h:417
#define GM_COMPATIBLE
Definition: wingdi.h:863
int ret
FLOAT eM11
Definition: wingdi.h:1720
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define broken(x)
Definition: _sntprintf.h:21
#define expect_window_ext(_hdc, _cx, _cy)
Definition: mapping.c:77
#define HORZSIZE
Definition: wingdi.h:713
#define expect_viewport_ext(_hdc, _cx, _cy)
Definition: mapping.c:76
#define VERTSIZE
Definition: wingdi.h:714
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57
FLOAT eM22
Definition: wingdi.h:1723
FLOAT eDy
Definition: wingdi.h:1725
#define VERTRES
Definition: wingdi.h:716
#define skip(...)
Definition: atltest.h:64
#define MM_TEXT
Definition: wingdi.h:872
#define LOGPIXELSY
Definition: wingdi.h:718
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define expect_LPtoDP(_hdc, _x, _y)
Definition: mapping.c:39
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define GM_ADVANCED
Definition: wingdi.h:864

Referenced by START_TEST().

◆ xform_near_match()

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

Definition at line 603 of file mapping.c.

604 {
605  ok(fabs(got->eM11 - expect->eM11) < 0.001, "%d: got %f expect %f\n", line, got->eM11, expect->eM11);
606  ok(fabs(got->eM12 - expect->eM12) < 0.001, "%d: got %f expect %f\n", line, got->eM12, expect->eM12);
607  ok(fabs(got->eM21 - expect->eM21) < 0.001, "%d: got %f expect %f\n", line, got->eM21, expect->eM21);
608  ok(fabs(got->eM22 - expect->eM22) < 0.001, "%d: got %f expect %f\n", line, got->eM22, expect->eM22);
609  ok(fabs(got->eDx - expect->eDx) < 0.001, "%d: got %f expect %f\n", line, got->eDx, expect->eDx);
610  ok(fabs(got->eDy - expect->eDy) < 0.001, "%d: got %f expect %f\n", line, got->eDy, expect->eDy);
611 }
FLOAT eDx
Definition: wingdi.h:1724
FLOAT eM21
Definition: wingdi.h:1722
FLOAT eM12
Definition: wingdi.h:1721
Definition: parser.c:48
FLOAT eM11
Definition: wingdi.h:1720
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
#define ok(value,...)
Definition: atltest.h:57
#define expect(expected, got)
Definition: combo.c:36
FLOAT eM22
Definition: wingdi.h:1723
FLOAT eDy
Definition: wingdi.h:1725

Referenced by test_gettransform().

Variable Documentation

◆ DWORD

XFORM* static DWORD

Definition at line 34 of file mapping.c.

◆ hRgn

◆ iCode

HRGN INT iCode

◆ layout

DWORD layout

Definition at line 31 of file mapping.c.