ReactOS 0.4.16-dev-340-g0540c21
xformobj.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _EXFORMOBJ
 

Macros

#define XFORMOBJ   EXFORMOBJ
 
#define XFORMOBJ_iGetXform   EXFORMOBJ_iGetXform
 
#define XFORMOBJ_iGetFloatObjXform   EXFORMOBJ_iGetFloatObjXform
 
#define XFORMOBJ_bApplyXform   EXFORMOBJ_bApplyXform
 
#define XFORMOBJ_vInit   EXFORMOBJ_vInit
 
#define XFORMOBJ_pmx   EXFORMOBJ_pmx
 
#define XFORMOBJ_iSetXform   EXFORMOBJ_iSetXform
 
#define XFORMOBJ_iCombine   EXFORMOBJ_iCombine
 
#define XFORMOBJ_iCombineXform   EXFORMOBJ_iCombineXform
 
#define XFORMOBJ_iInverse   EXFORMOBJ_iInverse
 

Typedefs

typedef struct _EXFORMOBJ EXFORMOBJ
 

Functions

FORCEINLINE VOID XFORMOBJ_vInit (OUT XFORMOBJ *pxo, IN MATRIX *pmx)
 
FORCEINLINE MATRIXXFORMOBJ_pmx (IN XFORMOBJ *pxo)
 
ULONG NTAPI XFORMOBJ_iSetXform (IN OUT XFORMOBJ *pxo, IN const XFORML *pxform)
 
ULONG NTAPI XFORMOBJ_iCombine (IN OUT XFORMOBJ *pxo, IN XFORMOBJ *pxo1, IN XFORMOBJ *pxo2)
 
ULONG NTAPI XFORMOBJ_iCombineXform (IN OUT XFORMOBJ *pxo, IN XFORMOBJ *pxo1, IN XFORML *pxform, IN BOOL bLeftMultiply)
 
ULONG NTAPI XFORMOBJ_iInverse (OUT XFORMOBJ *pxoDst, IN XFORMOBJ *pxoSrc)
 
ULONG APIENTRY XFORMOBJ_iGetXform (IN XFORMOBJ *pxo, OUT XFORML *pxform)
 
BOOL APIENTRY XFORMOBJ_bApplyXform (IN XFORMOBJ *pxo, IN ULONG iMode, IN ULONG cPoints, IN PVOID pvIn, OUT PVOID pvOut)
 
BOOL FASTCALL MX_IsInvertible (IN PMATRIX pmx)
 
VOID FASTCALL MX_Set0 (OUT PMATRIX pmx)
 

Macro Definition Documentation

◆ XFORMOBJ

Definition at line 8 of file xformobj.h.

◆ XFORMOBJ_bApplyXform

#define XFORMOBJ_bApplyXform   EXFORMOBJ_bApplyXform

Definition at line 11 of file xformobj.h.

◆ XFORMOBJ_iCombine

#define XFORMOBJ_iCombine   EXFORMOBJ_iCombine

Definition at line 15 of file xformobj.h.

◆ XFORMOBJ_iCombineXform

#define XFORMOBJ_iCombineXform   EXFORMOBJ_iCombineXform

Definition at line 16 of file xformobj.h.

◆ XFORMOBJ_iGetFloatObjXform

#define XFORMOBJ_iGetFloatObjXform   EXFORMOBJ_iGetFloatObjXform

Definition at line 10 of file xformobj.h.

◆ XFORMOBJ_iGetXform

#define XFORMOBJ_iGetXform   EXFORMOBJ_iGetXform

Definition at line 9 of file xformobj.h.

◆ XFORMOBJ_iInverse

#define XFORMOBJ_iInverse   EXFORMOBJ_iInverse

Definition at line 17 of file xformobj.h.

◆ XFORMOBJ_iSetXform

#define XFORMOBJ_iSetXform   EXFORMOBJ_iSetXform

Definition at line 14 of file xformobj.h.

◆ XFORMOBJ_pmx

#define XFORMOBJ_pmx   EXFORMOBJ_pmx

