ReactOS  0.4.15-dev-1070-ge1a01de
CombineTransform.c File Reference
#include "precomp.h"
Include dependency graph for CombineTransform.c:

Go to the source code of this file.

Classes

union  FLT_LONG
 

Macros

#define ok_flt(x, y)
 
#define ok_xform(xform, m11, m12, m21, m22, dx, dy)
 
#define set_xform(pxform, m11, m12, m21, m22, dx, dy)
 

Functions

FLOAT GetMaxValue (unsigned int Parameter, unsigned int Field)
 
void Test_CombineTransform ()
 
void Test_CombineTransform_Inval (float eInval, float eOut)
 
 START_TEST (CombineTransform)
 

Variables

float geINF
 
float geIND
 
float geQNAN
 

Macro Definition Documentation

◆ ok_flt

#define ok_flt (   x,
  y 
)
Value:
{ \
FLT_LONG __x, __y; \
__x.e = (x); \
__y.e = (y); \
if (_isnan(y)) {\
ok((__x.l == __y.l) || (__x.l == 0), "Wrong value for " #x ", expected " #y " (%f), got %f\n", (double)(y), (double)(x)); \
} else {\
ok(__x.l == __y.l, "Wrong value for " #x ", expected " #y " (%f), got %f\n", (double)(y), (double)(x)); \
} \
}
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Definition at line 16 of file CombineTransform.c.

◆ ok_xform

#define ok_xform (   xform,
  m11,
  m12,
  m21,
  m22,
  dx,
  dy 
)
Value:
ok_flt(xform.eM11, m11); \
ok_flt(xform.eM12, m12); \
ok_flt(xform.eM21, m21); \
ok_flt(xform.eM22, m22); \
ok_flt(xform.eDx, dx); \
ok_flt(xform.eDy, dy);
GLint dy
Definition: linetemp.h:97
#define m11
#define m21
#define m22
#define m12
GLint dx
Definition: linetemp.h:97
#define ok_flt(x, y)

Definition at line 28 of file CombineTransform.c.

◆ set_xform

#define set_xform (   pxform,
  m11,
  m12,
  m21,
  m22,
  dx,
  dy 
)
Value:
(pxform)->eM11 = m11; \
(pxform)->eM12 = m12; \
(pxform)->eM21 = m21; \
(pxform)->eM22 = m22; \
(pxform)->eDx = dx; \
(pxform)->eDy = dy;
GLint dy
Definition: linetemp.h:97
#define m11
#define m21
#define m22
#define m12
GLint dx
Definition: linetemp.h:97

Definition at line 36 of file CombineTransform.c.

Function Documentation

◆ GetMaxValue()

FLOAT GetMaxValue ( unsigned int  Parameter,
unsigned int  Field 
)

Definition at line 49 of file CombineTransform.c.

