ReactOS  0.4.15-dev-313-g8fde48b
coord.c File Reference
#include <precomp.h>
Include dependency graph for coord.c:

Go to the source code of this file.

Macros

#define MAX_OFFSET   4294967041.0
 
#define _fmul(x, y)   (((x) == 0) ? 0 : (x) * (y))
 

Functions

void MatrixToXForm (XFORM *pxform, const MATRIX *pmx)
 
void GdiTransformPoints2 (_In_ XFORM *pxform, _Out_writes_(nCount) PPOINT pptOut, _In_reads_(nCount) PPOINT pptIn, _In_ ULONG nCount)
 
FORCEINLINE void GdiTransformPoints (_In_ MATRIX *pmx, _Out_writes_(nCount) PPOINT pptOut, _In_reads_(nCount) PPOINT pptIn, _In_ ULONG nCount)
 
BOOL WINAPI CombineTransform (_Out_ LPXFORM pxfResult, _In_ const XFORM *pxf1, _In_ const XFORM *pxf2)
 
int WINAPI GetMapMode (_In_ HDC hdc)
 
INT WINAPI SetMapMode (_In_ HDC hdc, _In_ INT iMode)
 
BOOL WINAPI DPtoLP (_In_ HDC hdc, _Inout_updates_(nCount) LPPOINT lpPoints, _In_ INT nCount)
 
BOOL WINAPI LPtoDP (_In_ HDC hdc, _Inout_updates_(nCount) LPPOINT lpPoints, _In_ INT nCount)
 
BOOL WINAPI GetCurrentPositionEx (_In_ HDC hdc, _Out_ LPPOINT lpPoint)
 
BOOL WINAPI GetWorldTransform (_In_ HDC hdc, _Out_ LPXFORM pxform)
 
BOOL WINAPI SetWorldTransform (_In_ HDC hdc, _Out_ CONST XFORM *pxform)
 
BOOL WINAPI ModifyWorldTransform (_In_ HDC hdc, _In_opt_ CONST XFORM *pxform, _In_ DWORD dwMode)
 
BOOL WINAPI GetViewportExtEx (_In_ HDC hdc, _Out_ LPSIZE lpSize)
 
BOOL WINAPI GetViewportOrgEx (_In_ HDC hdc, _Out_ LPPOINT lpPoint)
 
BOOL WINAPI GetWindowExtEx (_In_ HDC hdc, _Out_ LPSIZE lpSize)
 
BOOL WINAPI GetWindowOrgEx (_In_ HDC hdc, _Out_ LPPOINT lpPoint)
 
BOOL WINAPI SetViewportExtEx (_In_ HDC hdc, _In_ int nXExtent, _In_ int nYExtent, _Out_opt_ LPSIZE lpSize)
 
BOOL WINAPI SetWindowOrgEx (_In_ HDC hdc, _In_ int X, _In_ int Y, _Out_opt_ LPPOINT lpPoint)
 
BOOL WINAPI SetWindowExtEx (_In_ HDC hdc, _In_ INT nXExtent, _In_ INT nYExtent, _Out_opt_ LPSIZE lpSize)
 
BOOL WINAPI SetViewportOrgEx (_In_ HDC hdc, _In_ int X, _In_ int Y, _Out_opt_ LPPOINT lpPoint)
 
BOOL WINAPI ScaleViewportExtEx (_In_ HDC hdc, _In_ INT xNum, _In_ INT xDenom, _In_ INT yNum, _In_ INT yDenom, _Out_ LPSIZE lpSize)
 
BOOL WINAPI ScaleWindowExtEx (_In_ HDC hdc, _In_ INT xNum, _In_ INT xDenom, _In_ INT yNum, _In_ INT yDenom, _Out_ LPSIZE lpSize)
 
DWORD WINAPI GetLayout (_In_ HDC hdc)
 
DWORD WINAPI SetLayout (_In_ HDC hdc, _In_ DWORD dwLayout)
 
DWORD WINAPI SetLayoutWidth (_In_ HDC hdc, _In_ LONG wox, _In_ DWORD dwLayout)
 
BOOL WINAPI GetDCOrgEx (_In_ HDC hdc, _Out_ LPPOINT lpPoint)
 
LONG WINAPI GetDCOrg (_In_ HDC hdc)
 
BOOL WINAPI OffsetViewportOrgEx (_In_ HDC hdc, _In_ int nXOffset, _In_ int nYOffset, _Out_opt_ LPPOINT lpPoint)
 
BOOL WINAPI OffsetWindowOrgEx (_In_ HDC hdc, _In_ int nXOffset, _In_ int nYOffset, _Out_opt_ LPPOINT lpPoint)
 

Macro Definition Documentation

◆ _fmul

#define _fmul (   x,
  y 
)    (((x) == 0) ? 0 : (x) * (y))

Definition at line 60 of file coord.c.

◆ MAX_OFFSET

#define MAX_OFFSET   4294967041.0

Definition at line 59 of file coord.c.

Function Documentation

◆ CombineTransform()

BOOL WINAPI CombineTransform ( _Out_ LPXFORM  pxfResult,
_In_ const XFORM pxf1,
_In_ const XFORM pxf2 
)

Definition at line 64 of file coord.c.

68 {
69  XFORM xformTmp;
70 
71  /* Check paramters */
72  if (!pxfResult || !pxf1 || !pxf2) return FALSE;
73 
74  /* Do matrix multiplication, start with scaling elements */
75  xformTmp.eM11 = (pxf1->eM11 * pxf2->eM11) + (pxf1->eM12 * pxf2->eM21);
76  xformTmp.eM22 = (pxf1->eM21 * pxf2->eM12) + (pxf1->eM22 * pxf2->eM22);
77 
78  /* Calculate shear/rotate elements only of they are present */
79  if ((pxf1->eM12 != 0.) || (pxf1->eM21 != 0.) ||
80  (pxf2->eM12 != 0.) || (pxf2->eM21 != 0.))
81  {
82  xformTmp.eM12 = (pxf1->eM11 * pxf2->eM12) + (pxf1->eM12 * pxf2->eM22);
83  xformTmp.eM21 = (pxf1->eM21 * pxf2->eM11) + (pxf1->eM22 * pxf2->eM21);
84  }
85  else
86  {
87  xformTmp.eM12 = 0.;
88  xformTmp.eM21 = 0.;
89  }
90 
91  /* Calculate the offset */
92  xformTmp.eDx = _fmul(pxf1->eDx, pxf2->eM11) + _fmul(pxf1->eDy, pxf2->eM21) + pxf2->eDx;
93  xformTmp.eDy = _fmul(pxf1->eDx, pxf2->eM12) + _fmul(pxf1->eDy, pxf2->eM22) + pxf2->eDy;
94 
95  /* Check for invalid offset ranges */
96  if ((xformTmp.eDx > MAX_OFFSET) || (xformTmp.eDx < -MAX_OFFSET) ||
97  (xformTmp.eDy > MAX_OFFSET) || (xformTmp.eDy < -MAX_OFFSET))
98  {
99  return FALSE;
100  }
101 
102  /* All is ok, return the calculated values */
103  *pxfResult = xformTmp;
104  return TRUE;
105 }
#define TRUE
Definition: types.h:120
FLOAT eDx
Definition: wingdi.h:1724
FLOAT eM21
Definition: wingdi.h:1722
FLOAT eM12
Definition: wingdi.h:1721
FLOAT eM11
Definition: wingdi.h:1720
#define _fmul(x, y)
Definition: coord.c:60
FLOAT eM22
Definition: wingdi.h:1723
FLOAT eDy
Definition: wingdi.h:1725
#define MAX_OFFSET
Definition: coord.c:59

