2003-05-18 17:16:18 +00:00
|
|
|
/*
|
2011-01-04 16:53:23 +00:00
|
|
|
* COPYRIGHT: GNU GPL, See COPYING in the top level directory
|
2002-07-04 19:56:38 +00:00
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: Coordinate systems
|
2011-12-14 04:07:06 +00:00
|
|
|
* FILE: subsystems/win32/win32k/objects/coord.c
|
2012-03-26 14:35:58 +00:00
|
|
|
* PROGRAMER: Timo Kreuzer (timo.kreuzer@rectos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Coordinate translation overview
|
|
|
|
* -------------------------------
|
|
|
|
*
|
|
|
|
* Windows uses 3 different coordinate systems, referred to as world space,
|
|
|
|
* page space and device space.
|
|
|
|
*
|
|
|
|
* Device space:
|
|
|
|
* This is the coordinate system of the physical device that displays the
|
|
|
|
* graphics. One unit matches one pixel of the surface. The coordinate system
|
|
|
|
* is always orthogonal.
|
|
|
|
*
|
|
|
|
* Page space:
|
|
|
|
* This is the coordinate system on the screen or on the paper layout for
|
|
|
|
* printer devices. The coordinate system is also orthogonal but one unit
|
|
|
|
* does not neccesarily match one pixel. Instead there are different mapping
|
|
|
|
* modes that can be set using SetMapMode() that specify how page space units
|
|
|
|
* are transformed into device space units. These mapping modes are:
|
|
|
|
* - MM_TEXT: One unit matches one unit in device space (one pixel)
|
|
|
|
* - MM_TWIPS One unit matches 1/20 point (1/1440 inch)
|
|
|
|
* - MM_LOMETRIC: One unit matches 0.1 millimeter
|
|
|
|
* - MM_HIMETRIC: One unit matches 0.01 millimeter
|
|
|
|
* - MM_LOENGLISH: One unit matches 0.01 inch
|
|
|
|
* - MM_HIENGLISH: One unit matches 0.001 inch
|
|
|
|
* - MM_ISOTROPIC:
|
|
|
|
* - MM_ANISOTROPIC:
|
|
|
|
* If the mapping mode is either MM_ISOTROPIC or MM_ANISOTROPIC, the actual
|
|
|
|
* transormation is calculated from the window and viewport extension.
|
|
|
|
* The window extension can be set using SetWindowExtEx() and describes the
|
|
|
|
* extents of an arbitrary window (not to confuse with the gui element!) in
|
|
|
|
* page space coordinates.
|
|
|
|
* The viewport extension can be set using SetViewportExtEx() and describes
|
|
|
|
* the extent of the same window in device space coordinates. If the mapping
|
|
|
|
* mode is MM_ISOTROPIC one of the viewport extensions can be adjusted by GDI
|
|
|
|
* to make sure the mapping stays isotropic, that is it has the same x/y ratio
|
|
|
|
* as the window extension.
|
|
|
|
*
|
|
|
|
* World space:
|
|
|
|
* World space is the coordinate system that is used for all GDI drawing
|
|
|
|
* operations. The metrics of this coordinate system depend on the DCs
|
|
|
|
* graphics mode, which can be set using SetGraphicsMode().
|
|
|
|
* If the graphics mode is GM_COMPATIBLE, world space is identical to page
|
|
|
|
* space and no additional transformation is applied.
|
|
|
|
* If the graphics mode is GM_ADVANCED, an arbitrary coordinate transformation
|
|
|
|
* can be set using SetWorldTransform(), which is applied to transform world
|
|
|
|
* space coordinates into page space coordinates.
|
|
|
|
*
|
|
|
|
* User mode data
|
|
|
|
* All coordinate translation data is stored in the dc attribute, so the values
|
|
|
|
* might be invalid. This has to be taken into account. Integer values might be
|
|
|
|
* zero, so when a division is made, the value has to be read first and then
|
|
|
|
* checked! For floating point values (FLOATOBJ as well) these restrictions do
|
|
|
|
* not apply, since we cannot get dividy-by-zero exceptions.
|
|
|
|
* Though the result might be a completely random and invalid value, if it was
|
|
|
|
* messed with in an illegal way in user mode. This is not a problem, since the
|
|
|
|
* result of coordinate transformations are never expected to be "valid" values.
|
|
|
|
* In the worst case, the drawing operation draws rubbish into the DC.
|
2002-07-04 19:56:38 +00:00
|
|
|
*/
|
1999-07-22 16:21:53 +00:00
|
|
|
|
2002-07-04 19:56:38 +00:00
|
|
|
/* INCLUDES ******************************************************************/
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
1999-07-22 16:21:53 +00:00
|
|
|
|
2005-06-29 07:09:25 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2012-03-26 14:35:58 +00:00
|
|
|
C_ASSERT(sizeof(XFORML) == sizeof(XFORM));
|
|
|
|
|
|
|
|
|
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
|
|
|
const MATRIX gmxIdentity =
|
|
|
|
{
|
|
|
|
FLOATOBJ_1, FLOATOBJ_0,
|
|
|
|
FLOATOBJ_0, FLOATOBJ_1,
|
|
|
|
FLOATOBJ_0, FLOATOBJ_0,
|
|
|
|
0, 0, XFORM_NO_TRANSLATION|XFORM_FORMAT_LTOL|XFORM_UNITY|XFORM_SCALE
|
|
|
|
};
|
|
|
|
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2002-07-04 19:56:38 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
DC_vFixIsotropicMapping(PDC pdc)
|
2006-06-21 08:33:27 +00:00
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2012-03-26 14:35:58 +00:00
|
|
|
LONG64 fx, fy;
|
|
|
|
LONG s;
|
|
|
|
SIZEL szlWindowExt, szlViewportExt;
|
|
|
|
ASSERT(pdc->pdcattr->iMapMode == MM_ISOTROPIC);
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-02-02 00:49:19 +00:00
|
|
|
/* Get a pointer to the DC_ATTR */
|
2011-01-04 16:53:23 +00:00
|
|
|
pdcattr = pdc->pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Read the extents, we rely on non-null values */
|
|
|
|
szlWindowExt = pdcattr->szlWindowExt;
|
|
|
|
szlViewportExt = pdcattr->szlViewportExt;
|
|
|
|
|
2009-02-02 00:49:19 +00:00
|
|
|
/* Check if all values are valid */
|
2012-03-26 14:35:58 +00:00
|
|
|
if ((szlWindowExt.cx == 0) || (szlWindowExt.cy == 0) ||
|
|
|
|
(szlViewportExt.cx == 0) || (szlViewportExt.cy == 0))
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Someone put rubbish into the fields, just ignore it. */
|
2009-02-02 00:49:19 +00:00
|
|
|
return;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
2009-02-02 00:49:19 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
fx = abs((LONG64)szlWindowExt.cx * szlViewportExt.cy);
|
|
|
|
fy = abs((LONG64)szlWindowExt.cy * szlViewportExt.cx);
|
2009-02-02 00:49:19 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
if (fx < fy)
|
2009-02-02 00:49:19 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
s = (szlWindowExt.cy ^ szlViewportExt.cx) > 0 ? 1 : -1;
|
|
|
|
pdcattr->szlViewportExt.cx = (LONG)(fx * s / szlWindowExt.cy);
|
2009-02-02 00:49:19 +00:00
|
|
|
}
|
|
|
|
else if (fx > fy)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
s = (szlWindowExt.cx ^ szlViewportExt.cy) > 0 ? 1 : -1;
|
|
|
|
pdcattr->szlViewportExt.cy = (LONG)(fy * s / szlWindowExt.cx);
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
2006-06-21 08:33:27 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Reset the flag */
|
|
|
|
pdc->pdcattr->flXform &= ~PAGE_EXTENTS_CHANGED;
|
2011-01-04 16:53:23 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
DC_vGetPageToDevice(PDC pdc, MATRIX *pmx)
|
2011-01-04 16:53:23 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
PDC_ATTR pdcattr = pdc->pdcattr;
|
|
|
|
PSIZEL pszlViewPortExt;
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Get the viewport extension */
|
|
|
|
pszlViewPortExt = DC_pszlViewportExt(pdc);
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* No shearing / rotation */
|
|
|
|
FLOATOBJ_SetLong(&pmx->efM12, 0);
|
|
|
|
FLOATOBJ_SetLong(&pmx->efM21, 0);
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Calculate scaling */
|
|
|
|
if (pdcattr->szlWindowExt.cx != 0)
|
2011-01-04 16:53:23 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
FLOATOBJ_SetLong(&pmx->efM11, pszlViewPortExt->cx);
|
|
|
|
FLOATOBJ_DivLong(&pmx->efM11, pdcattr->szlWindowExt.cx);
|
2011-01-04 16:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-26 14:35:58 +00:00
|
|
|
FLOATOBJ_SetLong(&pmx->efM11, 1);
|
|
|
|
|
|
|
|
if (pdcattr->szlWindowExt.cy != 0)
|
2011-01-04 16:53:23 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
FLOATOBJ_SetLong(&pmx->efM22, pszlViewPortExt->cy);
|
|
|
|
FLOATOBJ_DivLong(&pmx->efM22, pdcattr->szlWindowExt.cy);
|
2011-01-04 16:53:23 +00:00
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
else
|
|
|
|
FLOATOBJ_SetLong(&pmx->efM22, 1);
|
|
|
|
|
|
|
|
/* Calculate x offset */
|
|
|
|
FLOATOBJ_SetLong(&pmx->efDx, -pdcattr->ptlWindowOrg.x);
|
|
|
|
FLOATOBJ_Mul(&pmx->efDx, &pmx->efM11);
|
|
|
|
FLOATOBJ_AddLong(&pmx->efDx, pdcattr->ptlViewportOrg.x);
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Calculate y offset */
|
|
|
|
FLOATOBJ_SetLong(&pmx->efDy, -pdcattr->ptlWindowOrg.y);
|
|
|
|
FLOATOBJ_Mul(&pmx->efDy, &pmx->efM22);
|
|
|
|
FLOATOBJ_AddLong(&pmx->efDy, pdcattr->ptlViewportOrg.y);
|
2011-01-04 16:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_vUpdateWorldToDevice(PDC pdc)
|
2011-01-04 16:53:23 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ xoPageToDevice, xoWorldToPage, xoWorldToDevice;
|
|
|
|
MATRIX mxPageToDevice;
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
// FIXME: make sure world-to-page is valid!
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Construct a transformation to do the page-to-device conversion */
|
|
|
|
DC_vGetPageToDevice(pdc, &mxPageToDevice);
|
|
|
|
XFORMOBJ_vInit(&xoPageToDevice, &mxPageToDevice);
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Recalculate the world-to-device xform */
|
|
|
|
XFORMOBJ_vInit(&xoWorldToPage, &pdc->pdcattr->mxWorldToPage);
|
|
|
|
XFORMOBJ_vInit(&xoWorldToDevice, &pdc->pdcattr->mxWorldToDevice);
|
|
|
|
XFORMOBJ_iCombine(&xoWorldToDevice, &xoWorldToPage, &xoPageToDevice);
|
|
|
|
|
|
|
|
/* Reset the flags */
|
|
|
|
pdc->pdcattr->flXform &= ~(PAGE_XLATE_CHANGED|PAGE_EXTENTS_CHANGED|WORLD_XFORM_CHANGED);
|
2011-01-04 16:53:23 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
DC_vUpdateDeviceToWorld(PDC pdc)
|
2004-01-04 21:26:59 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ xoWorldToDevice, xoDeviceToWorld;
|
|
|
|
PMATRIX pmxWorldToDevice;
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Get the world-to-device translation */
|
|
|
|
pmxWorldToDevice = DC_pmxWorldToDevice(pdc);
|
|
|
|
XFORMOBJ_vInit(&xoWorldToDevice, pmxWorldToDevice);
|
|
|
|
|
|
|
|
/* Create inverse of world-to-device transformation */
|
|
|
|
XFORMOBJ_vInit(&xoDeviceToWorld, &pdc->pdcattr->mxDeviceToWorld);
|
|
|
|
if (XFORMOBJ_iInverse(&xoDeviceToWorld, &xoWorldToDevice) == DDI_ERROR)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
// FIXME: do we need to reset anything?
|
|
|
|
return;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Reset the flag */
|
|
|
|
pdc->pdcattr->flXform &= ~DEVICE_TO_WORLD_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
NTAPI
|
|
|
|
GreCombineTransform(
|
|
|
|
XFORML *pxformDest,
|
|
|
|
XFORML *pxform1,
|
|
|
|
XFORML *pxform2)
|
|
|
|
{
|
|
|
|
MATRIX mxDest, mx1, mx2;
|
|
|
|
XFORMOBJ xoDest, xo1, xo2;
|
|
|
|
|
|
|
|
/* Check for illegal parameters */
|
|
|
|
if (!pxformDest || !pxform1 || !pxform2) return FALSE;
|
|
|
|
|
|
|
|
/* Initialize XFORMOBJs */
|
|
|
|
XFORMOBJ_vInit(&xoDest, &mxDest);
|
|
|
|
XFORMOBJ_vInit(&xo1, &mx1);
|
|
|
|
XFORMOBJ_vInit(&xo2, &mx2);
|
|
|
|
|
|
|
|
/* Convert the XFORMLs into XFORMOBJs */
|
|
|
|
XFORMOBJ_iSetXform(&xo1, pxform1);
|
|
|
|
XFORMOBJ_iSetXform(&xo2, pxform2);
|
|
|
|
|
|
|
|
/* Combine them */
|
|
|
|
XFORMOBJ_iCombine(&xoDest, &xo1, &xo2);
|
|
|
|
|
|
|
|
/* Translate back into XFORML */
|
|
|
|
XFORMOBJ_iGetXform(&xoDest, pxformDest);
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2004-01-04 21:26:59 +00:00
|
|
|
}
|
|
|
|
|
2011-01-04 16:53:23 +00:00
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiCombineTransform(
|
|
|
|
LPXFORM UnsafeXFormResult,
|
|
|
|
LPXFORM Unsafexform1,
|
|
|
|
LPXFORM Unsafexform2)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
BOOL Ret;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(UnsafeXFormResult, sizeof(XFORM), 1);
|
|
|
|
ProbeForRead(Unsafexform1, sizeof(XFORM), 1);
|
|
|
|
ProbeForRead(Unsafexform2, sizeof(XFORM), 1);
|
2012-03-26 14:35:58 +00:00
|
|
|
Ret = GreCombineTransform((XFORML*)UnsafeXFormResult,
|
|
|
|
(XFORML*)Unsafexform1,
|
|
|
|
(XFORML*)Unsafexform2);
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
return Ret;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 17:47:58 +00:00
|
|
|
// FIXME: Should be XFORML and use XFORMOBJ functions directly
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiGetTransform(
|
2012-03-26 14:35:58 +00:00
|
|
|
HDC hdc,
|
2009-03-23 17:47:58 +00:00
|
|
|
DWORD iXform,
|
2012-03-26 14:35:58 +00:00
|
|
|
LPXFORM pXForm)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2011-01-04 16:53:23 +00:00
|
|
|
PDC pdc;
|
2012-03-26 14:35:58 +00:00
|
|
|
BOOL ret = TRUE;
|
|
|
|
MATRIX mxPageToDevice;
|
|
|
|
XFORMOBJ xo;
|
|
|
|
PMATRIX pmx;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
if (!pXForm)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2011-01-04 16:53:23 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
pdc = DC_LockDc(hdc);
|
2011-01-04 16:53:23 +00:00
|
|
|
if (!pdc)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2011-01-04 16:53:23 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
switch (iXform)
|
|
|
|
{
|
|
|
|
case GdiWorldSpaceToPageSpace:
|
|
|
|
pmx = DC_pmxWorldToPage(pdc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiWorldSpaceToDeviceSpace:
|
|
|
|
pmx = DC_pmxWorldToDevice(pdc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiDeviceSpaceToWorldSpace:
|
|
|
|
pmx = DC_pmxDeviceToWorld(pdc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiPageSpaceToDeviceSpace:
|
|
|
|
DC_vGetPageToDevice(pdc, &mxPageToDevice);
|
|
|
|
pmx = &mxPageToDevice;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DPRINT1("Unknown transform %lu\n", iXform);
|
|
|
|
ret = FALSE;
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize an XFORMOBJ */
|
|
|
|
XFORMOBJ_vInit(&xo, pmx);
|
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
ProbeForWrite(pXForm, sizeof(XFORML), 1);
|
|
|
|
XFORMOBJ_iGetXform(&xo, (XFORML*)pXForm);
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
ret = FALSE;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
leave:
|
2011-01-04 16:53:23 +00:00
|
|
|
DC_UnlockDc(pdc);
|
2012-03-26 14:35:58 +00:00
|
|
|
return ret;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2003-08-17 17:32:58 +00:00
|
|
|
|
2003-03-14 22:48:32 +00:00
|
|
|
/*!
|
2011-01-04 16:53:23 +00:00
|
|
|
* Converts points from logical coordinates into device coordinates.
|
|
|
|
* Conversion depends on the mapping mode,
|
2003-03-14 22:48:32 +00:00
|
|
|
* world transfrom, viewport origin settings for the given device context.
|
|
|
|
* \param hDC device context.
|
|
|
|
* \param Points an array of POINT structures (in/out).
|
|
|
|
* \param Count number of elements in the array of POINT structures.
|
2011-01-04 16:53:23 +00:00
|
|
|
* \return TRUE if success, FALSE otherwise.
|
2003-03-14 22:48:32 +00:00
|
|
|
*/
|
2007-08-10 07:39:46 +00:00
|
|
|
BOOL
|
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiTransformPoints(
|
|
|
|
HDC hDC,
|
|
|
|
PPOINT UnsafePtsIn,
|
|
|
|
PPOINT UnsafePtOut,
|
|
|
|
INT Count,
|
|
|
|
INT iMode)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2011-01-04 16:53:23 +00:00
|
|
|
PDC pdc;
|
2009-01-29 21:33:38 +00:00
|
|
|
LPPOINT Points;
|
|
|
|
ULONG Size;
|
2011-04-13 08:14:37 +00:00
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
|
|
|
if (Count <= 0)
|
|
|
|
return TRUE;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2011-01-04 16:53:23 +00:00
|
|
|
pdc = DC_LockDc(hDC);
|
|
|
|
if (!pdc)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2007-08-10 07:39:46 +00:00
|
|
|
return FALSE;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Size = Count * sizeof(POINT);
|
|
|
|
|
2009-03-24 02:58:14 +00:00
|
|
|
// FIXME: It would be wise to have a small stack buffer as optimization
|
2011-01-09 19:51:06 +00:00
|
|
|
Points = ExAllocatePoolWithTag(PagedPool, Size, GDITAG_TEMP);
|
2009-01-29 21:33:38 +00:00
|
|
|
if (!Points)
|
|
|
|
{
|
2011-01-04 16:53:23 +00:00
|
|
|
DC_UnlockDc(pdc);
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(UnsafePtOut, Size, 1);
|
|
|
|
ProbeForRead(UnsafePtsIn, Size, 1);
|
|
|
|
RtlCopyMemory(Points, UnsafePtsIn, Size);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
2011-04-13 08:14:37 +00:00
|
|
|
/* Do not set last error */
|
2011-01-04 16:53:23 +00:00
|
|
|
_SEH2_YIELD(goto leave;)
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
switch (iMode)
|
|
|
|
{
|
|
|
|
case GdiDpToLp:
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_vXformDeviceToWorld(pdc, Count, Points, Points);
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
2009-03-23 17:47:58 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
case GdiLpToDp:
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_vXformWorldToDevice(pdc, Count, Points, Points);
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
2009-03-23 17:47:58 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
case 2: // Not supported yet. Need testing.
|
|
|
|
default:
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2011-01-04 16:53:23 +00:00
|
|
|
ret = FALSE;
|
|
|
|
goto leave;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2011-12-14 04:07:06 +00:00
|
|
|
/* Pointer was already probed! */
|
2009-01-29 21:33:38 +00:00
|
|
|
RtlCopyMemory(UnsafePtOut, Points, Size);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
2011-04-13 08:14:37 +00:00
|
|
|
/* Do not set last error */
|
2012-12-18 21:44:58 +00:00
|
|
|
ret = 0;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
2007-08-21 05:01:00 +00:00
|
|
|
//
|
|
|
|
// If we are getting called that means User XForms is a mess!
|
|
|
|
//
|
2011-01-04 16:53:23 +00:00
|
|
|
leave:
|
|
|
|
DC_UnlockDc(pdc);
|
2011-01-09 19:51:06 +00:00
|
|
|
ExFreePoolWithTag(Points, GDITAG_TEMP);
|
2011-01-04 16:53:23 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
2012-03-26 14:35:58 +00:00
|
|
|
NTAPI
|
|
|
|
GreModifyWorldTransform(
|
|
|
|
PDC pdc,
|
|
|
|
const XFORML *pxform,
|
|
|
|
DWORD dwMode)
|
2011-01-04 16:53:23 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
MATRIX mxSrc;
|
|
|
|
XFORMOBJ xoSrc, xoDC;
|
2011-01-04 16:53:23 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
switch (dwMode)
|
2011-01-04 16:53:23 +00:00
|
|
|
{
|
|
|
|
case MWT_IDENTITY:
|
2012-03-26 14:35:58 +00:00
|
|
|
pdc->pdcattr->mxWorldToPage = gmxIdentity;
|
2011-01-04 16:53:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MWT_LEFTMULTIPLY:
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage);
|
|
|
|
XFORMOBJ_vInit(&xoSrc, &mxSrc);
|
2012-04-25 17:29:50 +00:00
|
|
|
if (XFORMOBJ_iSetXform(&xoSrc, pxform) == DDI_ERROR)
|
|
|
|
return FALSE;
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ_iCombine(&xoDC, &xoSrc, &xoDC);
|
2011-01-04 16:53:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MWT_RIGHTMULTIPLY:
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage);
|
|
|
|
XFORMOBJ_vInit(&xoSrc, &mxSrc);
|
2012-04-25 17:29:50 +00:00
|
|
|
if (XFORMOBJ_iSetXform(&xoSrc, pxform) == DDI_ERROR)
|
|
|
|
return FALSE;
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ_iCombine(&xoDC, &xoDC, &xoSrc);
|
2011-01-04 16:53:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MWT_MAX+1: // Must be MWT_SET????
|
2012-03-26 14:35:58 +00:00
|
|
|
XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage);
|
2012-04-25 17:29:50 +00:00
|
|
|
if (XFORMOBJ_iSetXform(&xoDC, pxform) == DDI_ERROR)
|
|
|
|
return FALSE;
|
2011-01-04 16:53:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
|
|
|
|
/*Set invalidation flags */
|
|
|
|
pdc->pdcattr->flXform |= WORLD_XFORM_CHANGED|DEVICE_TO_WORLD_INVALID;
|
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
return TRUE;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiModifyWorldTransform(
|
2012-03-26 14:35:58 +00:00
|
|
|
HDC hdc,
|
|
|
|
LPXFORM pxformUnsafe,
|
|
|
|
DWORD dwMode)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
PDC pdc;
|
|
|
|
XFORML xformSafe;
|
2009-01-29 21:33:38 +00:00
|
|
|
BOOL Ret = TRUE;
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
pdc = DC_LockDc(hdc);
|
|
|
|
if (!pdc)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* The xform is permitted to be NULL for MWT_IDENTITY.
|
|
|
|
* However, if it is not NULL, then it must be valid even
|
|
|
|
* though it is not used. */
|
|
|
|
if (pxformUnsafe != NULL || dwMode != MWT_IDENTITY)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
ProbeForRead(pxformUnsafe, sizeof(XFORML), 1);
|
|
|
|
RtlCopyMemory(&xformSafe, pxformUnsafe, sizeof(XFORML));
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
/* Safe to handle kernel mode data. */
|
|
|
|
if (Ret) Ret = GreModifyWorldTransform(pdc, &xformSafe, dwMode);
|
|
|
|
DC_UnlockDc(pdc);
|
2009-01-29 21:33:38 +00:00
|
|
|
return Ret;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiOffsetViewportOrgEx(
|
|
|
|
HDC hDC,
|
|
|
|
int XOffset,
|
|
|
|
int YOffset,
|
|
|
|
LPPOINT UnsafePoint)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC dc;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
dc = DC_LockDc(hDC);
|
|
|
|
if (!dc)
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
if (UnsafePoint)
|
2004-01-04 21:26:59 +00:00
|
|
|
{
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2005-07-26 12:22:55 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
ProbeForWrite(UnsafePoint, sizeof(POINT), 1);
|
2009-03-20 04:51:26 +00:00
|
|
|
UnsafePoint->x = pdcattr->ptlViewportOrg.x;
|
|
|
|
UnsafePoint->y = pdcattr->ptlViewportOrg.y;
|
|
|
|
if (pdcattr->dwLayout & LAYOUT_RTL)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
|
|
|
UnsafePoint->x = -UnsafePoint->x;
|
|
|
|
}
|
2005-07-26 12:22:55 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-07-26 12:22:55 +00:00
|
|
|
{
|
2008-11-30 19:28:11 +00:00
|
|
|
Status = _SEH2_GetExceptionCode();
|
2005-07-26 12:22:55 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2005-07-26 12:22:55 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-05-27 07:23:05 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
if (pdcattr->dwLayout & LAYOUT_RTL)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
|
|
|
XOffset = -XOffset;
|
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->ptlViewportOrg.x += XOffset;
|
|
|
|
pdcattr->ptlViewportOrg.y += YOffset;
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform |= PAGE_XLATE_CHANGED;
|
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
DC_UnlockDc(dc);
|
|
|
|
|
|
|
|
return TRUE;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiOffsetWindowOrgEx(
|
|
|
|
HDC hDC,
|
|
|
|
int XOffset,
|
|
|
|
int YOffset,
|
|
|
|
LPPOINT Point)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC dc;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
dc = DC_LockDc(hDC);
|
|
|
|
if (!dc)
|
2003-07-22 20:02:08 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
2003-07-22 20:02:08 +00:00
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (Point)
|
2003-07-22 20:02:08 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(Point, sizeof(POINT), 1);
|
2009-03-20 04:51:26 +00:00
|
|
|
Point->x = pdcattr->ptlWindowOrg.x;
|
|
|
|
Point->y = pdcattr->ptlWindowOrg.y;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-22 20:02:08 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->ptlWindowOrg.x += XOffset;
|
|
|
|
pdcattr->ptlWindowOrg.y += YOffset;
|
2012-07-28 18:31:24 +00:00
|
|
|
pdcattr->flXform |= PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID;
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
DC_UnlockDc(dc);
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
return TRUE;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiScaleViewportExtEx(
|
|
|
|
HDC hDC,
|
|
|
|
int Xnum,
|
|
|
|
int Xdenom,
|
|
|
|
int Ynum,
|
|
|
|
int Ydenom,
|
|
|
|
LPSIZE pSize)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC pDC;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
BOOL Ret = FALSE;
|
|
|
|
LONG X, Y;
|
|
|
|
|
|
|
|
pDC = DC_LockDc(hDC);
|
|
|
|
if (!pDC)
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2008-05-13 23:26:02 +00:00
|
|
|
return FALSE;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = pDC->pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
if (pdcattr->iMapMode > MM_TWIPS)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
|
|
|
if (Xdenom && Ydenom)
|
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_pszlViewportExt(pDC);
|
2009-03-20 04:51:26 +00:00
|
|
|
X = Xnum * pdcattr->szlViewportExt.cx / Xdenom;
|
2009-01-29 21:33:38 +00:00
|
|
|
if (X)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
Y = Ynum * pdcattr->szlViewportExt.cy / Ydenom;
|
2009-01-29 21:33:38 +00:00
|
|
|
if (Y)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->szlViewportExt.cx = X;
|
|
|
|
pdcattr->szlViewportExt.cy = Y;
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform |= PAGE_XLATE_CHANGED;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
IntMirrorWindowOrg(pDC);
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->flXform |= (PAGE_EXTENTS_CHANGED |
|
2009-03-23 17:47:58 +00:00
|
|
|
INVALIDATE_ATTRIBUTES |
|
|
|
|
DEVICE_TO_WORLD_INVALID);
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
if (pdcattr->iMapMode == MM_ISOTROPIC)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2012-03-26 14:35:58 +00:00
|
|
|
DC_vFixIsotropicMapping(pDC);
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2008-05-13 23:26:02 +00:00
|
|
|
}
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Ret = TRUE;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2011-01-04 16:53:23 +00:00
|
|
|
if (pSize)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2011-12-08 19:38:58 +00:00
|
|
|
ProbeForWrite(pSize, sizeof(SIZE), 1);
|
2011-01-04 16:53:23 +00:00
|
|
|
|
|
|
|
pSize->cx = pdcattr->szlViewportExt.cx;
|
|
|
|
pSize->cy = pdcattr->szlViewportExt.cy;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
SetLastNtError(_SEH2_GetExceptionCode());
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
}
|
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
DC_UnlockDc(pDC);
|
|
|
|
return Ret;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiScaleWindowExtEx(
|
|
|
|
HDC hDC,
|
|
|
|
int Xnum,
|
|
|
|
int Xdenom,
|
|
|
|
int Ynum,
|
|
|
|
int Ydenom,
|
|
|
|
LPSIZE pSize)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC pDC;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
BOOL Ret = FALSE;
|
|
|
|
LONG X, Y;
|
|
|
|
|
|
|
|
pDC = DC_LockDc(hDC);
|
|
|
|
if (!pDC)
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2008-05-13 23:26:02 +00:00
|
|
|
return FALSE;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = pDC->pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
if (pSize)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
2008-05-13 23:26:02 +00:00
|
|
|
{
|
2011-12-08 19:38:58 +00:00
|
|
|
ProbeForWrite(pSize, sizeof(SIZE), 1);
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
X = pdcattr->szlWindowExt.cx;
|
|
|
|
if (pdcattr->dwLayout & LAYOUT_RTL) X = -X;
|
2009-01-29 21:33:38 +00:00
|
|
|
pSize->cx = X;
|
2009-03-20 04:51:26 +00:00
|
|
|
pSize->cy = pdcattr->szlWindowExt.cy;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
DC_UnlockDc(pDC);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
if (pdcattr->iMapMode > MM_TWIPS)
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
|
|
|
if (Xdenom && Ydenom)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
X = Xnum * pdcattr->szlWindowExt.cx / Xdenom;
|
2009-01-29 21:33:38 +00:00
|
|
|
if (X)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
Y = Ynum * pdcattr->szlWindowExt.cy / Ydenom;
|
2009-01-29 21:33:38 +00:00
|
|
|
if (Y)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->szlWindowExt.cx = X;
|
|
|
|
pdcattr->szlWindowExt.cy = Y;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
IntMirrorWindowOrg(pDC);
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID);
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
Ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2008-05-13 23:26:02 +00:00
|
|
|
}
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Ret = TRUE;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
DC_UnlockDc(pDC);
|
|
|
|
return Ret;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
int
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
IntGdiSetMapMode(
|
|
|
|
PDC dc,
|
|
|
|
int MapMode)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
int PrevMapMode;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr = dc->pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
PrevMapMode = pdcattr->iMapMode;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->iMapMode = MapMode;
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform &= ~(ISO_OR_ANISO_MAP_MODE|PTOD_EFM22_NEGATIVE|
|
|
|
|
PTOD_EFM11_NEGATIVE|POSITIVE_Y_IS_UP|PAGE_TO_DEVICE_SCALE_IDENTITY|
|
|
|
|
PAGE_TO_DEVICE_IDENTITY);
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
switch (MapMode)
|
|
|
|
{
|
|
|
|
case MM_TEXT:
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->szlWindowExt.cx = 1;
|
|
|
|
pdcattr->szlWindowExt.cy = 1;
|
|
|
|
pdcattr->szlViewportExt.cx = 1;
|
|
|
|
pdcattr->szlViewportExt.cy = 1;
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform |= PAGE_TO_DEVICE_SCALE_IDENTITY;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_ISOTROPIC:
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->flXform |= ISO_OR_ANISO_MAP_MODE;
|
2009-01-29 21:33:38 +00:00
|
|
|
/* Fall through */
|
|
|
|
|
|
|
|
case MM_LOMETRIC:
|
2009-12-20 13:55:45 +00:00
|
|
|
pdcattr->szlWindowExt.cx = pdcattr->szlVirtualDeviceMm.cx * 10;
|
|
|
|
pdcattr->szlWindowExt.cy = pdcattr->szlVirtualDeviceMm.cy * 10;
|
|
|
|
pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
|
|
|
|
pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_HIMETRIC:
|
2009-12-20 13:55:45 +00:00
|
|
|
pdcattr->szlWindowExt.cx = pdcattr->szlVirtualDeviceMm.cx * 100;
|
|
|
|
pdcattr->szlWindowExt.cy = pdcattr->szlVirtualDeviceMm.cy * 100;
|
|
|
|
pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
|
|
|
|
pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_LOENGLISH:
|
2009-12-20 13:55:45 +00:00
|
|
|
pdcattr->szlWindowExt.cx = MulDiv(1000, pdcattr->szlVirtualDeviceMm.cx, 254);
|
|
|
|
pdcattr->szlWindowExt.cy = MulDiv(1000, pdcattr->szlVirtualDeviceMm.cy, 254);
|
|
|
|
pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
|
|
|
|
pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_HIENGLISH:
|
2009-12-20 13:55:45 +00:00
|
|
|
pdcattr->szlWindowExt.cx = MulDiv(10000, pdcattr->szlVirtualDeviceMm.cx, 254);
|
|
|
|
pdcattr->szlWindowExt.cy = MulDiv(10000, pdcattr->szlVirtualDeviceMm.cy, 254);
|
|
|
|
pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
|
|
|
|
pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_TWIPS:
|
2009-12-20 13:55:45 +00:00
|
|
|
pdcattr->szlWindowExt.cx = MulDiv(14400, pdcattr->szlVirtualDeviceMm.cx, 254);
|
|
|
|
pdcattr->szlWindowExt.cy = MulDiv(14400, pdcattr->szlVirtualDeviceMm.cy, 254);
|
|
|
|
pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
|
|
|
|
pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MM_ANISOTROPIC:
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->flXform &= ~(PAGE_TO_DEVICE_IDENTITY|POSITIVE_Y_IS_UP);
|
|
|
|
pdcattr->flXform |= ISO_OR_ANISO_MAP_MODE;
|
2009-01-29 21:33:38 +00:00
|
|
|
break;
|
2009-03-23 17:47:58 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
default:
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->iMapMode = PrevMapMode;
|
2009-01-29 21:33:38 +00:00
|
|
|
PrevMapMode = 0;
|
|
|
|
}
|
2012-03-26 14:35:58 +00:00
|
|
|
|
|
|
|
pdcattr->flXform |= (PAGE_XLATE_CHANGED|PAGE_EXTENTS_CHANGED|
|
|
|
|
INVALIDATE_ATTRIBUTES|DEVICE_TO_PAGE_INVALID|DEVICE_TO_WORLD_INVALID);
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
return PrevMapMode;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiSetViewportOrgEx(
|
|
|
|
HDC hDC,
|
|
|
|
int X,
|
|
|
|
int Y,
|
|
|
|
LPPOINT Point)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC dc;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
dc = DC_LockDc(hDC);
|
|
|
|
if (!dc)
|
2003-07-22 20:02:08 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
2003-07-22 20:02:08 +00:00
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (Point)
|
2003-07-22 20:02:08 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(Point, sizeof(POINT), 1);
|
2009-03-20 04:51:26 +00:00
|
|
|
Point->x = pdcattr->ptlViewportOrg.x;
|
|
|
|
Point->y = pdcattr->ptlViewportOrg.y;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-22 20:02:08 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->ptlViewportOrg.x = X;
|
|
|
|
pdcattr->ptlViewportOrg.y = Y;
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform |= PAGE_XLATE_CHANGED;
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
DC_UnlockDc(dc);
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
return TRUE;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiSetWindowOrgEx(
|
|
|
|
HDC hDC,
|
|
|
|
int X,
|
|
|
|
int Y,
|
|
|
|
LPPOINT Point)
|
1999-07-22 16:21:53 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC dc;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
dc = DC_LockDc(hDC);
|
|
|
|
if (!dc)
|
2003-07-22 20:02:08 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
2003-07-22 20:02:08 +00:00
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (Point)
|
2003-07-22 20:02:08 +00:00
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(Point, sizeof(POINT), 1);
|
2009-03-20 04:51:26 +00:00
|
|
|
Point->x = pdcattr->ptlWindowOrg.x;
|
|
|
|
Point->y = pdcattr->ptlWindowOrg.y;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-22 20:02:08 +00:00
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->ptlWindowOrg.x = X;
|
|
|
|
pdcattr->ptlWindowOrg.y = Y;
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform |= PAGE_XLATE_CHANGED;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
DC_UnlockDc(dc);
|
2003-07-22 20:02:08 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
return TRUE;
|
1999-07-22 16:21:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-01 21:47:27 +00:00
|
|
|
//
|
|
|
|
// Mirror Window function.
|
|
|
|
//
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
IntMirrorWindowOrg(PDC dc)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
LONG X;
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
if (!(pdcattr->dwLayout & LAYOUT_RTL))
|
2009-01-29 21:33:38 +00:00
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->ptlWindowOrg.x = pdcattr->lWindowOrgx; // Flip it back.
|
2009-01-29 21:33:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-03-20 04:51:26 +00:00
|
|
|
if (!pdcattr->szlViewportExt.cx) return;
|
2009-01-29 21:33:38 +00:00
|
|
|
//
|
|
|
|
// WOrgx = wox - (Width - 1) * WExtx / VExtx
|
|
|
|
//
|
|
|
|
X = (dc->erclWindow.right - dc->erclWindow.left) - 1; // Get device width - 1
|
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
X = (X * pdcattr->szlWindowExt.cx) / pdcattr->szlViewportExt.cx;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->ptlWindowOrg.x = pdcattr->lWindowOrgx - X; // Now set the inverted win origion.
|
2012-03-26 14:35:58 +00:00
|
|
|
pdcattr->flXform |= PAGE_XLATE_CHANGED;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
|
|
|
return;
|
2007-12-01 21:47:27 +00:00
|
|
|
}
|
|
|
|
|
2010-08-23 01:41:56 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
DC_vSetLayout(
|
|
|
|
IN PDC pdc,
|
2007-11-28 07:52:51 +00:00
|
|
|
IN LONG wox,
|
|
|
|
IN DWORD dwLayout)
|
|
|
|
{
|
2010-08-23 01:41:56 +00:00
|
|
|
PDC_ATTR pdcattr = pdc->pdcattr;
|
2007-11-28 07:52:51 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->dwLayout = dwLayout;
|
2007-11-28 07:52:51 +00:00
|
|
|
|
2010-08-23 01:41:56 +00:00
|
|
|
if (!(dwLayout & LAYOUT_ORIENTATIONMASK)) return;
|
2007-12-01 21:47:27 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (dwLayout & LAYOUT_RTL)
|
|
|
|
{
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->iMapMode = MM_ANISOTROPIC;
|
2009-01-29 21:33:38 +00:00
|
|
|
}
|
2007-12-01 21:47:27 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
//pdcattr->szlWindowExt.cy = -pdcattr->szlWindowExt.cy;
|
|
|
|
//pdcattr->ptlWindowOrg.x = -pdcattr->ptlWindowOrg.x;
|
2007-12-01 21:47:27 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
//if (wox == -1)
|
|
|
|
// IntMirrorWindowOrg(pdc);
|
|
|
|
//else
|
|
|
|
// pdcattr->ptlWindowOrg.x = wox - pdcattr->ptlWindowOrg.x;
|
2007-12-01 21:47:27 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
if (!(pdcattr->flTextAlign & TA_CENTER)) pdcattr->flTextAlign |= TA_RIGHT;
|
2007-12-01 21:47:27 +00:00
|
|
|
|
2010-08-23 01:41:56 +00:00
|
|
|
if (pdc->dclevel.flPath & DCPATH_CLOCKWISE)
|
|
|
|
pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
|
2009-01-29 21:33:38 +00:00
|
|
|
else
|
2010-08-23 01:41:56 +00:00
|
|
|
pdc->dclevel.flPath |= DCPATH_CLOCKWISE;
|
2007-12-01 21:47:27 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->flXform |= (PAGE_EXTENTS_CHANGED |
|
2009-01-29 21:33:38 +00:00
|
|
|
INVALIDATE_ATTRIBUTES |
|
|
|
|
DEVICE_TO_WORLD_INVALID);
|
2010-08-23 01:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NtGdiSetLayout
|
|
|
|
//
|
|
|
|
// The default is left to right. This function changes it to right to left, which
|
|
|
|
// is the standard in Arabic and Hebrew cultures.
|
|
|
|
//
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
APIENTRY
|
|
|
|
NtGdiSetLayout(
|
|
|
|
IN HDC hdc,
|
|
|
|
IN LONG wox,
|
|
|
|
IN DWORD dwLayout)
|
|
|
|
{
|
|
|
|
PDC pdc;
|
2012-03-26 14:35:58 +00:00
|
|
|
DWORD dwOldLayout;
|
2010-08-23 01:41:56 +00:00
|
|
|
|
|
|
|
pdc = DC_LockDc(hdc);
|
|
|
|
if (!pdc)
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2010-08-23 01:41:56 +00:00
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
dwOldLayout = pdc->pdcattr->dwLayout;
|
2010-08-23 01:41:56 +00:00
|
|
|
DC_vSetLayout(pdc, wox, dwLayout);
|
|
|
|
|
|
|
|
DC_UnlockDc(pdc);
|
2012-03-26 14:35:58 +00:00
|
|
|
return dwOldLayout;
|
2007-12-01 21:47:27 +00:00
|
|
|
}
|
2007-11-28 07:52:51 +00:00
|
|
|
|
2007-12-01 21:47:27 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
LONG
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetDeviceWidth(
|
|
|
|
IN HDC hdc)
|
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC dc;
|
|
|
|
LONG Ret;
|
|
|
|
dc = DC_LockDc(hdc);
|
|
|
|
if (!dc)
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Ret = dc->erclWindow.right - dc->erclWindow.left;
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return Ret;
|
2007-12-01 21:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiMirrorWindowOrg(
|
|
|
|
IN HDC hdc)
|
|
|
|
{
|
2009-01-29 21:33:38 +00:00
|
|
|
PDC dc;
|
|
|
|
dc = DC_LockDc(hdc);
|
|
|
|
if (!dc)
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-01-29 21:33:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
IntMirrorWindowOrg(dc);
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return TRUE;
|
2007-11-28 07:52:51 +00:00
|
|
|
}
|
1999-07-22 16:21:53 +00:00
|
|
|
|
2008-05-13 23:26:02 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiSetSizeDevice(
|
|
|
|
IN HDC hdc,
|
|
|
|
IN INT cxVirtualDevice,
|
|
|
|
IN INT cyVirtualDevice)
|
|
|
|
{
|
|
|
|
PDC dc;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-01-29 21:33:38 +00:00
|
|
|
if (!cxVirtualDevice || !cyVirtualDevice)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-13 23:26:02 +00:00
|
|
|
|
|
|
|
dc = DC_LockDc(hdc);
|
|
|
|
if (!dc) return FALSE;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->szlVirtualDeviceSize.cx = cxVirtualDevice;
|
|
|
|
pdcattr->szlVirtualDeviceSize.cy = cyVirtualDevice;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiSetVirtualResolution(
|
|
|
|
IN HDC hdc,
|
|
|
|
IN INT cxVirtualDevicePixel,
|
|
|
|
IN INT cyVirtualDevicePixel,
|
|
|
|
IN INT cxVirtualDeviceMm,
|
|
|
|
IN INT cyVirtualDeviceMm)
|
|
|
|
{
|
|
|
|
PDC dc;
|
2009-03-20 04:51:26 +00:00
|
|
|
PDC_ATTR pdcattr;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-12-19 18:57:27 +00:00
|
|
|
/* Check parameters (all zeroes resets to real resolution) */
|
|
|
|
if (cxVirtualDevicePixel == 0 && cyVirtualDevicePixel == 0 &&
|
|
|
|
cxVirtualDeviceMm == 0 && cyVirtualDeviceMm == 0)
|
|
|
|
{
|
|
|
|
cxVirtualDevicePixel = NtGdiGetDeviceCaps(hdc, HORZRES);
|
|
|
|
cyVirtualDevicePixel = NtGdiGetDeviceCaps(hdc, VERTRES);
|
|
|
|
cxVirtualDeviceMm = NtGdiGetDeviceCaps(hdc, HORZSIZE);
|
|
|
|
cyVirtualDeviceMm = NtGdiGetDeviceCaps(hdc, VERTSIZE);
|
|
|
|
}
|
2011-01-04 12:36:19 +00:00
|
|
|
else if (cxVirtualDevicePixel == 0 || cyVirtualDevicePixel == 0 ||
|
2009-12-19 18:57:27 +00:00
|
|
|
cxVirtualDeviceMm == 0 || cyVirtualDeviceMm == 0)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-13 23:26:02 +00:00
|
|
|
|
|
|
|
dc = DC_LockDc(hdc);
|
|
|
|
if (!dc) return FALSE;
|
2009-01-29 21:33:38 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2009-03-20 04:51:26 +00:00
|
|
|
pdcattr->szlVirtualDevicePixel.cx = cxVirtualDevicePixel;
|
|
|
|
pdcattr->szlVirtualDevicePixel.cy = cyVirtualDevicePixel;
|
|
|
|
pdcattr->szlVirtualDeviceMm.cx = cxVirtualDeviceMm;
|
|
|
|
pdcattr->szlVirtualDeviceMm.cy = cyVirtualDeviceMm;
|
2008-05-13 23:26:02 +00:00
|
|
|
|
2012-03-26 14:35:58 +00:00
|
|
|
// DC_vUpdateXforms(dc);
|
2008-05-13 23:26:02 +00:00
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-03-24 02:58:14 +00:00
|
|
|
static
|
|
|
|
VOID FASTCALL
|
|
|
|
DC_vGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio)
|
2009-03-23 03:43:11 +00:00
|
|
|
{
|
2009-03-24 02:58:14 +00:00
|
|
|
if (pDC->pdcattr->flFontMapper & 1) // TRUE assume 1.
|
2009-03-23 17:47:58 +00:00
|
|
|
{
|
|
|
|
// "This specifies that Windows should only match fonts that have the
|
|
|
|
// same aspect ratio as the display.", Programming Windows, Fifth Ed.
|
2009-08-16 12:57:41 +00:00
|
|
|
AspectRatio->cx = pDC->ppdev->gdiinfo.ulLogPixelsX;
|
|
|
|
AspectRatio->cy = pDC->ppdev->gdiinfo.ulLogPixelsY;
|
2009-03-23 17:47:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AspectRatio->cx = 0;
|
|
|
|
AspectRatio->cy = 0;
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL APIENTRY
|
2009-03-23 17:47:58 +00:00
|
|
|
NtGdiGetDCPoint(
|
|
|
|
HDC hDC,
|
|
|
|
UINT iPoint,
|
|
|
|
PPOINTL Point)
|
2009-03-23 03:43:11 +00:00
|
|
|
{
|
2009-03-23 17:47:58 +00:00
|
|
|
BOOL Ret = TRUE;
|
2009-03-24 02:58:14 +00:00
|
|
|
DC *pdc;
|
2009-03-23 17:47:58 +00:00
|
|
|
POINTL SafePoint;
|
|
|
|
SIZE Size;
|
2012-03-26 14:35:58 +00:00
|
|
|
PSIZEL pszlViewportExt;
|
2009-03-23 17:47:58 +00:00
|
|
|
|
|
|
|
if (!Point)
|
2009-03-23 03:43:11 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2009-03-23 17:47:58 +00:00
|
|
|
return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
}
|
2009-03-23 17:47:58 +00:00
|
|
|
|
2009-03-24 02:58:14 +00:00
|
|
|
pdc = DC_LockDc(hDC);
|
|
|
|
if (!pdc)
|
2009-03-23 03:43:11 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2009-03-23 17:47:58 +00:00
|
|
|
return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 17:47:58 +00:00
|
|
|
switch (iPoint)
|
|
|
|
{
|
|
|
|
case GdiGetViewPortExt:
|
2012-03-26 14:35:58 +00:00
|
|
|
pszlViewportExt = DC_pszlViewportExt(pdc);
|
|
|
|
SafePoint.x = pszlViewportExt->cx;
|
|
|
|
SafePoint.y = pszlViewportExt->cy;
|
2009-03-23 17:47:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiGetWindowExt:
|
2009-03-24 02:58:14 +00:00
|
|
|
SafePoint.x = pdc->pdcattr->szlWindowExt.cx;
|
|
|
|
SafePoint.y = pdc->pdcattr->szlWindowExt.cy;
|
2009-03-23 17:47:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiGetViewPortOrg:
|
2009-03-24 02:58:14 +00:00
|
|
|
SafePoint = pdc->pdcattr->ptlViewportOrg;
|
2009-03-23 17:47:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiGetWindowOrg:
|
2009-03-24 02:58:14 +00:00
|
|
|
SafePoint = pdc->pdcattr->ptlWindowOrg;
|
2009-03-23 17:47:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiGetDCOrg:
|
2009-03-24 02:58:14 +00:00
|
|
|
SafePoint = pdc->ptlDCOrig;
|
2009-03-23 17:47:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GdiGetAspectRatioFilter:
|
2009-03-24 02:58:14 +00:00
|
|
|
DC_vGetAspectRatioFilter(pdc, &Size);
|
2009-03-23 17:47:58 +00:00
|
|
|
SafePoint.x = Size.cx;
|
|
|
|
SafePoint.y = Size.cy;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2009-03-23 17:47:58 +00:00
|
|
|
Ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
|
2009-03-23 17:47:58 +00:00
|
|
|
if (Ret)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2009-03-24 02:58:14 +00:00
|
|
|
ProbeForWrite(Point, sizeof(POINT), 1);
|
2009-03-23 17:47:58 +00:00
|
|
|
*Point = SafePoint;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
2009-03-24 02:58:14 +00:00
|
|
|
Ret = FALSE;
|
|
|
|
}
|
2012-12-18 21:44:58 +00:00
|
|
|
_SEH2_END;
|
2009-03-23 17:47:58 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 02:58:14 +00:00
|
|
|
DC_UnlockDc(pdc);
|
2009-03-23 17:47:58 +00:00
|
|
|
return Ret;
|
2009-03-23 03:43:11 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|