ReactOS 0.4.15-dev-7924-g5949c20
coord.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for coord.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 C_ASSERT (sizeof(XFORML)==sizeof(XFORM))
 
VOID FASTCALL DC_vFixIsotropicMapping (PDC pdc)
 
VOID FASTCALL DC_vGetPageToDevice (PDC pdc, MATRIX *pmx)
 
VOID FASTCALL DC_vUpdateWorldToDevice (PDC pdc)
 
VOID FASTCALL DC_vUpdateDeviceToWorld (PDC pdc)
 
BOOL NTAPI GreCombineTransform (XFORML *pxformDest, XFORML *pxform1, XFORML *pxform2)
 
BOOL APIENTRY NtGdiCombineTransform (LPXFORM UnsafeXFormResult, LPXFORM Unsafexform1, LPXFORM Unsafexform2)
 
BOOL APIENTRY NtGdiGetTransform (HDC hdc, DWORD iXform, LPXFORM pXForm)
 
BOOL APIENTRY NtGdiTransformPoints (HDC hDC, PPOINT UnsafePtsIn, PPOINT UnsafePtOut, INT Count, INT iMode)
 
BOOL NTAPI GreModifyWorldTransform (PDC pdc, const XFORML *pxform, DWORD dwMode)
 
BOOL APIENTRY NtGdiModifyWorldTransform (HDC hdc, LPXFORM pxformUnsafe, DWORD dwMode)
 
BOOL APIENTRY NtGdiOffsetViewportOrgEx (HDC hDC, int XOffset, int YOffset, LPPOINT UnsafePoint)
 
BOOL APIENTRY NtGdiOffsetWindowOrgEx (HDC hDC, int XOffset, int YOffset, LPPOINT Point)
 
BOOL APIENTRY NtGdiScaleViewportExtEx (HDC hDC, int Xnum, int Xdenom, int Ynum, int Ydenom, LPSIZE pSize)
 
BOOL APIENTRY NtGdiScaleWindowExtEx (HDC hDC, int Xnum, int Xdenom, int Ynum, int Ydenom, LPSIZE pSize)
 
int APIENTRY IntGdiSetMapMode (PDC dc, int MapMode)
 
BOOL FASTCALL GreSetViewportOrgEx (HDC hDC, int X, int Y, LPPOINT Point)
 
BOOL APIENTRY NtGdiSetViewportOrgEx (HDC hDC, int X, int Y, LPPOINT Point)
 
BOOL APIENTRY NtGdiSetWindowOrgEx (HDC hDC, int X, int Y, LPPOINT Point)
 
VOID FASTCALL IntMirrorWindowOrg (PDC dc)
 
VOID NTAPI DC_vSetLayout (IN PDC pdc, IN LONG wox, IN DWORD dwLayout)
 
DWORD APIENTRY NtGdiSetLayout (IN HDC hdc, IN LONG wox, IN DWORD dwLayout)
 
LONG APIENTRY NtGdiGetDeviceWidth (IN HDC hdc)
 
BOOL APIENTRY NtGdiMirrorWindowOrg (IN HDC hdc)
 
BOOL APIENTRY NtGdiSetSizeDevice (IN HDC hdc, IN INT cxVirtualDevice, IN INT cyVirtualDevice)
 
BOOL APIENTRY NtGdiSetVirtualResolution (IN HDC hdc, IN INT cxVirtualDevicePixel, IN INT cyVirtualDevicePixel, IN INT cxVirtualDeviceMm, IN INT cyVirtualDeviceMm)
 
static VOID FASTCALL DC_vGetAspectRatioFilter (PDC pDC, LPSIZE AspectRatio)
 
BOOL APIENTRY GreGetDCPoint (HDC hDC, UINT iPoint, PPOINTL Point)
 
BOOL WINAPI GreSetDCOrg (_In_ HDC hdc, _In_ LONG x, _In_ LONG y, _In_opt_ PRECTL Rect)
 
BOOL WINAPI GreGetDCOrgEx (_In_ HDC hdc, _Out_ PPOINTL Point, _Out_ PRECTL Rect)
 
BOOL WINAPI GreGetWindowExtEx (_In_ HDC hdc, _Out_ LPSIZE lpSize)
 
BOOL WINAPI GreGetViewportExtEx (_In_ HDC hdc, _Out_ LPSIZE lpSize)
 
BOOL APIENTRY NtGdiGetDCPoint (HDC hDC, UINT iPoint, PPOINTL Point)
 

Variables

const MATRIX gmxIdentity
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 73 of file coord.c.

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(XFORML = =sizeof(XFORM))

◆ DC_vFixIsotropicMapping()

VOID FASTCALL DC_vFixIsotropicMapping ( PDC  pdc)

Definition at line 93 of file coord.c.

94{
95 PDC_ATTR pdcattr;
96 LONG64 fx, fy;
97 LONG s;
98 SIZEL szlWindowExt, szlViewportExt;
99 ASSERT(pdc->pdcattr->iMapMode == MM_ISOTROPIC);
100
101 /* Get a pointer to the DC_ATTR */
102 pdcattr = pdc->pdcattr;
103
104 /* Read the extents, we rely on non-null values */
105 szlWindowExt = pdcattr->szlWindowExt;
106 szlViewportExt = pdcattr->szlViewportExt;
107
108 /* Check if all values are valid */
109 if ((szlWindowExt.cx == 0) || (szlWindowExt.cy == 0) ||
110 (szlViewportExt.cx == 0) || (szlViewportExt.cy == 0))
111 {
112 /* Someone put rubbish into the fields, just ignore it. */
113 return;
114 }
115
116 fx = abs((LONG64)szlWindowExt.cx * szlViewportExt.cy);
117 fy = abs((LONG64)szlWindowExt.cy * szlViewportExt.cx);
118
119 if (fx < fy)
120 {
121 s = (szlWindowExt.cy ^ szlViewportExt.cx) > 0 ? 1 : -1;
122 pdcattr->szlViewportExt.cx = (LONG)(fx * s / szlWindowExt.cy);
123 }
124 else if (fx > fy)
125 {
126 s = (szlWindowExt.cx ^ szlViewportExt.cy) > 0 ? 1 : -1;
127 pdcattr->szlViewportExt.cy = (LONG)(fy * s / szlWindowExt.cx);
128 }
129
130 /* Reset the flag */
131 pdc->pdcattr->flXform &= ~PAGE_EXTENTS_CHANGED;
132}
#define abs(i)
Definition: fconv.c:206
GLdouble s
Definition: gl.h:2039
#define ASSERT(a)
Definition: mode.c:44
long LONG
Definition: pedump.c:60
SIZEL szlViewportExt
Definition: ntgdihdl.h:344
SIZEL szlWindowExt
Definition: ntgdihdl.h:342
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
GLfixed fx
Definition: tritemp.h:484
GLfixed fy
Definition: tritemp.h:490
int64_t LONG64
Definition: typedefs.h:68
#define MM_ISOTROPIC
Definition: wingdi.h:870