Referenced by EMF_Update_MF_Xform(), enum_emf_WorldTransform(), EnumEnhMetaFile(), GetMaxValue(), METAFILE_PlaybackUpdateGdiTransform(), PlayEnhMetaFileRecord(), Test_CombineTransform(), and Test_CombineTransform_Inval().

◆ DPtoLP()

BOOL WINAPI DPtoLP ( _In_ HDC  hdc,
_Inout_updates_(nCount) LPPOINT  lpPoints,
_In_ INT  nCount 
)

Definition at line 169 of file coord.c.

173 {
174  PDC_ATTR pdcattr;
175  SIZEL sizlView;
176 
177  if (nCount <= 0)
178  return TRUE;
179 
180  if (hdc == NULL)
181  {
183  return FALSE;
184  }
185  if (lpPoints == NULL)
186  {
187  return TRUE;
188  }
189 
190  pdcattr = GdiGetDcAttr(hdc);
191  if (pdcattr == NULL)
192  return FALSE;
193 
194  if (pdcattr->iMapMode == MM_ISOTROPIC)
195  {
196  if (NtGdiGetDCPoint(hdc, GdiGetViewPortExt, (PPOINTL)&sizlView))
197  {
198  if (sizlView.cx == 0 || sizlView.cy == 0)
199  return FALSE;
200  }
201  }
202 
203  return NtGdiTransformPoints(hdc, lpPoints, lpPoints, nCount, GdiDpToLp);
204 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
INT iMapMode
Definition: ntgdihdl.h:342
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
BOOL APIENTRY NtGdiGetDCPoint(HDC hDC, UINT iPoint, PPOINTL Point)
Definition: coord.c:1421
BOOL APIENTRY NtGdiTransformPoints(HDC hDC, PPOINT UnsafePtsIn, PPOINT UnsafePtOut, INT Count, INT iMode)
Definition: coord.c:366

Referenced by GetCurrentPositionEx().

◆ GdiTransformPoints()

FORCEINLINE void GdiTransformPoints ( _In_ MATRIX pmx,
_Out_writes_(nCount) PPOINT  pptOut,
_In_reads_(nCount) PPOINT  pptIn,
_In_ ULONG  nCount 
)

Definition at line 47 of file coord.c.

52 {
53  XFORM xform;
54 
55  MatrixToXForm(&xform, pmx);
56  GdiTransformPoints2(&xform, pptOut, pptIn, nCount);
57 }
void GdiTransformPoints2(_In_ XFORM *pxform, _Out_writes_(nCount) PPOINT pptOut, _In_reads_(nCount) PPOINT pptIn, _In_ ULONG nCount)
Definition: coord.c:27
_In_ UINT _Out_ PPOINTL pptOut
Definition: ntgdi.h:2197
void MatrixToXForm(XFORM *pxform, const MATRIX *pmx)
Definition: coord.c:15

◆ GdiTransformPoints2()

void GdiTransformPoints2 ( _In_ XFORM pxform,
_Out_writes_(nCount) PPOINT  pptOut,
_In_reads_(nCount) PPOINT  pptIn,
_In_ ULONG  nCount 
)

Definition at line 27 of file coord.c.

32 {
33  ULONG i;
34  FLOAT x, y;
35 
36  for (i = 0; i < nCount; i++)
37  {
38  x = pptIn[i].x * pxform->eM11 + pptIn[i].y * pxform->eM12 + pxform->eDx;
39  pptOut[i].x = _lrintf(x);
40  y = pptIn[i].x * pxform->eM21 + pptIn[i].y * pxform->eM22 + pxform->eDy;
41  pptOut[i].y = _lrintf(y);
42  }
43 }
FORCEINLINE int _lrintf(float f)
Definition: gdi32p.h:498
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG y
Definition: windef.h:330
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG x
Definition: windef.h:329
_In_ UINT _Out_ PPOINTL pptOut
Definition: ntgdi.h:2197
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
float FLOAT
Definition: typedefs.h:68
unsigned int ULONG
Definition: retypes.h:1

Referenced by GdiTransformPoints().

◆ GetCurrentPositionEx()

BOOL WINAPI GetCurrentPositionEx ( _In_ HDC  hdc,
_Out_ LPPOINT  lpPoint 
)

Definition at line 241 of file coord.c.

244 {
245  PDC_ATTR pdcattr;
246 
247  /* Get the DC attribute */
248  pdcattr = GdiGetDcAttr(hdc);
249  if ((pdcattr == NULL) || (lpPoint == NULL))
250  {
252  return FALSE;
253  }
254 
255  if (pdcattr->ulDirty_ & DIRTY_PTLCURRENT) // have a hit!
256  {
257  lpPoint->x = pdcattr->ptfxCurrent.x;
258  lpPoint->y = pdcattr->ptfxCurrent.y;
259  DPtoLP(hdc, lpPoint, 1); // reconvert back.
260  pdcattr->ptlCurrent.x = lpPoint->x; // save it
261  pdcattr->ptlCurrent.y = lpPoint->y;
262  pdcattr->ulDirty_ &= ~DIRTY_PTLCURRENT; // clear bit
263  }
264  else
265  {
266  lpPoint->x = pdcattr->ptlCurrent.x;
267  lpPoint->y = pdcattr->ptlCurrent.y;
268  }
269 
270  return TRUE;
271 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
LONG y
Definition: windef.h:330
smooth NULL
Definition: ftsmooth.c:416
ULONG ulDirty_
Definition: ntgdihdl.h:298
LONG x
Definition: windef.h:329
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
POINTL ptfxCurrent
Definition: ntgdihdl.h:316
#define DIRTY_PTLCURRENT
Definition: ntgdihdl.h:153
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(nCount) LPPOINT lpPoints, _In_ INT nCount)
Definition: coord.c:169
POINTL ptlCurrent
Definition: ntgdihdl.h:315

Referenced by EMFDRV_ArcChordPie(), EMFDRV_LineTo(), get_points_bounds(), test_closefigure(), test_polydraw(), and Test_SetMapMode().

◆ GetDCOrg()

LONG WINAPI GetDCOrg ( _In_ HDC  hdc)

Definition at line 838 of file coord.c.

840 {
841  POINT pt;
842 
843  /* Call the new API */
844  if (!GetDCOrgEx(hdc, &pt))
845  return 0;
846 
847  /* Return the point in the old way */
848  return(MAKELONG(pt.x, pt.y));
849 }
#define pt(x, y)
Definition: drawing.c:79
#define MAKELONG(a, b)
Definition: typedefs.h:248
HDC hdc
Definition: main.c:9
BOOL WINAPI GetDCOrgEx(_In_ HDC hdc, _Out_ LPPOINT lpPoint)
Definition: coord.c:825

◆ GetDCOrgEx()

BOOL WINAPI GetDCOrgEx ( _In_ HDC  hdc,
_Out_ LPPOINT  lpPoint 
)

Definition at line 825 of file coord.c.

828 {
829  return NtGdiGetDCPoint(hdc, GdiGetDCOrg, (PPOINTL)lpPoint);
830 }
HDC hdc
Definition: main.c:9
BOOL APIENTRY NtGdiGetDCPoint(HDC hDC, UINT iPoint, PPOINTL Point)
Definition: coord.c:1421

Referenced by cdtDrawExt(), get_window_region(), GetDCOrg(), and test_dc_layout().

◆ GetLayout()

DWORD WINAPI GetLayout ( _In_ HDC  hdc)

Definition at line 750 of file coord.c.

752 {
753  PDC_ATTR pdcattr;
754 
755  /* METADC16 is not supported in this API */
757  {
758  return GDI_ERROR;
759  }
760 
761  /* Get the DC attribute */
762  pdcattr = GdiGetDcAttr(hdc);
763  if (!pdcattr)
764  {
765  /* Set the error value and return failure */
767  return GDI_ERROR;
768  }
769 
770  /* Return the layout */
771  return pdcattr->dwLayout;
772 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
DWORD dwLayout
Definition: ntgdihdl.h:343
#define GDI_ERROR
Definition: wingdi.h:1308

Referenced by ExtSelectClipRgn(), InitBitBltCoords(), IntDrawState(), LPK_DrawUnderscore(), LpkExtTextOut(), and set_control_clipping().

◆ GetMapMode()

int WINAPI GetMapMode ( _In_ HDC  hdc)

Definition at line 114 of file coord.c.

116 {
117  PDC_ATTR pdcattr;
118 
119  /* Get the DC attribute */
120  pdcattr = GdiGetDcAttr(hdc);
121  if (pdcattr == NULL)
122  {
124  return 0;
125  }
126 
127  /* Return the map mode */
128  return pdcattr->iMapMode;
129 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
INT iMapMode
Definition: ntgdihdl.h:342
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9

Referenced by EnumEnhMetaFile(), RealDrawFrameControl(), Test_CreateCompatibleDC(), test_dc_layout(), and Test_IsSpecialState().

◆ GetViewportExtEx()

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

Definition at line 351 of file coord.c.

354 {
355  PDC_ATTR pdcattr;
356 
357  /* Get the DC attribute */
358  pdcattr = GdiGetDcAttr(hdc);
359  if (pdcattr == NULL)
360  {
361  /* Do not set LastError here! */
362  return FALSE;
363  }
364 
365  /* Check if we need to update values */
366  if ((pdcattr->flXform & PAGE_EXTENTS_CHANGED) &&
367  (pdcattr->iMapMode == MM_ISOTROPIC))
368  {
369  /* Call win32k to do the work */
370  return NtGdiGetDCPoint(hdc, GdiGetViewPortExt, (PPOINTL)lpSize);
371  }
372 
373  /* Nothing to calculate, return the current extension */
374  lpSize->cx = pdcattr->szlViewportExt.cx;
375  lpSize->cy = pdcattr->szlViewportExt.cy;
376 
377  return TRUE;
378 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define TRUE
Definition: types.h:120
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
INT iMapMode
Definition: ntgdihdl.h:342
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
#define PAGE_EXTENTS_CHANGED
Definition: ntgdihdl.h:202
HDC hdc
Definition: main.c:9
FLONG flXform
Definition: ntgdihdl.h:349
BOOL APIENTRY NtGdiGetDCPoint(HDC hDC, UINT iPoint, PPOINTL Point)
Definition: coord.c:1421
SIZEL szlViewportExt
Definition: ntgdihdl.h:348
LONG cy
Definition: windef.h:335

Referenced by check_dc_state(), DoTestEntry(), DrawTextExWorker(), EMFDRV_ExtTextOut(), EnumEnhMetaFile(), savedc_emf_enum_proc(), START_TEST(), test_ExtTextOutScale(), test_gettransform(), test_isotropic_mapping(), Test_IsSpecialState(), test_mf_SaveDC(), test_SaveDC(), Test_SetMapMode(), test_SetViewportExt(), test_setvirtualresolution(), test_SetWindowExt(), and Test_SetWindowExtEx().

◆ GetViewportOrgEx()

BOOL WINAPI GetViewportOrgEx ( _In_ HDC  hdc,
_Out_ LPPOINT  lpPoint 
)

Definition at line 383 of file coord.c.

386 {
387  PDC_ATTR pdcattr;
388 
389  /* Get the DC attribute */
390  pdcattr = GdiGetDcAttr(hdc);
391  if (pdcattr == NULL)
392  {
393  /* Do not set LastError here! */
394  return FALSE;
395  }
396 
397  /* Get the current viewport org */
398  lpPoint->x = pdcattr->ptlViewportOrg.x;
399  lpPoint->y = pdcattr->ptlViewportOrg.y;
400 
401  /* Handle right-to-left layout */
402  if (pdcattr->dwLayout & LAYOUT_RTL)
403  lpPoint->x = -lpPoint->x;
404 
405  return TRUE;
406 }
POINTL ptlViewportOrg
Definition: ntgdihdl.h:347
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
LONG y
Definition: windef.h:330
smooth NULL
Definition: ftsmooth.c:416
LONG x
Definition: windef.h:329
HDC hdc
Definition: main.c:9
DWORD dwLayout
Definition: ntgdihdl.h:343

Referenced by check_dc_state(), DoTestEntry(), EMFDRV_OffsetViewportOrgEx(), EnumEnhMetaFile(), savedc_emf_enum_proc(), test_buffer_dc_props(), test_dc_layout(), Test_IsSpecialState(), test_mf_SaveDC(), test_SaveDC(), test_SetViewportExt(), and test_SetWindowExt().

◆ GetWindowExtEx()

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

Definition at line 411 of file coord.c.

414 {
415  PDC_ATTR pdcattr;
416 
417  /* Get the DC attribute */
418  pdcattr = GdiGetDcAttr(hdc);
419  if (pdcattr == NULL)
420  {
421  /* Do not set LastError here! */
422  return FALSE;
423  }
424 
425  /* Get the current window extension */
426  lpSize->cx = pdcattr->szlWindowExt.cx;
427  lpSize->cy = pdcattr->szlWindowExt.cy;
428 
429  /* Handle right-to-left layout */
430  if (pdcattr->dwLayout & LAYOUT_RTL)
431  lpSize->cx = -lpSize->cx;
432 
433  return TRUE;
434 }
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
HDC hdc
Definition: main.c:9
SIZEL szlWindowExt
Definition: ntgdihdl.h:346
DWORD dwLayout
Definition: ntgdihdl.h:343
LONG cy
Definition: windef.h:335

Referenced by check_dc_state(), DoTestEntry(), DrawTextExWorker(), EMFDRV_ExtTextOut(), EnumEnhMetaFile(), savedc_emf_enum_proc(), START_TEST(), test_dc_layout(), test_ExtTextOutScale(), test_gettransform(), test_isotropic_mapping(), Test_IsSpecialState(), Test_SetMapMode(), test_SetViewportExt(), test_setvirtualresolution(), test_SetWindowExt(), and test_world_transform().

◆ GetWindowOrgEx()

BOOL WINAPI GetWindowOrgEx ( _In_ HDC  hdc,
_Out_ LPPOINT  lpPoint 
)

Definition at line 439 of file coord.c.

442 {
443  PDC_ATTR pdcattr;
444 
445  /* Get the DC attribute */
446  pdcattr = GdiGetDcAttr(hdc);
447  if (pdcattr == NULL)
448  {
449  /* Do not set LastError here! */
450  return FALSE;
451  }
452 
453  /* Get the current window origin */
454  lpPoint->x = pdcattr->ptlWindowOrg.x;
455  lpPoint->y = pdcattr->ptlWindowOrg.y;
456 
457  return TRUE;
458 }
#define TRUE
Definition: types.h:120
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
LONG y
Definition: windef.h:330
smooth NULL
Definition: ftsmooth.c:416
LONG x
Definition: windef.h:329
HDC hdc
Definition: main.c:9
POINTL ptlWindowOrg
Definition: ntgdihdl.h:345

Referenced by check_dc_state(), DoTestEntry(), EMFDRV_OffsetWindowOrgEx(), EnumEnhMetaFile(), savedc_emf_enum_proc(), test_buffer_dc_props(), test_dc_layout(), Test_IsSpecialState(), test_SetViewportExt(), and test_SetWindowExt().

◆ GetWorldTransform()

BOOL WINAPI GetWorldTransform ( _In_ HDC  hdc,
_Out_ LPXFORM  pxform 
)

Definition at line 278 of file coord.c.

281 {
282  PDC_ATTR pdcattr;
283 
284  pdcattr = GdiGetDcAttr(hdc);
285  if (!pdcattr)
286  {
288  return FALSE;
289  }
290 #if 0
291  if (pdcattr->flXform & ANY_XFORM_INVALID)
292  {
293  GdiFixupTransforms(pdcattr);
294  }
295 
296  MatrixToXForm(pxform, &pdcattr->mxWorldToDevice);
297 #endif
299 }
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL APIENTRY NtGdiGetTransform(HDC hdc, DWORD iXform, LPXFORM pXForm)
Definition: coord.c:286
#define GdiWorldSpaceToPageSpace
Definition: ntgdityp.h:182
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
FLONG flXform
Definition: ntgdihdl.h:349
MATRIX mxWorldToDevice
Definition: ntgdihdl.h:335
void MatrixToXForm(XFORM *pxform, const MATRIX *pmx)
Definition: coord.c:15

Referenced by check_dc_state(), clip_emf_enum_proc(), enum_emf_WorldTransform(), EnumEnhMetaFile(), font::MakeFont(), PlayEnhMetaFileRecord(), savedc_emf_enum_proc(), START_TEST(), test_buffer_dc_props(), and Test_SetWorldTransform().

◆ LPtoDP()

BOOL WINAPI LPtoDP ( _In_ HDC  hdc,
_Inout_updates_(nCount) LPPOINT  lpPoints,
_In_ INT  nCount 
)

Definition at line 208 of file coord.c.

212 {
213  PDC_ATTR pdcattr;
214 
215  if (nCount <= 0)
216  return TRUE;
217 
218  if (hdc == NULL)
219  {
221  return FALSE;
222  }
223  if (lpPoints == NULL)
224  {
225  return TRUE;
226  }
227 
228  pdcattr = GdiGetDcAttr(hdc);
229  if (pdcattr == NULL)
230  return FALSE;
231 
232  return NtGdiTransformPoints(hdc, lpPoints, lpPoints, nCount, GdiLpToDp);
233 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
BOOL APIENTRY NtGdiTransformPoints(HDC hDC, PPOINT UnsafePtsIn, PPOINT UnsafePtOut, INT Count, INT iMode)
Definition: coord.c:366

◆ MatrixToXForm()

void MatrixToXForm ( XFORM pxform,
const MATRIX pmx 
)

Definition at line 15 of file coord.c.

16 {
17  XFORML *pxforml = (XFORML*)pxform;
18  pxforml->eM11 = FOtoF(&pmx->efM11);
19  pxforml->eM12 = FOtoF(&pmx->efM12);
20  pxforml->eM21 = FOtoF(&pmx->efM21);
21  pxforml->eM22 = FOtoF(&pmx->efM22);
22  pxforml->eDx = FOtoF(&pmx->efDx);
23  pxforml->eDy = FOtoF(&pmx->efDy);
24 }
FLOATL eM11
Definition: winddi.h:1234
#define FOtoF(pfo)
Definition: gdi32p.h:492
FLOATL eDy
Definition: winddi.h:1239
FLOATL eM21
Definition: winddi.h:1236
FLOATL eDx
Definition: winddi.h:1238
FLOATL eM12
Definition: winddi.h:1235
FLOATL eM22
Definition: winddi.h:1237

Referenced by GdiTransformPoints(), and GetWorldTransform().

◆ ModifyWorldTransform()

BOOL WINAPI ModifyWorldTransform ( _In_ HDC  hdc,
_In_opt_ CONST XFORM pxform,
_In_ DWORD  dwMode 
)

Definition at line 314 of file coord.c.

318 {
319  PDC_ATTR pdcattr;
320 
322  return FALSE;
323 
324  if (dwMode == MWT_SET)
325  {
327  }
328  else
329  {
330  HANDLE_METADC(BOOL, ModifyWorldTransform, FALSE, hdc, pxform, dwMode);
331  }
332 
333  /* Get the DC attribute */
334  pdcattr = GdiGetDcAttr(hdc);
335  if (pdcattr == NULL)
336  {
338  return FALSE;
339  }
340 
341  /* Check that graphics mode is GM_ADVANCED */
342  if (pdcattr->iGraphicsMode != GM_ADVANCED)
343  return FALSE;
344 
345  /* Call win32k to do the work */
346  return NtGdiModifyWorldTransform(hdc, (LPXFORM)pxform, dwMode);
347 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define MWT_SET
Definition: ntgdityp.h:180
BOOL APIENTRY NtGdiModifyWorldTransform(HDC hdc, LPXFORM pxformUnsafe, DWORD dwMode)
Definition: coord.c:506
BOOL WINAPI ModifyWorldTransform(_In_ HDC hdc, _In_opt_ CONST XFORM *pxform, _In_ DWORD dwMode)
Definition: coord.c:314
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
BOOL WINAPI SetWorldTransform(_In_ HDC hdc, _Out_ CONST XFORM *pxform)
Definition: coord.c:304
#define GM_ADVANCED
Definition: wingdi.h:864
INT iGraphicsMode
Definition: ntgdihdl.h:310

Referenced by SetWorldTransform().

◆ OffsetViewportOrgEx()

BOOL WINAPI OffsetViewportOrgEx ( _In_ HDC  hdc,
_In_ int  nXOffset,
_In_ int  nYOffset,
_Out_opt_ LPPOINT  lpPoint 
)

Definition at line 858 of file coord.c.

863 {
864  PDC_ATTR pdcattr;
865 
866  HANDLE_METADC(BOOL, OffsetViewportOrgEx, FALSE, hdc, nXOffset, nYOffset, lpPoint);
867 
868  /* Get the DC attribute */
869  pdcattr = GdiGetDcAttr(hdc);
870  if (!pdcattr)
871  {
872  /* Do not set LastError here! */
873  return FALSE;
874  }
875 
876  if (lpPoint)
877  {
878  *lpPoint = pdcattr->ptlViewportOrg;
879  if ( pdcattr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x;
880  }
881 
882  if ( nXOffset || nYOffset != nXOffset )
883  {
884  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
885  {
886  if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
887  {
888  NtGdiFlush();
889  pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
890  }
891  }
892 
894  if (pdcattr->dwLayout & LAYOUT_RTL) nXOffset = -nXOffset;
895  pdcattr->ptlViewportOrg.x += nXOffset;
896  pdcattr->ptlViewportOrg.y += nYOffset;
897  }
898  return TRUE;
899 
900 // return NtGdiOffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint);
901 }
POINTL ptlViewportOrg
Definition: ntgdihdl.h:347
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
LONG y
Definition: windef.h:330
#define PAGE_XLATE_CHANGED
Definition: ntgdihdl.h:201
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG ulDirty_
Definition: ntgdihdl.h:298
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
BOOL WINAPI OffsetViewportOrgEx(_In_ HDC hdc, _In_ int nXOffset, _In_ int nYOffset, _Out_opt_ LPPOINT lpPoint)
Definition: coord.c:858
LONG x
Definition: windef.h:329
HDC hdc
Definition: main.c:9
FLONG flXform
Definition: ntgdihdl.h:349
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
#define WORLD_XFORM_CHANGED
Definition: ntgdihdl.h:203
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:192
DWORD dwLayout
Definition: ntgdihdl.h:343

Referenced by ClockWndProc(), DrawThemeParentBackground(), PAINTING_DrawStateJam(), PlayMetaFileRecord(), and UXTHEME_DrawImageBackground().

◆ OffsetWindowOrgEx()

BOOL WINAPI OffsetWindowOrgEx ( _In_ HDC  hdc,
_In_ int  nXOffset,
_In_ int  nYOffset,
_Out_opt_ LPPOINT  lpPoint 
)

Definition at line 909 of file coord.c.

914 {
915  PDC_ATTR pdcattr;
916 
917  HANDLE_METADC(BOOL, OffsetWindowOrgEx, FALSE, hdc, nXOffset, nYOffset, lpPoint);
918 
919  /* Get the DC attribute */
920  pdcattr = GdiGetDcAttr(hdc);
921  if (!pdcattr)
922  {
923  /* Do not set LastError here! */
924  return FALSE;
925  }
926 
927  if ( lpPoint )
928  {
929  *lpPoint = pdcattr->ptlWindowOrg;
930  //lpPoint->x = pdcattr->lWindowOrgx;
931  }
932 
933  if ( nXOffset || nYOffset != nXOffset )
934  {
935  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
936  {
937  if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
938  {
939  NtGdiFlush();
940  pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
941  }
942  }
943 
945  pdcattr->ptlWindowOrg.x += nXOffset;
946  pdcattr->ptlWindowOrg.y += nYOffset;
947  pdcattr->lWindowOrgx += nXOffset;
948  }
949  return TRUE;
950 
951 // return NtGdiOffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
952 }
#define TRUE
Definition: types.h:120
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
LONG y
Definition: windef.h:330
#define PAGE_XLATE_CHANGED
Definition: ntgdihdl.h:201
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG ulDirty_
Definition: ntgdihdl.h:298
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
LONG x
Definition: windef.h:329
LONG lWindowOrgx
Definition: ntgdihdl.h:344
HDC hdc
Definition: main.c:9
FLONG flXform
Definition: ntgdihdl.h:349
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
#define WORLD_XFORM_CHANGED
Definition: ntgdihdl.h:203
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:192
POINTL ptlWindowOrg
Definition: ntgdihdl.h:345
BOOL WINAPI OffsetWindowOrgEx(_In_ HDC hdc, _In_ int nXOffset, _In_ int nYOffset, _Out_opt_ LPPOINT lpPoint)
Definition: coord.c:909

Referenced by CAddressBand::OnEraseBackground(), PAGER_EraseBackground(), PlayMetaFileRecord(), and TOOLBAR_EraseBackground().

◆ ScaleViewportExtEx()

BOOL WINAPI ScaleViewportExtEx ( _In_ HDC  hdc,
_In_ INT  xNum,
_In_ INT  xDenom,
_In_ INT  yNum,
_In_ INT  yDenom,
_Out_ LPSIZE  lpSize 
)

Definition at line 702 of file coord.c.

709 {
710  HANDLE_METADC(BOOL, ScaleViewportExtEx, FALSE, hdc, xNum, xDenom, yNum, yDenom, lpSize);
711 
712  if (!GdiGetDcAttr(hdc))
713  {
715  return FALSE;
716  }
717 
718  return NtGdiScaleViewportExtEx(hdc, xNum, xDenom, yNum, yDenom, lpSize);
719 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI ScaleViewportExtEx(_In_ HDC hdc, _In_ INT xNum, _In_ INT xDenom, _In_ INT yNum, _In_ INT yDenom, _Out_ LPSIZE lpSize)
Definition: coord.c:702
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:418
BOOL APIENTRY NtGdiScaleViewportExtEx(HDC hDC, int Xnum, int Xdenom, int Ynum, int Ydenom, LPSIZE pSize)
Definition: coord.c:664
HDC hdc
Definition: main.c:9

◆ ScaleWindowExtEx()

BOOL WINAPI ScaleWindowExtEx ( _In_ HDC  hdc,
_In_ INT  xNum,
_In_ INT  xDenom,
_In_ INT  yNum,
_In_ INT  yDenom,
_Out_ LPSIZE  lpSize 
)

Definition at line 726 of file coord.c.

733 {
734  HANDLE_METADC(BOOL, ScaleWindowExtEx, FALSE, hdc, xNum, xDenom, yNum, yDenom, lpSize);
735 
736  if (!GdiGetDcAttr(hdc))
737  {
739  return FALSE;
740  }
741 
742  return NtGdiScaleWindowExtEx(hdc, xNum, xDenom, yNum, yDenom, lpSize);
743 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI ScaleWindowExtEx(_In_ HDC hdc, _In_ INT xNum, _In_ INT xDenom, _In_ INT yNum, _In_ INT yDenom, _Out_ LPSIZE lpSize)
Definition: coord.c:726
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
BOOL APIENTRY NtGdiScaleWindowExtEx(HDC hDC, int Xnum, int Xdenom, int Ynum, int Ydenom, LPSIZE pSize)
Definition: coord.c:743
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9

◆ SetLayout()

DWORD WINAPI SetLayout ( _In_ HDC  hdc,
_In_ DWORD  dwLayout 
)

Definition at line 780 of file coord.c.

783 {
784  HANDLE_METADC(DWORD, SetLayout, GDI_ERROR, hdc, dwLayout);
785 
786  if (!GdiGetDcAttr(hdc))
787  {
789  return GDI_ERROR;
790  }
791 
792  return NtGdiSetLayout(hdc, -1, dwLayout);
793 }
DWORD WINAPI SetLayout(_In_ HDC hdc, _In_ DWORD dwLayout)
Definition: coord.c:780
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
DWORD APIENTRY NtGdiSetLayout(IN HDC hdc, IN LONG wox, IN DWORD dwLayout)
Definition: coord.c:1130
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
#define GDI_ERROR
Definition: wingdi.h:1308

Referenced by draw_graphics(), IntDrawState(), and PlayEnhMetaFileRecord().

◆ SetLayoutWidth()

DWORD WINAPI SetLayoutWidth ( _In_ HDC  hdc,
_In_ LONG  wox,
_In_ DWORD  dwLayout 
)

Definition at line 800 of file coord.c.

804 {
805  /* Only normal DCs are handled here */
807  {
808  return GDI_ERROR;
809  }
810 
811  if (!GdiGetDcAttr(hdc))
812  {
814  return GDI_ERROR;
815  }
816 
817  return NtGdiSetLayout(hdc, wox, dwLayout);
818 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
DWORD APIENTRY NtGdiSetLayout(IN HDC hdc, IN LONG wox, IN DWORD dwLayout)
Definition: coord.c:1130
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
#define GDI_ERROR
Definition: wingdi.h:1308

◆ SetMapMode()

INT WINAPI SetMapMode ( _In_ HDC  hdc,
_In_ INT  iMode 
)

Definition at line 136 of file coord.c.

139 {
140  PDC_ATTR pdcattr;
141 
142  /* Handle METADC16 here, since we don't have a DCATTR. */
144  {
145  return GetAndSetDCDWord(hdc, GdiGetSetMapMode, iMode, 0, 0, 0 );
146  }
147 
148  /* Get the DC attribute */
149  pdcattr = GdiGetDcAttr(hdc);
150  if (pdcattr == NULL)
151  {
153  return 0;
154  }
155 
156  /* Force change if Isotropic is set for recompute. */
157  if ((iMode != pdcattr->iMapMode) || (iMode == MM_ISOTROPIC))
158  {
159  pdcattr->ulDirty_ &= ~SLOW_WIDTHS;
160  return GetAndSetDCDWord(hdc, GdiGetSetMapMode, iMode, 0, 0, 0 );
161  }
162 
163  return pdcattr->iMapMode;
164 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ ULONG iMode
Definition: winddi.h:3520
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
INT iMapMode
Definition: ntgdihdl.h:342
smooth NULL
Definition: ftsmooth.c:416
ULONG ulDirty_
Definition: ntgdihdl.h:298
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
#define SLOW_WIDTHS
Definition: ntgdihdl.h:150
DWORD WINAPI GetAndSetDCDWord(_In_ HDC hdc, _In_ UINT u, _In_ DWORD dwIn, _In_ ULONG ulMFId, _In_ USHORT usMF16Id, _In_ DWORD dwError)
Definition: dc.c:735

◆ SetViewportExtEx()

BOOL WINAPI SetViewportExtEx ( _In_ HDC  hdc,
_In_ int  nXExtent,
_In_ int  nYExtent,
_Out_opt_ LPSIZE  lpSize 
)

Definition at line 465 of file coord.c.

470 {
471  PDC_ATTR pdcattr;
472 
473  HANDLE_METADC(BOOL, SetViewportExtEx, FALSE, hdc, nXExtent, nYExtent, lpSize);
474 
475  /* Get the DC attribute */
476  pdcattr = GdiGetDcAttr(hdc);
477  if (pdcattr == NULL)
478  {
480  return FALSE;
481  }
482 
483  /* Check if the caller wants the old extension */
484  if (lpSize)
485  {
486  /* Return the current viewport extension */
487  lpSize->cx = pdcattr->szlViewportExt.cx;
488  lpSize->cy = pdcattr->szlViewportExt.cy;
489  }
490 
491  /* Check for trivial case */
492  if ((pdcattr->szlViewportExt.cx == nXExtent) &&
493  (pdcattr->szlViewportExt.cy == nYExtent))
494  return TRUE;
495 
496  if (nXExtent == 0 || nYExtent == 0)
497  return TRUE;
498 
499  /* Only change viewport extension if we are in iso or aniso mode */
500  if ((pdcattr->iMapMode == MM_ISOTROPIC) ||
501  (pdcattr->iMapMode == MM_ANISOTROPIC))
502  {
503  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
504  {
505  if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
506  {
507  NtGdiFlush(); // Sync up pdcattr from Kernel space.
508  pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
509  }
510  }
511 
512  /* Set the new viewport extension */
513  pdcattr->szlViewportExt.cx = nXExtent;
514  pdcattr->szlViewportExt.cy = nYExtent;
515 
516  /* Handle right-to-left layout */
517  if (pdcattr->dwLayout & LAYOUT_RTL)
519 
520  /* Update xform flags */
522  }
523 
524  return TRUE;
525 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
INT iMapMode
Definition: ntgdihdl.h:342
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL APIENTRY NtGdiMirrorWindowOrg(IN HDC hdc)
Definition: coord.c:1178
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
ULONG ulDirty_
Definition: ntgdihdl.h:298
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
#define PAGE_EXTENTS_CHANGED
Definition: ntgdihdl.h:202
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
FLONG flXform
Definition: ntgdihdl.h:349
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:192
SIZEL szlViewportExt
Definition: ntgdihdl.h:348
DWORD dwLayout
Definition: ntgdihdl.h:343
BOOL WINAPI SetViewportExtEx(_In_ HDC hdc, _In_ int nXExtent, _In_ int nYExtent, _Out_opt_ LPSIZE lpSize)
Definition: coord.c:465
#define INVALIDATE_ATTRIBUTES
Definition: ntgdihdl.h:195
LONG cy
Definition: windef.h:335

Referenced by ClockWndProc(), DataCache_Draw(), DoTestEntry(), EnumEnhMetaFile(), OLEPictureImpl_Render(), PlayMetaFileFromClipboard(), PlayMetaFileRecord(), render_masked_bitmap(), SetSpecialDCState(), SetSpecialDCState2(), SetWinMetaFileBits(), START_TEST(), test_boundsrect(), test_ellipse(), test_emf_BitBlt(), test_ExtTextOutScale(), test_GdiAlphaBlend(), Test_GetClipBox(), test_mf_SaveDC(), Test_OffsetClipRgn(), test_outline_font(), test_rectangle(), test_roundrect(), test_SaveDC(), test_scroll_window(), Test_SetMapMode(), test_SetTextJustification(), test_SetViewportExt(), Test_SetWindowExtEx(), test_StretchBlt(), and test_world_transform().

◆ SetViewportOrgEx()

BOOL WINAPI SetViewportOrgEx ( _In_ HDC  hdc,
_In_ int  X,
_In_ int  Y,
_Out_opt_ LPPOINT  lpPoint 
)

Definition at line 655 of file coord.c.

660 {
661  PDC_ATTR pdcattr;
662 
663  HANDLE_METADC(BOOL, SetViewportOrgEx, FALSE, hdc, X, Y, lpPoint);
664 
665  /* Get the DC attribute */
666  pdcattr = GdiGetDcAttr(hdc);
667  if (!pdcattr)
668  {
669  /* Do not set LastError here! */
670  return FALSE;
671  }
673  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
674  {
675  if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
676  {
677  NtGdiFlush();
678  pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
679  }
680  }
682  if (lpPoint)
683  {
684  lpPoint->x = pdcattr->ptlViewportOrg.x;
685  lpPoint->y = pdcattr->ptlViewportOrg.y;
686  if (pdcattr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x;
687  }
689  if (pdcattr->dwLayout & LAYOUT_RTL) X = -X;
690  pdcattr->ptlViewportOrg.x = X;
691  pdcattr->ptlViewportOrg.y = Y;
692  return TRUE;
693 
694 // return NtGdiSetViewportOrgEx(hdc,X,Y,lpPoint);
695 }
POINTL ptlViewportOrg
Definition: ntgdihdl.h:347
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
#define Y(I)
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
LONG y
Definition: windef.h:330
#define PAGE_XLATE_CHANGED
Definition: ntgdihdl.h:201
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG ulDirty_
Definition: ntgdihdl.h:298
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
LONG x
Definition: windef.h:329
HDC hdc
Definition: main.c:9
FLONG flXform
Definition: ntgdihdl.h:349
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
#define WORLD_XFORM_CHANGED
Definition: ntgdihdl.h:203
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:192
DWORD dwLayout
Definition: ntgdihdl.h:343
BOOL WINAPI SetViewportOrgEx(_In_ HDC hdc, _In_ int X, _In_ int Y, _Out_opt_ LPPOINT lpPoint)
Definition: coord.c:655
#define X(b, s)

Referenced by ClockWndProc(), DataCache_Draw(), DIALOG_FilePrint(), DoTestEntry(), DrawNCPreview(), DrawThemeParentBackground(), EnumEnhMetaFile(), gdi_transform_acquire(), HEADER_CreateDragImage(), OLEPictureImpl_Render(), PlayMetaFileFromClipboard(), PlayMetaFileRecord(), render_masked_bitmap(), SetSpecialDCState(), SetSpecialDCState2(), test_boundsrect(), test_cliphrgn_transform(), test_clipping(), test_emf_BitBlt(), test_gethrgn(), test_hdc_caching(), test_mf_SaveDC(), test_SaveDC(), test_scroll_window(), and UXTHEME_DrawImageBackground().

◆ SetWindowExtEx()

BOOL WINAPI SetWindowExtEx ( _In_ HDC  hdc,
_In_ INT  nXExtent,
_In_ INT  nYExtent,
_Out_opt_ LPSIZE  lpSize 
)

Definition at line 584 of file coord.c.

589 {
590  PDC_ATTR pdcattr;
591 
592  HANDLE_METADC(BOOL, SetWindowExtEx, FALSE, hdc, nXExtent, nYExtent, lpSize);
593 
594  /* Get the DC attr */
595  pdcattr = GdiGetDcAttr(hdc);
596  if (!pdcattr)
597  {
598  /* Set the error value and return failure */
600  return FALSE;
601  }
602 
603  /* Check if the caller wants the old extension */
604  if (lpSize)
605  {
606  /* Return the current window extension */
607  lpSize->cx = pdcattr->szlWindowExt.cx;
608  lpSize->cy = pdcattr->szlWindowExt.cy;
609 
610  /* Handle right-to-left layout */
611  if (pdcattr->dwLayout & LAYOUT_RTL)
612  lpSize->cx = -lpSize->cx;
613  }
614 
615  if (pdcattr->dwLayout & LAYOUT_RTL)
616  {
619  }
620  else if ((pdcattr->iMapMode == MM_ISOTROPIC) ||
621  (pdcattr->iMapMode == MM_ANISOTROPIC))
622  {
623  if ((pdcattr->szlWindowExt.cx == nXExtent) &&
624  (pdcattr->szlWindowExt.cy == nYExtent))
625  return TRUE;
626 
627  if ((!nXExtent) || (!nYExtent))
628  return FALSE;
629 
630  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
631  {
632  if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
633  {
634  NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
635  pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
636  }
637  }
638 
639  pdcattr->szlWindowExt.cx = nXExtent;
640  pdcattr->szlWindowExt.cy = nYExtent;
641  if (pdcattr->dwLayout & LAYOUT_RTL)
643 
645  }
646 
647  return TRUE;
648 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
INT iMapMode
Definition: ntgdihdl.h:342
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL APIENTRY NtGdiMirrorWindowOrg(IN HDC hdc)
Definition: coord.c:1178
LONG cx
Definition: windef.h:334
ULONG ulDirty_
Definition: ntgdihdl.h:298
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
#define PAGE_EXTENTS_CHANGED
Definition: ntgdihdl.h:202
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
FLONG flXform
Definition: ntgdihdl.h:349
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
SIZEL szlWindowExt
Definition: ntgdihdl.h:346
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:192
BOOL WINAPI SetWindowExtEx(_In_ HDC hdc, _In_ INT nXExtent, _In_ INT nYExtent, _Out_opt_ LPSIZE lpSize)
Definition: coord.c:584
DWORD dwLayout
Definition: ntgdihdl.h:343
#define INVALIDATE_ATTRIBUTES
Definition: ntgdihdl.h:195
LONG cy
Definition: windef.h:335

◆ SetWindowOrgEx()

BOOL WINAPI SetWindowOrgEx ( _In_ HDC  hdc,
_In_ int  X,
_In_ int  Y,
_Out_opt_ LPPOINT  lpPoint 
)

Definition at line 532 of file coord.c.

537 {
538  PDC_ATTR pdcattr;
539 
540  HANDLE_METADC(BOOL, SetWindowOrgEx, FALSE, hdc, X, Y, lpPoint);
541 
542  /* Get the DC attribute */
543  pdcattr = GdiGetDcAttr(hdc);
544  if (pdcattr == NULL)
545  {
546  /* Do not set LastError here! */
547  return FALSE;
548  }
549 
550  if (lpPoint)
551  {
552  lpPoint->x = pdcattr->ptlWindowOrg.x;
553  lpPoint->y = pdcattr->ptlWindowOrg.y;
554  }
555 
556  if ((pdcattr->ptlWindowOrg.x == X) && (pdcattr->ptlWindowOrg.y == Y))
557  return TRUE;
558 
559  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
560  {
561  if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
562  {
563  NtGdiFlush(); // Sync up pdcattr from Kernel space.
564  pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
565  }
566  }
567 
568  pdcattr->ptlWindowOrg.x = X;
569  pdcattr->ptlWindowOrg.y = Y;
570 
571  pdcattr->lWindowOrgx = X;
572  if (pdcattr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc);
574  return TRUE;
575 
576 // return NtGdiSetWindowOrgEx(hdc, X, Y, lpPoint);
577 }
#define TRUE
Definition: types.h:120
#define LAYOUT_RTL
Definition: wingdi.h:1370
#define Y(I)
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
BOOL WINAPI SetWindowOrgEx(_In_ HDC hdc, _In_ int X, _In_ int Y, _Out_opt_ LPPOINT lpPoint)
Definition: coord.c:532
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
LONG y
Definition: windef.h:330
#define PAGE_XLATE_CHANGED
Definition: ntgdihdl.h:201
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL APIENTRY NtGdiMirrorWindowOrg(IN HDC hdc)
Definition: coord.c:1178
smooth NULL
Definition: ftsmooth.c:416
ULONG ulDirty_
Definition: ntgdihdl.h:298
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
LONG x
Definition: windef.h:329
LONG lWindowOrgx
Definition: ntgdihdl.h:344
HDC hdc
Definition: main.c:9
FLONG flXform
Definition: ntgdihdl.h:349
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
#define WORLD_XFORM_CHANGED
Definition: ntgdihdl.h:203
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DEVICE_TO_WORLD_INVALID
Definition: ntgdihdl.h:192
DWORD dwLayout
Definition: ntgdihdl.h:343
#define X(b, s)
POINTL ptlWindowOrg
Definition: ntgdihdl.h:345

Referenced by DoTestEntry(), EnumEnhMetaFile(), gdi_transform_acquire(), LISTBOX_DrawFocusRect(), LISTBOX_Paint(), LISTBOX_RepaintItem(), OleMetafilePictFromIconAndLabel(), OLEPictureImpl_Render(), CAddressBand::OnEraseBackground(), PAGER_EraseBackground(), PlayMetaFileRecord(), render_masked_bitmap(), set_window(), SetSpecialDCState(), SetSpecialDCState2(), test_emf_BitBlt(), test_GdiAlphaBlend(), test_GdipDrawImagePointsRectOnMemoryDC(), test_GdipFillRectanglesOnMemoryDCSolidBrush(), test_GdipFillRectanglesOnMemoryDCTextureBrush(), test_GdipGetVisibleClipBounds_memoryDC(), test_mf_SaveDC(), test_SaveDC(), TOOLBAR_EraseBackground(), and WndProc().

◆ SetWorldTransform()

BOOL WINAPI SetWorldTransform ( _In_ HDC  hdc,
_Out_ CONST XFORM pxform 
)

Definition at line 304 of file coord.c.

307 {
308  return ModifyWorldTransform(hdc, pxform, MWT_SET);
309 }
#define MWT_SET
Definition: ntgdityp.h:180
BOOL WINAPI ModifyWorldTransform(_In_ HDC hdc, _In_opt_ CONST XFORM *pxform, _In_ DWORD dwMode)
Definition: coord.c:314
HDC hdc
Definition: main.c:9

Referenced by ModifyWorldTransform().