3 typedef struct tagFLOAT_POINT
8 /* Rounds a floating point number to integer. The world-to-viewport
9 * transformation process is done in floating point internally. This function
10 * is then used to round these coordinates to integer values.
12 static __inline INT
GDI_ROUND(FLOAT val
)
14 return (int)floor(val
+ 0.5);
18 /* FIXME: Do not use the fpu in kernel on x86, use FLOATOBJ_Xxx api instead
19 * Performs a world-to-viewport transformation on the specified point (which
20 * is in floating point format).
22 static __inline
void INTERNAL_LPTODP_FLOAT(DC
*dc
, FLOAT_POINT
*point
)
25 XFORM xformWorld2Vport
;
27 MatrixS2XForm(&xformWorld2Vport
, &dc
->pdcattr
->mxWorldToDevice
);
29 /* Perform the transformation */
32 point
->x
= x
* xformWorld2Vport
.eM11
+
33 y
* xformWorld2Vport
.eM21
+
36 point
->y
= x
* xformWorld2Vport
.eM12
+
37 y
* xformWorld2Vport
.eM22
+
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(pdcattr,tx) \
84 (MulDiv(((tx)-(pdcattr)->ptlViewportOrg.x), (pdcattr)->szlWindowExt.cx, (pdcattr)->szlViewportExt.cx) + (pdcattr)->ptlWindowOrg.x)
85 #define YDPTOLP(pdcattr,ty) \
86 (MulDiv(((ty)-(pdcattr)->ptlViewportOrg.y), (pdcattr)->szlWindowExt.cy, (pdcattr)->szlViewportExt.cy) + (pdcattr)->ptlWindowOrg.y)
87 #define XLPTODP(pdcattr,tx) \
88 (MulDiv(((tx)-(pdcattr)->ptlWindowOrg.x), (pdcattr)->szlViewportExt.cx, (pdcattr)->szlWindowExt.cx) + (pdcattr)->ptlViewportOrg.x)
89 #define YLPTODP(pdcattr,ty) \
90 (MulDiv(((ty)-(pdcattr)->ptlWindowOrg.y), (pdcattr)->szlViewportExt.cy, (pdcattr)->szlWindowExt.cy) + (pdcattr)->ptlViewportOrg.y)
92 /* Device <-> logical size conversion */
94 #define XDSTOLS(pdcattr,tx) \
95 MulDiv((tx), (pdcattr)->szlWindowExt.cx, (pdcattr)->szlViewportExt.cx)
96 #define YDSTOLS(DC_Attr,ty) \
97 MulDiv((ty), (pdcattr)->szlWindowExt.cy, (pdcattr)->szlViewportExt.cy)
98 #define XLSTODS(pdcattr,tx) \
99 MulDiv((tx), (pdcattr)->szlViewportExt.cx, (pdcattr)->szlWindowExt.cx)
100 #define YLSTODS(pdcattr,ty) \
101 MulDiv((ty), (pdcattr)->szlViewportExt.cy, (pdcattr)->szlWindowExt.cy)