3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Coordinate systems
6 * FILE: subsys/win32k/objects/coord.c
10 /* INCLUDES ******************************************************************/
13 #include <ddk/ntddk.h>
14 #include <win32k/coord.h>
15 #include <win32k/dc.h>
18 #include <win32k/debug1.h>
20 /* FUNCTIONS *****************************************************************/
22 BOOL STDCALL W32kCombineTransform(LPXFORM XFormResult,
28 /* Check for illegal parameters */
29 if (!XFormResult || !xform1 || !xform2)
33 /* Create the result in a temporary XFORM, since xformResult may be
34 * equal to xform1 or xform2 */
35 xformTemp.eM11 = xform1->eM11 * xform2->eM11 + xform1->eM12 * xform2->eM21;
36 xformTemp.eM12 = xform1->eM11 * xform2->eM12 + xform1->eM12 * xform2->eM22;
37 xformTemp.eM21 = xform1->eM21 * xform2->eM11 + xform1->eM22 * xform2->eM21;
38 xformTemp.eM22 = xform1->eM21 * xform2->eM12 + xform1->eM22 * xform2->eM22;
39 xformTemp.eDx = xform1->eDx * xform2->eM11 + xform1->eDy * xform2->eM21 + xform2->eDx;
40 xformTemp.eDy = xform1->eDx * xform2->eM12 + xform1->eDy * xform2->eM22 + xform2->eDy;
42 /* Copy the result to xformResult */
43 *XFormResult = xformTemp;
49 CoordDPtoLP(PDC Dc, LPPOINT Point)
54 Point->x = x * Dc->w.xformVport2World.eM11 +
55 y * Dc->w.xformVport2World.eM21 + Dc->w.xformVport2World.eDx;
56 Point->y = x * Dc->w.xformVport2World.eM12 +
57 y * Dc->w.xformVport2World.eM22 + Dc->w.xformVport2World.eDy;
68 Dc = DC_HandleToPtr (hDC);
69 if (Dc == NULL || !Dc->w.vport2WorldValid)
74 for (i = 0; i < Count; i++)
76 CoordDPtoLP(Dc, &Points[i]);
84 W32kGetGraphicsMode(HDC hDC)
89 dc = DC_HandleToPtr (hDC);
95 GraphicsMode = dc->w.GraphicsMode;
102 W32kGetWorldTransform(HDC hDC,
107 dc = DC_HandleToPtr (hDC);
116 *XForm = dc->w.xformWorld2Wnd;
117 DC_ReleasePtr( hDC );
122 CoordLPtoDP(PDC Dc, LPPOINT Point)
127 Point->x = x * Dc->w.xformWorld2Vport.eM11 +
128 y * Dc->w.xformWorld2Vport.eM21 + Dc->w.xformWorld2Vport.eDx;
129 Point->y = x * Dc->w.xformWorld2Vport.eM12 +
130 y * Dc->w.xformWorld2Vport.eM22 + Dc->w.xformWorld2Vport.eDy;
134 W32kLPtoDP(HDC hDC, LPPOINT Points, INT Count)
139 Dc = DC_HandleToPtr (hDC);
145 for (i = 0; i < Count; i++)
147 CoordLPtoDP(Dc, &Points[i]);
149 DC_ReleasePtr( hDC );
155 W32kModifyWorldTransform(HDC hDC,
161 dc = DC_HandleToPtr (hDC);
164 // SetLastError( ERROR_INVALID_HANDLE );
172 /* Check that graphics mode is GM_ADVANCED */
173 if (dc->w.GraphicsMode!=GM_ADVANCED)
180 dc->w.xformWorld2Wnd.eM11 = 1.0f;
181 dc->w.xformWorld2Wnd.eM12 = 0.0f;
182 dc->w.xformWorld2Wnd.eM21 = 0.0f;
183 dc->w.xformWorld2Wnd.eM22 = 1.0f;
184 dc->w.xformWorld2Wnd.eDx = 0.0f;
185 dc->w.xformWorld2Wnd.eDy = 0.0f;
188 case MWT_LEFTMULTIPLY:
189 W32kCombineTransform(&dc->w.xformWorld2Wnd, XForm, &dc->w.xformWorld2Wnd );
192 case MWT_RIGHTMULTIPLY:
193 W32kCombineTransform(&dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd, XForm);
197 DC_ReleasePtr( hDC );
200 DC_UpdateXforms (dc);
201 DC_ReleasePtr( hDC );
207 W32kOffsetViewportOrgEx(HDC hDC,
217 W32kOffsetWindowOrgEx(HDC hDC,
227 W32kScaleViewportExtEx(HDC hDC,
239 W32kScaleWindowExtEx(HDC hDC,
251 W32kSetGraphicsMode(HDC hDC,
257 dc = DC_HandleToPtr (hDC);
263 /* One would think that setting the graphics mode to GM_COMPATIBLE
264 * would also reset the world transformation matrix to the unity
265 * matrix. However, in Windows, this is not the case. This doesn't
266 * make a lot of sense to me, but that's the way it is.
269 if ((Mode != GM_COMPATIBLE) && (Mode != GM_ADVANCED))
271 DC_ReleasePtr( hDC );
274 ret = dc->w.GraphicsMode;
275 dc->w.GraphicsMode = Mode;
276 DC_ReleasePtr( hDC );
282 W32kSetMapMode(HDC hDC,
290 W32kSetViewportExtEx(HDC hDC,
300 W32kSetViewportOrgEx(HDC hDC,
310 W32kSetWindowExtEx(HDC hDC,
320 W32kSetWindowOrgEx(HDC hDC,
330 W32kSetWorldTransform(HDC hDC,
335 dc = DC_HandleToPtr (hDC);
342 DC_ReleasePtr( hDC );
346 /* Check that graphics mode is GM_ADVANCED */
347 if (dc->w.GraphicsMode != GM_ADVANCED)
349 DC_ReleasePtr( hDC );
352 dc->w.xformWorld2Wnd = *XForm;
353 DC_UpdateXforms (dc);
354 DC_ReleasePtr( hDC );