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