2008-08-30 01:01:52 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS win32 kernel mode subsystem
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: subsystems/win32/win32k/objects/xformobj.c
|
2011-12-14 04:07:06 +00:00
|
|
|
* PURPOSE: XFORMOBJ API
|
2008-08-30 01:01:52 +00:00
|
|
|
* PROGRAMMER: Timo Kreuzer
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Includes ******************************************************************/
|
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2008-08-30 01:01:52 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
C_ASSERT(sizeof(FIX) == sizeof(LONG));
|
|
|
|
#define FIX2LONG(x) ((x) >> 4)
|
|
|
|
#define LONG2FIX(x) ((x) << 4)
|
|
|
|
|
|
|
|
#define FLOATOBJ_Equal _FLOATOBJ_Equal
|
|
|
|
#define FLOATOBJ_GetLong _FLOATOBJ_GetLong
|
|
|
|
#define FLOATOBJ_GetFix _FLOATOBJ_GetFix
|
|
|
|
#define FLOATOBJ_IsLong _FLOATOBJ_IsLong
|
|
|
|
#define FLOATOBJ_Equal0 _FLOATOBJ_Equal0
|
|
|
|
#define FLOATOBJ_Equal1 _FLOATOBJ_Equal1
|
|
|
|
|
|
|
|
/** Inline helper functions ***************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inline helper to calculate pfo1 * pfo2 + pfo3 * pfo4
|
|
|
|
*/
|
2008-12-03 17:36:23 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
2008-08-30 01:01:52 +00:00
|
|
|
MulAdd(
|
|
|
|
PFLOATOBJ pfoDest,
|
|
|
|
PFLOATOBJ pfo1,
|
|
|
|
PFLOATOBJ pfo2,
|
|
|
|
PFLOATOBJ pfo3,
|
|
|
|
PFLOATOBJ pfo4)
|
|
|
|
{
|
|
|
|
FLOATOBJ foTmp;
|
|
|
|
|
|
|
|
*pfoDest = *pfo1;
|
|
|
|
FLOATOBJ_Mul(pfoDest, pfo2);
|
|
|
|
foTmp = *pfo3;
|
|
|
|
FLOATOBJ_Mul(&foTmp, pfo4);
|
|
|
|
FLOATOBJ_Add(pfoDest, &foTmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inline helper to calculate pfo1 * l2 + pfo3 * l4
|
|
|
|
*/
|
2008-12-03 17:36:23 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
2008-08-30 01:01:52 +00:00
|
|
|
MulAddLong(
|
|
|
|
PFLOATOBJ pfoDest,
|
|
|
|
PFLOATOBJ pfo1,
|
|
|
|
LONG l2,
|
|
|
|
PFLOATOBJ pfo3,
|
|
|
|
LONG l4)
|
|
|
|
{
|
|
|
|
FLOATOBJ foTmp;
|
|
|
|
|
|
|
|
*pfoDest = *pfo1;
|
|
|
|
FLOATOBJ_MulLong(pfoDest, l2);
|
|
|
|
foTmp = *pfo3;
|
|
|
|
FLOATOBJ_MulLong(&foTmp, l4);
|
|
|
|
FLOATOBJ_Add(pfoDest, &foTmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inline helper to calculate pfo1 * pfo2 - pfo3 * pfo4
|
|
|
|
*/
|
2008-12-03 17:36:23 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
2008-08-30 01:01:52 +00:00
|
|
|
MulSub(
|
|
|
|
PFLOATOBJ pfoDest,
|
|
|
|
PFLOATOBJ pfo1,
|
|
|
|
PFLOATOBJ pfo2,
|
|
|
|
PFLOATOBJ pfo3,
|
|
|
|
PFLOATOBJ pfo4)
|
|
|
|
{
|
|
|
|
FLOATOBJ foTmp;
|
|
|
|
|
|
|
|
*pfoDest = *pfo1;
|
|
|
|
FLOATOBJ_Mul(pfoDest, pfo2);
|
|
|
|
foTmp = *pfo3;
|
|
|
|
FLOATOBJ_Mul(&foTmp, pfo4);
|
|
|
|
FLOATOBJ_Sub(pfoDest, &foTmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inline helper to get the complexity hint from flAccel
|
|
|
|
*/
|
2008-12-03 17:36:23 +00:00
|
|
|
FORCEINLINE
|
|
|
|
ULONG
|
2008-08-30 01:01:52 +00:00
|
|
|
HintFromAccel(ULONG flAccel)
|
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
switch (flAccel & (XFORM_SCALE|XFORM_UNITY|XFORM_NO_TRANSLATION))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
case (XFORM_SCALE|XFORM_UNITY|XFORM_NO_TRANSLATION):
|
2011-01-06 22:00:26 +00:00
|
|
|
return GX_IDENTITY;
|
2012-03-26 14:35:58 +00:00
|
|
|
case (XFORM_SCALE|XFORM_UNITY):
|
2011-01-06 22:00:26 +00:00
|
|
|
return GX_OFFSET;
|
2012-03-26 14:35:58 +00:00
|
|
|
case XFORM_SCALE:
|
2011-01-06 22:00:26 +00:00
|
|
|
return GX_SCALE;
|
|
|
|
default:
|
|
|
|
return GX_GENERAL;
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Internal functions ********************************************************/
|
|
|
|
|
|
|
|
ULONG
|
2011-08-27 12:38:23 +00:00
|
|
|
NTAPI
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_UpdateAccel(
|
|
|
|
IN XFORMOBJ *pxo)
|
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
PMATRIX pmx = XFORMOBJ_pmx(pxo);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
/* Copy Dx and Dy to FIX format */
|
|
|
|
pmx->fxDx = FLOATOBJ_GetFix(&pmx->efDx);
|
|
|
|
pmx->fxDy = FLOATOBJ_GetFix(&pmx->efDy);
|
|
|
|
|
|
|
|
pmx->flAccel = 0;
|
|
|
|
|
|
|
|
if (FLOATOBJ_Equal0(&pmx->efDx) &&
|
2011-01-06 22:00:26 +00:00
|
|
|
FLOATOBJ_Equal0(&pmx->efDy))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
pmx->flAccel |= XFORM_NO_TRANSLATION;
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FLOATOBJ_Equal0(&pmx->efM12) &&
|
2011-01-06 22:00:26 +00:00
|
|
|
FLOATOBJ_Equal0(&pmx->efM21))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
pmx->flAccel |= XFORM_SCALE;
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FLOATOBJ_Equal1(&pmx->efM11) &&
|
2011-01-06 22:00:26 +00:00
|
|
|
FLOATOBJ_Equal1(&pmx->efM22))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
pmx->flAccel |= XFORM_UNITY;
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FLOATOBJ_IsLong(&pmx->efM11) && FLOATOBJ_IsLong(&pmx->efM12) &&
|
2011-01-06 22:00:26 +00:00
|
|
|
FLOATOBJ_IsLong(&pmx->efM21) && FLOATOBJ_IsLong(&pmx->efM22))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
pmx->flAccel |= XFORM_INTEGER;
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return HintFromAccel(pmx->flAccel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ULONG
|
2011-08-27 12:38:23 +00:00
|
|
|
NTAPI
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_iSetXform(
|
|
|
|
OUT XFORMOBJ *pxo,
|
2011-01-06 22:00:26 +00:00
|
|
|
IN const XFORML *pxform)
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
PMATRIX pmx = XFORMOBJ_pmx(pxo);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
/* Check parameters */
|
2012-04-25 17:29:50 +00:00
|
|
|
if (!pxo || !pxform) return DDI_ERROR;
|
|
|
|
|
|
|
|
/* Check if the xform is valid */
|
|
|
|
if ((pxform->eM11 == 0) || (pxform->eM22 == 0)) return DDI_ERROR;
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
/* Copy members */
|
|
|
|
FLOATOBJ_SetFloat(&pmx->efM11, pxform->eM11);
|
|
|
|
FLOATOBJ_SetFloat(&pmx->efM12, pxform->eM12);
|
|
|
|
FLOATOBJ_SetFloat(&pmx->efM21, pxform->eM21);
|
|
|
|
FLOATOBJ_SetFloat(&pmx->efM22, pxform->eM22);
|
|
|
|
FLOATOBJ_SetFloat(&pmx->efDx, pxform->eDx);
|
|
|
|
FLOATOBJ_SetFloat(&pmx->efDy, pxform->eDy);
|
|
|
|
|
|
|
|
/* Update accelerators and return complexity */
|
|
|
|
return XFORMOBJ_UpdateAccel(pxo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Multiplies pxo1 with pxo2 and stores the result in pxo.
|
|
|
|
* returns complexity hint
|
|
|
|
* | efM11 efM12 0 |
|
|
|
|
* | efM21 efM22 0 |
|
|
|
|
* | efDx efDy 1 |
|
|
|
|
*/
|
|
|
|
ULONG
|
2011-08-27 12:38:23 +00:00
|
|
|
NTAPI
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_iCombine(
|
|
|
|
IN XFORMOBJ *pxo,
|
|
|
|
IN XFORMOBJ *pxo1,
|
|
|
|
IN XFORMOBJ *pxo2)
|
|
|
|
{
|
|
|
|
MATRIX mx;
|
|
|
|
PMATRIX pmx, pmx1, pmx2;
|
|
|
|
|
2011-01-06 22:00:26 +00:00
|
|
|
pmx = XFORMOBJ_pmx(pxo);
|
|
|
|
pmx1 =XFORMOBJ_pmx(pxo1);
|
|
|
|
pmx2 = XFORMOBJ_pmx(pxo2);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
/* Do a 3 x 3 matrix multiplication with mx as destinantion */
|
|
|
|
MulAdd(&mx.efM11, &pmx1->efM11, &pmx2->efM11, &pmx1->efM12, &pmx2->efM21);
|
|
|
|
MulAdd(&mx.efM12, &pmx1->efM11, &pmx2->efM12, &pmx1->efM12, &pmx2->efM22);
|
|
|
|
MulAdd(&mx.efM21, &pmx1->efM21, &pmx2->efM11, &pmx1->efM22, &pmx2->efM21);
|
|
|
|
MulAdd(&mx.efM22, &pmx1->efM21, &pmx2->efM12, &pmx1->efM22, &pmx2->efM22);
|
|
|
|
MulAdd(&mx.efDx, &pmx1->efDx, &pmx2->efM11, &pmx1->efDy, &pmx2->efM21);
|
|
|
|
FLOATOBJ_Add(&mx.efDx, &pmx2->efDx);
|
|
|
|
MulAdd(&mx.efDy, &pmx1->efDx, &pmx2->efM12, &pmx1->efDy, &pmx2->efM22);
|
|
|
|
FLOATOBJ_Add(&mx.efDy, &pmx2->efDy);
|
|
|
|
|
|
|
|
/* Copy back */
|
|
|
|
*pmx = mx;
|
|
|
|
|
|
|
|
/* Update accelerators and return complexity */
|
|
|
|
return XFORMOBJ_UpdateAccel(pxo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ULONG
|
2011-08-27 12:38:23 +00:00
|
|
|
NTAPI
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_iCombineXform(
|
|
|
|
IN XFORMOBJ *pxo,
|
|
|
|
IN XFORMOBJ *pxo1,
|
|
|
|
IN XFORML *pxform,
|
|
|
|
IN BOOL bLeftMultiply)
|
|
|
|
{
|
|
|
|
MATRIX mx;
|
2011-01-06 22:00:26 +00:00
|
|
|
XFORMOBJ xo2;
|
2008-08-30 01:01:52 +00:00
|
|
|
|
2011-01-06 22:00:26 +00:00
|
|
|
XFORMOBJ_vInit(&xo2, &mx);
|
|
|
|
XFORMOBJ_iSetXform(&xo2, pxform);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
if (bLeftMultiply)
|
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
return XFORMOBJ_iCombine(pxo, &xo2, pxo1);
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
return XFORMOBJ_iCombine(pxo, pxo1, &xo2);
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A^-1 = adj(A) / det(AT)
|
|
|
|
* A^-1 = 1/(a*d - b*c) * (a22,-a12,a21,-a11)
|
|
|
|
*/
|
|
|
|
ULONG
|
2011-08-27 12:38:23 +00:00
|
|
|
NTAPI
|
2011-01-06 22:00:26 +00:00
|
|
|
XFORMOBJ_iInverse(
|
2008-08-30 01:01:52 +00:00
|
|
|
OUT XFORMOBJ *pxoDst,
|
|
|
|
IN XFORMOBJ *pxoSrc)
|
|
|
|
{
|
|
|
|
PMATRIX pmxDst, pmxSrc;
|
|
|
|
FLOATOBJ foDet;
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORM xformSrc;
|
2008-08-30 01:01:52 +00:00
|
|
|
|
2011-01-06 22:00:26 +00:00
|
|
|
pmxDst = XFORMOBJ_pmx(pxoDst);
|
|
|
|
pmxSrc = XFORMOBJ_pmx(pxoSrc);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ_iGetXform(pxoSrc, (XFORML*)&xformSrc);
|
|
|
|
|
2008-08-30 01:01:52 +00:00
|
|
|
/* det = M11 * M22 - M12 * M21 */
|
|
|
|
MulSub(&foDet, &pmxSrc->efM11, &pmxSrc->efM22, &pmxSrc->efM12, &pmxSrc->efM21);
|
|
|
|
|
|
|
|
if (FLOATOBJ_Equal0(&foDet))
|
|
|
|
{
|
|
|
|
/* Determinant is 0! */
|
|
|
|
return DDI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate adj(A) / det(A) */
|
|
|
|
pmxDst->efM11 = pmxSrc->efM22;
|
|
|
|
FLOATOBJ_Div(&pmxDst->efM11, &foDet);
|
|
|
|
pmxDst->efM22 = pmxSrc->efM11;
|
|
|
|
FLOATOBJ_Div(&pmxDst->efM22, &foDet);
|
|
|
|
|
|
|
|
/* The other 2 are negative, negate foDet for that */
|
|
|
|
FLOATOBJ_Neg(&foDet);
|
2012-03-26 14:35:58 +00:00
|
|
|
pmxDst->efM12 = pmxSrc->efM12;
|
2008-08-30 01:01:52 +00:00
|
|
|
FLOATOBJ_Div(&pmxDst->efM12, &foDet);
|
2012-03-26 14:35:58 +00:00
|
|
|
pmxDst->efM21 = pmxSrc->efM21;
|
|
|
|
FLOATOBJ_Div(&pmxDst->efM21, &foDet);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
2012-07-28 18:31:24 +00:00
|
|
|
/* Calculate the inverted x shift: Dx' = -Dx * M11' - Dy * M21' */
|
|
|
|
pmxDst->efDx = pmxSrc->efDx;
|
|
|
|
FLOATOBJ_Neg(&pmxDst->efDx);
|
|
|
|
MulSub(&pmxDst->efDx, &pmxDst->efDx, &pmxDst->efM11, &pmxSrc->efDy, &pmxDst->efM21);
|
|
|
|
|
|
|
|
/* Calculate the inverted y shift: Dy' = -Dy * M22' - Dx * M12' */
|
|
|
|
pmxDst->efDy = pmxSrc->efDy;
|
|
|
|
FLOATOBJ_Neg(&pmxDst->efDy);
|
|
|
|
MulSub(&pmxDst->efDy, &pmxDst->efDy, &pmxDst->efM22, &pmxSrc->efDx, &pmxDst->efM12);
|
|
|
|
|
2008-08-30 01:01:52 +00:00
|
|
|
/* Update accelerators and return complexity */
|
|
|
|
return XFORMOBJ_UpdateAccel(pxoDst);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
2011-08-27 12:38:23 +00:00
|
|
|
NTAPI
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_bXformFixPoints(
|
|
|
|
IN XFORMOBJ *pxo,
|
|
|
|
IN ULONG cPoints,
|
|
|
|
IN PPOINTL pptIn,
|
|
|
|
OUT PPOINTL pptOut)
|
|
|
|
{
|
|
|
|
PMATRIX pmx;
|
|
|
|
INT i;
|
|
|
|
FLOATOBJ fo1, fo2;
|
|
|
|
FLONG flAccel;
|
|
|
|
|
2011-01-06 22:00:26 +00:00
|
|
|
pmx = XFORMOBJ_pmx(pxo);
|
|
|
|
flAccel = pmx->flAccel;
|
2008-08-30 01:01:52 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
if ((flAccel & (XFORM_SCALE|XFORM_UNITY)) == (XFORM_SCALE|XFORM_UNITY))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
|
|
|
/* Identity transformation, nothing todo */
|
2011-01-06 22:00:26 +00:00
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
else if (flAccel & XFORM_INTEGER)
|
2011-01-06 22:00:26 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
if (flAccel & XFORM_UNITY)
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
/* 1-scale integer transform */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
LONG x = pptIn[i].x + pptIn[i].y * FLOATOBJ_GetLong(&pmx->efM21);
|
|
|
|
LONG y = pptIn[i].y + pptIn[i].x * FLOATOBJ_GetLong(&pmx->efM12);
|
|
|
|
pptOut[i].y = y;
|
|
|
|
pptOut[i].x = x;
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
else if (flAccel & XFORM_SCALE)
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
/* Diagonal integer transform */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
pptOut[i].x = pptIn[i].x * FLOATOBJ_GetLong(&pmx->efM11);
|
|
|
|
pptOut[i].y = pptIn[i].y * FLOATOBJ_GetLong(&pmx->efM22);
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
2011-01-06 22:00:26 +00:00
|
|
|
else
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
/* Full integer transform */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
LONG x;
|
|
|
|
x = pptIn[i].x * FLOATOBJ_GetLong(&pmx->efM11);
|
|
|
|
x += pptIn[i].y * FLOATOBJ_GetLong(&pmx->efM21);
|
|
|
|
pptOut[i].y = pptIn[i].y * FLOATOBJ_GetLong(&pmx->efM22);
|
|
|
|
pptOut[i].y += pptIn[i].x * FLOATOBJ_GetLong(&pmx->efM12);
|
|
|
|
pptOut[i].x = x;
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
2011-01-06 22:00:26 +00:00
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
else if (flAccel & XFORM_UNITY)
|
2011-01-06 22:00:26 +00:00
|
|
|
{
|
2008-08-30 01:01:52 +00:00
|
|
|
/* 1-scale transform */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
fo1 = pmx->efM21;
|
|
|
|
FLOATOBJ_MulLong(&fo1, pptIn[i].y);
|
|
|
|
fo2 = pmx->efM12;
|
|
|
|
FLOATOBJ_MulLong(&fo2, pptIn[i].x);
|
|
|
|
pptOut[i].x = pptIn[i].x + FLOATOBJ_GetLong(&fo1);
|
|
|
|
pptOut[i].y = pptIn[i].y + FLOATOBJ_GetLong(&fo2);
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
2011-01-06 22:00:26 +00:00
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
else if (flAccel & XFORM_SCALE)
|
2011-01-06 22:00:26 +00:00
|
|
|
{
|
2008-08-30 01:01:52 +00:00
|
|
|
/* Diagonal float transform */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
fo1 = pmx->efM11;
|
|
|
|
FLOATOBJ_MulLong(&fo1, pptIn[i].x);
|
|
|
|
pptOut[i].x = FLOATOBJ_GetLong(&fo1);
|
|
|
|
fo2 = pmx->efM22;
|
|
|
|
FLOATOBJ_MulLong(&fo2, pptIn[i].y);
|
|
|
|
pptOut[i].y = FLOATOBJ_GetLong(&fo2);
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
2011-01-06 22:00:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-30 01:01:52 +00:00
|
|
|
/* Full float transform */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
MulAddLong(&fo1, &pmx->efM11, pptIn[i].x, &pmx->efM21, pptIn[i].y);
|
|
|
|
MulAddLong(&fo2, &pmx->efM12, pptIn[i].x, &pmx->efM22, pptIn[i].y);
|
|
|
|
pptOut[i].x = FLOATOBJ_GetLong(&fo1);
|
|
|
|
pptOut[i].y = FLOATOBJ_GetLong(&fo2);
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
if (!(pmx->flAccel & XFORM_NO_TRANSLATION))
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
|
|
|
/* Translate points */
|
|
|
|
i = cPoints - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
pptOut[i].x += pmx->fxDx;
|
|
|
|
pptOut[i].y += pmx->fxDy;
|
|
|
|
}
|
|
|
|
while (--i >= 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Public functions **********************************************************/
|
|
|
|
|
|
|
|
// www.osr.com/ddk/graphics/gdifncs_0s2v.htm
|
|
|
|
ULONG
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_iGetXform(
|
|
|
|
IN XFORMOBJ *pxo,
|
|
|
|
OUT XFORML *pxform)
|
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
PMATRIX pmx = XFORMOBJ_pmx(pxo);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!pxo || !pxform)
|
|
|
|
{
|
|
|
|
return DDI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy members */
|
|
|
|
pxform->eM11 = FLOATOBJ_GetFloat(&pmx->efM11);
|
|
|
|
pxform->eM12 = FLOATOBJ_GetFloat(&pmx->efM12);
|
|
|
|
pxform->eM21 = FLOATOBJ_GetFloat(&pmx->efM21);
|
|
|
|
pxform->eM22 = FLOATOBJ_GetFloat(&pmx->efM22);
|
|
|
|
pxform->eDx = FLOATOBJ_GetFloat(&pmx->efDx);
|
|
|
|
pxform->eDy = FLOATOBJ_GetFloat(&pmx->efDy);
|
|
|
|
|
|
|
|
/* Return complexity hint */
|
|
|
|
return HintFromAccel(pmx->flAccel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// www.osr.com/ddk/graphics/gdifncs_5ig7.htm
|
|
|
|
ULONG
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_iGetFloatObjXform(
|
|
|
|
IN XFORMOBJ *pxo,
|
|
|
|
OUT FLOATOBJ_XFORM *pxfo)
|
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
PMATRIX pmx = XFORMOBJ_pmx(pxo);
|
2008-08-30 01:01:52 +00:00
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!pxo || !pxfo)
|
|
|
|
{
|
|
|
|
return DDI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy members */
|
|
|
|
pxfo->eM11 = pmx->efM11;
|
|
|
|
pxfo->eM12 = pmx->efM12;
|
|
|
|
pxfo->eM21 = pmx->efM21;
|
|
|
|
pxfo->eM22 = pmx->efM22;
|
|
|
|
pxfo->eDx = pmx->efDx;
|
|
|
|
pxfo->eDy = pmx->efDy;
|
|
|
|
|
|
|
|
/* Return complexity hint */
|
|
|
|
return HintFromAccel(pmx->flAccel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// www.osr.com/ddk/graphics/gdifncs_027b.htm
|
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-08-30 01:01:52 +00:00
|
|
|
XFORMOBJ_bApplyXform(
|
2011-01-06 22:00:26 +00:00
|
|
|
IN XFORMOBJ *pxo,
|
|
|
|
IN ULONG iMode,
|
|
|
|
IN ULONG cPoints,
|
|
|
|
IN PVOID pvIn,
|
|
|
|
OUT PVOID pvOut)
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
|
|
|
MATRIX mx;
|
2011-01-06 22:00:26 +00:00
|
|
|
XFORMOBJ xoInv;
|
2008-08-30 01:01:52 +00:00
|
|
|
POINTL *pptl;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!pxo || !pvIn || !pvOut || cPoints < 1)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use inverse xform? */
|
|
|
|
if (iMode == XF_INV_FXTOL || iMode == XF_INV_LTOL)
|
|
|
|
{
|
2011-01-06 22:00:26 +00:00
|
|
|
XFORMOBJ_vInit(&xoInv, &mx);
|
|
|
|
if (XFORMOBJ_iInverse(&xoInv, pxo) == DDI_ERROR)
|
2008-08-30 01:01:52 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-01-06 22:00:26 +00:00
|
|
|
pxo = &xoInv;
|
2008-08-30 01:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert POINTL to POINTFIX? */
|
|
|
|
if (iMode == XF_LTOFX || iMode == XF_LTOL || iMode == XF_INV_LTOL)
|
|
|
|
{
|
|
|
|
pptl = pvIn;
|
|
|
|
for (i = cPoints - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
pptl[i].x = LONG2FIX(pptl[i].x);
|
|
|
|
pptl[i].y = LONG2FIX(pptl[i].y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do the actual fixpoint transformation */
|
|
|
|
if (!XFORMOBJ_bXformFixPoints(pxo, cPoints, pvIn, pvOut))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert POINTFIX to POINTL? */
|
|
|
|
if (iMode == XF_INV_FXTOL || iMode == XF_INV_LTOL || iMode == XF_LTOL)
|
|
|
|
{
|
|
|
|
pptl = pvOut;
|
|
|
|
for (i = cPoints - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
pptl[i].x = FIX2LONG(pptl[i].x);
|
|
|
|
pptl[i].y = FIX2LONG(pptl[i].y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|