Include winerror.h if in Winelib mode.
[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)(PHYSDEV,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     INT      (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
171     BOOL     (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
172     BOOL     (*pFillPath)(PHYSDEV);
173     BOOL     (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
174     BOOL     (*pFlattenPath)(PHYSDEV);
175     BOOL     (*pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
176     BOOL     (*pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
177     BOOL     (*pGetDCOrgEx)(PHYSDEV,LPPOINT);
178     UINT     (*pGetDIBColorTable)(PHYSDEV,UINT,UINT,RGBQUAD*);
179     INT      (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
180     INT      (*pGetDeviceCaps)(PHYSDEV,INT);
181     BOOL     (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
182     COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
183     INT      (*pGetPixelFormat)(PHYSDEV);
184     BOOL     (*pGetTextExtentPoint)(PHYSDEV,LPCWSTR,INT,LPSIZE);
185     BOOL     (*pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
186     INT      (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
187     BOOL     (*pInvertRgn)(PHYSDEV,HRGN);
188     BOOL     (*pLineTo)(PHYSDEV,INT,INT);
189     BOOL     (*pMoveTo)(PHYSDEV,INT,INT);
190     INT      (*pOffsetClipRgn)(PHYSDEV,INT,INT);
191     BOOL     (*pOffsetViewportOrg)(PHYSDEV,INT,INT);
192     BOOL     (*pOffsetWindowOrg)(PHYSDEV,INT,INT);
193     BOOL     (*pPaintRgn)(PHYSDEV,HRGN);
194     BOOL     (*pPatBlt)(PHYSDEV,INT,INT,INT,INT,DWORD);
195     BOOL     (*pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
196     BOOL     (*pPolyBezier)(PHYSDEV,const POINT*,DWORD);
197     BOOL     (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
198     BOOL     (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
199     BOOL     (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
200     BOOL     (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
201     BOOL     (*pPolygon)(PHYSDEV,const POINT*,INT);
202     BOOL     (*pPolyline)(PHYSDEV,const POINT*,INT);
203     BOOL     (*pPolylineTo)(PHYSDEV,const POINT*,INT);
204     UINT     (*pRealizePalette)(PHYSDEV);
205     BOOL     (*pRectangle)(PHYSDEV,INT,INT,INT,INT);
206     HDC      (*pResetDC)(PHYSDEV,const DEVMODEA*);
207     BOOL     (*pRestoreDC)(PHYSDEV,INT);
208     BOOL     (*pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
209     INT      (*pSaveDC)(PHYSDEV);
210     BOOL     (*pScaleViewportExt)(PHYSDEV,INT,INT,INT,INT);
211     BOOL     (*pScaleWindowExt)(PHYSDEV,INT,INT,INT,INT);
212     HBITMAP  (*pSelectBitmap)(PHYSDEV,HBITMAP);
213     HBRUSH   (*pSelectBrush)(PHYSDEV,HBRUSH);
214     BOOL     (*pSelectClipPath)(PHYSDEV,INT);
215     HFONT    (*pSelectFont)(PHYSDEV,HFONT);
216     HPALETTE (*pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
217     HPEN     (*pSelectPen)(PHYSDEV,HPEN);
218     COLORREF (*pSetBkColor)(PHYSDEV,COLORREF);
219     INT      (*pSetBkMode)(PHYSDEV,INT);
220     UINT     (*pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
221     INT      (*pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
222     INT      (*pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
223                                    const BITMAPINFO*,UINT);
224     VOID     (*pSetDeviceClipping)(PHYSDEV,HRGN);
225     BOOL     (*pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
226     INT      (*pSetMapMode)(PHYSDEV,INT);
227     DWORD    (*pSetMapperFlags)(PHYSDEV,DWORD);
228     COLORREF (*pSetPixel)(PHYSDEV,INT,INT,COLORREF);
229     BOOL     (*pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
230     INT      (*pSetPolyFillMode)(PHYSDEV,INT);
231     INT      (*pSetROP2)(PHYSDEV,INT);
232     INT      (*pSetRelAbs)(PHYSDEV,INT);
233     INT      (*pSetStretchBltMode)(PHYSDEV,INT);
234     UINT     (*pSetTextAlign)(PHYSDEV,UINT);
235     INT      (*pSetTextCharacterExtra)(PHYSDEV,INT);
236     DWORD    (*pSetTextColor)(PHYSDEV,DWORD);
237     INT      (*pSetTextJustification)(PHYSDEV,INT,INT);
238     BOOL     (*pSetViewportExt)(PHYSDEV,INT,INT);
239     BOOL     (*pSetViewportOrg)(PHYSDEV,INT,INT);
240     BOOL     (*pSetWindowExt)(PHYSDEV,INT,INT);
241     BOOL     (*pSetWindowOrg)(PHYSDEV,INT,INT);
242     INT      (*pStartDoc)(PHYSDEV,const DOCINFOA*);
243     INT      (*pStartPage)(PHYSDEV);
244     BOOL     (*pStretchBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,INT,INT,DWORD);
245     INT      (*pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void *,
246                                const BITMAPINFO*,UINT,DWORD);
247     BOOL     (*pStrokeAndFillPath)(PHYSDEV);
248     BOOL     (*pStrokePath)(PHYSDEV);
249     BOOL     (*pSwapBuffers)(PHYSDEV);
250     BOOL     (*pWidenPath)(PHYSDEV);
251 } DC_FUNCTIONS;
252
253   /* DC hook codes */
254 #define DCHC_INVALIDVISRGN      0x0001
255 #define DCHC_DELETEDC           0x0002
256
257 #define DCHF_INVALIDATEVISRGN   0x0001
258 #define DCHF_VALIDATEVISRGN     0x0002
259
260   /* DC flags */
261 #define DC_MEMORY     0x0001   /* It is a memory DC */
262 #define DC_SAVED      0x0002   /* It is a saved DC */
263 #define DC_DIRTY      0x0004   /* hVisRgn has to be updated */
264 #define DC_THUNKHOOK  0x0008   /* DC hook is in the 16-bit code */ 
265
266 #define GDI_HEAP_SIZE 0xffe0
267
268 /* extra stock object: default 1x1 bitmap for memory DCs */
269 #define DEFAULT_BITMAP (STOCK_LAST+1)
270
271   /* Device <-> logical coords conversion */
272
273 /* A floating point version of the POINT structure */
274 typedef struct tagFLOAT_POINT
275 {
276    FLOAT x, y;
277 } FLOAT_POINT;
278
279 /* Rounds a floating point number to integer. The world-to-viewport
280  * transformation process is done in floating point internally. This function
281  * is then used to round these coordinates to integer values.
282  */
283 static inline INT WINE_UNUSED GDI_ROUND(FLOAT val)
284 {
285    return (int)floor(val + 0.5);
286 }
287
288 /* Performs a viewport-to-world transformation on the specified point (which
289  * is in floating point format). Returns TRUE if successful, else FALSE.
290  */
291 static inline BOOL WINE_UNUSED INTERNAL_DPTOLP_FLOAT(DC *dc, FLOAT_POINT *point)
292 {
293     FLOAT x, y;
294     
295     /* Check that the viewport-to-world transformation is valid */
296     if (!dc->vport2WorldValid)
297         return FALSE;
298
299     /* Perform the transformation */
300     x = point->x;
301     y = point->y;
302     point->x = x * dc->xformVport2World.eM11 +
303                y * dc->xformVport2World.eM21 +
304                dc->xformVport2World.eDx;
305     point->y = x * dc->xformVport2World.eM12 +
306                y * dc->xformVport2World.eM22 +
307                dc->xformVport2World.eDy;
308
309     return TRUE;
310 }
311
312 /* Performs a viewport-to-world transformation on the specified point (which
313  * is in integer format). Returns TRUE if successful, else FALSE.
314  */
315 static inline BOOL WINE_UNUSED INTERNAL_DPTOLP(DC *dc, LPPOINT point)
316 {
317     FLOAT_POINT floatPoint;
318     
319     /* Perform operation with floating point */
320     floatPoint.x=(FLOAT)point->x;
321     floatPoint.y=(FLOAT)point->y;
322     if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint))
323         return FALSE;
324     
325     /* Round to integers */
326     point->x = GDI_ROUND(floatPoint.x);
327     point->y = GDI_ROUND(floatPoint.y);
328
329     return TRUE;
330 }
331
332 /* Performs a world-to-viewport transformation on the specified point (which
333  * is in floating point format).
334  */
335 static inline void WINE_UNUSED INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
336 {
337     FLOAT x, y;
338     
339     /* Perform the transformation */
340     x = point->x;
341     y = point->y;
342     point->x = x * dc->xformWorld2Vport.eM11 +
343                y * dc->xformWorld2Vport.eM21 +
344                dc->xformWorld2Vport.eDx;
345     point->y = x * dc->xformWorld2Vport.eM12 +
346                y * dc->xformWorld2Vport.eM22 +
347                dc->xformWorld2Vport.eDy;
348 }
349
350 /* Performs a world-to-viewport transformation on the specified point (which
351  * is in integer format).
352  */
353 static inline void WINE_UNUSED INTERNAL_LPTODP(DC *dc, LPPOINT point)
354 {
355     FLOAT_POINT floatPoint;
356     
357     /* Perform operation with floating point */
358     floatPoint.x=(FLOAT)point->x;
359     floatPoint.y=(FLOAT)point->y;
360     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
361     
362     /* Round to integers */
363     point->x = GDI_ROUND(floatPoint.x);
364     point->y = GDI_ROUND(floatPoint.y);
365 }
366
367
368 /* Performs a world-to-viewport transformation on the specified point (which
369  * is in integer format).
370  */
371 static inline INT WINE_UNUSED INTERNAL_XWPTODP(DC *dc, INT x, INT y)
372 {
373     FLOAT_POINT floatPoint;
374
375     /* Perform operation with floating point */
376     floatPoint.x=(FLOAT)x;
377     floatPoint.y=(FLOAT)y;
378     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
379
380     /* Round to integers */
381     return GDI_ROUND(floatPoint.x);
382 }
383
384 /* Performs a world-to-viewport transformation on the specified point (which
385  * is in integer format).
386  */
387 static inline INT WINE_UNUSED INTERNAL_YWPTODP(DC *dc, INT x, INT y)
388 {
389     FLOAT_POINT floatPoint;
390
391     /* Perform operation with floating point */
392     floatPoint.x=(FLOAT)x;
393     floatPoint.y=(FLOAT)y;
394     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
395
396     /* Round to integers */
397     return GDI_ROUND(floatPoint.y);
398 }
399
400
401 /* Performs a viewport-to-world transformation on the specified point (which
402  * is in integer format).
403  */
404 static inline INT WINE_UNUSED INTERNAL_XDPTOWP(DC *dc, INT x, INT y)
405 {
406     FLOAT_POINT floatPoint;
407
408     /* Perform operation with floating point */
409     floatPoint.x=(FLOAT)x;
410     floatPoint.y=(FLOAT)y;
411     INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
412
413     /* Round to integers */
414     return GDI_ROUND(floatPoint.x);
415 }
416
417 /* Performs a viewport-to-world transformation on the specified point (which
418  * is in integer format).
419  */
420 static inline INT WINE_UNUSED INTERNAL_YDPTOWP(DC *dc, INT x, INT y)
421 {
422     FLOAT_POINT floatPoint;
423
424     /* Perform operation with floating point */
425     floatPoint.x=(FLOAT)x;
426     floatPoint.y=(FLOAT)y;
427     INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
428
429     /* Round to integers */
430     return GDI_ROUND(floatPoint.y);
431 }
432
433
434 #define XDPTOLP(dc,x) \
435     (MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
436 #define YDPTOLP(dc,y) \
437     (MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
438 #define XLPTODP(dc,x) \
439     (MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
440 #define YLPTODP(dc,y) \
441     (MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
442
443
444
445   /* World -> Device size conversion */
446
447 /* Performs a world-to-viewport transformation on the specified width (which
448  * is in floating point format).
449  */
450 static inline void WINE_UNUSED INTERNAL_XWSTODS_FLOAT(DC *dc, FLOAT *width)
451 {
452     /* Perform the transformation */
453     *width = *width * dc->xformWorld2Vport.eM11;
454 }
455
456 /* Performs a world-to-viewport transformation on the specified width (which
457  * is in integer format).
458  */
459 static inline INT WINE_UNUSED INTERNAL_XWSTODS(DC *dc, INT width)
460 {
461     FLOAT floatWidth;
462
463     /* Perform operation with floating point */
464     floatWidth = (FLOAT)width;
465     INTERNAL_XWSTODS_FLOAT(dc, &floatWidth);
466
467     /* Round to integers */
468     return GDI_ROUND(floatWidth);
469 }
470
471
472 /* Performs a world-to-viewport transformation on the specified size (which
473  * is in floating point format).
474  */
475 static inline void WINE_UNUSED INTERNAL_YWSTODS_FLOAT(DC *dc, FLOAT *height)
476 {
477     /* Perform the transformation */
478     *height = *height * dc->xformWorld2Vport.eM22;
479 }
480
481 /* Performs a world-to-viewport transformation on the specified size (which
482  * is in integer format).
483  */
484 static inline INT WINE_UNUSED INTERNAL_YWSTODS(DC *dc, INT height)
485 {
486     FLOAT floatHeight;
487
488     /* Perform operation with floating point */
489     floatHeight = (FLOAT)height;
490     INTERNAL_YWSTODS_FLOAT(dc, &floatHeight);
491
492     /* Round to integers */
493     return GDI_ROUND(floatHeight);
494 }
495
496
497   /* Device -> World size conversion */
498
499 /* Performs a device to world transformation on the specified width (which
500  * is in floating point format).
501  */
502 static inline void INTERNAL_XDSTOWS_FLOAT(DC *dc, FLOAT *width)
503 {
504     /* Perform the transformation */
505     *width = *width * dc->xformVport2World.eM11;
506 }
507
508 /* Performs a device to world transformation on the specified width (which
509  * is in integer format).
510  */
511 static inline INT INTERNAL_XDSTOWS(DC *dc, INT width)
512 {
513     FLOAT floatWidth;
514
515     /* Perform operation with floating point */
516     floatWidth = (FLOAT)width;
517     INTERNAL_XDSTOWS_FLOAT(dc, &floatWidth);
518
519     /* Round to integers */
520     return GDI_ROUND(floatWidth);
521 }
522
523
524 /* Performs a device to world transformation on the specified size (which
525  * is in floating point format).
526  */
527 static inline void INTERNAL_YDSTOWS_FLOAT(DC *dc, FLOAT *height)
528 {
529     /* Perform the transformation */
530     *height = *height * dc->xformVport2World.eM22;
531 }
532
533 /* Performs a device to world transformation on the specified size (which
534  * is in integer format).
535  */
536 static inline INT INTERNAL_YDSTOWS(DC *dc, INT height)
537 {
538     FLOAT floatHeight;
539
540     /* Perform operation with floating point */
541     floatHeight = (FLOAT)height;
542     INTERNAL_YDSTOWS_FLOAT(dc, &floatHeight);
543
544     /* Round to integers */
545     return GDI_ROUND(floatHeight);
546 }
547
548
549   /* Device <-> logical size conversion */
550
551 #define XDSTOLS(dc,x) \
552     MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
553 #define YDSTOLS(dc,y) \
554     MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
555 #define XLSTODS(dc,x) \
556     MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
557 #define YLSTODS(dc,y) \
558     MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
559
560   /* GDI local heap */
561
562 extern BOOL GDI_Init(void);
563 extern void *GDI_AllocObject( WORD, WORD, HGDIOBJ * );
564 extern void *GDI_ReallocObject( WORD, HGDIOBJ, void *obj );
565 extern BOOL GDI_FreeObject( HGDIOBJ, void *obj );
566 extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
567 extern void GDI_ReleaseObj( HGDIOBJ );
568 extern void GDI_CheckNotLock(void);
569
570 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name );
571 extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs );
572 extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs );
573 extern BOOL DRIVER_GetDriverName( LPCSTR device, LPSTR driver, DWORD size );
574
575 extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut );
576
577 extern DC * DC_AllocDC( const DC_FUNCTIONS *funcs );
578 extern DC * DC_GetDCPtr( HDC hdc );
579 extern DC * DC_GetDCUpdate( HDC hdc );
580 extern void DC_InitDC( DC * dc );
581 extern void DC_UpdateXforms( DC * dc );
582
583
584 #define CLIP_INTERSECT 0x0001
585 #define CLIP_EXCLUDE   0x0002
586 #define CLIP_KEEPRGN   0x0004
587
588 /* objects/clipping.c */
589 INT CLIPPING_IntersectClipRect( DC * dc, INT left, INT top,
590                                 INT right, INT bottom, UINT flags );
591 INT CLIPPING_IntersectVisRect( DC * dc, INT left, INT top,
592                                INT right, INT bottom, BOOL exclude );
593 extern void CLIPPING_UpdateGCRegion( DC * dc );
594
595 /* objects/enhmetafile.c */
596 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk );
597
598 #define WINE_GGO_GRAY16_BITMAP 0x7f
599
600 #endif  /* __WINE_GDI_H */