ReactOS 0.4.16-dev-297-gc569aee
xformobj.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for xformobj.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define DOES_VALUE_OVERFLOW_LONG(x)    (((__int64)((long)(x))) != (x))
 

Functions

FORCEINLINE VOID MulAdd (PFLOATOBJ pfoDest, PFLOATOBJ pfo1, PFLOATOBJ pfo2, PFLOATOBJ pfo3, PFLOATOBJ pfo4)
 
FORCEINLINE VOID MulAddLong (PFLOATOBJ pfoDest, PFLOATOBJ pfo1, LONG l2, PFLOATOBJ pfo3, LONG l4)
 
FORCEINLINE VOID MulSub (PFLOATOBJ pfoDest, PFLOATOBJ pfo1, PFLOATOBJ pfo2, PFLOATOBJ pfo3, PFLOATOBJ pfo4)
 
FORCEINLINE ULONG HintFromAccel (ULONG flAccel)
 
ULONG FASTCALL MX_UpdateAccel (IN OUT PMATRIX pmx)
 
ULONG NTAPI XFORMOBJ_UpdateAccel (IN OUT 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)
 
BOOL FASTCALL MX_IsInvertible (IN PMATRIX pmx)
 
VOID FASTCALL MX_Set0 (OUT PMATRIX pmx)
 
ULONG NTAPI XFORMOBJ_iInverse (OUT XFORMOBJ *pxoDst, IN XFORMOBJ *pxoSrc)
 
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 from the XFORMOBJ.
 
ULONG APIENTRY XFORMOBJ_iGetXform (IN XFORMOBJ *pxo, OUT XFORML *pxform)
 
ULONG APIENTRY XFORMOBJ_iGetFloatObjXform (IN XFORMOBJ *pxo, OUT FLOATOBJ_XFORM *pxfo)
 
BOOL APIENTRY XFORMOBJ_bApplyXform (IN XFORMOBJ *pxo, IN ULONG iMode, IN ULONG cPoints, IN PVOID pvIn, OUT PVOID pvOut)
 

Macro Definition Documentation

◆ DOES_VALUE_OVERFLOW_LONG

#define DOES_VALUE_OVERFLOW_LONG (   x)     (((__int64)((long)(x))) != (x))

Definition at line 16 of file xformobj.c.

◆ NDEBUG

#define NDEBUG

Includes

Definition at line 13 of file xformobj.c.

Function Documentation

◆ HintFromAccel()

FORCEINLINE ULONG HintFromAccel ( ULONG  flAccel)

Definition at line 89 of file xformobj.c.

90{
92 {
94 return GX_IDENTITY;
96 return GX_OFFSET;
97 case XFORM_SCALE:
98 return GX_SCALE;
99 default:
100 return GX_GENERAL;
101 }
102}
@ XFORM_NO_TRANSLATION
Definition: ntgdityp.h:112
@ XFORM_SCALE
Definition: ntgdityp.h:106
@ XFORM_UNITY
Definition: ntgdityp.h:107
#define GX_SCALE
Definition: winddi.h:182
#define GX_IDENTITY
Definition: winddi.h:180
#define GX_GENERAL
Definition: winddi.h:183
#define GX_OFFSET
Definition: winddi.h:181

Referenced by MX_UpdateAccel(), XFORMOBJ_iGetFloatObjXform(), and XFORMOBJ_iGetXform().

◆ MulAdd()

FORCEINLINE VOID MulAdd ( PFLOATOBJ  pfoDest,
PFLOATOBJ  pfo1,
PFLOATOBJ  pfo2,
PFLOATOBJ  pfo3,
PFLOATOBJ  pfo4 
)

Inline helper functions

Definition at line 26 of file xformobj.c.