Referenced by DC_pszlViewportExt(), and NtGdiScaleViewportExtEx().

◆ DC_vGetAspectRatioFilter()

static VOID FASTCALL DC_vGetAspectRatioFilter ( PDC  pDC,
LPSIZE  AspectRatio 
)
static

Definition at line 1274 of file coord.c.

1275{
1276 if (pDC->pdcattr->flFontMapper & 1) // TRUE assume 1.
1277 {
1278 // "This specifies that Windows should only match fonts that have the
1279 // same aspect ratio as the display.", Programming Windows, Fifth Ed.
1280 AspectRatio->cx = pDC->ppdev->gdiinfo.ulLogPixelsX;
1281 AspectRatio->cy = pDC->ppdev->gdiinfo.ulLogPixelsY;
1282 }
1283 else
1284 {
1285 AspectRatio->cx = 0;
1286 AspectRatio->cy = 0;
1287 }
1288}
LONG cx
Definition: windef.h:334
LONG cy
Definition: windef.h:335

Referenced by GreGetDCPoint().

◆ DC_vGetPageToDevice()

VOID FASTCALL DC_vGetPageToDevice ( PDC  pdc,
MATRIX pmx 
)

Definition at line 136 of file coord.c.

137{
138 PDC_ATTR pdcattr = pdc->pdcattr;
139 PSIZEL pszlViewPortExt;
140 SIZEL szlWindowExt;
141
142 /* Get the viewport extension */
143 pszlViewPortExt = DC_pszlViewportExt(pdc);
144
145 /* Copy the window extension, so no one can mess with it */
146 szlWindowExt = pdcattr->szlWindowExt;
147
148 /* No shearing / rotation */
149 FLOATOBJ_SetLong(&pmx->efM12, 0);
150 FLOATOBJ_SetLong(&pmx->efM21, 0);
151
152 /* Calculate scaling */
153 if (szlWindowExt.cx != 0)
154 {
155 FLOATOBJ_SetLong(&pmx->efM11, pszlViewPortExt->cx);
156 FLOATOBJ_DivLong(&pmx->efM11, szlWindowExt.cx);
157 }
158 else
159 FLOATOBJ_SetLong(&pmx->efM11, 1);
160
161 if (szlWindowExt.cy != 0)
162 {
163 FLOATOBJ_SetLong(&pmx->efM22, pszlViewPortExt->cy);
164 FLOATOBJ_DivLong(&pmx->efM22, szlWindowExt.cy);
165 }
166 else
167 FLOATOBJ_SetLong(&pmx->efM22, 1);
168
169 /* Calculate x offset */
170 FLOATOBJ_SetLong(&pmx->efDx, -pdcattr->ptlWindowOrg.x);
171 FLOATOBJ_Mul(&pmx->efDx, &pmx->efM11);
172 FLOATOBJ_AddLong(&pmx->efDx, pdcattr->ptlViewportOrg.x);
173
174 /* Calculate y offset */
175 FLOATOBJ_SetLong(&pmx->efDy, -pdcattr->ptlWindowOrg.y);
176 FLOATOBJ_Mul(&pmx->efDy, &pmx->efM22);
177 FLOATOBJ_AddLong(&pmx->efDy, pdcattr->ptlViewportOrg.y);
178}
FORCEINLINE PSIZEL DC_pszlViewportExt(PDC pdc)
Definition: coord.h:111
POINTL ptlViewportOrg
Definition: ntgdihdl.h:343
POINTL ptlWindowOrg
Definition: ntgdihdl.h:341
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
#define FLOATOBJ_DivLong(pf, l)
Definition: winddi.h:2829
#define FLOATOBJ_Mul(pf, pf1)
Definition: winddi.h:2824
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
#define FLOATOBJ_AddLong(pf, l)
Definition: winddi.h:2820

Referenced by DC_vUpdateWorldToDevice(), and NtGdiGetTransform().

◆ DC_vSetLayout()

VOID NTAPI DC_vSetLayout ( IN PDC  pdc,
IN LONG  wox,
IN DWORD  dwLayout 
)

Definition at line 1086 of file coord.c.