Definition at line 13 of file xformobj.h.

◆ XFORMOBJ_vInit

#define XFORMOBJ_vInit   EXFORMOBJ_vInit

Definition at line 12 of file xformobj.h.

Typedef Documentation

◆ EXFORMOBJ

Function Documentation

◆ MX_IsInvertible()

BOOL FASTCALL MX_IsInvertible ( IN PMATRIX  pmx)

Definition at line 267 of file xformobj.c.

268{
269 FLOATOBJ foDet;
270 MulSub(&foDet, &pmx->efM11, &pmx->efM22, &pmx->efM12, &pmx->efM21);
271 return !FLOATOBJ_Equal0(&foDet);
272}
#define FLOATOBJ_Equal0(pf)
Definition: floatobj.h:104
FLOAT FLOATOBJ
Definition: winddi.h:677
FORCEINLINE VOID MulSub(PFLOATOBJ pfoDest, PFLOATOBJ pfo1, PFLOATOBJ pfo2, PFLOATOBJ pfo3, PFLOATOBJ pfo4)
Definition: xformobj.c:68

Referenced by XFORMOBJ_iSetXform().

◆ MX_Set0()

VOID FASTCALL MX_Set0 ( OUT PMATRIX  pmx)

Definition at line 275 of file xformobj.c.

276{
277 FLOATOBJ_Set0(&pmx->efM11);
278 FLOATOBJ_Set0(&pmx->efM12);
279 FLOATOBJ_Set0(&pmx->efM21);
280 FLOATOBJ_Set0(&pmx->efM22);
281 FLOATOBJ_Set0(&pmx->efDx);
282 FLOATOBJ_Set0(&pmx->efDy);
283}
#define FLOATOBJ_Set0(fo)
Definition: floatobj.h:118

Referenced by DC_vUpdateDeviceToWorld().

◆ XFORMOBJ_bApplyXform()

BOOL APIENTRY XFORMOBJ_bApplyXform ( IN XFORMOBJ pxo,
IN ULONG  iMode,
IN ULONG  cPoints,
IN PVOID  pvIn,
OUT PVOID  pvOut 
)

Definition at line 664 of file xformobj.c.

670{
671 MATRIX mx;
672 XFORMOBJ xoInv;
673 PPOINTL pptlIn, pptlOut;
674 INT i;
675
676 /* Check parameters */
677 if (!pxo || !pvIn || !pvOut || cPoints < 1)
678 {
679 return FALSE;
680 }
681
682 /* Use inverse xform? */
683 if (iMode == XF_INV_FXTOL || iMode == XF_INV_LTOL)
684 {
685 XFORMOBJ_vInit(&xoInv, &mx);
686 if (XFORMOBJ_iInverse(&xoInv, pxo) == DDI_ERROR)
687 {
688 return FALSE;
689 }
690 pxo = &xoInv;
691 }
692
693 /* Convert POINTL to POINTFIX? */
694 if (iMode == XF_LTOFX || iMode == XF_LTOL || iMode == XF_INV_LTOL)
695 {
696 pptlIn = pvIn;
697 pptlOut = pvOut;
698 for (i = cPoints - 1; i >= 0; i--)
699 {
700 pptlOut[i].x = LONG2FIX(pptlIn[i].x);
701 pptlOut[i].y = LONG2FIX(pptlIn[i].y);
702 }
703
704 /* The input is in the out buffer now! */
705 pvIn = pvOut;
706 }
707
708 /* Do the actual fixpoint transformation */
709 if (!XFORMOBJ_bXformFixPoints(pxo, cPoints, pvIn, pvOut))
710 {
711 return FALSE;
712 }
713
714 /* Convert POINTFIX to POINTL? */
715 if (iMode == XF_INV_FXTOL || iMode == XF_INV_LTOL || iMode == XF_LTOL)
716 {
717 pptlOut = pvOut;
718 for (i = cPoints - 1; i >= 0; i--)
719 {
720 pptlOut[i].x = FIX2LONG(pptlOut[i].x);
721 pptlOut[i].y = FIX2LONG(pptlOut[i].y);
722 }
723 }
724
725 return TRUE;
726}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define LONG2FIX(x)
Definition: floatobj.h:5
#define FIX2LONG(x)
Definition: floatobj.h:4
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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
Definition: matrix.h:44
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
int32_t INT
Definition: typedefs.h:58
#define XF_LTOL
Definition: winddi.h:3109
#define XF_INV_LTOL
Definition: winddi.h:3110
#define DDI_ERROR
Definition: winddi.h:154
_In_ ULONG iMode
Definition: winddi.h:3520
#define XF_INV_FXTOL
Definition: winddi.h:3112
#define XF_LTOFX
Definition: winddi.h:3111
_In_ XLATEOBJ _In_ XFORMOBJ * pxo
Definition: winddi.h:3811
static BOOL NTAPI XFORMOBJ_bXformFixPoints(_In_ XFORMOBJ *pxo, _In_ ULONG cPoints, _In_reads_(cPoints) PPOINTL pptIn, _Out_writes_(cPoints) PPOINTL pptOut)
Transforms fix-point coordinates in an array of POINTL structures using the transformation matrix fro...
Definition: xformobj.c:365
#define XFORMOBJ_iInverse
Definition: xformobj.h:17
#define XFORMOBJ_vInit
Definition: xformobj.h:12

