1 #ifndef __WIN32K_FLOAT_H
2 #define __WIN32K_FLOAT_H
4 #include <win32k/math.h>
9 typedef struct tagFLOAT_POINT
14 /* Rounds a floating point number to integer. The world-to-viewport
15 * transformation process is done in floating point internally. This function
16 * is then used to round these coordinates to integer values.
18 static __inline INT
GDI_ROUND(FLOAT val
)
20 return (int)floor(val
+ 0.5);
23 /* Performs a world-to-viewport transformation on the specified point (which
24 * is in floating point format).
26 static __inline
void INTERNAL_LPTODP_FLOAT(DC
*dc
, FLOAT_POINT
*point
)
30 /* Perform the transformation */
33 point
->x
= x
* dc
->w
.xformWorld2Vport
.eM11
+
34 y
* dc
->w
.xformWorld2Vport
.eM21
+
35 dc
->w
.xformWorld2Vport
.eDx
;
36 point
->y
= x
* dc
->w
.xformWorld2Vport
.eM12
+
37 y
* dc
->w
.xformWorld2Vport
.eM22
+
38 dc
->w
.xformWorld2Vport
.eDy
;
41 /* Performs a viewport-to-world transformation on the specified point (which
42 * is in integer format). Returns TRUE if successful, else FALSE.
45 static __inline BOOL
INTERNAL_DPTOLP(DC
*dc
, LPPOINT point
)
47 FLOAT_POINT floatPoint
;
49 /* Perform operation with floating point */
50 floatPoint
.x
=(FLOAT
)point
->x
;
51 floatPoint
.y
=(FLOAT
)point
->y
;
52 if (!INTERNAL_DPTOLP_FLOAT(dc
, &floatPoint
))
55 /* Round to integers */
56 point
->x
= GDI_ROUND(floatPoint
.x
);
57 point
->y
= GDI_ROUND(floatPoint
.y
);
62 /* Performs a world-to-viewport transformation on the specified point (which
63 * is in integer format).
65 static __inline
void INTERNAL_LPTODP(DC
*dc
, LPPOINT point
)
67 FLOAT_POINT floatPoint
;
69 /* Perform operation with floating point */
70 floatPoint
.x
=(FLOAT
)point
->x
;
71 floatPoint
.y
=(FLOAT
)point
->y
;
72 INTERNAL_LPTODP_FLOAT(dc
, &floatPoint
);
74 /* Round to integers */
75 point
->x
= GDI_ROUND(floatPoint
.x
);
76 point
->y
= GDI_ROUND(floatPoint
.y
);
81 #define MulDiv( x, y, z ) EngMulDiv( x, y, z )
83 #define XDPTOLP(dc,x) \
84 (MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
85 #define YDPTOLP(dc,y) \
86 (MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
87 #define XLPTODP(dc,x) \
88 (MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
89 #define YLPTODP(dc,y) \
90 (MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
92 /* Device <-> logical size conversion */
94 #define XDSTOLS(dc,x) \
95 MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
96 #define YDSTOLS(dc,y) \
97 MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
98 #define XLSTODS(dc,x) \
99 MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
100 #define YLSTODS(dc,y) \
101 MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)