32{
33 FLOATOBJ foTmp;
34
35 *pfoDest = *pfo1;
36 FLOATOBJ_Mul(pfoDest, pfo2);
37 foTmp = *pfo3;
38 FLOATOBJ_Mul(&foTmp, pfo4);
39 FLOATOBJ_Add(pfoDest, &foTmp);
40}
FLOAT FLOATOBJ
Definition: winddi.h:677
#define FLOATOBJ_Add(pf, pf1)
Definition: winddi.h:2818
#define FLOATOBJ_Mul(pf, pf1)
Definition: winddi.h:2824

Referenced by XFORMOBJ_iCombine().

◆ MulAddLong()

FORCEINLINE VOID MulAddLong ( PFLOATOBJ  pfoDest,
PFLOATOBJ  pfo1,
LONG  l2,
PFLOATOBJ  pfo3,
LONG  l4 
)

Definition at line 47 of file xformobj.c.

53{
54 FLOATOBJ foTmp;
55
56 *pfoDest = *pfo1;
57 FLOATOBJ_MulLong(pfoDest, l2);
58 foTmp = *pfo3;
59 FLOATOBJ_MulLong(&foTmp, l4);
60 FLOATOBJ_Add(pfoDest, &foTmp);
61}
#define FLOATOBJ_MulLong(pf, l)
Definition: winddi.h:2826

Referenced by XFORMOBJ_bXformFixPoints().

◆ MulSub()

FORCEINLINE VOID MulSub ( PFLOATOBJ  pfoDest,
PFLOATOBJ  pfo1,
PFLOATOBJ  pfo2,
PFLOATOBJ  pfo3,
PFLOATOBJ  pfo4 
)

Definition at line 68 of file xformobj.c.

74{
75 FLOATOBJ foTmp;
76
77 *pfoDest = *pfo1;
78 FLOATOBJ_Mul(pfoDest, pfo2);
79 foTmp = *pfo3;
80 FLOATOBJ_Mul(&foTmp, pfo4);
81 FLOATOBJ_Sub(pfoDest, &foTmp);
82}
#define FLOATOBJ_Sub(pf, pf1)
Definition: winddi.h:2821

Referenced by MX_IsInvertible(), and XFORMOBJ_iInverse().

◆ 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
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().

◆ MX_UpdateAccel()

ULONG FASTCALL MX_UpdateAccel ( IN OUT PMATRIX  pmx)

Internal functions

Definition at line 108 of file xformobj.c.

109{
110 /* Copy Dx and Dy to FIX format */
111 pmx->fxDx = FLOATOBJ_GetFix(&pmx->efDx);
112 pmx->fxDy = FLOATOBJ_GetFix(&pmx->efDy);
113
114 pmx->flAccel = 0;
115
116 if (FLOATOBJ_Equal0(&pmx->efDx) &&
117 FLOATOBJ_Equal0(&pmx->efDy))
118 {
119 pmx->flAccel |= XFORM_NO_TRANSLATION;
120 }
121
122 if (FLOATOBJ_Equal0(&pmx->efM12) &&
123 FLOATOBJ_Equal0(&pmx->efM21))
124 {
125 pmx->flAccel |= XFORM_SCALE;
126 }
127
128 if (FLOATOBJ_Equal1(&pmx->efM11) &&
129 FLOATOBJ_Equal1(&pmx->efM22))
130 {
131 pmx->flAccel |= XFORM_UNITY;
132 }
133
134 if (FLOATOBJ_IsLong(&pmx->efM11) && FLOATOBJ_IsLong(&pmx->efM12) &&
135 FLOATOBJ_IsLong(&pmx->efM21) && FLOATOBJ_IsLong(&pmx->efM22))
136 {
137 pmx->flAccel |= XFORM_INTEGER;
138 }
139
140 return HintFromAccel(pmx->flAccel);
141}
#define FLOATOBJ_IsLong(pf)
Definition: floatobj.h:103
#define FLOATOBJ_GetFix(pf)
Definition: floatobj.h:106
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
@ XFORM_INTEGER
Definition: ntgdityp.h:115
FORCEINLINE ULONG HintFromAccel(ULONG flAccel)
Definition: xformobj.c:89