50 {
51  XFORM xform1, xform2, xform3;
52  FLOAT fmin, fmax, fmid;
53  PFLOAT target;
54 
55  if (Parameter == 0)
56  {
57  target = &xform1.eM11 + Field;
58  }
59  else
60  {
61  target = &xform2.eM11 + Field;
62  }
63 
64  fmin = 0;
65  fmax = 4294967296.0f;
66  fmid = (fmin + fmax) / 2;
67  while (fmin < fmax)
68  {
69  fmid = (fmin + fmax) / 2;
70 
71  //printf("fmin = %f, fmid = %f, fmax = %f\n", (double)fmin, (double)fmid, (double)fmax);
72  set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
73  set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
74  set_xform(&xform3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
75  *target = fmid;
76 
77  if (CombineTransform(&xform3, &xform1, &xform2))
78  {
79  if (fmid == fmin) break;
80  fmin = fmid;
81  }
82  else
83  {
84  if (fmid == fmax) break;
85  fmax = fmid;
86  }
87  }
88  //printf("fmin = %f, fmid = %f, fmax = %f\n", (double)fmin, (double)fmid, (double)fmax);
89  return fmin;
90 }
FLOAT * PFLOAT
Definition: windef.h:174
_In_ PVOID Parameter
Definition: ldrtypes.h:241
BOOL WINAPI CombineTransform(_Out_ LPXFORM pxformResult, _In_ const XFORM *pxform1, _In_ const XFORM *pxform2)
Definition: coord.c:64
double __cdecl fmax(double, double)
#define set_xform(pxform, m11, m12, m21, m22, dx, dy)
double __cdecl fmin(double, double)
FLOAT eM11
Definition: wingdi.h:1720
float FLOAT
Definition: typedefs.h:69
GLenum target
Definition: glext.h:7315

Referenced by Test_CombineTransform().

◆ START_TEST()

START_TEST ( CombineTransform  )

Definition at line 312 of file CombineTransform.c.

313 {
314  *(DWORD*)&geINF = 0x7f800000;
315  *(DWORD*)&geIND = 0xffc00000;
316  *(DWORD*)&geQNAN = 0x7fc00000;
317 
319 
323 
324 }
float geIND
float geQNAN
float geINF
void Test_CombineTransform()
unsigned long DWORD
Definition: ntddk_ex.h:95
void Test_CombineTransform_Inval(float eInval, float eOut)

◆ Test_CombineTransform()

void Test_CombineTransform ( )

Definition at line 93 of file CombineTransform.c.

94 {
95  XFORM xform1, xform2, xform3;
96  BOOL IsWow64;
97 
98  /* Test NULL paramters */
99  set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
100  set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
102  ok_int(CombineTransform(&xform3, &xform1, NULL), 0);
103  ok_int(CombineTransform(&xform3, NULL, &xform2), 0);
104  ok_int(CombineTransform(NULL, &xform1, &xform2), 0);
106 
107  /* 2 zero matrices */
108  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
109  set_xform(&xform2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
111  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
112  ok_xform(xform3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
114 
115  /* 2 Identity matrices */
116  set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
117  set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
119  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
120  ok_xform(xform3, 1.0, 0., 0., 1.0, 0., 0.);
122 
123  /* 2 Identity matrices with offsets */
124  set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 20.0, -100.0);
125  set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
126  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
127  ok_xform(xform3, 1.0, 0., 0., 1.0, 20.0, -100.0);
128 
129  xform2.eDx = -60.0;
130  xform2.eDy = -20;
131  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
132  ok_flt(xform3.eDx, -40.0);
133  ok_flt(xform3.eDy, -120.0);
134 
135  /* add some stretching */
136  xform2.eM11 = 2;
137  xform2.eM22 = 4;
138  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
139  ok_xform(xform3, 2.0, 0., 0., 4.0, -20.0, -420.0);
140 
141  /* add some more stretching */
142  xform1.eM11 = -2.5;
143  xform1.eM22 = 0.5;
144  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
145  ok_xform(xform3, -5.0, 0., 0., 2.0, -20.0, -420.0);
146 
147  xform1.eM12 = 2.0;
148  xform1.eM21 = -0.5;
149  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
150  ok_xform(xform3, -5.0, 8.0, -1.0, 2.0, -20.0, -420.0);
151 
152  xform2.eM12 = 4.0;
153  xform2.eM21 = 6.5;
154  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
155  ok_xform(xform3, 8.0, -2.0, 2.25, 0.0, -670.0, -340.0);
156 
158  {
159  ok_flt(GetMaxValue(0, 0), 4294967296.0);
160  ok_flt(GetMaxValue(0, 1), 4294967296.0);
161  ok_flt(GetMaxValue(0, 2), 4294967296.0);
162  ok_flt(GetMaxValue(0, 3), 4294967296.0);
163  ok_flt(GetMaxValue(0, 4), 4294967040.0);
164  ok_flt(GetMaxValue(0, 5), 4294967040.0);
165 
166  ok_flt(GetMaxValue(1, 0), 4294967296.0);
167  ok_flt(GetMaxValue(1, 1), 4294967296.0);
168  ok_flt(GetMaxValue(1, 2), 4294967296.0);
169  ok_flt(GetMaxValue(1, 3), 4294967296.0);
170  ok_flt(GetMaxValue(1, 4), 4294967296.0);
171  ok_flt(GetMaxValue(1, 5), 4294967296.0);
172  }
173  else
174  {
175  ok_flt(GetMaxValue(0, 0), 4294967296.0);
176  ok_flt(GetMaxValue(0, 1), 4294967296.0);
177  ok_flt(GetMaxValue(0, 2), 4294967296.0);
178  ok_flt(GetMaxValue(0, 3), 4294967296.0);
179  ok_flt(GetMaxValue(0, 4), 2147483520.0);
180  ok_flt(GetMaxValue(0, 5), 2147483520.0);
181 
182  ok_flt(GetMaxValue(1, 0), 4294967296.0);
183  ok_flt(GetMaxValue(1, 1), 4294967296.0);
184  ok_flt(GetMaxValue(1, 2), 4294967296.0);
185  ok_flt(GetMaxValue(1, 3), 4294967296.0);
186  ok_flt(GetMaxValue(1, 4), 4294967296.0);
187  ok_flt(GetMaxValue(1, 5), 4294967296.0);
188  }
189 
190  /* Some undefined values */
191  set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
192  set_xform(&xform2, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
194  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
195  ok_xform(xform3, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
197 
198  set_xform(&xform1, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
199  set_xform(&xform2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0);
200  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
201  ok_xform(xform3, geIND, geIND, geINF, geINF, 0.0, 0.0);
203 
204  set_xform(&xform1, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0);
205  set_xform(&xform2, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
206  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
207  ok_xform(xform3, geIND, geINF, geIND, geINF, 0.0, 0.0);
209 
210  set_xform(&xform1, (FLOAT)18446743500000000000.0, 0.0, 1.0, 0.0, 0.0, 0.0);
211  xform2 = xform1;
212  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
213  ok_flt(xform3.eM11, 340282326356119260000000000000000000000.0);
214 
215  xform1.eM11 = (FLOAT)18446745000000000000.0;
216  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
217  ok_flt(xform3.eM11, 340282346638528860000000000000000000000.0);
218 
219  xform1.eM11 = (FLOAT)18446746000000000000.0;
220  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
221  ok_long(*(DWORD*)&xform3.eM11, IsWow64 ? 0x7f800000 : 0x7f800001);
222 
223  /* zero matrix + 1 invalid */
224  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
225  set_xform(&xform2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
226  *(DWORD*)&xform2.eM22 = 0x7f800000; // (0.0F/0.0F)
227  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
228  ok_xform(xform3, 0.0, 0.0, 0.0, geIND, 0.0, 0.0);
229 
230  /* zero matrix + 1 invalid */
231  xform2 = xform1;
232  *(DWORD*)&xform2.eM12 = 0x7f800000; // (0.0F/0.0F)
233  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
234  ok_xform(xform3, 0.0, geIND, 0.0, geIND, 0.0, 0.0);
235 
236  /* Some undefined values */
237  set_xform(&xform1, 0.0, geIND, 0.0, 0.0, 0.0, 0.0);
238  set_xform(&xform2, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
239  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
240  ok_xform(xform3, IsWow64 ? geIND : 0.000000, IsWow64 ? geIND : -1.500000, geIND, geIND, 0.0, 0.0);
241 }
#define ERROR_SUCCESS
Definition: deptool.c:10
float geIND
#define FLOAT
Definition: i386-dis.c:516
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ok_long(expression, result)
Definition: atltest.h:133
float geINF
unsigned int BOOL
Definition: ntddk_ex.h:94
FLOAT eDx
Definition: wingdi.h:1724
FLOAT eM21
Definition: wingdi.h:1722
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
FLOAT eM12
Definition: wingdi.h:1721
BOOL WINAPI CombineTransform(_Out_ LPXFORM pxformResult, _In_ const XFORM *pxform1, _In_ const XFORM *pxform2)
Definition: coord.c:64
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1976
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
#define set_xform(pxform, m11, m12, m21, m22, dx, dy)
FLOAT eM11
Definition: wingdi.h:1720
#define GetCurrentProcess()
Definition: compat.h:507
#define ok_xform(xform, m11, m12, m21, m22, dx, dy)
FLOAT eM22
Definition: wingdi.h:1723
FLOAT eDy
Definition: wingdi.h:1725
float FLOAT
Definition: typedefs.h:69
BOOL IsWow64(VOID)
Definition: user_lib.cpp:579
FLOAT GetMaxValue(unsigned int Parameter, unsigned int Field)
#define ok_flt(x, y)

Referenced by START_TEST().

◆ Test_CombineTransform_Inval()

void Test_CombineTransform_Inval ( float  eInval,
float  eOut 
)

Definition at line 243 of file CombineTransform.c.

244 {
245  XFORM xform1, xform2, xform3;
246 
247  /* zero matrix / M11 invalid */
248  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
249  set_xform(&xform2, eInval, 0.0, 0.0, 0.0, 0.0, 0.0);
250  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
251  ok_xform(xform3, eOut, 0.0, 0.0, 0.0, 0.0, 0.0); // -> M21
252  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
253  ok_xform(xform3, eOut, 0.0, 0.0, 0.0, 0.0, 0.0); // -> M12
254 
255  /* zero matrix / M12 invalid */
256  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
257  set_xform(&xform2, 0.0, eInval, 0.0, 0.0, 0.0, 0.0);
258  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
259  ok_xform(xform3, 0.0, eOut, 0.0, eOut, 0.0, 0.0);
260  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
261  ok_xform(xform3, eOut, eOut, 0.0, 0.0, 0.0, 0.0);
262 
263  /* zero matrix / M21 invalid */
264  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
265  set_xform(&xform2, 0.0, 0.0, eInval, 0.0, 0.0, 0.0);
266  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
267  ok_xform(xform3, eOut, 0.0, eOut, 0.0, 0.0, 0.0);
268  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
269  ok_xform(xform3, 0.0, 0.0, eOut, eOut, 0.0, 0.0);
270 
271  /* zero matrix / M22 invalid */
272  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
273  set_xform(&xform2, 0.0, 0.0, 0.0, eInval, 0.0, 0.0);
274  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
275  ok_xform(xform3, 0.0, 0.0, 0.0, eOut, 0.0, 0.0); // -> M12
276  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
277  ok_xform(xform3, 0.0, 0.0, 0.0, eOut, 0.0, 0.0); // -> M21
278 
279  /* zero matrix / M11,M12 invalid */
280  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
281  set_xform(&xform2, eInval, eInval, 0.0, 0.0, 0.0, 0.0);
282  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
283  ok_xform(xform3, eOut, eOut, eOut, eOut, 0.0, 0.0);
284  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
285  ok_xform(xform3, eOut, eOut, 0.0, 0.0, 0.0, 0.0);
286 
287  /* zero matrix / M11,M21 invalid */
288  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
289  set_xform(&xform2, eInval, 0.0, eInval, 0.0, 0.0, 0.0);
290  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
291  ok_xform(xform3, eOut, 0.0, eOut, 0.0, 0.0, 0.0);
292  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
293  ok_xform(xform3, eOut, eOut, eOut, eOut, 0.0, 0.0);
294 
295  /* zero matrix / M11,M22 invalid */
296  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
297  set_xform(&xform2, eInval, 0.0, 0.0, eInval, 0.0, 0.0);
298  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
299  ok_xform(xform3, eOut, 0.0, 0.0, eOut, 0.0, 0.0); // -> M12, M21
300  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
301  ok_xform(xform3, eOut, 0.0, 0.0, eOut, 0.0, 0.0);
302 
303  /* zero matrix / M12,M21 invalid */
304  set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
305  set_xform(&xform2, 0.0, eInval, eInval, 0.0, 0.0, 0.0);
306  ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
307  ok_xform(xform3, eOut, eOut, eOut, eOut, 0.0, 0.0);
308  ok_int(CombineTransform(&xform3, &xform2, &xform1), 1);
309  ok_xform(xform3, eOut, eOut, eOut, eOut, 0.0, 0.0);
310 }
#define ok_int(expression, result)
Definition: atltest.h:134
BOOL WINAPI CombineTransform(_Out_ LPXFORM pxformResult, _In_ const XFORM *pxform1, _In_ const XFORM *pxform2)
Definition: coord.c:64
#define set_xform(pxform, m11, m12, m21, m22, dx, dy)
#define ok_xform(xform, m11, m12, m21, m22, dx, dy)

Referenced by START_TEST().

Variable Documentation

◆ geIND

float geIND

Definition at line 45 of file CombineTransform.c.

Referenced by START_TEST(), and Test_CombineTransform().

◆ geINF

float geINF

Definition at line 44 of file CombineTransform.c.

Referenced by START_TEST(), and Test_CombineTransform().

◆ geQNAN

float geQNAN

Definition at line 46 of file CombineTransform.c.

Referenced by START_TEST().