[WIN32SS][NTGDI] Wrap IntLPtoDP and IntDPtoLP macros by do { .... } while (0)
[reactos.git] / win32ss / gdi / ntgdi / coord.h
1 #pragma once
2
3 /* Maximum extend of coordinate space */
4 #define MIN_COORD (INT_MIN / 16)
5 #define MAX_COORD (INT_MAX / 16)
6
7 #define IntLPtoDP(pdc, ppt, count) do { \
8 DC_vUpdateWorldToDevice(pdc); \
9 DC_vXformWorldToDevice(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt)); \
10 } while (0)
11 #define CoordLPtoDP(pdc, ppt) \
12 DC_vXformWorldToDevice(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
13 #define IntDPtoLP(pdc, ppt, count) do { \
14 DC_vUpdateDeviceToWorld(pdc); \
15 DC_vXformDeviceToWorld(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt)); \
16 } while (0)
17 #define CoordDPtoLP(pdc, ppt) \
18 DC_vXformDeviceToWorld(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
19
20 #define XForm2MatrixS(m, x) XFormToMatrix(m, (XFORML*)x)
21 #define MatrixS2XForm(x, m) MatrixToXForm((XFORML*)x, m)
22
23 FORCEINLINE
24 void
25 XFormToMatrix(
26 MATRIX *pmx,
27 const XFORML *pxform)
28 {
29 XFORMOBJ xo;
30 XFORMOBJ_vInit(&xo, pmx);
31 XFORMOBJ_iSetXform(&xo, pxform);
32 }
33
34 FORCEINLINE
35 void
36 MatrixToXForm(
37 XFORML *pxform,
38 const MATRIX *pmx)
39 {
40 XFORMOBJ xo;
41 XFORMOBJ_vInit(&xo, (MATRIX*)pmx);
42 XFORMOBJ_iGetXform(&xo, pxform);
43 }
44
45 FORCEINLINE
46 void
47 InvertXform(
48 XFORML *pxformDest,
49 const XFORML *pxformSource)
50 {
51 XFORMOBJ xo;
52 MATRIX mx;
53
54 XFORMOBJ_vInit(&xo, &mx);
55 XFORMOBJ_iSetXform(&xo, pxformSource);
56 XFORMOBJ_iInverse(&xo, &xo);
57 XFORMOBJ_iGetXform(&xo, pxformDest);
58 }
59
60 VOID
61 FASTCALL
62 DC_vFixIsotropicMapping(PDC pdc);
63
64 VOID
65 FASTCALL
66 DC_vUpdateWorldToDevice(PDC pdc);
67
68 VOID
69 FASTCALL
70 DC_vUpdateDeviceToWorld(PDC pdc);
71
72 FORCEINLINE
73 PSIZEL
74 DC_pszlViewportExt(PDC pdc)
75 {
76 PDC_ATTR pdcattr = pdc->pdcattr;
77
78 /* Check if we need isotropic fixup */
79 if ((pdcattr->flXform & PAGE_EXTENTS_CHANGED) &&
80 (pdcattr->iMapMode == MM_ISOTROPIC))
81 {
82 /* Fixup viewport extension */
83 DC_vFixIsotropicMapping(pdc);
84 }
85
86 return &pdcattr->szlViewportExt;
87 }
88
89 FORCEINLINE
90 PMATRIX
91 DC_pmxWorldToPage(PDC pdc)
92 {
93 return &pdc->pdcattr->mxWorldToPage;
94 }
95
96 FORCEINLINE
97 PMATRIX
98 DC_pmxWorldToDevice(PDC pdc)
99 {
100 /* Check if world or page xform was changed */
101 if (pdc->pdcattr->flXform & (PAGE_XLATE_CHANGED|PAGE_EXTENTS_CHANGED|WORLD_XFORM_CHANGED))
102 {
103 /* Update the world-to-device xform */
104 DC_vUpdateWorldToDevice(pdc);
105 }
106
107 return &pdc->pdcattr->mxWorldToDevice;
108 }
109
110 FORCEINLINE
111 PMATRIX
112 DC_pmxDeviceToWorld(PDC pdc)
113 {
114 /* Check if the device-to-world xform is invalid */
115 if (pdc->pdcattr->flXform & DEVICE_TO_WORLD_INVALID)
116 {
117 /* Update the world-to-device xform */
118 DC_vUpdateDeviceToWorld(pdc);
119 }
120
121 return &pdc->pdcattr->mxDeviceToWorld;
122 }
123
124 FORCEINLINE
125 VOID
126 DC_vXformDeviceToWorld(
127 IN PDC pdc,
128 IN ULONG cNumPoints,
129 OUT PPOINTL pptlDest,
130 IN PPOINTL pptlSource)
131 {
132 XFORMOBJ xo;
133 PMATRIX pmx;
134
135 pmx = DC_pmxDeviceToWorld(pdc);
136 if (!MX_IsInvertible(pmx))
137 return;
138
139 XFORMOBJ_vInit(&xo, pmx);
140 XFORMOBJ_bApplyXform(&xo, XF_LTOL, cNumPoints, pptlDest, pptlSource);
141 }
142
143 FORCEINLINE
144 VOID
145 DC_vXformWorldToDevice(
146 IN PDC pdc,
147 IN ULONG cNumPoints,
148 OUT PPOINTL pptlDest,
149 IN PPOINTL pptlSource)
150 {
151 XFORMOBJ xo;
152 PMATRIX pmx;
153
154 pmx = DC_pmxWorldToDevice(pdc);
155 XFORMOBJ_vInit(&xo, pmx);
156 XFORMOBJ_bApplyXform(&xo, XF_LTOL, cNumPoints, pptlDest, pptlSource);
157 }
158
159 BOOL
160 NTAPI
161 GreModifyWorldTransform(
162 PDC pdc,
163 const XFORML *pXForm,
164 DWORD dwMode);
165
166 VOID FASTCALL IntMirrorWindowOrg(PDC);
167 int APIENTRY IntGdiSetMapMode(PDC, int);
168 BOOL FASTCALL GreLPtoDP(HDC, LPPOINT, INT);
169 BOOL FASTCALL GreDPtoLP(HDC, LPPOINT, INT);
170 BOOL APIENTRY GreGetDCPoint(HDC,UINT,PPOINTL);
171 BOOL WINAPI GreGetWindowExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize);
172 BOOL WINAPI GreGetViewportExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize);
173 BOOL FASTCALL GreSetViewportOrgEx(HDC,int,int,LPPOINT);
174 BOOL WINAPI GreGetDCOrgEx(_In_ HDC, _Out_ PPOINTL, _Out_ PRECTL);
175 BOOL WINAPI GreSetDCOrg(_In_ HDC, _In_ LONG, _In_ LONG, _In_opt_ PRECTL);