Referenced by XFORMOBJ_iSetXform(), and XFORMOBJ_UpdateAccel().

◆ 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_bXformFixPoints()

static BOOL NTAPI XFORMOBJ_bXformFixPoints ( _In_ XFORMOBJ pxo,
_In_ ULONG  cPoints,
_In_reads_(cPoints) PPOINTL  pptIn,
_Out_writes_(cPoints) PPOINTL  pptOut 
)
static

Transforms fix-point coordinates in an array of POINTL structures using the transformation matrix from the XFORMOBJ.

Parameters
pxo- Pointer to the XFORMOBJ
cPoints- Number of coordinates to transform
pptIn- Pointer to an array of POINTL structures containing the source coordinates.
pptOut- Pointer to an array of POINTL structures, receiving the transformed coordinates. Can be the same as pptIn.
Returns
TRUE if the operation was successful, FALSE if any of the calculations caused an integer overflow.
Note
If the function returns FALSE, it might still have written to the output buffer. If pptIn and pptOut are equal, the source coordinates might have been partly overwritten!

Definition at line 365 of file xformobj.c.

370{
371 PMATRIX pmx;
372 INT i;
373 FLOATOBJ fo1, fo2;
374 FLONG flAccel;
375 LONG lM11, lM12, lM21, lM22, lTemp;
376 register LONGLONG llx, lly;
377
378 pmx = XFORMOBJ_pmx(pxo);
379 flAccel = pmx->flAccel;
380
381 if ((flAccel & (XFORM_SCALE|XFORM_UNITY)) == (XFORM_SCALE|XFORM_UNITY))
382 {
383 /* Identity transformation */
384 RtlCopyMemory(pptOut, pptIn, cPoints * sizeof(POINTL));
385 }
386 else if (flAccel & XFORM_INTEGER)
387 {
388 if (flAccel & XFORM_UNITY)
389 {
390 /* 1-scale integer transform, get the off-diagonal elements */
391 if (!FLOATOBJ_bConvertToLong(&pmx->efM12, &lM12) ||
392 !FLOATOBJ_bConvertToLong(&pmx->efM21, &lM21))
393 {
395 return FALSE;
396 }
397
398 i = cPoints - 1;
399 do
400 {
401 /* Calculate x in 64 bit and check for overflow */
402 llx = Int32x32To64(pptIn[i].y, lM21) + pptIn[i].x;
404 {
405 return FALSE;
406 }
407
408 /* Calculate y in 64 bit and check for overflow */
409 lly = Int32x32To64(pptIn[i].x, lM12) + pptIn[i].y;
411 {
412 return FALSE;
413 }
414
415 /* Write back the results */
416 pptOut[i].x = (LONG)llx;
417 pptOut[i].y = (LONG)lly;
418 }
419 while (--i >= 0);
420 }
421 else if (flAccel & XFORM_SCALE)
422 {
423 /* Diagonal integer transform, get the diagonal elements */
424 if (!FLOATOBJ_bConvertToLong(&pmx->efM11, &lM11) ||
425 !FLOATOBJ_bConvertToLong(&pmx->efM22, &lM22))
426 {
428 return FALSE;
429 }
430
431 i = cPoints - 1;
432 do
433 {
434 /* Calculate x in 64 bit and check for overflow */
435 llx = Int32x32To64(pptIn[i].x, lM11);
437 {
438 return FALSE;
439 }
440
441 /* Calculate y in 64 bit and check for overflow */
442 lly = Int32x32To64(pptIn[i].y, lM22);
444 {
445 return FALSE;
446 }
447
448 /* Write back the results */
449 pptOut[i].x = (LONG)llx;
450 pptOut[i].y = (LONG)lly;
451 }
452 while (--i >= 0);
453 }
454 else
455 {
456 /* Full integer transform */
457 if (!FLOATOBJ_bConvertToLong(&pmx->efM11, &lM11) ||
458 !FLOATOBJ_bConvertToLong(&pmx->efM12, &lM12) ||
459 !FLOATOBJ_bConvertToLong(&pmx->efM21, &lM21) ||
460 !FLOATOBJ_bConvertToLong(&pmx->efM22, &lM22))
461 {
463 return FALSE;
464 }
465
466 i = cPoints - 1;
467 do
468 {
469 /* Calculate x in 64 bit and check for overflow */
470 llx = Int32x32To64(pptIn[i].x, lM11);
471 llx += Int32x32To64(pptIn[i].y, lM21);
473 {
474 return FALSE;
475 }
476
477 /* Calculate y in 64 bit and check for overflow */
478 lly = Int32x32To64(pptIn[i].y, lM22);
479 lly += Int32x32To64(pptIn[i].x, lM12);
481 {
482 return FALSE;
483 }
484
485 /* Write back the results */
486 pptOut[i].x = (LONG)llx;
487 pptOut[i].y = (LONG)lly;
488 }
489 while (--i >= 0);
490 }
491 }
492 else if (flAccel & XFORM_UNITY)
493 {
494 /* 1-scale transform */
495 i = cPoints - 1;
496 do
497 {
498 /* Calculate x in 64 bit and check for overflow */
499 fo1 = pmx->efM21;
500 FLOATOBJ_MulLong(&fo1, pptIn[i].y);
501 if (!FLOATOBJ_bConvertToLong(&fo1, &lTemp))
502 {
503 return FALSE;
504 }
505 llx = (LONGLONG)pptIn[i].x + lTemp;
507 {
508 return FALSE;
509 }
510
511 /* Calculate y in 64 bit and check for overflow */
512 fo2 = pmx->efM12;
513 FLOATOBJ_MulLong(&fo2, pptIn[i].x);
514 if (!FLOATOBJ_bConvertToLong(&fo2, &lTemp))
515 {
516 return FALSE;
517 }
518 lly = (LONGLONG)pptIn[i].y + lTemp;
520 {
521 return FALSE;
522 }
523
524 /* Write back the results */
525 pptOut[i].x = (LONG)llx;
526 pptOut[i].y = (LONG)lly;
527 }
528 while (--i >= 0);
529 }
530 else if (flAccel & XFORM_SCALE)
531 {
532 /* Diagonal float transform */
533 i = cPoints - 1;
534 do
535 {
536 fo1 = pmx->efM11;
537 FLOATOBJ_MulLong(&fo1, pptIn[i].x);
538 if (!FLOATOBJ_bConvertToLong(&fo1, &pptOut[i].x))
539 {
540 return FALSE;
541 }
542
543 fo2 = pmx->efM22;
544 FLOATOBJ_MulLong(&fo2, pptIn[i].y);
545 if (!FLOATOBJ_bConvertToLong(&fo2, &pptOut[i].y))
546 {
547 return FALSE;
548 }
549 }
550 while (--i >= 0);
551 }
552 else
553 {
554 /* Full float transform */
555 i = cPoints - 1;
556 do
557 {
558 /* Calculate x as FLOATOBJ */
559 MulAddLong(&fo1, &pmx->efM11, pptIn[i].x, &pmx->efM21, pptIn[i].y);
560
561 /* Calculate y as FLOATOBJ */
562 MulAddLong(&fo2, &pmx->efM12, pptIn[i].x, &pmx->efM22, pptIn[i].y);
563
564 if (!FLOATOBJ_bConvertToLong(&fo1, &pptOut[i].x))
565 {
566 return FALSE;
567 }
568
569 if (!FLOATOBJ_bConvertToLong(&fo2, &pptOut[i].y))
570 {
571 return FALSE;
572 }
573 }
574 while (--i >= 0);
575 }
576
577 if (!(pmx->flAccel & XFORM_NO_TRANSLATION))
578 {
579 /* Translate points */
580 i = cPoints - 1;
581 do
582 {
583 llx = (LONGLONG)pptOut[i].x + pmx->fxDx;
585 {
586 return FALSE;
587 }
588 pptOut[i].x = (LONG)llx;
589
590 lly = (LONGLONG)pptOut[i].y + pmx->fxDy;
592 {
593 return FALSE;
594 }
595 pptOut[i].y = (LONG)lly;
596 }
597 while (--i >= 0);
598 }
599
600 return TRUE;
601}
#define FLOATOBJ_bConvertToLong(pf, pl)
Definition: floatobj.h:102
if(dx< 0)
Definition: linetemp.h:194
#define Int32x32To64(a, b)
unsigned long FLONG
Definition: ntbasedef.h:374
_In_ UINT _Out_ PPOINTL pptOut
Definition: ntgdi.h:2198
long LONG
Definition: pedump.c:60
FIX fxDy
Definition: ntgdityp.h:419
FLOATOBJ efM21
Definition: ntgdityp.h:414
FLOATOBJ efM11
Definition: ntgdityp.h:412
FIX fxDx
Definition: ntgdityp.h:418
FLONG flAccel
Definition: ntgdityp.h:420
FLOATOBJ efM22
Definition: ntgdityp.h:415
FLOATOBJ efM12
Definition: ntgdityp.h:413
int64_t LONGLONG
Definition: typedefs.h:68
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define NT_ASSERT
Definition: rtlfuncs.h:3327
#define DOES_VALUE_OVERFLOW_LONG(x)
Definition: xformobj.c:16
FORCEINLINE VOID MulAddLong(PFLOATOBJ pfoDest, PFLOATOBJ pfo1, LONG l2, PFLOATOBJ pfo3, LONG l4)
Definition: xformobj.c:47
#define XFORMOBJ_pmx
Definition: xformobj.h:13

