ReactOS 0.4.15-dev-8138-g1e75ea8
DPtoLP.c File Reference
#include "precomp.h"
Include dependency graph for DPtoLP.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 BOOL InverseXForm (XFORM *pxform)
 
static void DoTestEntry (HDC hDC, const TEST_ENTRY *entry)
 
 START_TEST (DPtoLP)
 

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 13 of file DPtoLP.c.

◆ CALC_VALUE_2

#define CALC_VALUE_2   0xFEEDF00D

Definition at line 14 of file DPtoLP.c.

◆ CALC_VALUE_3

#define CALC_VALUE_3   0xDEADCAD1

Definition at line 15 of file DPtoLP.c.

◆ DISPLAY_SIZE

#define DISPLAY_SIZE   0xDEADBEEF

Definition at line 16 of file DPtoLP.c.

◆ INVALID_POINTER

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

Definition at line 11 of file DPtoLP.c.

◆ NEGA_DISPLAY_SIZE

#define NEGA_DISPLAY_SIZE   0xBEEFDEAD

Definition at line 17 of file DPtoLP.c.

◆ NO_CHECK

#define NO_CHECK   0xFACECAFE

Definition at line 12 of file DPtoLP.c.

◆ PRESET0

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

Definition at line 57 of file DPtoLP.c.

◆ PRESET1

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

Definition at line 58 of file DPtoLP.c.

◆ PRESET2

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

Definition at line 59 of file DPtoLP.c.

◆ PRESET3

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

Definition at line 60 of file DPtoLP.c.

◆ PRESET4

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

Definition at line 61 of file DPtoLP.c.

◆ PRESET5

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

Definition at line 62 of file DPtoLP.c.

◆ PRESET6

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

Definition at line 63 of file DPtoLP.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 305 of file DPtoLP.c.

