- Add defines for the NMTBHOTITEM flag word.
[wine] / include / gdi.h
1 /*
2  * GDI definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_GDI_H
22 #define __WINE_GDI_H
23
24 #include "windef.h"
25 #include "wingdi.h"
26 #include "wine/wingdi16.h"
27 #include "path.h"
28 #include <math.h>
29
30   /* GDI objects magic numbers */
31 #define FIRST_MAGIC           0x4f47
32 #define PEN_MAGIC             0x4f47
33 #define BRUSH_MAGIC           0x4f48
34 #define FONT_MAGIC            0x4f49
35 #define PALETTE_MAGIC         0x4f4a
36 #define BITMAP_MAGIC          0x4f4b
37 #define REGION_MAGIC          0x4f4c
38 #define DC_MAGIC              0x4f4d
39 #define DISABLED_DC_MAGIC     0x4f4e
40 #define META_DC_MAGIC         0x4f4f
41 #define METAFILE_MAGIC        0x4f50
42 #define METAFILE_DC_MAGIC     0x4f51
43 #define ENHMETAFILE_MAGIC     0x4f52
44 #define ENHMETAFILE_DC_MAGIC  0x4f53
45 #define LAST_MAGIC            0x4f53
46
47 #define MAGIC_DONTCARE        0xffff
48
49 /* GDI constants for making objects private/system (naming undoc. !) */
50 #define OBJECT_PRIVATE        0x2000
51 #define OBJECT_NOSYSTEM       0x8000
52
53 #define GDIMAGIC(magic) ((magic) & ~(OBJECT_PRIVATE|OBJECT_NOSYSTEM))
54
55 typedef struct tagGDIOBJHDR
56 {
57     HANDLE16    hNext;
58     WORD        wMagic;
59     DWORD       dwCount;
60 } GDIOBJHDR;
61
62
63 typedef struct tagGdiFont *GdiFont;
64
65 typedef struct { int opaque; } *PHYSDEV;  /* PHYSDEV is an opaque pointer */
66
67 typedef struct tagDC
68 {
69     GDIOBJHDR    header;
70     HDC          hSelf;            /* Handle to this DC */
71     const struct tagDC_FUNCS *funcs; /* DC function table */
72     PHYSDEV      physDev;         /* Physical device (driver-specific) */
73     INT          saveLevel;
74     DWORD        dwHookData;
75     FARPROC16    hookProc;         /* the original SEGPTR ... */
76     DCHOOKPROC   hookThunk;        /* ... and the thunk to call it */
77
78     INT          wndOrgX;          /* Window origin */
79     INT          wndOrgY;
80     INT          wndExtX;          /* Window extent */
81     INT          wndExtY;
82     INT          vportOrgX;        /* Viewport origin */
83     INT          vportOrgY;
84     INT          vportExtX;        /* Viewport extent */
85     INT          vportExtY;
86
87     int           flags;
88     HRGN16        hClipRgn;     /* Clip region (may be 0) */
89     HRGN16        hVisRgn;      /* Visible region (must never be 0) */
90     HRGN16        hGCClipRgn;   /* GC clip region (ClipRgn AND VisRgn) */
91     HPEN16        hPen;
92     HBRUSH16      hBrush;
93     HFONT16       hFont;
94     HBITMAP16     hBitmap;
95     HANDLE16      hDevice;
96     HPALETTE16    hPalette;
97
98     GdiFont       gdiFont;
99     GdiPath       path;
100
101     WORD          ROPmode;
102     WORD          polyFillMode;
103     WORD          stretchBltMode;
104     WORD          relAbsMode;
105     WORD          backgroundMode;
106     COLORREF      backgroundColor;
107     COLORREF      textColor;
108     short         brushOrgX;
109     short         brushOrgY;
110
111     WORD          textAlign;         /* Text alignment from SetTextAlign() */
112     short         charExtra;         /* Spacing from SetTextCharacterExtra() */
113     short         breakTotalExtra;   /* Total extra space for justification */
114     short         breakCount;        /* Break char. count */
115     short         breakExtra;        /* breakTotalExtra / breakCount */
116     short         breakRem;          /* breakTotalExtra % breakCount */
117
118     RECT          totalExtent;
119     BYTE          bitsPerPixel;
120
121     INT           MapMode;
122     INT           GraphicsMode;      /* Graphics mode */
123     INT           DCOrgX;            /* DC origin */
124     INT           DCOrgY;
125     ABORTPROC     pAbortProc;        /* AbortProc for Printing */
126     ABORTPROC16   pAbortProc16;
127     INT           CursPosX;          /* Current position */
128     INT           CursPosY;
129     INT           ArcDirection;
130     XFORM         xformWorld2Wnd;    /* World-to-window transformation */
131     XFORM         xformWorld2Vport;  /* World-to-viewport transformation */
132     XFORM         xformVport2World;  /* Inverse of the above transformation */
133     BOOL          vport2WorldValid;  /* Is xformVport2World valid? */
134 } DC;
135
136 /* Device functions for the Wine driver interface */
137
138 typedef INT (*DEVICEFONTENUMPROC)(LPENUMLOGFONTEXW,LPNEWTEXTMETRICEXW,DWORD,
139                                   LPARAM);
140
141 typedef struct tagDC_FUNCS
142 {
143     INT      (*pAbortDoc)(PHYSDEV);
144     BOOL     (*pAbortPath)(PHYSDEV);
145     BOOL     (*pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
146     BOOL     (*pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
147     BOOL     (*pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
148     BOOL     (*pBeginPath)(PHYSDEV);
149     BOOL     (*pBitBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,DWORD);
150     LONG     (*pBitmapBits)(HBITMAP,void*,LONG,WORD);
151     INT      (*pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *);
152     BOOL     (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
153     BOOL     (*pCloseFigure)(PHYSDEV);
154     BOOL     (*pCreateBitmap)(HBITMAP);
155     BOOL     (*pCreateDC)(DC *,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*);
156     HBITMAP  (*pCreateDIBSection)(PHYSDEV,BITMAPINFO *,UINT,LPVOID *,HANDLE,DWORD,DWORD);
157     BOOL     (*pDeleteDC)(PHYSDEV);
158     BOOL     (*pDeleteObject)(HGDIOBJ);
159     INT      (*pDescribePixelFormat)(PHYSDEV,INT,UINT,PIXELFORMATDESCRIPTOR *);
160     DWORD    (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
161     BOOL     (*pEllipse)(PHYSDEV,INT,INT,INT,INT);
162     INT      (*pEndDoc)(PHYSDEV);
163     INT      (*pEndPage)(PHYSDEV);
164     BOOL     (*pEndPath)(PHYSDEV);
165     BOOL     (*pEnumDeviceFonts)(HDC,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
166     INT      (*pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
167     INT      (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
168     INT      (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
169     BOOL     (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
170     BOOL     (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
171     BOOL     (*pFillPath)(PHYSDEV);
172     BOOL     (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
173     BOOL     (*pFlattenPath)(PHYSDEV);
174     BOOL     (*pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
175     BOOL     (*pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
176     BOOL     (*pGetDCOrgEx)(PHYSDEV,LPPOINT);
177     UINT     (*pGetDIBColorTable)(PHYSDEV,UINT,UINT,RGBQUAD*);
178     INT      (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
179     INT      (*pGetDeviceCaps)(PHYSDEV,INT);
180     BOOL     (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
181     COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
182     INT      (*pGetPixelFormat)(PHYSDEV);
183     BOOL     (*pGetTextExtentPoint)(PHYSDEV,LPCWSTR,INT,LPSIZE);
184     BOOL     (*pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
185     INT      (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
186     BOOL     (*pInvertRgn)(PHYSDEV,HRGN);
187     BOOL     (*pLineTo)(PHYSDEV,INT,INT);
188     BOOL     (*pMoveTo)(PHYSDEV,INT,INT);
189     INT      (*pOffsetClipRgn)(PHYSDEV,INT,INT);
190     BOOL     (*pOffsetViewportOrg)(PHYSDEV,INT,INT);
191     BOOL     (*pOffsetWindowOrg)(PHYSDEV,INT,INT);
192     BOOL     (*pPaintRgn)(PHYSDEV,HRGN);
193     BOOL     (*pPatBlt)(PHYSDEV,INT,INT,INT,INT,DWORD);
194     BOOL     (*pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
195     BOOL     (*pPolyBezier)(PHYSDEV,const POINT*,DWORD);
196     BOOL     (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
197     BOOL     (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
198     BOOL     (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
199     BOOL     (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
200     BOOL     (*pPolygon)(PHYSDEV,const POINT*,INT);
201     BOOL     (*pPolyline)(PHYSDEV,const POINT*,INT);
202     BOOL     (*pPolylineTo)(PHYSDEV,const POINT*,INT);
203     UINT     (*pRealizePalette)(PHYSDEV);
204     BOOL     (*pRectangle)(PHYSDEV,INT,INT,INT,INT);
205     BOOL     (*pRestoreDC)(PHYSDEV,INT);
206     BOOL     (*pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
207     INT      (*pSaveDC)(PHYSDEV);
208     BOOL     (*pScaleViewportExt)(PHYSDEV,INT,INT,INT,INT);
209     BOOL     (*pScaleWindowExt)(PHYSDEV,INT,INT,INT,INT);
210     HBITMAP  (*pSelectBitmap)(PHYSDEV,HBITMAP);
211     HBRUSH   (*pSelectBrush)(PHYSDEV,HBRUSH);
212     BOOL     (*pSelectClipPath)(PHYSDEV,INT);
213     INT      (*pSelectClipRgn)(PHYSDEV,HRGN);
214     HFONT    (*pSelectFont)(PHYSDEV,HFONT);
215     HPALETTE (*pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
216     HPEN     (*pSelectPen)(PHYSDEV,HPEN);
217     COLORREF (*pSetBkColor)(PHYSDEV,COLORREF);
218     INT      (*pSetBkMode)(PHYSDEV,INT);
219     UINT     (*pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
220     INT      (*pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
221     INT      (*pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
222                                    const BITMAPINFO*,UINT);
223     VOID     (*pSetDeviceClipping)(PHYSDEV);
224     BOOL     (*pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
225     INT      (*pSetMapMode)(PHYSDEV,INT);
226     DWORD    (*pSetMapperFlags)(PHYSDEV,DWORD);
227     COLORREF (*pSetPixel)(PHYSDEV,INT,INT,COLORREF);
228     BOOL     (*pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
229     INT      (*pSetPolyFillMode)(PHYSDEV,INT);
230     INT      (*pSetROP2)(PHYSDEV,INT);
231     INT      (*pSetRelAbs)(PHYSDEV,INT);
232     INT      (*pSetStretchBltMode)(PHYSDEV,INT);
233     UINT     (*pSetTextAlign)(PHYSDEV,UINT);
234     INT      (*pSetTextCharacterExtra)(PHYSDEV,INT);
235     DWORD    (*pSetTextColor)(PHYSDEV,DWORD);
236     INT      (*pSetTextJustification)(PHYSDEV,INT,INT);
237     BOOL     (*pSetViewportExt)(PHYSDEV,INT,INT);
238     BOOL     (*pSetViewportOrg)(PHYSDEV,INT,INT);
239     BOOL     (*pSetWindowExt)(PHYSDEV,INT,INT);
240     BOOL     (*pSetWindowOrg)(PHYSDEV,INT,INT);
241     INT      (*pStartDoc)(PHYSDEV,const DOCINFOA*);
242     INT      (*pStartPage)(PHYSDEV);
243     BOOL     (*pStretchBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,INT,INT,DWORD);
244     INT      (*pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void *,
245                                const BITMAPINFO*,UINT,DWORD);
246     BOOL     (*pStrokeAndFillPath)(PHYSDEV);
247     BOOL     (*pStrokePath)(PHYSDEV);
248     BOOL     (*pSwapBuffers)(PHYSDEV);
249     BOOL     (*pWidenPath)(PHYSDEV);
250 } DC_FUNCTIONS;
251
252   /* DC hook codes */
253 #define DCHC_INVALIDVISRGN      0x0001
254 #define DCHC_DELETEDC           0x0002
255
256 #define DCHF_INVALIDATEVISRGN   0x0001
257 #define DCHF_VALIDATEVISRGN     0x0002
258
259   /* DC flags */
260 #define DC_MEMORY     0x0001   /* It is a memory DC */
261 #define DC_SAVED      0x0002   /* It is a saved DC */
262 #define DC_DIRTY      0x0004   /* hVisRgn has to be updated */
263 #define DC_THUNKHOOK  0x0008   /* DC hook is in the 16-bit code */ 
264
265 #define GDI_HEAP_SIZE 0xffe0
266
267 /* extra stock object: default 1x1 bitmap for memory DCs */
268 #define DEFAULT_BITMAP (STOCK_LAST+1)
269
270   /* Device <-> logical coords conversion */
271
272 /* A floating point version of the POINT structure */
273 typedef struct tagFLOAT_POINT
274 {
275    FLOAT x, y;
276 } FLOAT_POINT;
277
278 /* Rounds a floating point number to integer. The world-to-viewport
279  * transformation process is done in floating point internally. This function
280  * is then used to round these coordinates to integer values.
281  */
282 static inline INT WINE_UNUSED GDI_ROUND(FLOAT val)
283 {
284    return (int)floor(val + 0.5);
285 }
286
287 /* Performs a viewport-to-world transformation on the specified point (which
288  * is in floating point format). Returns TRUE if successful, else FALSE.
289  */
290 static inline BOOL WINE_UNUSED INTERNAL_DPTOLP_FLOAT(DC *dc, FLOAT_POINT *point)
291 {
292     FLOAT x, y;
293     
294     /* Check that the viewport-to-world transformation is valid */
295     if (!dc->vport2WorldValid)
296         return FALSE;
297
298     /* Perform the transformation */
299     x = point->x;
300     y = point->y;
301     point->x = x * dc->xformVport2World.eM11 +
302                y * dc->xformVport2World.eM21 +
303                dc->xformVport2World.eDx;
304     point->y = x * dc->xformVport2World.eM12 +
305                y * dc->xformVport2World.eM22 +
306                dc->xformVport2World.eDy;
307
308     return TRUE;
309 }
310
311 /* Performs a viewport-to-world transformation on the specified point (which
312  * is in integer format). Returns TRUE if successful, else FALSE.
313  */
314 static inline BOOL WINE_UNUSED INTERNAL_DPTOLP(DC *dc, LPPOINT point)
315 {
316     FLOAT_POINT floatPoint;
317     
318     /* Perform operation with floating point */
319     floatPoint.x=(FLOAT)point->x;
320     floatPoint.y=(FLOAT)point->y;
321     if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint))
322         return FALSE;
323     
324     /* Round to integers */
325     point->x = GDI_ROUND(floatPoint.x);
326     point->y = GDI_ROUND(floatPoint.y);
327
328     return TRUE;
329 }
330
331 /* Performs a world-to-viewport transformation on the specified point (which
332  * is in floating point format).
333  */
334 static inline void WINE_UNUSED INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
335 {
336     FLOAT x, y;
337     
338     /* Perform the transformation */
339     x = point->x;
340     y = point->y;
341     point->x = x * dc->xformWorld2Vport.eM11 +
342                y * dc->xformWorld2Vport.eM21 +
343                dc->xformWorld2Vport.eDx;
344     point->y = x * dc->xformWorld2Vport.eM12 +
345                y * dc->xformWorld2Vport.eM22 +
346                dc->xformWorld2Vport.eDy;
347 }
348
349 /* Performs a world-to-viewport transformation on the specified point (which
350  * is in integer format).
351  */
352 static inline void WINE_UNUSED INTERNAL_LPTODP(DC *dc, LPPOINT point)
353 {
354     FLOAT_POINT floatPoint;
355     
356     /* Perform operation with floating point */
357     floatPoint.x=(FLOAT)point->x;
358     floatPoint.y=(FLOAT)point->y;
359     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
360     
361     /* Round to integers */
362     point->x = GDI_ROUND(floatPoint.x);
363     point->y = GDI_ROUND(floatPoint.y);
364 }
365
366
367 /* Performs a world-to-viewport transformation on the specified point (which
368  * is in integer format).
369  */
370 static inline INT WINE_UNUSED INTERNAL_XWPTODP(DC *dc, INT x, INT y)
371 {
372     FLOAT_POINT floatPoint;
373
374     /* Perform operation with floating point */
375     floatPoint.x=(FLOAT)x;
376     floatPoint.y=(FLOAT)y;
377     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
378
379     /* Round to integers */
380     return GDI_ROUND(floatPoint.x);
381 }
382
383 /* Performs a world-to-viewport transformation on the specified point (which
384  * is in integer format).
385  */
386 static inline INT WINE_UNUSED INTERNAL_YWPTODP(DC *dc, INT x, INT y)
387 {
388     FLOAT_POINT floatPoint;
389
390     /* Perform operation with floating point */
391     floatPoint.x=(FLOAT)x;
392     floatPoint.y=(FLOAT)y;
393     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
394
395     /* Round to integers */
396     return GDI_ROUND(floatPoint.y);
397 }
398
399
400 /* Performs a viewport-to-world transformation on the specified point (which
401  * is in integer format).
402  */
403 static inline INT WINE_UNUSED INTERNAL_XDPTOWP(DC *dc, INT x, INT y)
404 {
405     FLOAT_POINT floatPoint;
406
407     /* Perform operation with floating point */
408     floatPoint.x=(FLOAT)x;
409     floatPoint.y=(FLOAT)y;
410     INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
411
412     /* Round to integers */
413     return GDI_ROUND(floatPoint.x);
414 }
415
416 /* Performs a viewport-to-world transformation on the specified point (which
417  * is in integer format).
418  */
419 static inline INT WINE_UNUSED INTERNAL_YDPTOWP(DC *dc, INT x, INT y)
420 {
421     FLOAT_POINT floatPoint;
422
423     /* Perform operation with floating point */
424     floatPoint.x=(FLOAT)x;
425     floatPoint.y=(FLOAT)y;
426     INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
427
428     /* Round to integers */
429     return GDI_ROUND(floatPoint.y);
430 }
431
432
433 #define XDPTOLP(dc,x) \
434     (MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
435 #define YDPTOLP(dc,y) \
436     (MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
437 #define XLPTODP(dc,x) \
438     (MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
439 #define YLPTODP(dc,y) \
440     (MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
441
442
443
444   /* World -> Device size conversion */
445
446 /* Performs a world-to-viewport transformation on the specified width (which
447  * is in floating point format).
448  */
449 static inline void WINE_UNUSED INTERNAL_XWSTODS_FLOAT(DC *dc, FLOAT *width)
450 {
451     /* Perform the transformation */
452     *width = *width * dc->xformWorld2Vport.eM11;
453 }
454
455 /* Performs a world-to-viewport transformation on the specified width (which
456  * is in integer format).
457  */
458 static inline INT WINE_UNUSED INTERNAL_XWSTODS(DC *dc, INT width)
459 {
460     FLOAT floatWidth;
461
462     /* Perform operation with floating point */
463     floatWidth = (FLOAT)width;
464     INTERNAL_XWSTODS_FLOAT(dc, &floatWidth);
465
466     /* Round to integers */
467     return GDI_ROUND(floatWidth);
468 }
469
470
471 /* Performs a world-to-viewport transformation on the specified size (which
472  * is in floating point format).
473  */
474 static inline void WINE_UNUSED INTERNAL_YWSTODS_FLOAT(DC *dc, FLOAT *height)
475 {
476     /* Perform the transformation */
477     *height = *height * dc->xformWorld2Vport.eM22;
478 }
479
480 /* Performs a world-to-viewport transformation on the specified size (which
481  * is in integer format).
482  */
483 static inline INT WINE_UNUSED INTERNAL_YWSTODS(DC *dc, INT height)
484 {
485     FLOAT floatHeight;
486
487     /* Perform operation with floating point */
488     floatHeight = (FLOAT)height;
489     INTERNAL_YWSTODS_FLOAT(dc, &floatHeight);
490
491     /* Round to integers */
492     return GDI_ROUND(floatHeight);
493 }
494
495
496   /* Device -> World size conversion */
497
498 /* Performs a device to world transformation on the specified width (which
499  * is in floating point format).
500  */
501 static inline void INTERNAL_XDSTOWS_FLOAT(DC *dc, FLOAT *width)
502 {
503     /* Perform the transformation */
504     *width = *width * dc->xformVport2World.eM11;
505 }
506
507 /* Performs a device to world transformation on the specified width (which
508  * is in integer format).
509  */
510 static inline INT INTERNAL_XDSTOWS(DC *dc, INT width)
511 {
512     FLOAT floatWidth;
513
514     /* Perform operation with floating point */
515     floatWidth = (FLOAT)width;
516     INTERNAL_XDSTOWS_FLOAT(dc, &floatWidth);
517
518     /* Round to integers */
519     return GDI_ROUND(floatWidth);
520 }
521
522
523 /* Performs a device to world transformation on the specified size (which
524  * is in floating point format).
525  */
526 static inline void INTERNAL_YDSTOWS_FLOAT(DC *dc, FLOAT *height)
527 {
528     /* Perform the transformation */
529     *height = *height * dc->xformVport2World.eM22;
530 }
531
532 /* Performs a device to world transformation on the specified size (which
533  * is in integer format).
534  */
535 static inline INT INTERNAL_YDSTOWS(DC *dc, INT height)
536 {
537     FLOAT floatHeight;
538
539     /* Perform operation with floating point */
540     floatHeight = (FLOAT)height;
541     INTERNAL_YDSTOWS_FLOAT(dc, &floatHeight);
542
543     /* Round to integers */
544     return GDI_ROUND(floatHeight);
545 }
546
547
548   /* Device <-> logical size conversion */
549
550 #define XDSTOLS(dc,x) \
551     MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
552 #define YDSTOLS(dc,y) \
553     MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
554 #define XLSTODS(dc,x) \
555     MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
556 #define YLSTODS(dc,y) \
557     MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
558
559   /* GDI local heap */
560
561 extern BOOL GDI_Init(void);
562 extern void *GDI_AllocObject( WORD, WORD, HGDIOBJ * );
563 extern void *GDI_ReallocObject( WORD, HGDIOBJ, void *obj );
564 extern BOOL GDI_FreeObject( HGDIOBJ, void *obj );
565 extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
566 extern void GDI_ReleaseObj( HGDIOBJ );
567 extern void GDI_CheckNotLock(void);
568
569 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name );
570 extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs );
571 extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs );
572 extern BOOL DRIVER_GetDriverName( LPCSTR device, LPSTR driver, DWORD size );
573
574 extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut );
575
576 extern DC * DC_AllocDC( const DC_FUNCTIONS *funcs );
577 extern DC * DC_GetDCPtr( HDC hdc );
578 extern DC * DC_GetDCUpdate( HDC hdc );
579 extern void DC_InitDC( DC * dc );
580 extern void DC_UpdateXforms( DC * dc );
581
582
583 #define CLIP_INTERSECT 0x0001
584 #define CLIP_EXCLUDE   0x0002
585 #define CLIP_KEEPRGN   0x0004
586
587 /* objects/clipping.c */
588 INT CLIPPING_IntersectClipRect( DC * dc, INT left, INT top,
589                                 INT right, INT bottom, UINT flags );
590 INT CLIPPING_IntersectVisRect( DC * dc, INT left, INT top,
591                                INT right, INT bottom, BOOL exclude );
592 extern void CLIPPING_UpdateGCRegion( DC * dc );
593
594 /* objects/enhmetafile.c */
595 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk );
596
597 #define WINE_GGO_GRAY16_BITMAP 0x7f
598
599 #endif  /* __WINE_GDI_H */