1090{
1091 PDC_ATTR pdcattr = pdc->pdcattr;
1092
1093 pdcattr->dwLayout = dwLayout;
1094
1095 if (!(dwLayout & LAYOUT_ORIENTATIONMASK)) return;
1096
1097 if (dwLayout & LAYOUT_RTL)
1098 {
1099 pdcattr->iMapMode = MM_ANISOTROPIC;
1100 }
1101
1102 //pdcattr->szlWindowExt.cy = -pdcattr->szlWindowExt.cy;
1103 //pdcattr->ptlWindowOrg.x = -pdcattr->ptlWindowOrg.x;
1104
1105 //if (wox == -1)
1106 // IntMirrorWindowOrg(pdc);
1107 //else
1108 // pdcattr->ptlWindowOrg.x = wox - pdcattr->ptlWindowOrg.x;
1109
1110 if (!(pdcattr->flTextAlign & TA_CENTER)) pdcattr->flTextAlign |= TA_RIGHT;
1111
1112 if (pdc->dclevel.flPath & DCPATH_CLOCKWISE)
1113 pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
1114 else
1115 pdc->dclevel.flPath |= DCPATH_CLOCKWISE;
1116
1117 pdcattr->flXform |= (PAGE_EXTENTS_CHANGED |
1121}
#define PAGE_EXTENTS_CHANGED
Definition: ntgdihdl.h:187
#define WORLD_XFORM_CHANGED
Definition: ntgdihdl.h:188
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:177
#define INVALIDATE_ATTRIBUTES
Definition: ntgdihdl.h:180
@ DCPATH_CLOCKWISE
Definition: path.h:8
INT iMapMode
Definition: ntgdihdl.h:338
FLONG flXform
Definition: ntgdihdl.h:345
DWORD dwLayout
Definition: ntgdihdl.h:339
FLONG flTextAlign
Definition: ntgdihdl.h:324
#define TA_RIGHT
Definition: wingdi.h:933
#define MM_ANISOTROPIC
Definition: wingdi.h:867
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define TA_CENTER
Definition: wingdi.h:931
#define LAYOUT_ORIENTATIONMASK
Definition: wingdi.h:1374

Referenced by NtGdiSetLayout().

◆ DC_vUpdateDeviceToWorld()

VOID FASTCALL DC_vUpdateDeviceToWorld ( PDC  pdc)

Definition at line 204 of file coord.c.

205{
206 XFORMOBJ xoWorldToDevice, xoDeviceToWorld;
207 PMATRIX pmxWorldToDevice;
208
209 /* Get the world-to-device translation */
210 pmxWorldToDevice = DC_pmxWorldToDevice(pdc);
211 XFORMOBJ_vInit(&xoWorldToDevice, pmxWorldToDevice);
212
213 /* Create inverse of world-to-device transformation */
214 XFORMOBJ_vInit(&xoDeviceToWorld, &pdc->pdcattr->mxDeviceToWorld);
215 if (XFORMOBJ_iInverse(&xoDeviceToWorld, &xoWorldToDevice) == DDI_ERROR)
216 {
217 MX_Set0(&pdc->pdcattr->mxDeviceToWorld);
218 return;
219 }
220
221 /* Reset the flag */
222 pdc->pdcattr->flXform &= ~DEVICE_TO_WORLD_INVALID;
223}
FORCEINLINE PMATRIX DC_pmxWorldToDevice(PDC pdc)
Definition: coord.h:135
#define DDI_ERROR
Definition: winddi.h:154
VOID FASTCALL MX_Set0(OUT PMATRIX pmx)
Definition: xformobj.c:275
#define XFORMOBJ_iInverse
Definition: xformobj.h:17
#define XFORMOBJ_vInit
Definition: xformobj.h:12

Referenced by DC_pmxDeviceToWorld(), and IntDPtoLP().

◆ DC_vUpdateWorldToDevice()

VOID FASTCALL DC_vUpdateWorldToDevice ( PDC  pdc)

Definition at line 182 of file coord.c.

183{
184 XFORMOBJ xoPageToDevice, xoWorldToPage, xoWorldToDevice;
185 MATRIX mxPageToDevice;
186
187 // FIXME: make sure world-to-page is valid!
188
189 /* Construct a transformation to do the page-to-device conversion */
190 DC_vGetPageToDevice(pdc, &mxPageToDevice);
191 XFORMOBJ_vInit(&xoPageToDevice, &mxPageToDevice);
192
193 /* Recalculate the world-to-device xform */
194 XFORMOBJ_vInit(&xoWorldToPage, &pdc->pdcattr->mxWorldToPage);
195 XFORMOBJ_vInit(&xoWorldToDevice, &pdc->pdcattr->mxWorldToDevice);
196 XFORMOBJ_iCombine(&xoWorldToDevice, &xoWorldToPage, &xoPageToDevice);
197
198 /* Reset the flags */
199 pdc->pdcattr->flXform &= ~WORLD_XFORM_CHANGED;
200}
VOID FASTCALL DC_vGetPageToDevice(PDC pdc, MATRIX *pmx)
Definition: coord.c:136
Definition: matrix.h:44
#define XFORMOBJ_iCombine
Definition: xformobj.h:15

Referenced by DC_pmxWorldToDevice(), and IntLPtoDP().

◆ GreCombineTransform()

BOOL NTAPI GreCombineTransform ( XFORML pxformDest,
XFORML pxform1,
XFORML pxform2 
)

Definition at line 227 of file coord.c.

231{
232 MATRIX mxDest, mx1, mx2;
233 XFORMOBJ xoDest, xo1, xo2;
234
235 /* Check for illegal parameters */
236 if (!pxformDest || !pxform1 || !pxform2) return FALSE;
237
238 /* Initialize XFORMOBJs */
239 XFORMOBJ_vInit(&xoDest, &mxDest);
240 XFORMOBJ_vInit(&xo1, &mx1);
241 XFORMOBJ_vInit(&xo2, &mx2);
242
243 /* Convert the XFORMLs into XFORMOBJs */
244 XFORMOBJ_iSetXform(&xo1, pxform1);
245 XFORMOBJ_iSetXform(&xo2, pxform2);
246
247 /* Combine them */
248 XFORMOBJ_iCombine(&xoDest, &xo1, &xo2);
249
250 /* Translate back into XFORML */
251 XFORMOBJ_iGetXform(&xoDest, pxformDest);
252
253 return TRUE;
254}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define XFORMOBJ_iSetXform
Definition: xformobj.h:14
#define XFORMOBJ_iGetXform
Definition: xformobj.h:9

Referenced by NtGdiCombineTransform().

◆ GreGetDCOrgEx()

BOOL WINAPI GreGetDCOrgEx ( _In_ HDC  hdc,
_Out_ PPOINTL  Point,
_Out_ PRECTL  Rect 
)

Definition at line 1386 of file coord.c.

1390{
1391 PDC dc;
1392
1393 dc = DC_LockDc(hdc);
1394 if (!dc) return FALSE;
1395
1396 /* Retrieve DC Window Rectangle without a check */
1397 *Rect = dc->erclWindow;
1398
1399 DC_UnlockDc(dc);
1400
1401 /* Use default call for DC Origin and parameter checking */
1403}
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
static const WCHAR dc[]
HDC hdc
Definition: main.c:9
BOOL APIENTRY GreGetDCPoint(HDC hDC, UINT iPoint, PPOINTL Point)
Definition: coord.c:1291
@ GdiGetDCOrg
Definition: ntgdityp.h:80
Definition: polytest.cpp:41

◆ GreGetDCPoint()

BOOL APIENTRY GreGetDCPoint ( HDC  hDC,
UINT  iPoint,
PPOINTL  Point 
)

Definition at line 1291 of file coord.c.

1295{
1296 BOOL Ret = TRUE;
1297 DC *pdc;
1298 SIZE Size;
1299 PSIZEL pszlViewportExt;
1300
1301 if (!Point)
1302 {
1304 return FALSE;
1305 }
1306
1307 pdc = DC_LockDc(hDC);
1308 if (!pdc)
1309 {
1311 return FALSE;
1312 }
1313
1314 switch (iPoint)
1315 {
1316 case GdiGetViewPortExt:
1317 pszlViewportExt = DC_pszlViewportExt(pdc);
1318 Point->x = pszlViewportExt->cx;
1319 Point->y = pszlViewportExt->cy;
1320 break;
1321
1322 case GdiGetWindowExt:
1323 Point->x = pdc->pdcattr->szlWindowExt.cx;
1324 Point->y = pdc->pdcattr->szlWindowExt.cy;
1325 break;
1326
1327 case GdiGetViewPortOrg:
1328 *Point = pdc->pdcattr->ptlViewportOrg;
1329 break;
1330
1331 case GdiGetWindowOrg:
1332 *Point = pdc->pdcattr->ptlWindowOrg;
1333 break;
1334
1335 case GdiGetDCOrg:
1336 *Point = pdc->ptlDCOrig;
1337 break;
1338
1341 Point->x = Size.cx;
1342 Point->y = Size.cy;
1343 break;
1344
1345 default:
1347 Ret = FALSE;
1348 break;
1349 }
1350
1351 DC_UnlockDc(pdc);
1352 return Ret;
1353}
static HDC hDC
Definition: 3dtext.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID FASTCALL DC_vGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio)
Definition: coord.c:1274
_In_ UINT iPoint
Definition: ntgdi.h:2197
@ GdiGetViewPortExt
Definition: ntgdityp.h:75
@ GdiGetAspectRatioFilter
Definition: ntgdityp.h:79
@ GdiGetWindowExt
Definition: ntgdityp.h:76
@ GdiGetViewPortOrg
Definition: ntgdityp.h:77
@ GdiGetWindowOrg
Definition: ntgdityp.h:78
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22

