ReactOS  0.4.14-dev-317-g96040ec
ExtCreateRegion.c File Reference
#include "precomp.h"
#include <math.h>
Include dependency graph for ExtCreateRegion.c:

Go to the source code of this file.

Macros

#define CheckRect(prect, _left, _top, _right, _bottom)
 
#define CheckRectRegion(hrgn, _left, _top, _right, _bottom)
 

Functions

VOID InitXFORM (PXFORM pxform, FLOAT eM11, FLOAT eM12, FLOAT eM21, FLOAT eM22, FLOAT eDx, FLOAT eDy)
 
void Test_ExtCreateRegion_Transform ()
 
 START_TEST (ExtCreateRegion)
 

Macro Definition Documentation

◆ CheckRect

#define CheckRect (   prect,
  _left,
  _top,
  _right,
  _bottom 
)
Value:
do { \
ok(((prect)->left == _left) && ((prect)->top == _top) && \
((prect)->right == _right) && ((prect)->bottom == _bottom), \
"Region does not match, expected (%d,%d,%d,%d) got (%ld,%ld,%ld,%ld)\n", \
_left, _top, _right, _bottom, \
(prect)->left, (prect)->top, (prect)->right, (prect)->bottom); \
} while (0)
GLint GLint bottom
Definition: glext.h:7726
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859

Definition at line 38 of file ExtCreateRegion.c.

◆ CheckRectRegion

#define CheckRectRegion (   hrgn,
  _left,
  _top,
  _right,
  _bottom 
)
Value:
do { \
HRGN hrgnTemp = CreateRectRgn(_left, _top, _right, _bottom); \
RECT rcTemp; \
ok(GetRgnBox(hrgn, &rcTemp) == SIMPLEREGION, "Region is not SIMPLEREGION\n"); \
CheckRect(&rcTemp, _left, _top, _right, _bottom); \
ok(EqualRgn(hrgn, hrgnTemp), "Region does not match\n"); \
DeleteObject(hrgnTemp); \
} while (0)
BOOL WINAPI EqualRgn(_In_ HRGN, _In_ HRGN)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
static HRGN hrgn
Definition: win.c:55
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
#define SIMPLEREGION
Definition: wingdi.h:361

Definition at line 47 of file ExtCreateRegion.c.

Function Documentation

◆ InitXFORM()

VOID InitXFORM ( PXFORM  pxform,
FLOAT  eM11,
FLOAT  eM12,
FLOAT  eM21,
FLOAT  eM22,
FLOAT  eDx,
FLOAT  eDy 
)

Definition at line 13 of file ExtCreateRegion.c.

21 {
22  pxform->eM11 = eM11;
23  pxform->eM12 = eM12;
24  pxform->eM21 = eM21;
25  pxform->eM22 = eM22;
26  pxform->eDx = eDx;
27  pxform->eDy = eDy;
28 }
FLOAT eDx
Definition: wingdi.h:1720
FLOAT eM21
Definition: wingdi.h:1718
FLOAT eM12
Definition: wingdi.h:1717
FLOAT eM11
Definition: wingdi.h:1716
FLOAT eM22
Definition: wingdi.h:1719
FLOAT eDy
Definition: wingdi.h:1721

Referenced by Test_ExtCreateRegion_Transform().

◆ START_TEST()

START_TEST ( ExtCreateRegion  )

Definition at line 124 of file ExtCreateRegion.c.

125 {
127 }
void Test_ExtCreateRegion_Transform()

◆ Test_ExtCreateRegion_Transform()

void Test_ExtCreateRegion_Transform ( )

Definition at line 57 of file ExtCreateRegion.c.

