RtlGenerate8dot3Name() is now "pass"ed
[reactos.git] / include / win32k / float.h
1 #ifndef __WIN32K_FLOAT_H
2 #define __WIN32K_FLOAT_H
3
4 #include <win32k/math.h>
5 #include <win32k/dc.h>
6 #include <freetype/freetype.h>
7
8 typedef struct tagFLOAT_POINT
9 {
10    FLOAT x, y;
11 } FLOAT_POINT;
12
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.
16  */
17 static inline INT GDI_ROUND(FLOAT val)
18 {
19    return (int)floor(val + 0.5);
20 }
21
22 /* Performs a world-to-viewport transformation on the specified point (which
23  * is in floating point format).
24  */
25 static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
26 {
27     FLOAT x, y;
28
29     /* Perform the transformation */
30     x = point->x;
31     y = point->y;
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;
38 }
39
40 /* Performs a viewport-to-world transformation on the specified point (which
41  * is in integer format). Returns TRUE if successful, else FALSE.
42  */
43 #if 0
44 static inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point)
45 {
46     FLOAT_POINT floatPoint;
47
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))
52         return FALSE;
53
54     /* Round to integers */
55     point->x = GDI_ROUND(floatPoint.x);
56     point->y = GDI_ROUND(floatPoint.y);
57
58     return TRUE;
59 }
60
61 /* Performs a world-to-viewport transformation on the specified point (which
62  * is in integer format).
63  */
64 static inline void INTERNAL_LPTODP(DC *dc, LPPOINT point)
65 {
66     FLOAT_POINT floatPoint;
67
68     /* Perform operation with floating point */
69     floatPoint.x=(FLOAT)point->x;
70     floatPoint.y=(FLOAT)point->y;
71     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
72
73     /* Round to integers */
74     point->x = GDI_ROUND(floatPoint.x);
75     point->y = GDI_ROUND(floatPoint.y);
76 }
77
78 #endif
79
80 #define MulDiv( x, y, z ) EngMulDiv( x, y, z )
81
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)
90
91   /* Device <-> logical size conversion */
92
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)
101
102 #endif