Referenced by co_UserExcludeUpdateRgn(), GreGetDCOrgEx(), GreGetViewportExtEx(), GreGetWindowExtEx(), and NtGdiGetDCPoint().

◆ GreGetViewportExtEx()

BOOL WINAPI GreGetViewportExtEx ( _In_ HDC  hdc,
_Out_ LPSIZE  lpSize 
)

Definition at line 1416 of file coord.c.

1419{
1420 return GreGetDCPoint(hdc, GdiGetViewPortExt, (PPOINTL)lpSize);
1421}

Referenced by DrawTextExWorker().

◆ GreGetWindowExtEx()

BOOL WINAPI GreGetWindowExtEx ( _In_ HDC  hdc,
_Out_ LPSIZE  lpSize 
)

Definition at line 1407 of file coord.c.

1410{
1411 return GreGetDCPoint(hdc, GdiGetWindowExt, (PPOINTL)lpSize);
1412}

Referenced by DrawTextExWorker().

◆ GreModifyWorldTransform()

BOOL NTAPI GreModifyWorldTransform ( PDC  pdc,
const XFORML pxform,
DWORD  dwMode 
)

Definition at line 461 of file coord.c.

465{
466 MATRIX mxSrc;
467 XFORMOBJ xoSrc, xoDC;
468
469 switch (dwMode)
470 {
471 case MWT_IDENTITY:
472 pdc->pdcattr->mxWorldToPage = gmxIdentity;
473 break;
474
475 case MWT_LEFTMULTIPLY:
476 XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage);
477 XFORMOBJ_vInit(&xoSrc, &mxSrc);
478 if (XFORMOBJ_iSetXform(&xoSrc, pxform) == DDI_ERROR)
479 return FALSE;
480 XFORMOBJ_iCombine(&xoDC, &xoSrc, &xoDC);
481 break;
482
484 XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage);
485 XFORMOBJ_vInit(&xoSrc, &mxSrc);
486 if (XFORMOBJ_iSetXform(&xoSrc, pxform) == DDI_ERROR)
487 return FALSE;
488 XFORMOBJ_iCombine(&xoDC, &xoDC, &xoSrc);
489 break;
490
491 case MWT_SET:
492 XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage);
493 if (XFORMOBJ_iSetXform(&xoDC, pxform) == DDI_ERROR)
494 return FALSE;
495 break;
496
497 default:
498 return FALSE;
499 }
500
501 /*Set invalidation flags */
502 pdc->pdcattr->flXform |= WORLD_XFORM_CHANGED|DEVICE_TO_WORLD_INVALID;
503
504 return TRUE;
505}
const MATRIX gmxIdentity
Definition: coord.c:80
#define MWT_SET
Definition: ntgdityp.h:180
#define MWT_LEFTMULTIPLY
Definition: wingdi.h:945
#define MWT_RIGHTMULTIPLY
Definition: wingdi.h:946
#define MWT_IDENTITY
Definition: wingdi.h:944

Referenced by NtGdiModifyWorldTransform(), PATH_FillPathEx(), and PATH_StrokePath().

◆ GreSetDCOrg()

BOOL WINAPI GreSetDCOrg ( _In_ HDC  hdc,
_In_ LONG  x,
_In_ LONG  y,
_In_opt_ PRECTL  Rect 
)

Definition at line 1357 of file coord.c.

1362{
1363 PDC dc;
1364
1365 dc = DC_LockDc(hdc);
1366 if (!dc) return FALSE;
1367
1368 /* Set DC Origin */
1369 dc->ptlDCOrig.x = x;
1370 dc->ptlDCOrig.y = y;
1371
1372 /* Recalculate Fill Origin */
1373 dc->ptlFillOrigin.x = dc->dclevel.ptlBrushOrigin.x + x;
1374 dc->ptlFillOrigin.y = dc->dclevel.ptlBrushOrigin.y + y;
1375
1376 /* Set DC Window Rectangle */
1377 if (Rect)
1378 dc->erclWindow = *Rect;
1379
1380 DC_UnlockDc(dc);
1381 return TRUE;
1382}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by DceSetDrawable().

◆ GreSetViewportOrgEx()

BOOL FASTCALL GreSetViewportOrgEx ( HDC  hDC,
int  X,
int  Y,
LPPOINT  Point 
)

Definition at line 915 of file coord.c.

920{
921 PDC dc;
922 PDC_ATTR pdcattr;
923
924 dc = DC_LockDc(hDC);
925 if (!dc)
926 {
928 return FALSE;
929 }
930 pdcattr = dc->pdcattr;
931
932 if (Point)
933 {
934 Point->x = pdcattr->ptlViewportOrg.x;
935 Point->y = pdcattr->ptlViewportOrg.y;
936 }
937
938 pdcattr->ptlViewportOrg.x = X;
939 pdcattr->ptlViewportOrg.y = Y;
941
943 return TRUE;
944}
#define Y(I)
#define X(b, s)
#define PAGE_XLATE_CHANGED
Definition: ntgdihdl.h:186

Referenced by MENU_DrawBitmapItem().

◆ IntGdiSetMapMode()

int APIENTRY IntGdiSetMapMode ( PDC  dc,
int  MapMode 
)

Definition at line 828 of file coord.c.