◆ XFORMOBJ_iCombine()

ULONG NTAPI XFORMOBJ_iCombine ( IN OUT XFORMOBJ pxo,
IN XFORMOBJ pxo1,
IN XFORMOBJ pxo2 
)

Definition at line 211 of file xformobj.c.

215{
216 MATRIX mx;
217 PMATRIX pmx, pmx1, pmx2;
218
219 /* Get the source matrices */
220 pmx1 = XFORMOBJ_pmx(pxo1);
221 pmx2 = XFORMOBJ_pmx(pxo2);
222
223 /* Do a 3 x 3 matrix multiplication with mx as destinantion */
224 MulAdd(&mx.efM11, &pmx1->efM11, &pmx2->efM11, &pmx1->efM12, &pmx2->efM21);
225 MulAdd(&mx.efM12, &pmx1->efM11, &pmx2->efM12, &pmx1->efM12, &pmx2->efM22);
226 MulAdd(&mx.efM21, &pmx1->efM21, &pmx2->efM11, &pmx1->efM22, &pmx2->efM21);
227 MulAdd(&mx.efM22, &pmx1->efM21, &pmx2->efM12, &pmx1->efM22, &pmx2->efM22);
228 MulAdd(&mx.efDx, &pmx1->efDx, &pmx2->efM11, &pmx1->efDy, &pmx2->efM21);
229 FLOATOBJ_Add(&mx.efDx, &pmx2->efDx);
230 MulAdd(&mx.efDy, &pmx1->efDx, &pmx2->efM12, &pmx1->efDy, &pmx2->efM22);
231 FLOATOBJ_Add(&mx.efDy, &pmx2->efDy);
232
233 /* Copy back */
234 pmx = XFORMOBJ_pmx(pxo);
235 *pmx = mx;
236
237 /* Update accelerators and return complexity */
239}
FLOATOBJ efM21
Definition: ntgdityp.h:414
FLOATOBJ efM11
Definition: ntgdityp.h:412
FLOATOBJ efDx
Definition: ntgdityp.h:416
FLOATOBJ efDy
Definition: ntgdityp.h:417
FLOATOBJ efM22
Definition: ntgdityp.h:415
FLOATOBJ efM12
Definition: ntgdityp.h:413
#define FLOATOBJ_Add(pf, pf1)
Definition: winddi.h:2818
FORCEINLINE VOID MulAdd(PFLOATOBJ pfoDest, PFLOATOBJ pfo1, PFLOATOBJ pfo2, PFLOATOBJ pfo3, PFLOATOBJ pfo4)
Definition: xformobj.c:26
ULONG NTAPI XFORMOBJ_UpdateAccel(IN OUT XFORMOBJ *pxo)
Definition: xformobj.c:145
#define XFORMOBJ_pmx
Definition: xformobj.h:13

