1 #ifndef __WIN32K_FLOAT_H
2 #define __WIN32K_FLOAT_H
4 #include <win32k/math.h>
6 #include <freetype/freetype.h>
8 typedef struct tagFLOAT_POINT
13 /* Rounds a floating point number to integer. The world-to-viewport
14 * transformation process is done in floating point internally. This function
15 * is then used to round these coordinates to integer values.
17 static inline INT GDI_ROUND(FLOAT val)
19 return (int)floor(val + 0.5);
22 /* Performs a world-to-viewport transformation on the specified point (which
23 * is in floating point format).
25 static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
29 /* Perform the transformation */
32 point->x = x * dc->w.xformWorld2Vport.eM11 +
33 y * dc->w.xformWorld2Vport.eM21 +
34 dc->w.xformWorld2Vport.eDx;
35 point->y = x * dc->w.xformWorld2Vport.eM12 +
36 y * dc->w.xformWorld2Vport.eM22 +
37 dc->w.xformWorld2Vport.eDy;
40 /* Performs a viewport-to-world transformation on the specified point (which
41 * is in integer format). Returns TRUE if successful, else FALSE.
44 static inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point)
46 FLOAT_POINT floatPoint;
48 /* Perform operation with floating point */
49 floatPoint.x=(FLOAT)point->x;
50 floatPoint.y=(FLOAT)point->y;
51 if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint))
54 /* Round to integers */
55 point->x = GDI_ROUND(floatPoint.x);
56 point->y = GDI_ROUND(floatPoint.y);
61 /* Performs a world-to-viewport transformation on the specified point (which
62 * is in integer format).
64 static inline void INTERNAL_LPTODP(DC *dc, LPPOINT point)
66 FLOAT_POINT floatPoint;
68 /* Perform operation with floating point */
69 floatPoint.x=(FLOAT)point->x;
70 floatPoint.y=(FLOAT)point->y;
71 INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
73 /* Round to integers */
74 point->x = GDI_ROUND(floatPoint.x);
75 point->y = GDI_ROUND(floatPoint.y);
80 #define MulDiv( x, y, z ) EngMulDiv( x, y, z )
82 #define XDPTOLP(dc,x) \
83 (MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
84 #define YDPTOLP(dc,y) \
85 (MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
86 #define XLPTODP(dc,x) \
87 (MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
88 #define YLPTODP(dc,y) \
89 (MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
91 /* Device <-> logical size conversion */
93 #define XDSTOLS(dc,x) \
94 MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
95 #define YDSTOLS(dc,y) \
96 MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
97 #define XLSTODS(dc,x) \
98 MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
99 #define YLSTODS(dc,y) \
100 MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)