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