◆ XFORMOBJ_iCombineXform()

ULONG NTAPI XFORMOBJ_iCombineXform ( IN OUT XFORMOBJ pxo,
IN XFORMOBJ pxo1,
IN XFORML pxform,
IN BOOL  bLeftMultiply 
)

Definition at line 244 of file xformobj.c.

249{
250 MATRIX mx;
251 XFORMOBJ xo2;
252
253 XFORMOBJ_vInit(&xo2, &mx);
254 XFORMOBJ_iSetXform(&xo2, pxform);
255
256 if (bLeftMultiply)
257 {
258 return XFORMOBJ_iCombine(pxo, &xo2, pxo1);
259 }
260 else
261 {
262 return XFORMOBJ_iCombine(pxo, pxo1, &xo2);
263 }
264}
#define XFORMOBJ_iSetXform
Definition: xformobj.h:14
#define XFORMOBJ_iCombine
Definition: xformobj.h:15

◆ XFORMOBJ_iGetXform()

ULONG APIENTRY XFORMOBJ_iGetXform ( IN XFORMOBJ pxo,
OUT XFORML pxform 
)

Public functions

Definition at line 608 of file xformobj.c.

611{
612 PMATRIX pmx = XFORMOBJ_pmx(pxo);
613
614 /* Check parameters */
615 if (!pxo || !pxform)
616 {
617 return DDI_ERROR;
618 }
619
620 /* Copy members */
621 pxform->eM11 = FLOATOBJ_GetFloat(&pmx->efM11);
622 pxform->eM12 = FLOATOBJ_GetFloat(&pmx->efM12);
623 pxform->eM21 = FLOATOBJ_GetFloat(&pmx->efM21);
624 pxform->eM22 = FLOATOBJ_GetFloat(&pmx->efM22);
625 pxform->eDx = FLOATOBJ_GetFloat(&pmx->efDx);
626 pxform->eDy = FLOATOBJ_GetFloat(&pmx->efDy);
627
628 /* Return complexity hint */
629 return HintFromAccel(pmx->flAccel);
630}
FLONG flAccel
Definition: ntgdityp.h:420
#define FLOATOBJ_GetFloat(pf)
Definition: winddi.h:2816
FORCEINLINE ULONG HintFromAccel(ULONG flAccel)
Definition: xformobj.c:89

◆ XFORMOBJ_iInverse()

ULONG NTAPI XFORMOBJ_iInverse ( OUT XFORMOBJ pxoDst,
IN XFORMOBJ pxoSrc 
)

Definition at line 291 of file xformobj.c.

294{
295 PMATRIX pmxDst, pmxSrc;
296 FLOATOBJ foDet;
297 XFORM xformSrc;
298
299 pmxDst = XFORMOBJ_pmx(pxoDst);
300 pmxSrc = XFORMOBJ_pmx(pxoSrc);
301
302 XFORMOBJ_iGetXform(pxoSrc, (XFORML*)&xformSrc);
303
304 /* det = M11 * M22 - M12 * M21 */
305 MulSub(&foDet, &pmxSrc->efM11, &pmxSrc->efM22, &pmxSrc->efM12, &pmxSrc->efM21);
306
307 if (FLOATOBJ_Equal0(&foDet))
308 {
309 /* Determinant is 0! */
310 return DDI_ERROR;
311 }
312
313 /* Calculate adj(A) / det(A) */
314 pmxDst->efM11 = pmxSrc->efM22;
315 FLOATOBJ_Div(&pmxDst->efM11, &foDet);
316 pmxDst->efM22 = pmxSrc->efM11;
317 FLOATOBJ_Div(&pmxDst->efM22, &foDet);
318
319 /* The other 2 are negative, negate foDet for that */
320 FLOATOBJ_Neg(&foDet);
321 pmxDst->efM12 = pmxSrc->efM12;
322 FLOATOBJ_Div(&pmxDst->efM12, &foDet);
323 pmxDst->efM21 = pmxSrc->efM21;
324 FLOATOBJ_Div(&pmxDst->efM21, &foDet);
325
326 /* Calculate the inverted x shift: Dx' = -Dx * M11' - Dy * M21' */
327 pmxDst->efDx = pmxSrc->efDx;
328 FLOATOBJ_Neg(&pmxDst->efDx);
329 MulSub(&pmxDst->efDx, &pmxDst->efDx, &pmxDst->efM11, &pmxSrc->efDy, &pmxDst->efM21);
330
331 /* Calculate the inverted y shift: Dy' = -Dy * M22' - Dx * M12' */
332 pmxDst->efDy = pmxSrc->efDy;
333 FLOATOBJ_Neg(&pmxDst->efDy);
334 MulSub(&pmxDst->efDy, &pmxDst->efDy, &pmxDst->efM22, &pmxSrc->efDx, &pmxDst->efM12);
335
336 /* Update accelerators and return complexity */
337 return XFORMOBJ_UpdateAccel(pxoDst);
338}
#define FLOATOBJ_Div(pf, pf1)
Definition: winddi.h:2827
#define FLOATOBJ_Neg(pf)
Definition: winddi.h:2830
#define XFORMOBJ_iGetXform
Definition: xformobj.h:9