306{
307 POINT pt, ptWnd, ptView;
308 SIZE siz, sizWnd, sizView;
309 INT ret;
310
311 SetMapMode(hDC, entry->nMapMode);
312
313 ret = SetWindowOrgEx(hDC, entry->preset.xWnd, entry->preset.yWnd, NULL);
314 ok(ret == TRUE, "Line %d: SetWindowOrgEx failed\n", entry->lineno);
315
316 ret = SetWindowExtEx(hDC, entry->preset.cxWnd, entry->preset.cyWnd, NULL);
317 ok(ret == entry->bWndExt, "Line %d: SetWindowExtEx() expected %d, was %d\n", entry->lineno, entry->bWndExt, ret);
318
319 ret = SetViewportOrgEx(hDC, entry->preset.xView, entry->preset.yView, NULL);
320 ok(ret == TRUE, "Line %d: SetViewportOrgEx failed\n", entry->lineno);
321
322 ret = SetViewportExtEx(hDC, entry->preset.cxView, entry->preset.cyView, NULL);
323 ok(ret == TRUE, "Line %d: SetViewportExtEx failed\n", entry->lineno);
324
325 ok(GetWindowOrgEx(hDC, &pt) == TRUE, "Line %d: GetWindowOrgEx failed\n", entry->lineno);
326 ptWnd = pt;
327 ok(GetWindowExtEx(hDC, &siz) == TRUE, "Line %d: GetWindowExtEx failed\n", entry->lineno);
328 sizWnd = siz;
329
330 ok(pt.x == entry->xWndOut && pt.y == entry->yWndOut,
331 "Line %d: Window org expected (%ld, %ld), was (%ld, %ld)\n",
332 entry->lineno, entry->xWndOut, entry->yWndOut, pt.x, pt.y);
333
334 if (entry->cxWndOut == DISPLAY_SIZE || entry->cxWndOut == NEGA_DISPLAY_SIZE)
335 {
338 if (entry->cxWndOut == NEGA_DISPLAY_SIZE)
339 cx = -cx;
340 if (entry->cyWndOut == NEGA_DISPLAY_SIZE)
341 cy = -cy;
342 ok(siz.cx == cx && siz.cy == cy,
343 "Line %d: Window ext expected display size (%ld, %ld), was (%ld, %ld)\n",
344 entry->lineno, cx, cy, siz.cx, siz.cy);
345 }
346 else if (entry->cxWndOut != NO_CHECK)
347 {
348 ok(siz.cx == entry->cxWndOut && siz.cy == entry->cyWndOut,
349 "Line %d: Window ext expected (%ld, %ld), was (%ld, %ld)\n",
350 entry->lineno, entry->cxWndOut, entry->cyWndOut, siz.cx, siz.cy);
351 }
352
353 ok(GetViewportOrgEx(hDC, &pt) == TRUE, "Line %d: GetViewportOrgEx failed\n", entry->lineno);
354 ptView = pt;
355 ok(GetViewportExtEx(hDC, &siz) == TRUE, "Line %d: GetViewportExtEx failed\n", entry->lineno);
356 sizView = siz;
357
358 ok(pt.x == entry->xViewOut && pt.y == entry->yViewOut,
359 "Line %d: Viewport org expected (%ld, %ld), was (%ld, %ld)\n",
360 entry->lineno, entry->xViewOut , entry->yViewOut, pt.x, pt.y);
361
362 if (entry->cxViewOut == DISPLAY_SIZE || entry->cxViewOut == NEGA_DISPLAY_SIZE)
363 {
366 if (entry->cxViewOut == NEGA_DISPLAY_SIZE)
367 cx = -cx;
368 if (entry->cyViewOut == NEGA_DISPLAY_SIZE)
369 cy = -cy;
370 ok(siz.cx == cx && siz.cy == cy,
371 "Line %d: Viewport ext expected display size (%ld, %ld), was (%ld, %ld)\n",
372 entry->lineno, cx, cy, siz.cx, siz.cy);
373 }
374 else if (entry->cxViewOut != NO_CHECK)
375 {
376 ok(siz.cx == entry->cxViewOut && siz.cy == entry->cyViewOut,
377 "Line %d: Viewport ext expected (%ld, %ld), was (%ld, %ld)\n",
378 entry->lineno, entry->cxViewOut, entry->cyViewOut, siz.cx, siz.cy);
379 }
380
381 pt = entry->ptSrc;
382
383 SetLastError(0xDEADBEEF);
384 ret = DPtoLP(hDC, &pt, 1);
385 ok(ret == entry->ret, "Line %d: DPtoLP() expected %d, was %d\n", entry->lineno, entry->ret, ret);
386
387 ok(GetLastError() == entry->error, "Line %d: GetLastError() expected %ld, was %ld\n",
388 entry->lineno, entry->error, GetLastError());
389
390 if (entry->ptDest.x == CALC_VALUE_1)
391 {
392 LONG x = MulDiv(entry->ptSrc.x - ptView.x, sizWnd.cx, sizView.cx) + ptWnd.x;
393 LONG y = MulDiv(entry->ptSrc.y - ptView.y, sizWnd.cy, sizView.cy) + ptWnd.y;
394 // TODO: make more accurate
395 ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
396 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
397 entry->lineno, x, y, pt.x, pt.y);
398 }
399 else if (entry->ptDest.x == CALC_VALUE_2)
400 {
401 XFORM xform;
402 LONG x, y;
403 SetXForm1(&xform);
404 if (InverseXForm(&xform))
405 {
406 x = MulDiv(entry->ptSrc.x - ptView.x, sizWnd.cx, sizView.cx) + ptWnd.x;
407 y = MulDiv(entry->ptSrc.y - ptView.y, sizWnd.cy, sizView.cy) + ptWnd.y;
408 x = (LONG)((xform.eM11 * x + xform.eM12 * y) + xform.eDx);
409 y = (LONG)((xform.eM21 * x + xform.eM22 * y) + xform.eDy);
410 // TODO: make more accurate
411 ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
412 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
413 entry->lineno, x, y, pt.x, pt.y);
414 }
415 }
416 else if (entry->ptDest.x == CALC_VALUE_3)
417 {
418 XFORM xform;
419 LONG x, y;
420 SetXForm2(&xform);
421 if (InverseXForm(&xform))
422 {
423 x = MulDiv(entry->ptSrc.x - ptView.x, sizWnd.cx, sizView.cx) + ptWnd.x;
424 y = MulDiv(entry->ptSrc.y - ptView.y, sizWnd.cy, sizView.cy) + ptWnd.y;
425 x = (LONG)((xform.eM11 * x + xform.eM12 * y) + xform.eDx);
426 y = (LONG)((xform.eM21 * x + xform.eM22 * y) + xform.eDy);
427 // TODO: make more accurate
428 ok(labs(pt.x - x) <= 2 && labs(pt.y - y) <= 2,
429 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
430 entry->lineno, x, y, pt.x, pt.y);
431 }
432 }
433 else if (entry->ptDest.x != NO_CHECK)
434 {
435 ok(pt.x == entry->ptDest.x && pt.y == entry->ptDest.y,
436 "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
437 entry->lineno, entry->ptDest.x, entry->ptDest.y, pt.x, pt.y);
438 }
439}
static HDC hDC
Definition: 3dtext.c:33
#define DISPLAY_SIZE
Definition: DPtoLP.c:16
#define NO_CHECK
Definition: DPtoLP.c:12
#define CALC_VALUE_1
Definition: DPtoLP.c:13
static void SetXForm1(XFORM *pxform)
Definition: DPtoLP.c:269
static void SetXForm2(XFORM *pxform)
Definition: DPtoLP.c:279
#define NEGA_DISPLAY_SIZE
Definition: DPtoLP.c:17
#define CALC_VALUE_3
Definition: DPtoLP.c:15
#define CALC_VALUE_2
Definition: DPtoLP.c:14
static BOOL InverseXForm(XFORM *pxform)
Definition: DPtoLP.c:289
#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 DPtoLP(_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().

◆ InverseXForm()

static BOOL InverseXForm ( XFORM pxform)
static

Definition at line 289 of file DPtoLP.c.

