ReactOS 0.4.15-dev-8241-g63935f8
LPtoDP.c File Reference
#include "precomp.h"
Include dependency graph for LPtoDP.c:

Go to the source code of this file.

Classes

struct  PRESET
 
struct  TEST_ENTRY
 

Macros

#define INVALID_POINTER   ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
 
#define NO_CHECK   0xFACECAFE
 
#define CALC_VALUE_1   0xBADACE01
 
#define CALC_VALUE_2   0xFEEDF00D
 
#define CALC_VALUE_3   0xDEADCAD1
 
#define DISPLAY_SIZE   0xDEADBEEF
 
#define NEGA_DISPLAY_SIZE   0xBEEFDEAD
 
#define PRESET0   { 0, 0, 0, 0, 0, 0, 0, 0 }
 
#define PRESET1   { 0, 0, 1, 1, 0, 0, 1, 1 }
 
#define PRESET2   { 75, 0, 1, 1, 0, 0, 10, 10 }
 
#define PRESET3   { 0, 180, 1, 1, 120, 0, 1, 1 }
 
#define PRESET4   { 0, 0, 200, 1, 50, 0, 1, 1 }
 
#define PRESET5   { 0, 0, 1, 200, 0, 0, -100, 1 }
 
#define PRESET6   { 50, 0, 1, 200, 10, 0, 100, 200 }
 

Typedefs

typedef struct PRESET PRESET
 
typedef struct TEST_ENTRY TEST_ENTRY
 

Functions

static void SetXForm1 (XFORM *pxform)
 
static void SetXForm2 (XFORM *pxform)
 
static void DoTestEntry (HDC hDC, const TEST_ENTRY *entry)
 
 START_TEST (LPtoDP)
 

Variables

static const TEST_ENTRY s_entries []
 
static const size_t s_entries_count = _countof(s_entries)
 
static const TEST_ENTRY s_shifted_entries []
 
static const size_t s_shifted_entries_count = _countof(s_shifted_entries)
 
static const TEST_ENTRY s_transformed_entries []
 
static const size_t s_transformed_entries_count = _countof(s_transformed_entries)
 

Macro Definition Documentation

◆ CALC_VALUE_1

#define CALC_VALUE_1   0xBADACE01

Definition at line 12 of file LPtoDP.c.

◆ CALC_VALUE_2

#define CALC_VALUE_2   0xFEEDF00D

Definition at line 13 of file LPtoDP.c.

◆ CALC_VALUE_3

#define CALC_VALUE_3   0xDEADCAD1

Definition at line 14 of file LPtoDP.c.

◆ DISPLAY_SIZE

#define DISPLAY_SIZE   0xDEADBEEF

Definition at line 15 of file LPtoDP.c.

◆ INVALID_POINTER

#define INVALID_POINTER   ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)

Definition at line 10 of file LPtoDP.c.

◆ NEGA_DISPLAY_SIZE

#define NEGA_DISPLAY_SIZE   0xBEEFDEAD

Definition at line 16 of file LPtoDP.c.

◆ NO_CHECK

#define NO_CHECK   0xFACECAFE

Definition at line 11 of file LPtoDP.c.

◆ PRESET0

#define PRESET0   { 0, 0, 0, 0, 0, 0, 0, 0 }

Definition at line 56 of file LPtoDP.c.

◆ PRESET1

#define PRESET1   { 0, 0, 1, 1, 0, 0, 1, 1 }

Definition at line 57 of file LPtoDP.c.

◆ PRESET2

#define PRESET2   { 75, 0, 1, 1, 0, 0, 10, 10 }

Definition at line 58 of file LPtoDP.c.

◆ PRESET3

#define PRESET3   { 0, 180, 1, 1, 120, 0, 1, 1 }

Definition at line 59 of file LPtoDP.c.

◆ PRESET4

#define PRESET4   { 0, 0, 200, 1, 50, 0, 1, 1 }

Definition at line 60 of file LPtoDP.c.

◆ PRESET5

#define PRESET5   { 0, 0, 1, 200, 0, 0, -100, 1 }

Definition at line 61 of file LPtoDP.c.

◆ PRESET6

#define PRESET6   { 50, 0, 1, 200, 10, 0, 100, 200 }

Definition at line 62 of file LPtoDP.c.

Typedef Documentation

◆ PRESET

typedef struct PRESET PRESET

◆ TEST_ENTRY

Function Documentation

◆ DoTestEntry()

static void DoTestEntry ( HDC  hDC,
const TEST_ENTRY entry 
)
static