◆ XFORMOBJ_iSetXform()

ULONG NTAPI XFORMOBJ_iSetXform ( IN OUT XFORMOBJ pxo,
IN const XFORML pxform 
)

Definition at line 156 of file xformobj.c.

159{
160 PMATRIX pmx;
161 MATRIX mxTemp;
162 ULONG Hint;
163
164 /* Check parameters */
165 if (!pxo || !pxform) return DDI_ERROR;
166
167 /* Copy members */
168 FLOATOBJ_SetFloat(&mxTemp.efM11, pxform->eM11);
169 FLOATOBJ_SetFloat(&mxTemp.efM12, pxform->eM12);
170 FLOATOBJ_SetFloat(&mxTemp.efM21, pxform->eM21);
171 FLOATOBJ_SetFloat(&mxTemp.efM22, pxform->eM22);
172 FLOATOBJ_SetFloat(&mxTemp.efDx, pxform->eDx);
173 FLOATOBJ_SetFloat(&mxTemp.efDy, pxform->eDy);
174
175 /* Update accelerators and return complexity */
176 Hint = MX_UpdateAccel(&mxTemp);
177
178 /* Check whether det = (M11 * M22 - M12 * M21) is non-zero */
179 if (Hint == GX_SCALE)
180 {
181 if (FLOATOBJ_Equal0(&mxTemp.efM11) || FLOATOBJ_Equal0(&mxTemp.efM22))
182 {
183 return DDI_ERROR;
184 }
185 }
186 else if (Hint == GX_GENERAL)
187 {
188 if (!MX_IsInvertible(&mxTemp))
189 {
190 return DDI_ERROR;
191 }
192 }
193
194 /* Store */
195 pmx = XFORMOBJ_pmx(pxo);
196 *pmx = mxTemp;
197
198 return Hint;
199}
uint32_t ULONG
Definition: typedefs.h:59
#define GX_SCALE
Definition: winddi.h:182
#define FLOATOBJ_SetFloat(pf, f)
Definition: winddi.h:2814
#define GX_GENERAL
Definition: winddi.h:183
ULONG FASTCALL MX_UpdateAccel(IN OUT PMATRIX pmx)
Definition: xformobj.c:108
BOOL FASTCALL MX_IsInvertible(IN PMATRIX pmx)
Definition: xformobj.c:267

◆ XFORMOBJ_pmx()

FORCEINLINE MATRIX * XFORMOBJ_pmx ( IN XFORMOBJ pxo)

Definition at line 30 of file xformobj.h.

32{
33 return pxo->pmx;
34}

◆ XFORMOBJ_vInit()

FORCEINLINE VOID XFORMOBJ_vInit ( OUT XFORMOBJ pxo,
IN MATRIX pmx 
)

Definition at line 21 of file xformobj.h.

24{
25 pxo->pmx = pmx;
26}