2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2014-12-18 08:12:41 +00:00
|
|
|
/* Maximum extend of coordinate space */
|
|
|
|
#define MIN_COORD (INT_MIN / 16)
|
|
|
|
#define MAX_COORD (INT_MAX / 16)
|
|
|
|
|
2021-03-17 17:43:59 +00:00
|
|
|
/*
|
|
|
|
* Applies matrix (which is made of FLOATOBJs) to the points array, which are made of integers.
|
|
|
|
*/
|
|
|
|
static
|
|
|
|
inline
|
|
|
|
BOOLEAN
|
|
|
|
INTERNAL_APPLY_MATRIX(PMATRIX matrix, LPPOINT points, UINT count)
|
|
|
|
{
|
|
|
|
while (count--)
|
|
|
|
{
|
|
|
|
FLOATOBJ x, y;
|
|
|
|
FLOATOBJ tmp;
|
|
|
|
|
|
|
|
/* x = x * matrix->efM11 + y * matrix->efM21 + matrix->efDx; */
|
|
|
|
FLOATOBJ_SetLong(&x, points[count].x);
|
|
|
|
FLOATOBJ_Mul(&x, &matrix->efM11);
|
|
|
|
tmp = matrix->efM21;
|
|
|
|
FLOATOBJ_MulLong(&tmp, points[count].y);
|
|
|
|
FLOATOBJ_Add(&x, &tmp);
|
|
|
|
FLOATOBJ_Add(&x, &matrix->efDx);
|
|
|
|
|
|
|
|
/* y = x * matrix->efM12 + y * matrix->efM22 + matrix->efDy; */
|
|
|
|
FLOATOBJ_SetLong(&y, points[count].y);
|
|
|
|
FLOATOBJ_Mul(&y, &matrix->efM22);
|
|
|
|
tmp = matrix->efM12;
|
|
|
|
FLOATOBJ_MulLong(&tmp, points[count].x);
|
|
|
|
FLOATOBJ_Add(&y, &tmp);
|
|
|
|
FLOATOBJ_Add(&y, &matrix->efDy);
|
|
|
|
|
|
|
|
if (!FLOATOBJ_bConvertToLong(&x, &points[count].x))
|
|
|
|
return FALSE;
|
|
|
|
if (!FLOATOBJ_bConvertToLong(&y, &points[count].y))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-01-06 22:00:26 +00:00
|
|
|
|
2021-03-17 17:43:59 +00:00
|
|
|
static
|
|
|
|
inline
|
|
|
|
BOOLEAN
|
|
|
|
INTERNAL_LPTODP(DC *dc, LPPOINT points, UINT count)
|
|
|
|
{
|
|
|
|
return INTERNAL_APPLY_MATRIX(&dc->pdcattr->mxWorldToDevice, points, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
inline
|
|
|
|
BOOLEAN
|
|
|
|
INTERNAL_DPTOLP(DC *dc, LPPOINT points, UINT count)
|
|
|
|
{
|
|
|
|
return INTERNAL_APPLY_MATRIX(&dc->pdcattr->mxDeviceToWorld, points, count);
|
|
|
|
}
|
2011-01-06 22:00:26 +00:00
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
XFormToMatrix(
|
|
|
|
MATRIX *pmx,
|
|
|
|
const XFORML *pxform)
|
|
|
|
{
|
|
|
|
XFORMOBJ xo;
|
|
|
|
XFORMOBJ_vInit(&xo, pmx);
|
|
|
|
XFORMOBJ_iSetXform(&xo, pxform);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
MatrixToXForm(
|
|
|
|
XFORML *pxform,
|
|
|
|
const MATRIX *pmx)
|
|
|
|
{
|
|
|
|
XFORMOBJ xo;
|
|
|
|
XFORMOBJ_vInit(&xo, (MATRIX*)pmx);
|
|
|
|
XFORMOBJ_iGetXform(&xo, pxform);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
InvertXform(
|
|
|
|
XFORML *pxformDest,
|
|
|
|
const XFORML *pxformSource)
|
|
|
|
{
|
|
|
|
XFORMOBJ xo;
|
|
|
|
MATRIX mx;
|
|
|
|
|
|
|
|
XFORMOBJ_vInit(&xo, &mx);
|
|
|
|
XFORMOBJ_iSetXform(&xo, pxformSource);
|
|
|
|
XFORMOBJ_iInverse(&xo, &xo);
|
|
|
|
XFORMOBJ_iGetXform(&xo, pxformDest);
|
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
DC_vFixIsotropicMapping(PDC pdc);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
DC_vUpdateWorldToDevice(PDC pdc);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
DC_vUpdateDeviceToWorld(PDC pdc);
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-05-04 09:45:42 +00:00
|
|
|
PSIZEL
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_pszlViewportExt(PDC pdc)
|
|
|
|
{
|
|
|
|
PDC_ATTR pdcattr = pdc->pdcattr;
|
|
|
|
|
|
|
|
/* Check if we need isotropic fixup */
|
|
|
|
if ((pdcattr->flXform & PAGE_EXTENTS_CHANGED) &&
|
|
|
|
(pdcattr->iMapMode == MM_ISOTROPIC))
|
|
|
|
{
|
|
|
|
/* Fixup viewport extension */
|
|
|
|
DC_vFixIsotropicMapping(pdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &pdcattr->szlViewportExt;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-05-04 09:45:42 +00:00
|
|
|
PMATRIX
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_pmxWorldToPage(PDC pdc)
|
|
|
|
{
|
|
|
|
return &pdc->pdcattr->mxWorldToPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-05-04 09:45:42 +00:00
|
|
|
PMATRIX
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_pmxWorldToDevice(PDC pdc)
|
|
|
|
{
|
|
|
|
/* Check if world or page xform was changed */
|
|
|
|
if (pdc->pdcattr->flXform & (PAGE_XLATE_CHANGED|PAGE_EXTENTS_CHANGED|WORLD_XFORM_CHANGED))
|
|
|
|
{
|
|
|
|
/* Update the world-to-device xform */
|
|
|
|
DC_vUpdateWorldToDevice(pdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &pdc->pdcattr->mxWorldToDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-05-04 09:45:42 +00:00
|
|
|
PMATRIX
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_pmxDeviceToWorld(PDC pdc)
|
|
|
|
{
|
|
|
|
/* Check if the device-to-world xform is invalid */
|
|
|
|
if (pdc->pdcattr->flXform & DEVICE_TO_WORLD_INVALID)
|
|
|
|
{
|
|
|
|
/* Update the world-to-device xform */
|
|
|
|
DC_vUpdateDeviceToWorld(pdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &pdc->pdcattr->mxDeviceToWorld;
|
|
|
|
}
|
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
BOOL
|
2012-03-26 14:35:58 +00:00
|
|
|
NTAPI
|
|
|
|
GreModifyWorldTransform(
|
|
|
|
PDC pdc,
|
|
|
|
const XFORML *pXForm,
|
|
|
|
DWORD dwMode);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2008-05-13 23:26:02 +00:00
|
|
|
VOID FASTCALL IntMirrorWindowOrg(PDC);
|
2012-07-29 11:20:05 +00:00
|
|
|
int APIENTRY IntGdiSetMapMode(PDC, int);
|
2014-04-13 11:41:19 +00:00
|
|
|
BOOL FASTCALL GreLPtoDP(HDC, LPPOINT, INT);
|
|
|
|
BOOL FASTCALL GreDPtoLP(HDC, LPPOINT, INT);
|
2015-08-07 05:56:01 +00:00
|
|
|
BOOL APIENTRY GreGetDCPoint(HDC,UINT,PPOINTL);
|
|
|
|
BOOL WINAPI GreGetWindowExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize);
|
|
|
|
BOOL WINAPI GreGetViewportExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize);
|
|
|
|
BOOL FASTCALL GreSetViewportOrgEx(HDC,int,int,LPPOINT);
|
2017-05-14 01:00:27 +00:00
|
|
|
BOOL WINAPI GreGetDCOrgEx(_In_ HDC, _Out_ PPOINTL, _Out_ PRECTL);
|
|
|
|
BOOL WINAPI GreSetDCOrg(_In_ HDC, _In_ LONG, _In_ LONG, _In_opt_ PRECTL);
|
2021-03-17 17:43:59 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
inline
|
|
|
|
BOOLEAN
|
|
|
|
IntLPtoDP(DC* pdc, PPOINTL ppt, UINT count)
|
|
|
|
{
|
|
|
|
DC_vUpdateWorldToDevice(pdc);
|
|
|
|
return INTERNAL_LPTODP(pdc, (LPPOINT)ppt, count);
|
|
|
|
}
|
|
|
|
#define CoordLPtoDP(pdc, ppt) INTERNAL_LPTODP(pdc, ppt, 1)
|
|
|
|
|
|
|
|
static
|
|
|
|
inline
|
|
|
|
BOOLEAN
|
|
|
|
IntDPtoLP(DC* pdc, PPOINTL ppt, UINT count)
|
|
|
|
{
|
|
|
|
DC_vUpdateDeviceToWorld(pdc);
|
|
|
|
return INTERNAL_DPTOLP(pdc, (LPPOINT)ppt, count);
|
|
|
|
}
|
|
|
|
#define CoordDPtoLP(pdc, ppt) INTERNAL_DPTOLP(pdc, ppt, 1)
|
|
|
|
|
|
|
|
#define XForm2MatrixS(m, x) XFormToMatrix(m, (XFORML*)x)
|
|
|
|
#define MatrixS2XForm(x, m) MatrixToXForm((XFORML*)x, m)
|