Definition at line 288 of file LPtoDP.c.

289{
290 POINT pt, ptWnd, ptView;
291 SIZE siz, sizWnd, sizView;
292 INT ret;
293
294 SetMapMode(hDC, entry->nMapMode);
295
296 ret = SetWindowOrgEx(hDC, entry->preset.xWnd, entry->preset.yWnd, NULL);
297 ok(ret == TRUE, "Line %d: SetWindowOrgEx failed\n", entry->lineno);
298
299 ret = SetWindowExtEx(hDC, entry->preset.cxWnd, entry->preset.cyWnd, NULL);
300 ok(ret == entry->bWndExt, "Line %d: SetWindowExtEx() expected %d, was %d\n", entry->lineno, entry->bWndExt, ret);
301
302 ret = SetViewportOrgEx(hDC, entry->preset.xView, entry->preset.yView, NULL);
303 ok(ret == TRUE, "Line %d: SetViewportOrgEx failed\n", entry->lineno);
304
305 ret = SetViewportExtEx(hDC, entry->preset.cxView, entry->preset.cyView, NULL);
306 ok(ret == TRUE, "Line %d: SetViewportExtEx failed\n", entry->lineno);
307
308 ok(GetWindowOrgEx(hDC, &pt) == TRUE, "Line %d: GetWindowOrgEx failed\n", entry->lineno);
309 ptWnd = pt;
310 ok(GetWindowExtEx(hDC, &siz) == TRUE, "Line %d: GetWindowExtEx failed\n", entry->lineno);
311 sizWnd = siz;
312
313 ok(pt.x == entry->xWndOut && pt.y == entry->yWndOut,
314 "Line %d: Window org expected (%ld, %ld), was (%ld, %ld)\n",
315 entry->lineno, entry->xWndOut, entry->yWndOut, pt.x, pt.y);
316
317 if (entry->cxWndOut == DISPLAY_SIZE || entry->cxWndOut == NEGA_DISPLAY_SIZE)
318 {
321 if (entry->cxWndOut == NEGA_DISPLAY_SIZE)
322 cx = -cx;
323 if (entry->cyWndOut == NEGA_DISPLAY_SIZE)
324 cy = -cy;
325 ok(siz.cx == cx && siz.cy == cy,
326 "Line %d: Window ext expected display size (%ld, %ld), was (%ld, %ld)\n",
327 entry->lineno, cx, cy, siz.cx, siz.cy);
328 }
329 else if (entry->cxWndOut != NO_CHECK)
330 {
331 ok(siz.cx == entry->cxWndOut && siz.cy == entry->cyWndOut,
332 "Line %d: Window ext expected (%ld, %ld), was (%ld, %ld)\n",
333 entry->lineno, entry->cxWndOut, entry->cyWndOut, siz.cx, siz.cy);
334 }
335
336 ok(GetViewportOrgEx(hDC, &pt) == TRUE, "Line %d: GetViewportOrgEx failed\n", entry->lineno);
337 ptView = pt;
338 ok(GetViewportExtEx(hDC, &siz) == TRUE, "Line %d: GetViewportExtEx failed\n", entry->lineno);
339 sizView = siz;
340
341 ok(pt.x == entry->xViewOut && pt.y == entry->yViewOut,
342 "Line %d: Viewport org expected (%ld, %ld), was (%ld, %ld)\n",
343 entry->lineno, entry->xViewOut , entry->yViewOut, pt.x, pt.y);
344
345 if (entry->cxViewOut == DISPLAY_SIZE || entry->cxViewOut == NEGA_DISPLAY_SIZE)
346 {
349 if (entry->cxViewOut == NEGA_DISPLAY_SIZE)
350 cx = -cx;
351 if (entry->cyViewOut == NEGA_DISPLAY_SIZE)
352 cy = -cy;
353 ok(siz.cx == cx && siz.cy == cy,
354 "Line %d: Viewport ext expected display size (%ld, %ld), was (%ld, %ld)\n",
355 entry->lineno, cx, cy, siz.cx, siz.cy);
356 }
357 else if (entry->cxViewOut != NO_CHECK)
358 {
359 ok(siz.cx == entry->cxViewOut && siz.cy == entry->cyViewOut,
360 "Line %d: Viewport ext expected (%ld, %ld), was (%ld, %ld)\n",
361 entry->lineno, entry->cxViewOut, entry->cyViewOut, siz.cx, siz.cy);
362 }
363
364 pt = entry->ptSrc;
365
366 SetLastError(0xDEADBEEF);
367 ret = LPtoDP(hDC, &pt, 1);
368 ok(ret == entry->ret, "Line %d: LPtoDP() expected %d, was %d\n", entry->lineno, entry->ret, ret);
369
370 ok(GetLastError() == entry->error, "Line %d: GetLastError() expected %ld, was %ld\n",
371 entry->lineno, entry->error, GetLastError());
372
373 if (entry->ptDest.x == CALC_VALUE_1)
374 {
375 LONG x = MulDiv(entry->ptSrc.x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x;
376 LONG y = MulDiv(entry->ptSrc.y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y;
377 // TODO: make more accurate
378 ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
379 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
380 entry->lineno, x, y, pt.x, pt.y);
381 }
382 else if (entry->ptDest.x == CALC_VALUE_2)
383 {
384 XFORM xform;
385 LONG x, y;
386 SetXForm1(&xform);
387 x = (LONG)((xform.eM11 * entry->ptSrc.x + xform.eM12 * entry->ptSrc.y) + xform.eDx);
388 y = (LONG)((xform.eM21 * entry->ptSrc.x + xform.eM22 * entry->ptSrc.y) + xform.eDy);
389 x = MulDiv(x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x;
390 y = MulDiv(y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y;
391 // TODO: make more accurate
392 ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
393 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
394 entry->lineno, x, y, pt.x, pt.y);
395 }
396 else if (entry->ptDest.x == CALC_VALUE_3)
397 {
398 XFORM xform;
399 LONG x, y;
400 SetXForm2(&xform);
401 x = (LONG)((xform.eM11 * entry->ptSrc.x + xform.eM12 * entry->ptSrc.y) + xform.eDx);
402 y = (LONG)((xform.eM21 * entry->ptSrc.x + xform.eM22 * entry->ptSrc.y) + xform.eDy);
403 x = MulDiv(x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x;
404 y = MulDiv(y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y;
405 // TODO: make more accurate
406 ok(labs(pt.x - x) <= 2 && labs(pt.y - y) <= 2,
407 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
408 entry->lineno, x, y, pt.x, pt.y);
409 }
410 else if (entry->ptDest.x != NO_CHECK)
411 {
412 ok(pt.x == entry->ptDest.x && pt.y == entry->ptDest.y,
413 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
414 entry->lineno, entry->ptDest.x, entry->ptDest.y, pt.x, pt.y);
415 }
416}
static HDC hDC
Definition: 3dtext.c:33
#define DISPLAY_SIZE
Definition: LPtoDP.c:15
#define NO_CHECK
Definition: LPtoDP.c:11
#define CALC_VALUE_1
Definition: LPtoDP.c:12
static void SetXForm1(XFORM *pxform)
Definition: LPtoDP.c:268
static void SetXForm2(XFORM *pxform)
Definition: LPtoDP.c:278
#define NEGA_DISPLAY_SIZE
Definition: LPtoDP.c:16
#define CALC_VALUE_3
Definition: LPtoDP.c:14
#define CALC_VALUE_2
Definition: LPtoDP.c:13
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define SetLastError(x)
Definition: compat.h:752
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Check_return_ long __cdecl labs(_In_ long x)
uint32_t entry
Definition: isohybrid.c:63
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
long LONG
Definition: pedump.c:60
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
FLOAT eDy
Definition: wingdi.h:1726
FLOAT eM11
Definition: wingdi.h:1721
FLOAT eM21
Definition: wingdi.h:1723
FLOAT eM22
Definition: wingdi.h:1724
FLOAT eM12
Definition: wingdi.h:1722
FLOAT eDx
Definition: wingdi.h:1725
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t INT
Definition: typedefs.h:58
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define HORZRES
Definition: wingdi.h:716
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:439
BOOL WINAPI LPtoDP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define VERTRES
Definition: wingdi.h:717
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:383

Referenced by START_TEST().

◆ SetXForm1()

static void SetXForm1 ( XFORM pxform)
static

Definition at line 268 of file LPtoDP.c.

269{
270 pxform->eM11 = 1;
271 pxform->eM12 = 0;
272 pxform->eM21 = 0;
273 pxform->eM22 = 1;
274 pxform->eDx = 314;
275 pxform->eDy = -99;
276}

Referenced by DoTestEntry(), and START_TEST().

◆ SetXForm2()

static void SetXForm2 ( XFORM pxform)
static

Definition at line 278 of file LPtoDP.c.

279{
280 pxform->eM11 = 2;
281 pxform->eM12 = 0;
282 pxform->eM21 = 0;
283 pxform->eM22 = 3;
284 pxform->eDx = 0;
285 pxform->eDy = 0;
286}

Referenced by DoTestEntry(), and START_TEST().

◆ START_TEST()

START_TEST ( LPtoDP  )

Definition at line 418 of file LPtoDP.c.

419{
420 size_t i;
421 POINT apt[2];
422 XFORM xform;
423
425 ok(hDC != NULL, "hDC is NULL\n");
426
427 SetLastError(0xDEADBEEF);
428 ok_int(LPtoDP(NULL, NULL, 0), 1);
429 ok_err(0xDEADBEEF);
430
431 ok_int(LPtoDP(NULL, NULL, -1), 1);
432 ok_err(0xDEADBEEF);
433
435 ok_err(0xDEADBEEF);
436
437 ok_int(LPtoDP(NULL, NULL, 2), 0);
439
440 SetLastError(0xDEADBEEF);
441 ok_int(LPtoDP(NULL, apt, 2), 0);
443
444 SetLastError(0xDEADBEEF);
445 ok_int(LPtoDP(NULL, apt, 0), 1);
446 ok_err(0xDEADBEEF);
447
448 SetLastError(0xDEADBEEF);
449 ok_int(LPtoDP(NULL, apt, -2), 1);
450 ok_err(0xDEADBEEF);
451
452 SetLastError(0xDEADBEEF);
453 ok_int(LPtoDP((HDC)-4, apt, -2), 1);
454 ok_err(0xDEADBEEF);
455
456 SetLastError(0xDEADBEEF);
457 ok_int(LPtoDP(hDC, NULL, 2), 1);
458 ok_err(0xDEADBEEF);
459
460 SetLastError(0xDEADBEEF);
462 ok_err(0xDEADBEEF);
463
466
467 for (i = 0; i < s_entries_count; ++i)
468 {
470 }
471
474
475 for (i = 0; i < s_entries_count; ++i)
476 {
478 }
479
480 SetXForm1(&xform);
482 SetWorldTransform(hDC, &xform);
483 for (i = 0; i < s_shifted_entries_count; ++i)
484 {
486 }
487
488 SetXForm2(&xform);
490 SetWorldTransform(hDC, &xform);
491 for (i = 0; i < s_transformed_entries_count; ++i)
492 {
494 }
495
496 DeleteDC(hDC);
497}
static const TEST_ENTRY s_transformed_entries[]
Definition: LPtoDP.c:200
static const TEST_ENTRY s_entries[]
Definition: LPtoDP.c:64
static const size_t s_entries_count
Definition: LPtoDP.c:130
static const size_t s_transformed_entries_count
Definition: LPtoDP.c:266
#define INVALID_POINTER
Definition: LPtoDP.c:10
static const size_t s_shifted_entries_count
Definition: LPtoDP.c:198
static void DoTestEntry(HDC hDC, const TEST_ENTRY *entry)
Definition: LPtoDP.c:288
static const TEST_ENTRY s_shifted_entries[]
Definition: LPtoDP.c:132
#define ok_err(error)
Definition: atltest.h:124
#define ok_int(expression, result)
Definition: atltest.h:134
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HDC
Definition: imagelist.c:92
#define GM_COMPATIBLE
Definition: wingdi.h:864
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1226
#define GM_ADVANCED
Definition: wingdi.h:865
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define MWT_IDENTITY
Definition: wingdi.h:944
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI ModifyWorldTransform(_In_ HDC, _In_opt_ const XFORM *, _In_ DWORD)

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 64 of file LPtoDP.c.

Referenced by START_TEST().

◆ s_entries_count

const size_t s_entries_count = _countof(s_entries)
static

Definition at line 130 of file LPtoDP.c.

Referenced by START_TEST().

◆ s_shifted_entries

const TEST_ENTRY s_shifted_entries[]
static

Definition at line 132 of file LPtoDP.c.

Referenced by START_TEST().

◆ s_shifted_entries_count

const size_t s_shifted_entries_count = _countof(s_shifted_entries)
static

Definition at line 198 of file LPtoDP.c.

Referenced by START_TEST().

◆ s_transformed_entries

const TEST_ENTRY s_transformed_entries[]
static

Definition at line 200 of file LPtoDP.c.

Referenced by START_TEST().

◆ s_transformed_entries_count

const size_t s_transformed_entries_count = _countof(s_transformed_entries)
static

Definition at line 266 of file LPtoDP.c.

Referenced by START_TEST().