Better encapsulation of the font and metafile objects.
[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 struct gdi_obj_funcs
56 {
57     HGDIOBJ (*pSelectObject)( HGDIOBJ handle, void *obj, HDC hdc );
58     INT     (*pGetObject16)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
59     INT     (*pGetObjectA)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
60     INT     (*pGetObjectW)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
61     BOOL    (*pUnrealizeObject)( HGDIOBJ handle, void *obj );
62     BOOL    (*pDeleteObject)( HGDIOBJ handle, void *obj );
63 };
64
65 typedef struct tagGDIOBJHDR
66 {
67     HANDLE16    hNext;
68     WORD        wMagic;
69     DWORD       dwCount;
70     const struct gdi_obj_funcs *funcs;
71 } GDIOBJHDR;
72
73
74 typedef struct tagGdiFont *GdiFont;
75
76 typedef struct { int opaque; } *PHYSDEV;  /* PHYSDEV is an opaque pointer */
77
78 typedef struct tagDC
79 {
80     GDIOBJHDR    header;
81     HDC          hSelf;            /* Handle to this DC */
82     const struct tagDC_FUNCS *funcs; /* DC function table */
83     PHYSDEV      physDev;         /* Physical device (driver-specific) */
84     INT          saveLevel;
85     DWORD        dwHookData;
86     FARPROC16    hookProc;         /* the original SEGPTR ... */
87     DCHOOKPROC   hookThunk;        /* ... and the thunk to call it */
88
89     INT          wndOrgX;          /* Window origin */
90     INT          wndOrgY;
91     INT          wndExtX;          /* Window extent */
92     INT          wndExtY;
93     INT          vportOrgX;        /* Viewport origin */
94     INT          vportOrgY;
95     INT          vportExtX;        /* Viewport extent */
96     INT          vportExtY;
97
98     int           flags;
99     HRGN16        hClipRgn;     /* Clip region (may be 0) */
100     HRGN16        hVisRgn;      /* Visible region (must never be 0) */
101     HRGN16        hGCClipRgn;   /* GC clip region (ClipRgn AND VisRgn) */
102     HPEN16        hPen;
103     HBRUSH16      hBrush;
104     HFONT16       hFont;
105     HBITMAP16     hBitmap;
106     HANDLE16      hDevice;
107     HPALETTE16    hPalette;
108
109     GdiFont       gdiFont;
110     GdiPath       path;
111
112     WORD          ROPmode;
113     WORD          polyFillMode;
114     WORD          stretchBltMode;
115     WORD          relAbsMode;
116     WORD          backgroundMode;
117     COLORREF      backgroundColor;
118     COLORREF      textColor;
119     short         brushOrgX;
120     short         brushOrgY;
121
122     WORD          textAlign;         /* Text alignment from SetTextAlign() */
123     short         charExtra;         /* Spacing from SetTextCharacterExtra() */
124     short         breakTotalExtra;   /* Total extra space for justification */
125     short         breakCount;        /* Break char. count */
126     short         breakExtra;        /* breakTotalExtra / breakCount */
127     short         breakRem;          /* breakTotalExtra % breakCount */
128
129     RECT          totalExtent;
130     BYTE          bitsPerPixel;
131
132     INT           MapMode;
133     INT           GraphicsMode;      /* Graphics mode */
134     INT           DCOrgX;            /* DC origin */
135     INT           DCOrgY;
136     ABORTPROC     pAbortProc;        /* AbortProc for Printing */
137     ABORTPROC16   pAbortProc16;
138     INT           CursPosX;          /* Current position */
139     INT           CursPosY;
140     INT           ArcDirection;
141     XFORM         xformWorld2Wnd;    /* World-to-window transformation */
142     XFORM         xformWorld2Vport;  /* World-to-viewport transformation */
143     XFORM         xformVport2World;  /* Inverse of the above transformation */
144     BOOL          vport2WorldValid;  /* Is xformVport2World valid? */
145 } DC;
146
147 /* Device functions for the Wine driver interface */
148
149 typedef INT (*DEVICEFONTENUMPROC)(LPENUMLOGFONTEXW,LPNEWTEXTMETRICEXW,DWORD,
150                                   LPARAM);
151
152 typedef struct tagDC_FUNCS
153 {
154     INT      (*pAbortDoc)(PHYSDEV);
155     BOOL     (*pAbortPath)(PHYSDEV);
156     BOOL     (*pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
157     BOOL     (*pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
158     BOOL     (*pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
159     BOOL     (*pBeginPath)(PHYSDEV);
160     BOOL     (*pBitBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,DWORD);
161     INT      (*pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *);
162     BOOL     (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
163     BOOL     (*pCloseFigure)(PHYSDEV);
164     BOOL     (*pCreateBitmap)(PHYSDEV,HBITMAP);
165     BOOL     (*pCreateDC)(DC *,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*);
166     HBITMAP  (*pCreateDIBSection)(PHYSDEV,BITMAPINFO *,UINT,LPVOID *,HANDLE,DWORD,DWORD);
167     BOOL     (*pDeleteBitmap)(HBITMAP);
168     BOOL     (*pDeleteDC)(PHYSDEV);
169     INT      (*pDescribePixelFormat)(PHYSDEV,INT,UINT,PIXELFORMATDESCRIPTOR *);
170     DWORD    (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
171     BOOL     (*pEllipse)(PHYSDEV,INT,INT,INT,INT);
172     INT      (*pEndDoc)(PHYSDEV);
173     INT      (*pEndPage)(PHYSDEV);
174     BOOL     (*pEndPath)(PHYSDEV);
175     BOOL     (*pEnumDeviceFonts)(PHYSDEV,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
176     INT      (*pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
177     INT      (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
178     INT      (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
179     BOOL     (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
180     INT      (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
181     BOOL     (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
182     BOOL     (*pFillPath)(PHYSDEV);
183     BOOL     (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
184     BOOL     (*pFlattenPath)(PHYSDEV);
185     BOOL     (*pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
186     LONG     (*pGetBitmapBits)(HBITMAP,void*,LONG);
187     BOOL     (*pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
188     BOOL     (*pGetDCOrgEx)(PHYSDEV,LPPOINT);
189     UINT     (*pGetDIBColorTable)(PHYSDEV,UINT,UINT,RGBQUAD*);
190     INT      (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
191     INT      (*pGetDeviceCaps)(PHYSDEV,INT);
192     BOOL     (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
193     COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF);
194     COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
195     INT      (*pGetPixelFormat)(PHYSDEV);
196     UINT     (*pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
197     BOOL     (*pGetTextExtentPoint)(PHYSDEV,LPCWSTR,INT,LPSIZE);
198     BOOL     (*pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
199     INT      (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
200     BOOL     (*pInvertRgn)(PHYSDEV,HRGN);
201     BOOL     (*pLineTo)(PHYSDEV,INT,INT);
202     BOOL     (*pMoveTo)(PHYSDEV,INT,INT);
203     INT      (*pOffsetClipRgn)(PHYSDEV,INT,INT);
204     BOOL     (*pOffsetViewportOrg)(PHYSDEV,INT,INT);
205     BOOL     (*pOffsetWindowOrg)(PHYSDEV,INT,INT);
206     BOOL     (*pPaintRgn)(PHYSDEV,HRGN);
207     BOOL     (*pPatBlt)(PHYSDEV,INT,INT,INT,INT,DWORD);
208     BOOL     (*pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
209     BOOL     (*pPolyBezier)(PHYSDEV,const POINT*,DWORD);
210     BOOL     (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
211     BOOL     (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
212     BOOL     (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
213     BOOL     (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
214     BOOL     (*pPolygon)(PHYSDEV,const POINT*,INT);
215     BOOL     (*pPolyline)(PHYSDEV,const POINT*,INT);
216     BOOL     (*pPolylineTo)(PHYSDEV,const POINT*,INT);
217     UINT     (*pRealizeDefaultPalette)(PHYSDEV);
218     UINT     (*pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
219     BOOL     (*pRectangle)(PHYSDEV,INT,INT,INT,INT);
220     HDC      (*pResetDC)(PHYSDEV,const DEVMODEA*);
221     BOOL     (*pRestoreDC)(PHYSDEV,INT);
222     BOOL     (*pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
223     INT      (*pSaveDC)(PHYSDEV);
224     BOOL     (*pScaleViewportExt)(PHYSDEV,INT,INT,INT,INT);
225     BOOL     (*pScaleWindowExt)(PHYSDEV,INT,INT,INT,INT);
226     HBITMAP  (*pSelectBitmap)(PHYSDEV,HBITMAP);
227     HBRUSH   (*pSelectBrush)(PHYSDEV,HBRUSH);
228     BOOL     (*pSelectClipPath)(PHYSDEV,INT);
229     HFONT    (*pSelectFont)(PHYSDEV,HFONT);
230     HPALETTE (*pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
231     HPEN     (*pSelectPen)(PHYSDEV,HPEN);
232     LONG     (*pSetBitmapBits)(HBITMAP,const void*,LONG);
233     COLORREF (*pSetBkColor)(PHYSDEV,COLORREF);
234     INT      (*pSetBkMode)(PHYSDEV,INT);
235     UINT     (*pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
236     INT      (*pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
237     INT      (*pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
238                                    const BITMAPINFO*,UINT);
239     VOID     (*pSetDeviceClipping)(PHYSDEV,HRGN);
240     BOOL     (*pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
241     INT      (*pSetMapMode)(PHYSDEV,INT);
242     DWORD    (*pSetMapperFlags)(PHYSDEV,DWORD);
243     COLORREF (*pSetPixel)(PHYSDEV,INT,INT,COLORREF);
244     BOOL     (*pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
245     INT      (*pSetPolyFillMode)(PHYSDEV,INT);
246     INT      (*pSetROP2)(PHYSDEV,INT);
247     INT      (*pSetRelAbs)(PHYSDEV,INT);
248     INT      (*pSetStretchBltMode)(PHYSDEV,INT);
249     UINT     (*pSetTextAlign)(PHYSDEV,UINT);
250     INT      (*pSetTextCharacterExtra)(PHYSDEV,INT);
251     DWORD    (*pSetTextColor)(PHYSDEV,DWORD);
252     INT      (*pSetTextJustification)(PHYSDEV,INT,INT);
253     BOOL     (*pSetViewportExt)(PHYSDEV,INT,INT);
254     BOOL     (*pSetViewportOrg)(PHYSDEV,INT,INT);
255     BOOL     (*pSetWindowExt)(PHYSDEV,INT,INT);
256     BOOL     (*pSetWindowOrg)(PHYSDEV,INT,INT);
257     INT      (*pStartDoc)(PHYSDEV,const DOCINFOA*);
258     INT      (*pStartPage)(PHYSDEV);
259     BOOL     (*pStretchBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,INT,INT,DWORD);
260     INT      (*pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void *,
261                                const BITMAPINFO*,UINT,DWORD);
262     BOOL     (*pStrokeAndFillPath)(PHYSDEV);
263     BOOL     (*pStrokePath)(PHYSDEV);
264     BOOL     (*pSwapBuffers)(PHYSDEV);
265     BOOL     (*pWidenPath)(PHYSDEV);
266 } DC_FUNCTIONS;
267
268   /* DC hook codes */
269 #define DCHC_INVALIDVISRGN      0x0001
270 #define DCHC_DELETEDC           0x0002
271
272 #define DCHF_INVALIDATEVISRGN   0x0001
273 #define DCHF_VALIDATEVISRGN     0x0002
274
275   /* DC flags */
276 #define DC_MEMORY     0x0001   /* It is a memory DC */
277 #define DC_SAVED      0x0002   /* It is a saved DC */
278 #define DC_DIRTY      0x0004   /* hVisRgn has to be updated */
279 #define DC_THUNKHOOK  0x0008   /* DC hook is in the 16-bit code */
280
281 #define GDI_HEAP_SIZE 0xffe0
282
283 /* extra stock object: default 1x1 bitmap for memory DCs */
284 #define DEFAULT_BITMAP (STOCK_LAST+1)
285
286 /* Metafile defines */
287
288 #define META_EOF 0x0000
289 /* values of mtType in METAHEADER.  Note however that the disk image of a disk
290    based metafile has mtType == 1 */
291 #define METAFILE_MEMORY 1
292 #define METAFILE_DISK   2
293
294   /* Device <-> logical coords conversion */
295
296 /* A floating point version of the POINT structure */
297 typedef struct tagFLOAT_POINT
298 {
299    FLOAT x, y;
300 } FLOAT_POINT;
301
302 /* Rounds a floating point number to integer. The world-to-viewport
303  * transformation process is done in floating point internally. This function
304  * is then used to round these coordinates to integer values.
305  */
306 static inline INT WINE_UNUSED GDI_ROUND(FLOAT val)
307 {
308    return (int)floor(val + 0.5);
309 }
310
311 /* Performs a viewport-to-world transformation on the specified point (which
312  * is in floating point format). Returns TRUE if successful, else FALSE.
313  */
314 static inline BOOL WINE_UNUSED INTERNAL_DPTOLP_FLOAT(DC *dc, FLOAT_POINT *point)
315 {
316     FLOAT x, y;
317
318     /* Check that the viewport-to-world transformation is valid */
319     if (!dc->vport2WorldValid)
320         return FALSE;
321
322     /* Perform the transformation */
323     x = point->x;
324     y = point->y;
325     point->x = x * dc->xformVport2World.eM11 +
326                y * dc->xformVport2World.eM21 +
327                dc->xformVport2World.eDx;
328     point->y = x * dc->xformVport2World.eM12 +
329                y * dc->xformVport2World.eM22 +
330                dc->xformVport2World.eDy;
331
332     return TRUE;
333 }
334
335 /* Performs a viewport-to-world transformation on the specified point (which
336  * is in integer format). Returns TRUE if successful, else FALSE.
337  */
338 static inline BOOL WINE_UNUSED INTERNAL_DPTOLP(DC *dc, LPPOINT point)
339 {
340     FLOAT_POINT floatPoint;
341
342     /* Perform operation with floating point */
343     floatPoint.x=(FLOAT)point->x;
344     floatPoint.y=(FLOAT)point->y;
345     if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint))
346         return FALSE;
347
348     /* Round to integers */
349     point->x = GDI_ROUND(floatPoint.x);
350     point->y = GDI_ROUND(floatPoint.y);
351
352     return TRUE;
353 }
354
355 /* Performs a world-to-viewport transformation on the specified point (which
356  * is in floating point format).
357  */
358 static inline void WINE_UNUSED INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
359 {
360     FLOAT x, y;
361
362     /* Perform the transformation */
363     x = point->x;
364     y = point->y;
365     point->x = x * dc->xformWorld2Vport.eM11 +
366                y * dc->xformWorld2Vport.eM21 +
367                dc->xformWorld2Vport.eDx;
368     point->y = x * dc->xformWorld2Vport.eM12 +
369                y * dc->xformWorld2Vport.eM22 +
370                dc->xformWorld2Vport.eDy;
371 }
372
373 /* Performs a world-to-viewport transformation on the specified point (which
374  * is in integer format).
375  */
376 static inline void WINE_UNUSED INTERNAL_LPTODP(DC *dc, LPPOINT point)
377 {
378     FLOAT_POINT floatPoint;
379
380     /* Perform operation with floating point */
381     floatPoint.x=(FLOAT)point->x;
382     floatPoint.y=(FLOAT)point->y;
383     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
384
385     /* Round to integers */
386     point->x = GDI_ROUND(floatPoint.x);
387     point->y = GDI_ROUND(floatPoint.y);
388 }
389
390
391 /* Performs a world-to-viewport transformation on the specified point (which
392  * is in integer format).
393  */
394 static inline INT WINE_UNUSED INTERNAL_XWPTODP(DC *dc, INT x, INT y)
395 {
396     FLOAT_POINT floatPoint;
397
398     /* Perform operation with floating point */
399     floatPoint.x=(FLOAT)x;
400     floatPoint.y=(FLOAT)y;
401     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
402
403     /* Round to integers */
404     return GDI_ROUND(floatPoint.x);
405 }
406
407 /* Performs a world-to-viewport transformation on the specified point (which
408  * is in integer format).
409  */
410 static inline INT WINE_UNUSED INTERNAL_YWPTODP(DC *dc, INT x, INT y)
411 {
412     FLOAT_POINT floatPoint;
413
414     /* Perform operation with floating point */
415     floatPoint.x=(FLOAT)x;
416     floatPoint.y=(FLOAT)y;
417     INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
418
419     /* Round to integers */
420     return GDI_ROUND(floatPoint.y);
421 }
422
423
424 /* Performs a viewport-to-world transformation on the specified point (which
425  * is in integer format).
426  */
427 static inline INT WINE_UNUSED INTERNAL_XDPTOWP(DC *dc, INT x, INT y)
428 {
429     FLOAT_POINT floatPoint;
430
431     /* Perform operation with floating point */
432     floatPoint.x=(FLOAT)x;
433     floatPoint.y=(FLOAT)y;
434     INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
435
436     /* Round to integers */
437     return GDI_ROUND(floatPoint.x);
438 }
439
440 /* Performs a viewport-to-world transformation on the specified point (which
441  * is in integer format).
442  */
443 static inline INT WINE_UNUSED INTERNAL_YDPTOWP(DC *dc, INT x, INT y)
444 {
445     FLOAT_POINT floatPoint;
446
447     /* Perform operation with floating point */
448     floatPoint.x=(FLOAT)x;
449     floatPoint.y=(FLOAT)y;
450     INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
451
452     /* Round to integers */
453     return GDI_ROUND(floatPoint.y);
454 }
455
456
457 #define XDPTOLP(dc,x) \
458     (MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
459 #define YDPTOLP(dc,y) \
460     (MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
461 #define XLPTODP(dc,x) \
462     (MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
463 #define YLPTODP(dc,y) \
464     (MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
465
466
467
468   /* World -> Device size conversion */
469
470 /* Performs a world-to-viewport transformation on the specified width (which
471  * is in floating point format).
472  */
473 static inline void WINE_UNUSED INTERNAL_XWSTODS_FLOAT(DC *dc, FLOAT *width)
474 {
475     /* Perform the transformation */
476     *width = *width * dc->xformWorld2Vport.eM11;
477 }
478
479 /* Performs a world-to-viewport transformation on the specified width (which
480  * is in integer format).
481  */
482 static inline INT WINE_UNUSED INTERNAL_XWSTODS(DC *dc, INT width)
483 {
484     FLOAT floatWidth;
485
486     /* Perform operation with floating point */
487     floatWidth = (FLOAT)width;
488     INTERNAL_XWSTODS_FLOAT(dc, &floatWidth);
489
490     /* Round to integers */
491     return GDI_ROUND(floatWidth);
492 }
493
494
495 /* Performs a world-to-viewport transformation on the specified size (which
496  * is in floating point format).
497  */
498 static inline void WINE_UNUSED INTERNAL_YWSTODS_FLOAT(DC *dc, FLOAT *height)
499 {
500     /* Perform the transformation */
501     *height = *height * dc->xformWorld2Vport.eM22;
502 }
503
504 /* Performs a world-to-viewport transformation on the specified size (which
505  * is in integer format).
506  */
507 static inline INT WINE_UNUSED INTERNAL_YWSTODS(DC *dc, INT height)
508 {
509     FLOAT floatHeight;
510
511     /* Perform operation with floating point */
512     floatHeight = (FLOAT)height;
513     INTERNAL_YWSTODS_FLOAT(dc, &floatHeight);
514
515     /* Round to integers */
516     return GDI_ROUND(floatHeight);
517 }
518
519
520   /* Device -> World size conversion */
521
522 /* Performs a device to world transformation on the specified width (which
523  * is in floating point format).
524  */
525 static inline void INTERNAL_XDSTOWS_FLOAT(DC *dc, FLOAT *width)
526 {
527     /* Perform the transformation */
528     *width = *width * dc->xformVport2World.eM11;
529 }
530
531 /* Performs a device to world transformation on the specified width (which
532  * is in integer format).
533  */
534 static inline INT INTERNAL_XDSTOWS(DC *dc, INT width)
535 {
536     FLOAT floatWidth;
537
538     /* Perform operation with floating point */
539     floatWidth = (FLOAT)width;
540     INTERNAL_XDSTOWS_FLOAT(dc, &floatWidth);
541
542     /* Round to integers */
543     return GDI_ROUND(floatWidth);
544 }
545
546
547 /* Performs a device to world transformation on the specified size (which
548  * is in floating point format).
549  */
550 static inline void INTERNAL_YDSTOWS_FLOAT(DC *dc, FLOAT *height)
551 {
552     /* Perform the transformation */
553     *height = *height * dc->xformVport2World.eM22;
554 }
555
556 /* Performs a device to world transformation on the specified size (which
557  * is in integer format).
558  */
559 static inline INT INTERNAL_YDSTOWS(DC *dc, INT height)
560 {
561     FLOAT floatHeight;
562
563     /* Perform operation with floating point */
564     floatHeight = (FLOAT)height;
565     INTERNAL_YDSTOWS_FLOAT(dc, &floatHeight);
566
567     /* Round to integers */
568     return GDI_ROUND(floatHeight);
569 }
570
571
572   /* Device <-> logical size conversion */
573
574 #define XDSTOLS(dc,x) \
575     MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
576 #define YDSTOLS(dc,y) \
577     MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
578 #define XLSTODS(dc,x) \
579     MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
580 #define YLSTODS(dc,y) \
581     MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
582
583   /* GDI local heap */
584
585 extern BOOL GDI_Init(void);
586 extern void *GDI_AllocObject( WORD, WORD, HGDIOBJ *, const struct gdi_obj_funcs *funcs );
587 extern void *GDI_ReallocObject( WORD, HGDIOBJ, void *obj );
588 extern BOOL GDI_FreeObject( HGDIOBJ, void *obj );
589 extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
590 extern void GDI_ReleaseObj( HGDIOBJ );
591 extern void GDI_CheckNotLock(void);
592
593 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name );
594 extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs );
595 extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs );
596 extern BOOL DRIVER_GetDriverName( LPCSTR device, LPSTR driver, DWORD size );
597
598 extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut );
599
600 extern DC * DC_AllocDC( const DC_FUNCTIONS *funcs );
601 extern DC * DC_GetDCPtr( HDC hdc );
602 extern DC * DC_GetDCUpdate( HDC hdc );
603 extern void DC_InitDC( DC * dc );
604 extern void DC_UpdateXforms( DC * dc );
605
606 /* clipping.c */
607 extern void CLIPPING_UpdateGCRegion( DC * dc );
608
609 /* enhmetafile.c */
610 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk );
611
612 /* metafile.c */
613 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh);
614 extern HMETAFILE16 MF_Create_HMETAFILE16(METAHEADER *mh);
615 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename);
616
617 /* region.c */
618 extern HRGN REGION_CropRgn( HRGN hDst, HRGN hSrc, const RECT *lpRect, const POINT *lpPt );
619 extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y );
620
621 #define WINE_GGO_GRAY16_BITMAP 0x7f
622
623 #endif  /* __WINE_GDI_H */