Referenced by XFORMOBJ_bApplyXform().

◆ 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 efDx
Definition: ntgdityp.h:416
FLOATOBJ efDy
Definition: ntgdityp.h:417
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

◆ 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_iGetFloatObjXform()

ULONG APIENTRY XFORMOBJ_iGetFloatObjXform ( IN XFORMOBJ pxo,
OUT FLOATOBJ_XFORM pxfo 
)

Definition at line 636 of file xformobj.c.

639{
640 PMATRIX pmx = XFORMOBJ_pmx(pxo);
641
642 /* Check parameters */
643 if (!pxo || !pxfo)
644 {
645 return DDI_ERROR;
646 }
647
648 /* Copy members */
649 pxfo->eM11 = pmx->efM11;
650 pxfo->eM12 = pmx->efM12;
651 pxfo->eM21 = pmx->efM21;
652 pxfo->eM22 = pmx->efM22;
653 pxfo->eDx = pmx->efDx;
654 pxfo->eDy = pmx->efDy;
655
656 /* Return complexity hint */
657 return HintFromAccel(pmx->flAccel);
658}

◆ 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}
#define FLOATOBJ_GetFloat(pf)
Definition: winddi.h:2816

◆ 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 FLOATOBJ_SetFloat(pf, f)
Definition: winddi.h:2814
ULONG FASTCALL MX_UpdateAccel(IN OUT PMATRIX pmx)
Definition: xformobj.c:108
BOOL FASTCALL MX_IsInvertible(IN PMATRIX pmx)
Definition: xformobj.c:267

◆ XFORMOBJ_UpdateAccel()

ULONG NTAPI XFORMOBJ_UpdateAccel ( IN OUT XFORMOBJ pxo)

Definition at line 145 of file xformobj.c.

147{
148 PMATRIX pmx = XFORMOBJ_pmx(pxo);
149
150 return MX_UpdateAccel(pmx);
151}

Referenced by XFORMOBJ_iCombine(), and XFORMOBJ_iInverse().