290{
291 XFORM xform = *pxform;
292 FLOAT delta = xform.eM11 * xform.eM22 - xform.eM12 * xform.eM21;
293 if (delta == 0)
294 return FALSE;
295
296 pxform->eM11 = xform.eM22 / delta;
297 pxform->eM12 = -xform.eM12 / delta;
298 pxform->eM21 = -xform.eM21 / delta;
299 pxform->eM22 = xform.eM11 / delta;
300 pxform->eDx = (-xform.eM22 * xform.eDx + xform.eM12 * xform.eDy);
301 pxform->eDy = (xform.eM21 * xform.eDx - xform.eM11 * xform.eDy);
302 return TRUE;
303}
#define FALSE
Definition: types.h:117
float FLOAT
Definition: typedefs.h:69

Referenced by DoTestEntry().

◆ SetXForm1()

static void SetXForm1 ( XFORM pxform)
static

Definition at line 269 of file DPtoLP.c.

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

Referenced by DoTestEntry(), and START_TEST().

◆ SetXForm2()

static void SetXForm2 ( XFORM pxform)
static

Definition at line 279 of file DPtoLP.c.

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

Referenced by DoTestEntry(), and START_TEST().

◆ START_TEST()

START_TEST ( DPtoLP  )

Definition at line 441 of file DPtoLP.c.

442{
443 size_t i;
444 POINT apt[2];
445 XFORM xform;
446
448 ok(hDC != NULL, "hDC is NULL\n");
449
450 SetLastError(0xDEADBEEF);
451 ok_int(DPtoLP(NULL, NULL, 0), 1);
452 ok_err(0xDEADBEEF);
453
454 ok_int(DPtoLP(NULL, NULL, -1), 1);
455 ok_err(0xDEADBEEF);
456
458 ok_err(0xDEADBEEF);
459
460 ok_int(DPtoLP(NULL, NULL, 2), 0);
462
463 SetLastError(0xDEADBEEF);
464 ok_int(DPtoLP(NULL, apt, 2), 0);
466
467 SetLastError(0xDEADBEEF);
468 ok_int(DPtoLP(NULL, apt, 0), 1);
469 ok_err(0xDEADBEEF);
470
471 SetLastError(0xDEADBEEF);
472 ok_int(DPtoLP(NULL, apt, -2), 1);
473 ok_err(0xDEADBEEF);
474
475 SetLastError(0xDEADBEEF);
476 ok_int(DPtoLP((HDC)-4, apt, -2), 1);
477 ok_err(0xDEADBEEF);
478
479 SetLastError(0xDEADBEEF);
480 ok_int(DPtoLP(hDC, NULL, 2), 1);
481 ok_err(0xDEADBEEF);
482
483 SetLastError(0xDEADBEEF);
485 ok_err(0xDEADBEEF);
486
489
490 for (i = 0; i < s_entries_count; ++i)
491 {
493 }
494
497
498 for (i = 0; i < s_entries_count; ++i)
499 {
501 }
502
503 SetXForm1(&xform);
505 SetWorldTransform(hDC, &xform);
506 for (i = 0; i < s_shifted_entries_count; ++i)
507 {
509 }
510
511 SetXForm2(&xform);
513 SetWorldTransform(hDC, &xform);
514 for (i = 0; i < s_transformed_entries_count; ++i)
515 {
517 }
518
519 DeleteDC(hDC);
520}
static const TEST_ENTRY s_transformed_entries[]
Definition: DPtoLP.c:201
static const TEST_ENTRY s_entries[]
Definition: DPtoLP.c:65
static const size_t s_entries_count
Definition: DPtoLP.c:131
static const size_t s_transformed_entries_count
Definition: DPtoLP.c:267
#define INVALID_POINTER
Definition: DPtoLP.c:11
static const size_t s_shifted_entries_count
Definition: DPtoLP.c:199
static void DoTestEntry(HDC hDC, const TEST_ENTRY *entry)
Definition: DPtoLP.c:305
static const TEST_ENTRY s_shifted_entries[]
Definition: DPtoLP.c:133
#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 65 of file DPtoLP.c.

Referenced by START_TEST().

◆ s_entries_count

const size_t s_entries_count = _countof(s_entries)
static

Definition at line 131 of file DPtoLP.c.

Referenced by START_TEST().

◆ s_shifted_entries

const TEST_ENTRY s_shifted_entries[]
static

Definition at line 133 of file DPtoLP.c.

Referenced by START_TEST().

◆ s_shifted_entries_count

const size_t s_shifted_entries_count = _countof(s_shifted_entries)
static

Definition at line 199 of file DPtoLP.c.

Referenced by START_TEST().

◆ s_transformed_entries

const TEST_ENTRY s_transformed_entries[]
static

Definition at line 201 of file DPtoLP.c.

Referenced by START_TEST().

◆ s_transformed_entries_count

const size_t s_transformed_entries_count = _countof(s_transformed_entries)
static

Definition at line 267 of file DPtoLP.c.

Referenced by START_TEST().