gdi32: Properly manage the driver stack during DC creation and deletion.
[wine] / dlls / gdi32 / gdi_private.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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_GDI_PRIVATE_H
22 #define __WINE_GDI_PRIVATE_H
23
24 #include <math.h>
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29
30 /* Metafile defines */
31 #define META_EOF 0x0000
32 /* values of mtType in METAHEADER.  Note however that the disk image of a disk
33    based metafile has mtType == 1 */
34 #define METAFILE_MEMORY 1
35 #define METAFILE_DISK   2
36 #define MFHEADERSIZE (sizeof(METAHEADER))
37 #define MFVERSION 0x300
38
39 typedef struct {
40     EMR   emr;
41     INT   nBreakExtra;
42     INT   nBreakCount;
43 } EMRSETTEXTJUSTIFICATION, *PEMRSETTEXTJUSTIFICATION;
44
45 /* extra stock object: default 1x1 bitmap for memory DCs */
46 #define DEFAULT_BITMAP (STOCK_LAST+1)
47
48 struct gdi_obj_funcs
49 {
50     HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
51     INT     (*pGetObjectA)( HGDIOBJ handle, INT count, LPVOID buffer );
52     INT     (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer );
53     BOOL    (*pUnrealizeObject)( HGDIOBJ handle );
54     BOOL    (*pDeleteObject)( HGDIOBJ handle );
55 };
56
57 struct hdc_list
58 {
59     HDC hdc;
60     struct hdc_list *next;
61 };
62
63 typedef struct tagGDIOBJHDR
64 {
65     WORD        type;         /* object type (one of the OBJ_* constants) */
66     WORD        system : 1;   /* system object flag */
67     WORD        deleted : 1;  /* whether DeleteObject has been called on this object */
68     DWORD       selcount;     /* number of times the object is selected in a DC */
69     const struct gdi_obj_funcs *funcs;
70     struct hdc_list *hdcs;
71 } GDIOBJHDR;
72
73 /* Device functions for the Wine driver interface */
74
75 typedef struct gdi_physdev
76 {
77     const struct tagDC_FUNCS *funcs;
78     struct gdi_physdev       *next;
79     HDC                       hdc;
80 } *PHYSDEV;
81
82 typedef struct tagDC_FUNCS
83 {
84     INT      (CDECL *pAbortDoc)(PHYSDEV);
85     BOOL     (CDECL *pAbortPath)(PHYSDEV);
86     BOOL     (CDECL *pAlphaBlend)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,INT,INT,BLENDFUNCTION);
87     BOOL     (CDECL *pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
88     BOOL     (CDECL *pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
89     BOOL     (CDECL *pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
90     BOOL     (CDECL *pBeginPath)(PHYSDEV);
91     BOOL     (CDECL *pBitBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,DWORD);
92     INT      (CDECL *pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *);
93     BOOL     (CDECL *pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
94     BOOL     (CDECL *pCloseFigure)(PHYSDEV);
95     BOOL     (CDECL *pCreateBitmap)(PHYSDEV,HBITMAP,LPVOID);
96     BOOL     (CDECL *pCreateDC)(HDC,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*);
97     HBITMAP  (CDECL *pCreateDIBSection)(PHYSDEV,HBITMAP,const BITMAPINFO *,UINT);
98     BOOL     (CDECL *pDeleteBitmap)(HBITMAP);
99     BOOL     (CDECL *pDeleteDC)(PHYSDEV);
100     BOOL     (CDECL *pDeleteObject)(PHYSDEV,HGDIOBJ);
101     INT      (CDECL *pDescribePixelFormat)(PHYSDEV,INT,UINT,PIXELFORMATDESCRIPTOR *);
102     DWORD    (CDECL *pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
103     BOOL     (CDECL *pEllipse)(PHYSDEV,INT,INT,INT,INT);
104     INT      (CDECL *pEndDoc)(PHYSDEV);
105     INT      (CDECL *pEndPage)(PHYSDEV);
106     BOOL     (CDECL *pEndPath)(PHYSDEV);
107     BOOL     (CDECL *pEnumDeviceFonts)(PHYSDEV,LPLOGFONTW,FONTENUMPROCW,LPARAM);
108     INT      (CDECL *pEnumICMProfiles)(PHYSDEV,ICMENUMPROCW,LPARAM);
109     INT      (CDECL *pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
110     INT      (CDECL *pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
111     INT      (CDECL *pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
112     BOOL     (CDECL *pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
113     INT      (CDECL *pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
114     BOOL     (CDECL *pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
115     BOOL     (CDECL *pFillPath)(PHYSDEV);
116     BOOL     (CDECL *pFillRgn)(PHYSDEV,HRGN,HBRUSH);
117     BOOL     (CDECL *pFlattenPath)(PHYSDEV);
118     BOOL     (CDECL *pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
119     BOOL     (CDECL *pGdiComment)(PHYSDEV,UINT,CONST BYTE*);
120     LONG     (CDECL *pGetBitmapBits)(HBITMAP,void*,LONG);
121     BOOL     (CDECL *pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
122     INT      (CDECL *pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
123     INT      (CDECL *pGetDeviceCaps)(PHYSDEV,INT);
124     BOOL     (CDECL *pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
125     BOOL     (CDECL *pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR);
126     COLORREF (CDECL *pGetNearestColor)(PHYSDEV,COLORREF);
127     COLORREF (CDECL *pGetPixel)(PHYSDEV,INT,INT);
128     INT      (CDECL *pGetPixelFormat)(PHYSDEV);
129     UINT     (CDECL *pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
130     BOOL     (CDECL *pGetTextExtentExPoint)(PHYSDEV,LPCWSTR,INT,INT,LPINT,LPINT,LPSIZE);
131     BOOL     (CDECL *pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
132     INT      (CDECL *pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
133     BOOL     (CDECL *pInvertRgn)(PHYSDEV,HRGN);
134     BOOL     (CDECL *pLineTo)(PHYSDEV,INT,INT);
135     BOOL     (CDECL *pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD);
136     BOOL     (CDECL *pMoveTo)(PHYSDEV,INT,INT);
137     INT      (CDECL *pOffsetClipRgn)(PHYSDEV,INT,INT);
138     BOOL     (CDECL *pOffsetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
139     BOOL     (CDECL *pOffsetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
140     BOOL     (CDECL *pPaintRgn)(PHYSDEV,HRGN);
141     BOOL     (CDECL *pPatBlt)(PHYSDEV,INT,INT,INT,INT,DWORD);
142     BOOL     (CDECL *pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
143     BOOL     (CDECL *pPolyBezier)(PHYSDEV,const POINT*,DWORD);
144     BOOL     (CDECL *pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
145     BOOL     (CDECL *pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
146     BOOL     (CDECL *pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
147     BOOL     (CDECL *pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
148     BOOL     (CDECL *pPolygon)(PHYSDEV,const POINT*,INT);
149     BOOL     (CDECL *pPolyline)(PHYSDEV,const POINT*,INT);
150     BOOL     (CDECL *pPolylineTo)(PHYSDEV,const POINT*,INT);
151     UINT     (CDECL *pRealizeDefaultPalette)(PHYSDEV);
152     UINT     (CDECL *pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
153     BOOL     (CDECL *pRectangle)(PHYSDEV,INT,INT,INT,INT);
154     HDC      (CDECL *pResetDC)(PHYSDEV,const DEVMODEW*);
155     BOOL     (CDECL *pRestoreDC)(PHYSDEV,INT);
156     BOOL     (CDECL *pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
157     INT      (CDECL *pSaveDC)(PHYSDEV);
158     BOOL     (CDECL *pScaleViewportExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
159     BOOL     (CDECL *pScaleWindowExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
160     HBITMAP  (CDECL *pSelectBitmap)(PHYSDEV,HBITMAP);
161     HBRUSH   (CDECL *pSelectBrush)(PHYSDEV,HBRUSH);
162     BOOL     (CDECL *pSelectClipPath)(PHYSDEV,INT);
163     HFONT    (CDECL *pSelectFont)(PHYSDEV,HFONT,HANDLE);
164     HPALETTE (CDECL *pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
165     HPEN     (CDECL *pSelectPen)(PHYSDEV,HPEN);
166     INT      (CDECL *pSetArcDirection)(PHYSDEV,INT);
167     LONG     (CDECL *pSetBitmapBits)(HBITMAP,const void*,LONG);
168     COLORREF (CDECL *pSetBkColor)(PHYSDEV,COLORREF);
169     INT      (CDECL *pSetBkMode)(PHYSDEV,INT);
170     COLORREF (CDECL *pSetDCBrushColor)(PHYSDEV, COLORREF);
171     COLORREF (CDECL *pSetDCPenColor)(PHYSDEV, COLORREF);
172     UINT     (CDECL *pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
173     INT      (CDECL *pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
174     INT      (CDECL *pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
175                                            const BITMAPINFO*,UINT);
176     VOID     (CDECL *pSetDeviceClipping)(PHYSDEV,HRGN,HRGN);
177     BOOL     (CDECL *pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
178     DWORD    (CDECL *pSetLayout)(PHYSDEV,DWORD);
179     INT      (CDECL *pSetMapMode)(PHYSDEV,INT);
180     DWORD    (CDECL *pSetMapperFlags)(PHYSDEV,DWORD);
181     COLORREF (CDECL *pSetPixel)(PHYSDEV,INT,INT,COLORREF);
182     BOOL     (CDECL *pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
183     INT      (CDECL *pSetPolyFillMode)(PHYSDEV,INT);
184     INT      (CDECL *pSetROP2)(PHYSDEV,INT);
185     INT      (CDECL *pSetRelAbs)(PHYSDEV,INT);
186     INT      (CDECL *pSetStretchBltMode)(PHYSDEV,INT);
187     UINT     (CDECL *pSetTextAlign)(PHYSDEV,UINT);
188     INT      (CDECL *pSetTextCharacterExtra)(PHYSDEV,INT);
189     COLORREF (CDECL *pSetTextColor)(PHYSDEV,COLORREF);
190     BOOL     (CDECL *pSetTextJustification)(PHYSDEV,INT,INT);
191     BOOL     (CDECL *pSetViewportExtEx)(PHYSDEV,INT,INT,SIZE*);
192     BOOL     (CDECL *pSetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
193     BOOL     (CDECL *pSetWindowExtEx)(PHYSDEV,INT,INT,SIZE*);
194     BOOL     (CDECL *pSetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
195     BOOL     (CDECL *pSetWorldTransform)(PHYSDEV,const XFORM*);
196     INT      (CDECL *pStartDoc)(PHYSDEV,const DOCINFOW*);
197     INT      (CDECL *pStartPage)(PHYSDEV);
198     BOOL     (CDECL *pStretchBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,INT,INT,DWORD);
199     INT      (CDECL *pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void *,
200                                        const BITMAPINFO*,UINT,DWORD);
201     BOOL     (CDECL *pStrokeAndFillPath)(PHYSDEV);
202     BOOL     (CDECL *pStrokePath)(PHYSDEV);
203     BOOL     (CDECL *pSwapBuffers)(PHYSDEV);
204     BOOL     (CDECL *pUnrealizePalette)(HPALETTE);
205     BOOL     (CDECL *pWidenPath)(PHYSDEV);
206
207     /* OpenGL32 */
208     BOOL     (CDECL *pwglCopyContext)(HGLRC, HGLRC, UINT);
209     HGLRC    (CDECL *pwglCreateContext)(PHYSDEV);
210     HGLRC    (CDECL *pwglCreateContextAttribsARB)(PHYSDEV, HGLRC, const int*);
211     BOOL     (CDECL *pwglDeleteContext)(HGLRC);
212     PROC     (CDECL *pwglGetProcAddress)(LPCSTR);
213     HDC      (CDECL *pwglGetPbufferDCARB)(PHYSDEV, void*);
214     BOOL     (CDECL *pwglMakeCurrent)(PHYSDEV, HGLRC);
215     BOOL     (CDECL *pwglMakeContextCurrentARB)(PHYSDEV, PHYSDEV, HGLRC);
216     BOOL     (CDECL *pwglSetPixelFormatWINE)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
217     BOOL     (CDECL *pwglShareLists)(HGLRC hglrc1, HGLRC hglrc2);
218     BOOL     (CDECL *pwglUseFontBitmapsA)(PHYSDEV, DWORD, DWORD, DWORD);
219     BOOL     (CDECL *pwglUseFontBitmapsW)(PHYSDEV, DWORD, DWORD, DWORD);
220 } DC_FUNCTIONS;
221
222 /* It should not be necessary to access the contents of the GdiPath
223  * structure directly; if you find that the exported functions don't
224  * allow you to do what you want, then please place a new exported
225  * function that does this job in path.c.
226  */
227 typedef enum tagGdiPathState
228 {
229    PATH_Null,
230    PATH_Open,
231    PATH_Closed
232 } GdiPathState;
233
234 typedef struct tagGdiPath
235 {
236    GdiPathState state;
237    POINT      *pPoints;
238    BYTE         *pFlags;
239    int          numEntriesUsed, numEntriesAllocated;
240    BOOL       newStroke;
241 } GdiPath;
242
243 typedef struct tagGdiFont GdiFont;
244
245 typedef struct tagDC
246 {
247     GDIOBJHDR    header;
248     HDC          hSelf;            /* Handle to this DC */
249     struct gdi_physdev nulldrv;    /* physdev for the null driver */
250     const struct tagDC_FUNCS *funcs; /* DC function table */
251     PHYSDEV      physDev;         /* Physical device (driver-specific) */
252     DWORD        thread;          /* thread owning the DC */
253     LONG         refcount;        /* thread refcount */
254     LONG         dirty;           /* dirty flag */
255     INT          saveLevel;
256     struct tagDC *saved_dc;
257     DWORD_PTR    dwHookData;
258     DCHOOKPROC   hookProc;         /* DC hook */
259
260     INT          wndOrgX;          /* Window origin */
261     INT          wndOrgY;
262     INT          wndExtX;          /* Window extent */
263     INT          wndExtY;
264     INT          vportOrgX;        /* Viewport origin */
265     INT          vportOrgY;
266     INT          vportExtX;        /* Viewport extent */
267     INT          vportExtY;
268     SIZE         virtual_res;      /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
269     SIZE         virtual_size;     /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
270     RECT         vis_rect;         /* visible rectangle in screen coords */
271     FLOAT        miterLimit;
272
273     int           flags;
274     DWORD         layout;
275     HRGN          hClipRgn;      /* Clip region (may be 0) */
276     HRGN          hMetaRgn;      /* Meta region (may be 0) */
277     HRGN          hMetaClipRgn;  /* Intersection of meta and clip regions (may be 0) */
278     HRGN          hVisRgn;       /* Visible region (must never be 0) */
279     HPEN          hPen;
280     HBRUSH        hBrush;
281     HFONT         hFont;
282     HBITMAP       hBitmap;
283     HANDLE        hDevice;
284     HPALETTE      hPalette;
285
286     GdiFont      *gdiFont;
287     GdiPath       path;
288
289     UINT          font_code_page;
290     WORD          ROPmode;
291     WORD          polyFillMode;
292     WORD          stretchBltMode;
293     WORD          relAbsMode;
294     WORD          backgroundMode;
295     COLORREF      backgroundColor;
296     COLORREF      textColor;
297     COLORREF      dcBrushColor;
298     COLORREF      dcPenColor;
299     short         brushOrgX;
300     short         brushOrgY;
301
302     DWORD         mapperFlags;       /* Font mapper flags */
303     WORD          textAlign;         /* Text alignment from SetTextAlign() */
304     INT           charExtra;         /* Spacing from SetTextCharacterExtra() */
305     INT           breakExtra;        /* breakTotalExtra / breakCount */
306     INT           breakRem;          /* breakTotalExtra % breakCount */
307     INT           MapMode;
308     INT           GraphicsMode;      /* Graphics mode */
309     ABORTPROC     pAbortProc;        /* AbortProc for Printing */
310     INT           CursPosX;          /* Current position */
311     INT           CursPosY;
312     INT           ArcDirection;
313     XFORM         xformWorld2Wnd;    /* World-to-window transformation */
314     XFORM         xformWorld2Vport;  /* World-to-viewport transformation */
315     XFORM         xformVport2World;  /* Inverse of the above transformation */
316     BOOL          vport2WorldValid;  /* Is xformVport2World valid? */
317     RECT          BoundsRect;        /* Current bounding rect */
318 } DC;
319
320   /* DC flags */
321 #define DC_BOUNDS_ENABLE 0x0008   /* Bounding rectangle tracking is enabled */
322 #define DC_BOUNDS_SET    0x0010   /* Bounding rectangle has been set */
323
324 /* Certain functions will do no further processing if the driver returns this.
325    Used by mfdrv for example. */
326 #define GDI_NO_MORE_WORK 2
327
328 /* Rounds a floating point number to integer. The world-to-viewport
329  * transformation process is done in floating point internally. This function
330  * is then used to round these coordinates to integer values.
331  */
332 static inline INT GDI_ROUND(double val)
333 {
334    return (int)floor(val + 0.5);
335 }
336
337 /* bitmap object */
338
339 typedef struct tagBITMAPOBJ
340 {
341     GDIOBJHDR           header;
342     BITMAP              bitmap;
343     SIZE                size;   /* For SetBitmapDimension() */
344     const DC_FUNCTIONS *funcs; /* DC function table */
345     /* For device-independent bitmaps: */
346     DIBSECTION         *dib;
347     RGBQUAD            *color_table;  /* DIB color table if <= 8bpp */
348     UINT                nb_colors;    /* number of colors in table */
349 } BITMAPOBJ;
350
351 /* bidi.c */
352
353 /* Wine_GCPW Flags */
354 /* Directionality -
355  * LOOSE means taking the directionality of the first strong character, if there is found one.
356  * FORCE means the paragraph direction is forced. (RLE/LRE)
357  */
358 #define WINE_GCPW_FORCE_LTR 0
359 #define WINE_GCPW_FORCE_RTL 1
360 #define WINE_GCPW_LOOSE_LTR 2
361 #define WINE_GCPW_LOOSE_RTL 3
362 #define WINE_GCPW_DIR_MASK 3
363 #define WINE_GCPW_LOOSE_MASK 2
364
365 extern BOOL BIDI_Reorder( HDC hDC, LPCWSTR lpString, INT uCount, DWORD dwFlags, DWORD dwWineGCP_Flags,
366                           LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT* cGlyphs ) DECLSPEC_HIDDEN;
367
368 /* bitmap.c */
369 extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
370 extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) DECLSPEC_HIDDEN;
371 extern INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp ) DECLSPEC_HIDDEN;
372
373 /* clipping.c */
374 extern void CLIPPING_UpdateGCRegion( DC * dc ) DECLSPEC_HIDDEN;
375
376 /* dc.c */
377 extern DC *alloc_dc_ptr( WORD magic ) DECLSPEC_HIDDEN;
378 extern void free_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
379 extern DC *get_dc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
380 extern void release_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
381 extern void update_dc( DC *dc ) DECLSPEC_HIDDEN;
382 extern void push_dc_driver( DC * dc, PHYSDEV physdev, const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN;
383 extern void pop_dc_driver( DC * dc, PHYSDEV physdev ) DECLSPEC_HIDDEN;
384 extern void DC_InitDC( DC * dc ) DECLSPEC_HIDDEN;
385 extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
386
387 /* dib.c */
388 extern int DIB_GetDIBWidthBytes( int width, int depth ) DECLSPEC_HIDDEN;
389 extern int DIB_GetDIBImageBytes( int width, int height, int depth ) DECLSPEC_HIDDEN;
390 extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
391 extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
392                               LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size ) DECLSPEC_HIDDEN;
393
394 /* driver.c */
395 extern const DC_FUNCTIONS null_driver DECLSPEC_HIDDEN;
396 extern const DC_FUNCTIONS *DRIVER_get_display_driver(void) DECLSPEC_HIDDEN;
397 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) DECLSPEC_HIDDEN;
398 extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size ) DECLSPEC_HIDDEN;
399
400 static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
401 {
402     while (!((void **)dev->funcs)[offset / sizeof(void *)]) dev = dev->next;
403     return dev;
404 }
405
406 #define GET_DC_PHYSDEV(dc,func) get_physdev_entry_point( (dc)->physDev, FIELD_OFFSET(DC_FUNCTIONS,func))
407 #define GET_NEXT_PHYSDEV(dev,func) get_physdev_entry_point( (dev)->next, FIELD_OFFSET(DC_FUNCTIONS,func))
408
409 /* enhmetafile.c */
410 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ) DECLSPEC_HIDDEN;
411
412 /* freetype.c */
413
414 /* Undocumented structure filled in by GdiRealizationInfo */
415 typedef struct
416 {
417     DWORD flags;       /* 1 for bitmap fonts, 3 for scalable fonts */
418     DWORD cache_num;   /* keeps incrementing - num of fonts that have been created allowing for caching?? */
419     DWORD unknown2;    /* fixed for a given font - looks like it could be the order of the face in the font list or the order
420                           in which the face was first rendered. */
421 } realization_info_t;
422
423
424 extern INT WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
425 extern HANDLE WineEngAddFontMemResourceEx(PVOID, DWORD, PVOID, LPDWORD) DECLSPEC_HIDDEN;
426 extern GdiFont* WineEngCreateFontInstance(DC*, HFONT) DECLSPEC_HIDDEN;
427 extern BOOL WineEngDestroyFontInstance(HFONT handle) DECLSPEC_HIDDEN;
428 extern DWORD WineEngEnumFonts(LPLOGFONTW, FONTENUMPROCW, LPARAM) DECLSPEC_HIDDEN;
429 extern BOOL WineEngGetCharABCWidths(GdiFont *font, UINT firstChar,
430                                     UINT lastChar, LPABC buffer) DECLSPEC_HIDDEN;
431 extern BOOL WineEngGetCharABCWidthsFloat(GdiFont *font, UINT firstChar,
432                                          UINT lastChar, LPABCFLOAT buffer) DECLSPEC_HIDDEN;
433 extern BOOL WineEngGetCharABCWidthsI(GdiFont *font, UINT firstChar,
434                                     UINT count, LPWORD pgi, LPABC buffer) DECLSPEC_HIDDEN;
435 extern BOOL WineEngGetCharWidth(GdiFont*, UINT, UINT, LPINT) DECLSPEC_HIDDEN;
436 extern DWORD WineEngGetFontData(GdiFont*, DWORD, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN;
437 extern DWORD WineEngGetFontUnicodeRanges(GdiFont *, LPGLYPHSET) DECLSPEC_HIDDEN;
438 extern DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
439                                     LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN;
440 extern DWORD WineEngGetGlyphOutline(GdiFont*, UINT glyph, UINT format,
441                                     LPGLYPHMETRICS, DWORD buflen, LPVOID buf,
442                                     const MAT2*) DECLSPEC_HIDDEN;
443 extern DWORD WineEngGetKerningPairs(GdiFont*, DWORD, KERNINGPAIR *) DECLSPEC_HIDDEN;
444 extern BOOL WineEngGetLinkedHFont(DC *dc, WCHAR c, HFONT *new_hfont, UINT *glyph) DECLSPEC_HIDDEN;
445 extern UINT WineEngGetOutlineTextMetrics(GdiFont*, UINT, LPOUTLINETEXTMETRICW) DECLSPEC_HIDDEN;
446 extern UINT WineEngGetTextCharsetInfo(GdiFont *font, LPFONTSIGNATURE fs, DWORD flags) DECLSPEC_HIDDEN;
447 extern BOOL WineEngGetTextExtentExPoint(GdiFont*, LPCWSTR, INT, INT, LPINT, LPINT, LPSIZE) DECLSPEC_HIDDEN;
448 extern BOOL WineEngGetTextExtentExPointI(GdiFont*, const WORD *, INT, INT, LPINT, LPINT, LPSIZE) DECLSPEC_HIDDEN;
449 extern INT  WineEngGetTextFace(GdiFont*, INT, LPWSTR) DECLSPEC_HIDDEN;
450 extern BOOL WineEngGetTextMetrics(GdiFont*, LPTEXTMETRICW) DECLSPEC_HIDDEN;
451 extern BOOL WineEngFontIsLinked(GdiFont*) DECLSPEC_HIDDEN;
452 extern BOOL WineEngInit(void) DECLSPEC_HIDDEN;
453 extern BOOL WineEngRealizationInfo(GdiFont*, realization_info_t*) DECLSPEC_HIDDEN;
454 extern BOOL WineEngRemoveFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
455
456 /* gdiobj.c */
457 extern HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
458 extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
459 extern void *GDI_GetObjPtr( HGDIOBJ, WORD ) DECLSPEC_HIDDEN;
460 extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN;
461 extern void GDI_CheckNotLock(void) DECLSPEC_HIDDEN;
462 extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
463 extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
464 extern BOOL GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
465 extern BOOL GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
466
467 /* metafile.c */
468 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh) DECLSPEC_HIDDEN;
469 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCVOID filename, BOOL unicode ) DECLSPEC_HIDDEN;
470
471 /* path.c */
472
473 #define PATH_IsPathOpen(path) ((path).state==PATH_Open)
474 /* Returns TRUE if the specified path is in the open state, i.e. in the
475  * state where points will be added to the path, or FALSE otherwise. This
476  * function is implemented as a macro for performance reasons.
477  */
478
479 extern void PATH_InitGdiPath(GdiPath *pPath) DECLSPEC_HIDDEN;
480 extern void PATH_DestroyGdiPath(GdiPath *pPath) DECLSPEC_HIDDEN;
481 extern BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc) DECLSPEC_HIDDEN;
482
483 extern BOOL PATH_MoveTo(DC *dc) DECLSPEC_HIDDEN;
484 extern BOOL PATH_LineTo(DC *dc, INT x, INT y) DECLSPEC_HIDDEN;
485 extern BOOL PATH_Rectangle(DC *dc, INT x1, INT y1, INT x2, INT y2) DECLSPEC_HIDDEN;
486 extern BOOL PATH_ExtTextOut(DC *dc, INT x, INT y, UINT flags, const RECT *lprc,
487                             LPCWSTR str, UINT count, const INT *dx) DECLSPEC_HIDDEN;
488 extern BOOL PATH_Ellipse(DC *dc, INT x1, INT y1, INT x2, INT y2) DECLSPEC_HIDDEN;
489 extern BOOL PATH_Arc(DC *dc, INT x1, INT y1, INT x2, INT y2,
490                      INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines) DECLSPEC_HIDDEN;
491 extern BOOL PATH_PolyBezierTo(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
492 extern BOOL PATH_PolyBezier(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
493 extern BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types, DWORD cbCount) DECLSPEC_HIDDEN;
494 extern BOOL PATH_PolylineTo(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
495 extern BOOL PATH_Polyline(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
496 extern BOOL PATH_Polygon(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
497 extern BOOL PATH_PolyPolyline(DC *dc, const POINT *pt, const DWORD *counts, DWORD polylines) DECLSPEC_HIDDEN;
498 extern BOOL PATH_PolyPolygon(DC *dc, const POINT *pt, const INT *counts, UINT polygons) DECLSPEC_HIDDEN;
499 extern BOOL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height) DECLSPEC_HIDDEN;
500
501 /* painting.c */
502 extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut ) DECLSPEC_HIDDEN;
503
504 /* palette.c */
505 extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg);
506 extern UINT WINAPI GDIRealizePalette( HDC hdc );
507 extern HPALETTE PALETTE_Init(void) DECLSPEC_HIDDEN;
508
509 /* region.c */
510 extern INT mirror_region( HRGN dst, HRGN src, INT width ) DECLSPEC_HIDDEN;
511 extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y ) DECLSPEC_HIDDEN;
512
513 /* null driver entry points */
514 extern BOOL CDECL nulldrv_AbortPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
515 extern BOOL CDECL nulldrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT start, FLOAT sweep ) DECLSPEC_HIDDEN;
516 extern BOOL CDECL nulldrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
517 extern BOOL CDECL nulldrv_BeginPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
518 extern BOOL CDECL nulldrv_CloseFigure( PHYSDEV dev ) DECLSPEC_HIDDEN;
519 extern BOOL CDECL nulldrv_EndPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
520 extern INT  CDECL nulldrv_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
521 extern INT  CDECL nulldrv_ExtSelectClipRgn( PHYSDEV dev, HRGN rgn, INT mode ) DECLSPEC_HIDDEN;
522 extern BOOL CDECL nulldrv_FillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
523 extern BOOL CDECL nulldrv_FillRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush ) DECLSPEC_HIDDEN;
524 extern BOOL CDECL nulldrv_FlattenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
525 extern BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, INT height ) DECLSPEC_HIDDEN;
526 extern LONG CDECL nulldrv_GetBitmapBits( HBITMAP bitmap, void *bits, LONG size ) DECLSPEC_HIDDEN;
527 extern INT  CDECL nulldrv_GetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, LPVOID bits, BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
528 extern COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
529 extern INT  CDECL nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
530 extern BOOL CDECL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn ) DECLSPEC_HIDDEN;
531 extern BOOL CDECL nulldrv_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD mode ) DECLSPEC_HIDDEN;
532 extern INT  CDECL nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y ) DECLSPEC_HIDDEN;
533 extern BOOL CDECL nulldrv_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
534 extern BOOL CDECL nulldrv_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
535 extern BOOL CDECL nulldrv_PolyBezier( PHYSDEV dev, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
536 extern BOOL CDECL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
537 extern BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types, DWORD count ) DECLSPEC_HIDDEN;
538 extern BOOL CDECL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count ) DECLSPEC_HIDDEN;
539 extern BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN;
540 extern INT  CDECL nulldrv_SaveDC( PHYSDEV dev ) DECLSPEC_HIDDEN;
541 extern BOOL CDECL nulldrv_ScaleViewportExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN;
542 extern BOOL CDECL nulldrv_ScaleWindowExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN;
543 extern BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
544 extern LONG CDECL nulldrv_SetBitmapBits( HBITMAP bitmap, const void *bits, LONG size ) DECLSPEC_HIDDEN;
545 extern INT  CDECL nulldrv_SetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, const void *bits, const BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
546 extern INT  CDECL nulldrv_SetMapMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
547 extern BOOL CDECL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN;
548 extern BOOL CDECL nulldrv_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
549 extern BOOL CDECL nulldrv_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN;
550 extern BOOL CDECL nulldrv_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
551 extern BOOL CDECL nulldrv_SetWorldTransform( PHYSDEV dev, const XFORM *xform ) DECLSPEC_HIDDEN;
552 extern BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
553 extern BOOL CDECL nulldrv_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
554 extern BOOL CDECL nulldrv_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
555
556 static inline DC *get_nulldrv_dc( PHYSDEV dev )
557 {
558     return CONTAINING_RECORD( dev, DC, nulldrv );
559 }
560
561 /* Undocumented value for DIB's iUsage: Indicates a mono DIB w/o pal entries */
562 #define DIB_PAL_MONO 2
563
564 BOOL WINAPI FontIsLinked(HDC);
565
566 BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, DWORD horz_size, DWORD vert_size);
567
568 #endif /* __WINE_GDI_PRIVATE_H */