831{
832 INT iPrevMapMode;
833 FLONG flXform;
834 PDC_ATTR pdcattr = dc->pdcattr;
835
836 if (MapMode == pdcattr->iMapMode)
837 return MapMode;
838
842
843 switch (MapMode)
844 {
845 case MM_TEXT:
846 pdcattr->szlWindowExt.cx = 1;
847 pdcattr->szlWindowExt.cy = 1;
848 pdcattr->szlViewportExt.cx = 1;
849 pdcattr->szlViewportExt.cy = 1;
851 break;
852
853 case MM_ISOTROPIC:
854 flXform |= ISO_OR_ANISO_MAP_MODE;
855 /* Fall through */
856
857 case MM_LOMETRIC:
858 pdcattr->szlWindowExt.cx = pdcattr->szlVirtualDeviceMm.cx * 10;
859 pdcattr->szlWindowExt.cy = pdcattr->szlVirtualDeviceMm.cy * 10;
860 pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
861 pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
862 break;
863
864 case MM_HIMETRIC:
865 pdcattr->szlWindowExt.cx = pdcattr->szlVirtualDeviceMm.cx * 100;
866 pdcattr->szlWindowExt.cy = pdcattr->szlVirtualDeviceMm.cy * 100;
867 pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
868 pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
869 break;
870
871 case MM_LOENGLISH:
872 pdcattr->szlWindowExt.cx = EngMulDiv(1000, pdcattr->szlVirtualDeviceMm.cx, 254);
873 pdcattr->szlWindowExt.cy = EngMulDiv(1000, pdcattr->szlVirtualDeviceMm.cy, 254);
874 pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
875 pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
876 break;
877
878 case MM_HIENGLISH:
879 pdcattr->szlWindowExt.cx = EngMulDiv(10000, pdcattr->szlVirtualDeviceMm.cx, 254);
880 pdcattr->szlWindowExt.cy = EngMulDiv(10000, pdcattr->szlVirtualDeviceMm.cy, 254);
881 pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
882 pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
883 break;
884
885 case MM_TWIPS:
886 pdcattr->szlWindowExt.cx = EngMulDiv(14400, pdcattr->szlVirtualDeviceMm.cx, 254);
887 pdcattr->szlWindowExt.cy = EngMulDiv(14400, pdcattr->szlVirtualDeviceMm.cy, 254);
888 pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx;
889 pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy;
890 break;
891
892 case MM_ANISOTROPIC:
894 flXform |= ISO_OR_ANISO_MAP_MODE;
895 break;
896
897 default:
898 return 0;
899 }
900
901 /* Save the old map mode and set the new one */
902 iPrevMapMode = pdcattr->iMapMode;
903 pdcattr->iMapMode = MapMode;
904
905 /* Update xform flags */
906 pdcattr->flXform = flXform | (PAGE_XLATE_CHANGED | PAGE_EXTENTS_CHANGED |
909
910 return iPrevMapMode;
911}
unsigned long FLONG
Definition: ntbasedef.h:366
#define PAGE_TO_DEVICE_SCALE_IDENTITY
Definition: ntgdihdl.h:185
#define PTOD_EFM22_NEGATIVE
Definition: ntgdihdl.h:182
#define POSITIVE_Y_IS_UP
Definition: ntgdihdl.h:179
#define DEVICE_TO_PAGE_INVALID
Definition: ntgdihdl.h:176
#define PTOD_EFM11_NEGATIVE
Definition: ntgdihdl.h:181
#define ISO_OR_ANISO_MAP_MODE
Definition: ntgdihdl.h:183
#define PAGE_TO_DEVICE_IDENTITY
Definition: ntgdihdl.h:184
SIZEL szlVirtualDevicePixel
Definition: ntgdihdl.h:346
SIZEL szlVirtualDeviceMm
Definition: ntgdihdl.h:347
int32_t INT
Definition: typedefs.h:58
ENGAPI INT APIENTRY EngMulDiv(_In_ INT a, _In_ INT b, _In_ INT c)
Definition: math.c:26
#define MM_HIENGLISH
Definition: wingdi.h:868
#define MM_LOENGLISH
Definition: wingdi.h:871
#define MM_HIMETRIC
Definition: wingdi.h:869
#define MM_TWIPS
Definition: wingdi.h:874
#define MM_LOMETRIC
Definition: wingdi.h:872
#define MM_TEXT
Definition: wingdi.h:873

Referenced by _Success_(), and PATH_FillPathEx().

◆ IntMirrorWindowOrg()

VOID FASTCALL IntMirrorWindowOrg ( PDC  dc)

Definition at line 1055 of file coord.c.

1056{
1057 PDC_ATTR pdcattr;
1058 LONG X, cx;
1059
1060 pdcattr = dc->pdcattr;
1061
1062 if (!(pdcattr->dwLayout & LAYOUT_RTL))
1063 {
1064 pdcattr->ptlWindowOrg.x = pdcattr->lWindowOrgx; // Flip it back.
1065 return;
1066 }
1067
1068 /* Copy the window extension, so no one can mess with it */
1069 cx = pdcattr->szlViewportExt.cx;
1070 if (cx == 0) return;
1071 //
1072 // WOrgx = wox - (Width - 1) * WExtx / VExtx
1073 //
1074 X = (dc->erclWindow.right - dc->erclWindow.left) - 1; // Get device width - 1
1075
1076 X = (X * pdcattr->szlWindowExt.cx) / cx;
1077
1078 pdcattr->ptlWindowOrg.x = pdcattr->lWindowOrgx - X; // Now set the inverted win origion.
1080
1081 return;
1082}
_Out_opt_ int * cx
Definition: commctrl.h:585
LONG lWindowOrgx
Definition: ntgdihdl.h:340

Referenced by NtGdiMirrorWindowOrg(), NtGdiScaleViewportExtEx(), and NtGdiScaleWindowExtEx().

◆ NtGdiCombineTransform()

BOOL APIENTRY NtGdiCombineTransform ( LPXFORM  UnsafeXFormResult,
LPXFORM  Unsafexform1,
LPXFORM  Unsafexform2 
)

Definition at line 258 of file coord.c.

262{
263 BOOL Ret;
264
266 {
267 ProbeForWrite(UnsafeXFormResult, sizeof(XFORM), 1);
268 ProbeForRead(Unsafexform1, sizeof(XFORM), 1);
269 ProbeForRead(Unsafexform2, sizeof(XFORM), 1);
270 Ret = GreCombineTransform((XFORML*)UnsafeXFormResult,
271 (XFORML*)Unsafexform1,
272 (XFORML*)Unsafexform2);
273 }
275 {
276 Ret = FALSE;
277 }
278 _SEH2_END;
279
280 return Ret;
281}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOL NTAPI GreCombineTransform(XFORML *pxformDest, XFORML *pxform1, XFORML *pxform2)
Definition: coord.c:227
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34

◆ NtGdiGetDCPoint()

BOOL APIENTRY NtGdiGetDCPoint ( HDC  hDC,
UINT  iPoint,
PPOINTL  Point 
)

Definition at line 1424 of file coord.c.

1428{
1429 BOOL Ret;
1430 POINTL SafePoint;
1431
1432 if (!Point)
1433 {
1435 return FALSE;
1436 }
1437
1438 Ret = GreGetDCPoint(hDC, iPoint, &SafePoint);
1439 if (Ret)
1440 {
1441 _SEH2_TRY
1442 {
1443 ProbeForWrite(Point, sizeof(POINT), 1);
1444 *Point = SafePoint;
1445 }
1447 {
1448 Ret = FALSE;
1449 }
1450 _SEH2_END;
1451 }
1452
1453 return Ret;
1454}

Referenced by DPtoLP(), GetAspectRatioFilterEx(), GetDCOrgEx(), and GetViewportExtEx().

◆ NtGdiGetDeviceWidth()

LONG APIENTRY NtGdiGetDeviceWidth ( IN HDC  hdc)

Definition at line 1160 of file coord.c.

1162{
1163 PDC dc;
1164 LONG Ret;
1165 dc = DC_LockDc(hdc);
1166 if (!dc)
1167 {
1169 return 0;
1170 }
1171 Ret = dc->erclWindow.right - dc->erclWindow.left;
1172 DC_UnlockDc(dc);
1173 return Ret;
1174}

◆ NtGdiGetTransform()

BOOL APIENTRY NtGdiGetTransform ( HDC  hdc,
DWORD  iXform,
LPXFORM  pXForm 
)

Definition at line 286 of file coord.c.

290{
291 PDC pdc;
292 BOOL ret = TRUE;
293 MATRIX mxPageToDevice;
294 XFORMOBJ xo;
295 PMATRIX pmx;
296
297 if (!pXForm)
298 {
300 return FALSE;
301 }
302
303 pdc = DC_LockDc(hdc);
304 if (!pdc)
305 {
307 return FALSE;
308 }
309
310 switch (iXform)
311 {
313 pmx = DC_pmxWorldToPage(pdc);
314 break;
315
317 pmx = DC_pmxWorldToDevice(pdc);
318 break;
319
321 pmx = DC_pmxDeviceToWorld(pdc);
322 break;
323
325 DC_vGetPageToDevice(pdc, &mxPageToDevice);
326 pmx = &mxPageToDevice;
327 break;
328
329 default:
330 DPRINT1("Unknown transform %lu\n", iXform);
331 ret = FALSE;
332 goto leave;
333 }
334
335 /* Initialize an XFORMOBJ */
336 XFORMOBJ_vInit(&xo, pmx);
337
339 {
340 ProbeForWrite(pXForm, sizeof(XFORML), 1);
341 XFORMOBJ_iGetXform(&xo, (XFORML*)pXForm);
342 }
344 {
345 ret = FALSE;
346 }
347 _SEH2_END;
348
349leave:
350 DC_UnlockDc(pdc);
351 return ret;
352}
#define DPRINT1
Definition: precomp.h:8
#define leave
Definition: btrfs_drv.h:138
FORCEINLINE PMATRIX DC_pmxDeviceToWorld(PDC pdc)
Definition: coord.h:149
FORCEINLINE PMATRIX DC_pmxWorldToPage(PDC pdc)
Definition: coord.h:128
#define GdiWorldSpaceToDeviceSpace
Definition: gdi_private.h:221
_In_ DWORD iXform
Definition: ntgdi.h:2251
#define GdiPageSpaceToDeviceSpace
Definition: ntgdityp.h:184
#define GdiWorldSpaceToPageSpace
Definition: ntgdityp.h:182
#define GdiDeviceSpaceToWorldSpace
Definition: ntgdityp.h:185
int ret

◆ NtGdiMirrorWindowOrg()

BOOL APIENTRY NtGdiMirrorWindowOrg ( IN HDC  hdc)

Definition at line 1181 of file coord.c.

1183{
1184 PDC dc;
1185 dc = DC_LockDc(hdc);
1186 if (!dc)
1187 {
1189 return FALSE;
1190 }
1192 DC_UnlockDc(dc);
1193 return TRUE;
1194}
VOID FASTCALL IntMirrorWindowOrg(PDC dc)
Definition: coord.c:1055

◆ NtGdiModifyWorldTransform()

BOOL APIENTRY NtGdiModifyWorldTransform ( HDC  hdc,
LPXFORM  pxformUnsafe,
DWORD  dwMode 
)

Definition at line 509 of file coord.c.

513{
514 PDC pdc;
515 XFORML xformSafe;
516 BOOL Ret = TRUE;
517
518 pdc = DC_LockDc(hdc);
519 if (!pdc)
520 {
522 return FALSE;
523 }
524
525 /* The xform is permitted to be NULL for MWT_IDENTITY.
526 * However, if it is not NULL, then it must be valid even
527 * though it is not used. */
528 if ((dwMode != MWT_IDENTITY) && (pxformUnsafe == NULL))
529 {
530 DC_UnlockDc(pdc);
531 return FALSE;
532 }
533
534 if (pxformUnsafe != NULL)
535 {
537 {
538 ProbeForRead(pxformUnsafe, sizeof(XFORML), 1);
539 RtlCopyMemory(&xformSafe, pxformUnsafe, sizeof(XFORML));
540 }
542 {
543 Ret = FALSE;
544 }
545 _SEH2_END;
546 }
547
548 /* Safe to handle kernel mode data. */
549 if (Ret) Ret = GreModifyWorldTransform(pdc, &xformSafe, dwMode);
550 DC_UnlockDc(pdc);
551 return Ret;
552}
#define NULL
Definition: types.h:112
BOOL NTAPI GreModifyWorldTransform(PDC pdc, const XFORML *pxform, DWORD dwMode)
Definition: coord.c:461
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ NtGdiOffsetViewportOrgEx()

BOOL APIENTRY NtGdiOffsetViewportOrgEx ( HDC  hDC,
int  XOffset,
int  YOffset,
LPPOINT  UnsafePoint 
)

Definition at line 556 of file coord.c.

561{
562 PDC dc;
563 PDC_ATTR pdcattr;
565
566 dc = DC_LockDc(hDC);
567 if (!dc)
568 {
570 return FALSE;
571 }
572 pdcattr = dc->pdcattr;
573
574 if (UnsafePoint)
575 {
577 {
578 ProbeForWrite(UnsafePoint, sizeof(POINT), 1);
579 UnsafePoint->x = pdcattr->ptlViewportOrg.x;
580 UnsafePoint->y = pdcattr->ptlViewportOrg.y;
581 if (pdcattr->dwLayout & LAYOUT_RTL)
582 {
583 UnsafePoint->x = -UnsafePoint->x;
584 }
585 }
587 {
589 }
590 _SEH2_END;
591
592 if (!NT_SUCCESS(Status))
593 {
596 return FALSE;
597 }
598 }
599
600 if (pdcattr->dwLayout & LAYOUT_RTL)
601 {
602 XOffset = -XOffset;
603 }
604 pdcattr->ptlViewportOrg.x += XOffset;
605 pdcattr->ptlViewportOrg.y += YOffset;
607
609
610 return TRUE;
611}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define STATUS_SUCCESS
Definition: shellext.h:65
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31

◆ NtGdiOffsetWindowOrgEx()

BOOL APIENTRY NtGdiOffsetWindowOrgEx ( HDC  hDC,
int  XOffset,
int  YOffset,
LPPOINT  Point 
)

Definition at line 615 of file coord.c.

620{
621 PDC dc;
622 PDC_ATTR pdcattr;
623
624 dc = DC_LockDc(hDC);
625 if (!dc)
626 {
628 return FALSE;
629 }
630 pdcattr = dc->pdcattr;
631
632 if (Point)
633 {
635
637 {
638 ProbeForWrite(Point, sizeof(POINT), 1);
639 Point->x = pdcattr->ptlWindowOrg.x;
640 Point->y = pdcattr->ptlWindowOrg.y;
641 }
643 {
645 }
646 _SEH2_END;
647
648 if (!NT_SUCCESS(Status))
649 {
652 return FALSE;
653 }
654 }
655
656 pdcattr->ptlWindowOrg.x += XOffset;
657 pdcattr->ptlWindowOrg.y += YOffset;
659
661
662 return TRUE;
663}

◆ NtGdiScaleViewportExtEx()

BOOL APIENTRY NtGdiScaleViewportExtEx ( HDC  hDC,
int  Xnum,
int  Xdenom,
int  Ynum,
int  Ydenom,
LPSIZE  pSize 
)

Definition at line 667 of file coord.c.

674{
675 PDC pDC;
676 PDC_ATTR pdcattr;
677 BOOL Ret = FALSE;
678 LONG X, Y;
679
680 pDC = DC_LockDc(hDC);
681 if (!pDC)
682 {
684 return FALSE;
685 }
686 pdcattr = pDC->pdcattr;
687
688 if (pdcattr->iMapMode > MM_TWIPS)
689 {
690 if (Xdenom && Ydenom)
691 {
693 X = Xnum * pdcattr->szlViewportExt.cx / Xdenom;
694 if (X)
695 {
696 Y = Ynum * pdcattr->szlViewportExt.cy / Ydenom;
697 if (Y)
698 {
699 pdcattr->szlViewportExt.cx = X;
700 pdcattr->szlViewportExt.cy = Y;
701 pdcattr->flXform |= PAGE_XLATE_CHANGED;
702
704
705 pdcattr->flXform |= (PAGE_EXTENTS_CHANGED |
709
710 if (pdcattr->iMapMode == MM_ISOTROPIC)
711 {
713 }
714
715 Ret = TRUE;
716 }
717 }
718 }
719 }
720 else
721 Ret = TRUE;
722
723 if (pSize)
724 {
726 {
727 ProbeForWrite(pSize, sizeof(SIZE), 1);
728
729 pSize->cx = pdcattr->szlViewportExt.cx;
730 pSize->cy = pdcattr->szlViewportExt.cy;
731 }
733 {
735 Ret = FALSE;
736 }
737 _SEH2_END;
738 }
739
740 DC_UnlockDc(pDC);
741 return Ret;
742}
VOID FASTCALL DC_vFixIsotropicMapping(PDC pdc)
Definition: coord.c:93

◆ NtGdiScaleWindowExtEx()

BOOL APIENTRY NtGdiScaleWindowExtEx ( HDC  hDC,
int  Xnum,
int  Xdenom,
int  Ynum,
int  Ydenom,
LPSIZE  pSize 
)

Definition at line 746 of file coord.c.

753{
754 PDC pDC;
755 PDC_ATTR pdcattr;
756 BOOL Ret = FALSE;
757 LONG X, Y;
758
759 pDC = DC_LockDc(hDC);
760 if (!pDC)
761 {
763 return FALSE;
764 }
765 pdcattr = pDC->pdcattr;
766
767 if (pSize)
768 {
770
772 {
773 ProbeForWrite(pSize, sizeof(SIZE), 1);
774
775 X = pdcattr->szlWindowExt.cx;
776 if (pdcattr->dwLayout & LAYOUT_RTL) X = -X;
777 pSize->cx = X;
778 pSize->cy = pdcattr->szlWindowExt.cy;
779 }
781 {
783 }
784 _SEH2_END;
785
786 if (!NT_SUCCESS(Status))
787 {
789 DC_UnlockDc(pDC);
790 return FALSE;
791 }
792 }
793
794 if (pdcattr->iMapMode > MM_TWIPS)
795 {
796 if (Xdenom && Ydenom)
797 {
798 X = Xnum * pdcattr->szlWindowExt.cx / Xdenom;
799 if (X)
800 {
801 Y = Ynum * pdcattr->szlWindowExt.cy / Ydenom;
802 if (Y)
803 {
804 pdcattr->szlWindowExt.cx = X;
805 pdcattr->szlWindowExt.cy = Y;
806
808
809 pdcattr->flXform |= (PAGE_EXTENTS_CHANGED |
813
814 Ret = TRUE;
815 }
816 }
817 }
818 }
819 else
820 Ret = TRUE;
821
822 DC_UnlockDc(pDC);
823 return Ret;
824}

◆ NtGdiSetLayout()

DWORD APIENTRY NtGdiSetLayout ( IN HDC  hdc,
IN LONG  wox,
IN DWORD  dwLayout 
)

Definition at line 1133 of file coord.c.

1137{
1138 PDC pdc;
1139 DWORD dwOldLayout;
1140
1141 pdc = DC_LockDc(hdc);
1142 if (!pdc)
1143 {
1145 return GDI_ERROR;
1146 }
1147
1148 dwOldLayout = pdc->pdcattr->dwLayout;
1149 DC_vSetLayout(pdc, wox, dwLayout);
1150
1151 DC_UnlockDc(pdc);
1152 return dwOldLayout;
1153}
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID NTAPI DC_vSetLayout(IN PDC pdc, IN LONG wox, IN DWORD dwLayout)
Definition: coord.c:1086
#define GDI_ERROR
Definition: wingdi.h:1309

◆ NtGdiSetSizeDevice()

BOOL APIENTRY NtGdiSetSizeDevice ( IN HDC  hdc,
IN INT  cxVirtualDevice,
IN INT  cyVirtualDevice 
)

Definition at line 1201 of file coord.c.

1205{
1206 PDC dc;
1207 PDC_ATTR pdcattr;
1208
1209 if (!cxVirtualDevice || !cyVirtualDevice)
1210 {
1211 return FALSE;
1212 }
1213
1214 dc = DC_LockDc(hdc);
1215 if (!dc) return FALSE;
1216
1217 pdcattr = dc->pdcattr;
1218
1219 pdcattr->szlVirtualDeviceSize.cx = cxVirtualDevice;
1220 pdcattr->szlVirtualDeviceSize.cy = cyVirtualDevice;
1221
1222 DC_UnlockDc(dc);
1223
1224 return TRUE;
1225}
SIZEL szlVirtualDeviceSize
Definition: ntgdihdl.h:348

◆ NtGdiSetViewportOrgEx()

BOOL APIENTRY NtGdiSetViewportOrgEx ( HDC  hDC,
int  X,
int  Y,
LPPOINT  Point 
)

Definition at line 948 of file coord.c.

953{
954 PDC dc;
955 PDC_ATTR pdcattr;
956
957 dc = DC_LockDc(hDC);
958 if (!dc)
959 {
961 return FALSE;
962 }
963 pdcattr = dc->pdcattr;
964
965 if (Point)
966 {
968
970 {
971 ProbeForWrite(Point, sizeof(POINT), 1);
972 Point->x = pdcattr->ptlViewportOrg.x;
973 Point->y = pdcattr->ptlViewportOrg.y;
974 }
976 {
978 }
979 _SEH2_END;
980
981 if (!NT_SUCCESS(Status))
982 {
985 return FALSE;
986 }
987 }
988
989 pdcattr->ptlViewportOrg.x = X;
990 pdcattr->ptlViewportOrg.y = Y;
992
994
995 return TRUE;
996}

◆ NtGdiSetVirtualResolution()

BOOL APIENTRY NtGdiSetVirtualResolution ( IN HDC  hdc,
IN INT  cxVirtualDevicePixel,
IN INT  cyVirtualDevicePixel,
IN INT  cxVirtualDeviceMm,
IN INT  cyVirtualDeviceMm 
)

Definition at line 1232 of file coord.c.

1238{
1239 PDC dc;
1240 PDC_ATTR pdcattr;
1241
1242 /* Check parameters (all zeroes resets to real resolution) */
1243 if (cxVirtualDevicePixel == 0 && cyVirtualDevicePixel == 0 &&
1244 cxVirtualDeviceMm == 0 && cyVirtualDeviceMm == 0)
1245 {
1246 cxVirtualDevicePixel = NtGdiGetDeviceCaps(hdc, HORZRES);
1247 cyVirtualDevicePixel = NtGdiGetDeviceCaps(hdc, VERTRES);
1248 cxVirtualDeviceMm = NtGdiGetDeviceCaps(hdc, HORZSIZE);
1249 cyVirtualDeviceMm = NtGdiGetDeviceCaps(hdc, VERTSIZE);
1250 }
1251 else if (cxVirtualDevicePixel == 0 || cyVirtualDevicePixel == 0 ||
1252 cxVirtualDeviceMm == 0 || cyVirtualDeviceMm == 0)
1253 {
1254 return FALSE;
1255 }
1256
1257 dc = DC_LockDc(hdc);
1258 if (!dc) return FALSE;
1259
1260 pdcattr = dc->pdcattr;
1261
1262 pdcattr->szlVirtualDevicePixel.cx = cxVirtualDevicePixel;
1263 pdcattr->szlVirtualDevicePixel.cy = cyVirtualDevicePixel;
1264 pdcattr->szlVirtualDeviceMm.cx = cxVirtualDeviceMm;
1265 pdcattr->szlVirtualDeviceMm.cy = cyVirtualDeviceMm;
1266
1267// DC_vUpdateXforms(dc);
1268 DC_UnlockDc(dc);
1269 return TRUE;
1270}
__kernel_entry W32KAPI INT APIENTRY NtGdiGetDeviceCaps(_In_ HDC hdc, _In_ INT i)
#define HORZRES
Definition: wingdi.h:716
#define VERTSIZE
Definition: wingdi.h:715
#define HORZSIZE
Definition: wingdi.h:714
#define VERTRES
Definition: wingdi.h:717

◆ NtGdiSetWindowOrgEx()

BOOL APIENTRY NtGdiSetWindowOrgEx ( HDC  hDC,
int  X,
int  Y,
LPPOINT  Point 
)

Definition at line 1000 of file coord.c.

1005{
1006 PDC dc;
1007 PDC_ATTR pdcattr;
1008
1009 dc = DC_LockDc(hDC);
1010 if (!dc)
1011 {
1013 return FALSE;
1014 }
1015 pdcattr = dc->pdcattr;
1016
1017 if (Point)
1018 {
1020
1021 _SEH2_TRY
1022 {
1023 ProbeForWrite(Point, sizeof(POINT), 1);
1024 Point->x = pdcattr->ptlWindowOrg.x;
1025 Point->y = pdcattr->ptlWindowOrg.y;
1026 }
1028 {
1030 }
1031 _SEH2_END;
1032
1033 if (!NT_SUCCESS(Status))
1034 {
1036 DC_UnlockDc(dc);
1037 return FALSE;
1038 }
1039 }
1040
1041 pdcattr->ptlWindowOrg.x = X;
1042 pdcattr->ptlWindowOrg.y = Y;
1044
1045 DC_UnlockDc(dc);
1046
1047 return TRUE;
1048}

◆ NtGdiTransformPoints()

BOOL APIENTRY NtGdiTransformPoints ( HDC  hDC,
PPOINT  UnsafePtsIn,
PPOINT  UnsafePtOut,
INT  Count,
INT  iMode 
)

Converts points from logical coordinates into device coordinates. Conversion depends on the mapping mode, world transfrom, viewport origin settings for the given device context.

Parameters
hDCdevice context.
Pointsan array of POINT structures (in/out).
Countnumber of elements in the array of POINT structures.
Returns
TRUE if success, FALSE otherwise.

Definition at line 366 of file coord.c.

372{
373 PDC pdc;
374 LPPOINT Points;
375 ULONG Size;
376 BOOL ret = TRUE;
377
378 if (Count <= 0)
379 return TRUE;
380
381 if (!UnsafePtsIn || !UnsafePtOut)
382 {
383 return FALSE;
384 }
385
386 pdc = DC_LockDc(hDC);
387 if (!pdc)
388 {
389 return FALSE;
390 }
391
392 Size = Count * sizeof(POINT);
393
394 // FIXME: It would be wise to have a small stack buffer as optimization
396 if (!Points)
397 {
398 DC_UnlockDc(pdc);
400 return FALSE;
401 }
402
404 {
405 ProbeForWrite(UnsafePtOut, Size, 1);
406 ProbeForRead(UnsafePtsIn, Size, 1);
407 RtlCopyMemory(Points, UnsafePtsIn, Size);
408 }
410 {
411 /* Do not set last error */
412 _SEH2_YIELD(goto leave;)
413 }
414 _SEH2_END;
415
416 switch (iMode)
417 {
418 case GdiDpToLp:
420 break;
421
422 case GdiLpToDp:
424 break;
425
426 case 2: // Not supported yet. Need testing.
427 default:
428 {
430 ret = FALSE;
431 goto leave;
432 }
433 }
434
435 if (ret)
436 {
438 {
439 /* Pointer was already probed! */
440 RtlCopyMemory(UnsafePtOut, Points, Size);
441 }
443 {
444 /* Do not set last error */
445 ret = FALSE;
446 }
447 _SEH2_END;
448 }
449
450//
451// If we are getting called that means User XForms is a mess!
452//
453leave:
454 DC_UnlockDc(pdc);
456 return ret;
457}
static BOOLEAN INTERNAL_APPLY_MATRIX(PMATRIX matrix, LPPOINT points, UINT count)
Definition: coord.h:13
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
int Count
Definition: noreturn.cpp:7
@ GdiDpToLp
Definition: ntgdityp.h:99
@ GdiLpToDp
Definition: ntgdityp.h:100
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
uint32_t ULONG
Definition: typedefs.h:59
#define POINT
Definition: precomp.h:30
#define GDITAG_TEMP
Definition: tags.h:167
_In_ ULONG iMode
Definition: winddi.h:3520

Variable Documentation

◆ gmxIdentity

const MATRIX gmxIdentity
Initial value:
=
{
}
#define FLOATOBJ_0
Definition: floatobj.h:108
#define FLOATOBJ_1
Definition: floatobj.h:109
@ XFORM_NO_TRANSLATION
Definition: ntgdityp.h:112
@ XFORM_SCALE
Definition: ntgdityp.h:106
@ XFORM_UNITY
Definition: ntgdityp.h:107
@ XFORM_FORMAT_LTOL
Definition: ntgdityp.h:111

Definition at line 80 of file coord.c.

Referenced by GreModifyWorldTransform().