58 {
59  struct
60  {
61  RGNDATA rgndata;
62  CHAR data[sizeof(RECT) - 1];
63  } RgnDataBuffer;
64  PRECT prect = (PRECT)&RgnDataBuffer.rgndata.Buffer;
65  const RGNDATA *pRgnData = (const RGNDATA *)&RgnDataBuffer;
66  XFORM xform;
67  FLOAT eAngle;
68  HRGN hrgn;
69  RECT rcTemp;
70 
71  RgnDataBuffer.rgndata.rdh.dwSize = sizeof(RGNDATAHEADER);
72  RgnDataBuffer.rgndata.rdh.iType = RDH_RECTANGLES;
73  RgnDataBuffer.rgndata.rdh.nCount = 1;
74  RgnDataBuffer.rgndata.rdh.nRgnSize = sizeof(RGNDATAHEADER) + sizeof(RECT);
75  RgnDataBuffer.rgndata.rdh.rcBound.left = 0;
76  RgnDataBuffer.rgndata.rdh.rcBound.top = 0;
77  RgnDataBuffer.rgndata.rdh.rcBound.right = 10;
78  RgnDataBuffer.rgndata.rdh.rcBound.bottom = 10;
79  prect->left = 0;
80  prect->top = 0;
81  prect->right = 10;
82  prect->bottom = 10;
83 
84  SetRectEmpty(&RgnDataBuffer.rgndata.rdh.rcBound);
85 
86  hrgn = ExtCreateRegion(NULL, sizeof(RgnDataBuffer), pRgnData);
87  ok(hrgn != NULL, "ExtCreateRegion failed with without transform\n");
88  CheckRectRegion(hrgn, 0, 0, 10, 10);
89 
90  InitXFORM(&xform, 1., 0., 0., 1., 0., 0.);
91  hrgn = ExtCreateRegion(&xform, sizeof(RgnDataBuffer), pRgnData);
92  ok(hrgn != NULL, "ExtCreateRegion failed with identity transform\n");
93  CheckRectRegion(hrgn, 0, 0, 10, 10);
94 
95  InitXFORM(&xform, 1., 0., 0., 1., 10., 10.);
96  hrgn = ExtCreateRegion(&xform, sizeof(RgnDataBuffer), pRgnData);
97  ok(hrgn != NULL, "ExtCreateRegion failed with offset transform\n");
98  CheckRectRegion(hrgn, 10, 10, 20, 20);
99 
100  InitXFORM(&xform, 2.5, 0., 0., 1.5, 0., 0.);
101  hrgn = ExtCreateRegion(&xform, sizeof(RgnDataBuffer), pRgnData);
102  ok(hrgn != NULL, "ExtCreateRegion failed with scaling transform\n");
103  CheckRectRegion(hrgn, 0, 0, 25, 15);
104 
105  InitXFORM(&xform, 2.5, 0., 0., 1.5, 20., 40.);
106  hrgn = ExtCreateRegion(&xform, sizeof(RgnDataBuffer), pRgnData);
107  ok(hrgn != NULL, "ExtCreateRegion failed with scaling+offset transform\n");
108  CheckRectRegion(hrgn, 20, 40, 45, 55);
109 
110  InitXFORM(&xform, 1., 10., 0., 1., 0., 0.);
111  hrgn = ExtCreateRegion(&xform, sizeof(RgnDataBuffer), pRgnData);
112  ok(hrgn != NULL, "ExtCreateRegion failed with shearing transform\n");
113  ok(GetRgnBox(hrgn, &rcTemp) == COMPLEXREGION, "not a complex region\n");
114  CheckRect(&rcTemp, 0, 1, 10, 101);
115 
116  eAngle = 23.6f;
117  InitXFORM(&xform, cosf(eAngle), -sinf(eAngle), sinf(eAngle), cosf(eAngle), 10., 10.);
118  hrgn = ExtCreateRegion(&xform, sizeof(RgnDataBuffer), pRgnData);
119  ok(hrgn != NULL, "ExtCreateRegion failed with rotating transform\n");
120  CheckRectRegion(hrgn, 0, 10, 10, 20);
121 
122 }
struct _RGNDATAHEADER RGNDATAHEADER
#define CheckRectRegion(hrgn, _left, _top, _right, _bottom)
char CHAR
Definition: xmlstorage.h:175
#define COMPLEXREGION
Definition: wingdi.h:362
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define cosf
Definition: cosf.c:6
struct tagRECT RECT
VOID InitXFORM(PXFORM pxform, FLOAT eM11, FLOAT eM12, FLOAT eM21, FLOAT eM22, FLOAT eDx, FLOAT eDy)
smooth NULL
Definition: ftsmooth.c:416
#define CheckRect(prect, _left, _top, _right, _bottom)
#define RDH_RECTANGLES
Definition: wingdi.h:668
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HRGN hrgn
Definition: win.c:55
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
HRGN WINAPI ExtCreateRegion(_In_opt_ const XFORM *lpx, _In_ DWORD nCount, _In_reads_bytes_(nCount) const RGNDATA *lpData)
#define ok(value,...)
Definition: atltest.h:57
float FLOAT
Definition: typedefs.h:67
LONG bottom
Definition: windef.h:294
#define sinf
Definition: sinf.c:6
struct tagRECT * PRECT

Referenced by START_TEST().