reg: Use is_switch() where possible.
[wine.git] / include / wine / gdi_driver.h
blob124bb41f7d922ad7c5097bdfc9a9e06f335cdb02
1 /*
2 * Definitions for Wine GDI drivers
4 * Copyright 2011 Alexandre Julliard
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.
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.
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
21 #ifndef __WINE_WINE_GDI_DRIVER_H
22 #define __WINE_WINE_GDI_DRIVER_H
24 #include "winternl.h"
25 #include "ddk/d3dkmthk.h"
26 #include "wine/list.h"
28 struct gdi_dc_funcs;
29 struct opengl_funcs;
30 struct vulkan_funcs;
32 typedef struct gdi_physdev
34 const struct gdi_dc_funcs *funcs;
35 struct gdi_physdev *next;
36 HDC hdc;
37 } *PHYSDEV;
39 struct bitblt_coords
41 int log_x; /* original position and size, in logical coords */
42 int log_y;
43 int log_width;
44 int log_height;
45 int x; /* mapped position and size, in device coords */
46 int y;
47 int width;
48 int height;
49 RECT visrect; /* rectangle clipped to the visible part, in device coords */
50 DWORD layout; /* DC layout */
53 struct gdi_image_bits
55 void *ptr; /* pointer to the bits */
56 BOOL is_copy; /* whether this is a copy of the bits that can be modified */
57 void (CDECL *free)(struct gdi_image_bits *); /* callback for freeing the bits */
58 void *param; /* extra parameter for callback private use */
61 struct brush_pattern
63 BITMAPINFO *info; /* DIB info */
64 struct gdi_image_bits bits; /* DIB bits */
65 UINT usage; /* color usage for DIB info */
68 struct gdi_dc_funcs
70 INT (CDECL *pAbortDoc)(PHYSDEV);
71 BOOL (CDECL *pAbortPath)(PHYSDEV);
72 BOOL (CDECL *pAlphaBlend)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,BLENDFUNCTION);
73 BOOL (CDECL *pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
74 BOOL (CDECL *pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
75 BOOL (CDECL *pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
76 BOOL (CDECL *pBeginPath)(PHYSDEV);
77 DWORD (CDECL *pBlendImage)(PHYSDEV,BITMAPINFO*,const struct gdi_image_bits*,struct bitblt_coords*,struct bitblt_coords*,BLENDFUNCTION);
78 BOOL (CDECL *pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
79 BOOL (CDECL *pCloseFigure)(PHYSDEV);
80 BOOL (CDECL *pCreateCompatibleDC)(PHYSDEV,PHYSDEV*);
81 BOOL (CDECL *pCreateDC)(PHYSDEV*,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*);
82 BOOL (CDECL *pDeleteDC)(PHYSDEV);
83 BOOL (CDECL *pDeleteObject)(PHYSDEV,HGDIOBJ);
84 DWORD (CDECL *pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
85 BOOL (CDECL *pEllipse)(PHYSDEV,INT,INT,INT,INT);
86 INT (CDECL *pEndDoc)(PHYSDEV);
87 INT (CDECL *pEndPage)(PHYSDEV);
88 BOOL (CDECL *pEndPath)(PHYSDEV);
89 BOOL (CDECL *pEnumFonts)(PHYSDEV,LPLOGFONTW,FONTENUMPROCW,LPARAM);
90 INT (CDECL *pEnumICMProfiles)(PHYSDEV,ICMENUMPROCW,LPARAM);
91 INT (CDECL *pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
92 INT (CDECL *pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
93 INT (CDECL *pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
94 BOOL (CDECL *pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
95 INT (CDECL *pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
96 BOOL (CDECL *pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
97 BOOL (CDECL *pFillPath)(PHYSDEV);
98 BOOL (CDECL *pFillRgn)(PHYSDEV,HRGN,HBRUSH);
99 BOOL (CDECL *pFlattenPath)(PHYSDEV);
100 BOOL (CDECL *pFontIsLinked)(PHYSDEV);
101 BOOL (CDECL *pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
102 BOOL (CDECL *pGdiComment)(PHYSDEV,UINT,const BYTE*);
103 UINT (CDECL *pGetBoundsRect)(PHYSDEV,RECT*,UINT);
104 BOOL (CDECL *pGetCharABCWidths)(PHYSDEV,UINT,UINT,LPABC);
105 BOOL (CDECL *pGetCharABCWidthsI)(PHYSDEV,UINT,UINT,WORD*,LPABC);
106 BOOL (CDECL *pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
107 BOOL (CDECL *pGetCharWidthInfo)(PHYSDEV,void*);
108 INT (CDECL *pGetDeviceCaps)(PHYSDEV,INT);
109 BOOL (CDECL *pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
110 DWORD (CDECL *pGetFontData)(PHYSDEV,DWORD,DWORD,LPVOID,DWORD);
111 BOOL (CDECL *pGetFontRealizationInfo)(PHYSDEV,void*);
112 DWORD (CDECL *pGetFontUnicodeRanges)(PHYSDEV,LPGLYPHSET);
113 DWORD (CDECL *pGetGlyphIndices)(PHYSDEV,LPCWSTR,INT,LPWORD,DWORD);
114 DWORD (CDECL *pGetGlyphOutline)(PHYSDEV,UINT,UINT,LPGLYPHMETRICS,DWORD,LPVOID,const MAT2*);
115 BOOL (CDECL *pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR);
116 DWORD (CDECL *pGetImage)(PHYSDEV,BITMAPINFO*,struct gdi_image_bits*,struct bitblt_coords*);
117 DWORD (CDECL *pGetKerningPairs)(PHYSDEV,DWORD,LPKERNINGPAIR);
118 COLORREF (CDECL *pGetNearestColor)(PHYSDEV,COLORREF);
119 UINT (CDECL *pGetOutlineTextMetrics)(PHYSDEV,UINT,LPOUTLINETEXTMETRICW);
120 COLORREF (CDECL *pGetPixel)(PHYSDEV,INT,INT);
121 UINT (CDECL *pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
122 UINT (CDECL *pGetTextCharsetInfo)(PHYSDEV,LPFONTSIGNATURE,DWORD);
123 BOOL (CDECL *pGetTextExtentExPoint)(PHYSDEV,LPCWSTR,INT,LPINT);
124 BOOL (CDECL *pGetTextExtentExPointI)(PHYSDEV,const WORD*,INT,LPINT);
125 INT (CDECL *pGetTextFace)(PHYSDEV,INT,LPWSTR);
126 BOOL (CDECL *pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
127 BOOL (CDECL *pGradientFill)(PHYSDEV,TRIVERTEX*,ULONG,void*,ULONG,ULONG);
128 INT (CDECL *pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
129 BOOL (CDECL *pInvertRgn)(PHYSDEV,HRGN);
130 BOOL (CDECL *pLineTo)(PHYSDEV,INT,INT);
131 BOOL (CDECL *pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD);
132 BOOL (CDECL *pMoveTo)(PHYSDEV,INT,INT);
133 INT (CDECL *pOffsetClipRgn)(PHYSDEV,INT,INT);
134 BOOL (CDECL *pOffsetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
135 BOOL (CDECL *pOffsetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
136 BOOL (CDECL *pPaintRgn)(PHYSDEV,HRGN);
137 BOOL (CDECL *pPatBlt)(PHYSDEV,struct bitblt_coords*,DWORD);
138 BOOL (CDECL *pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
139 BOOL (CDECL *pPolyBezier)(PHYSDEV,const POINT*,DWORD);
140 BOOL (CDECL *pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
141 BOOL (CDECL *pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
142 BOOL (CDECL *pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
143 BOOL (CDECL *pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
144 BOOL (CDECL *pPolygon)(PHYSDEV,const POINT*,INT);
145 BOOL (CDECL *pPolyline)(PHYSDEV,const POINT*,INT);
146 BOOL (CDECL *pPolylineTo)(PHYSDEV,const POINT*,INT);
147 DWORD (CDECL *pPutImage)(PHYSDEV,HRGN,BITMAPINFO*,const struct gdi_image_bits*,struct bitblt_coords*,struct bitblt_coords*,DWORD);
148 UINT (CDECL *pRealizeDefaultPalette)(PHYSDEV);
149 UINT (CDECL *pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
150 BOOL (CDECL *pRectangle)(PHYSDEV,INT,INT,INT,INT);
151 HDC (CDECL *pResetDC)(PHYSDEV,const DEVMODEW*);
152 BOOL (CDECL *pRestoreDC)(PHYSDEV,INT);
153 BOOL (CDECL *pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
154 INT (CDECL *pSaveDC)(PHYSDEV);
155 BOOL (CDECL *pScaleViewportExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
156 BOOL (CDECL *pScaleWindowExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
157 HBITMAP (CDECL *pSelectBitmap)(PHYSDEV,HBITMAP);
158 HBRUSH (CDECL *pSelectBrush)(PHYSDEV,HBRUSH,const struct brush_pattern*);
159 BOOL (CDECL *pSelectClipPath)(PHYSDEV,INT);
160 HFONT (CDECL *pSelectFont)(PHYSDEV,HFONT,UINT*);
161 HPALETTE (CDECL *pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
162 HPEN (CDECL *pSelectPen)(PHYSDEV,HPEN,const struct brush_pattern*);
163 INT (CDECL *pSetArcDirection)(PHYSDEV,INT);
164 COLORREF (CDECL *pSetBkColor)(PHYSDEV,COLORREF);
165 INT (CDECL *pSetBkMode)(PHYSDEV,INT);
166 UINT (CDECL *pSetBoundsRect)(PHYSDEV,RECT*,UINT);
167 COLORREF (CDECL *pSetDCBrushColor)(PHYSDEV, COLORREF);
168 COLORREF (CDECL *pSetDCPenColor)(PHYSDEV, COLORREF);
169 INT (CDECL *pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,BITMAPINFO*,UINT);
170 VOID (CDECL *pSetDeviceClipping)(PHYSDEV,HRGN);
171 BOOL (CDECL *pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
172 DWORD (CDECL *pSetLayout)(PHYSDEV,DWORD);
173 INT (CDECL *pSetMapMode)(PHYSDEV,INT);
174 DWORD (CDECL *pSetMapperFlags)(PHYSDEV,DWORD);
175 COLORREF (CDECL *pSetPixel)(PHYSDEV,INT,INT,COLORREF);
176 INT (CDECL *pSetPolyFillMode)(PHYSDEV,INT);
177 INT (CDECL *pSetROP2)(PHYSDEV,INT);
178 INT (CDECL *pSetRelAbs)(PHYSDEV,INT);
179 INT (CDECL *pSetStretchBltMode)(PHYSDEV,INT);
180 UINT (CDECL *pSetTextAlign)(PHYSDEV,UINT);
181 INT (CDECL *pSetTextCharacterExtra)(PHYSDEV,INT);
182 COLORREF (CDECL *pSetTextColor)(PHYSDEV,COLORREF);
183 BOOL (CDECL *pSetTextJustification)(PHYSDEV,INT,INT);
184 BOOL (CDECL *pSetViewportExtEx)(PHYSDEV,INT,INT,SIZE*);
185 BOOL (CDECL *pSetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
186 BOOL (CDECL *pSetWindowExtEx)(PHYSDEV,INT,INT,SIZE*);
187 BOOL (CDECL *pSetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
188 BOOL (CDECL *pSetWorldTransform)(PHYSDEV,const XFORM*);
189 INT (CDECL *pStartDoc)(PHYSDEV,const DOCINFOW*);
190 INT (CDECL *pStartPage)(PHYSDEV);
191 BOOL (CDECL *pStretchBlt)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,DWORD);
192 INT (CDECL *pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void*,BITMAPINFO*,UINT,DWORD);
193 BOOL (CDECL *pStrokeAndFillPath)(PHYSDEV);
194 BOOL (CDECL *pStrokePath)(PHYSDEV);
195 BOOL (CDECL *pUnrealizePalette)(HPALETTE);
196 BOOL (CDECL *pWidenPath)(PHYSDEV);
197 NTSTATUS (CDECL *pD3DKMTCheckVidPnExclusiveOwnership)(const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *);
198 NTSTATUS (CDECL *pD3DKMTSetVidPnSourceOwner)(const D3DKMT_SETVIDPNSOURCEOWNER *);
199 struct opengl_funcs * (CDECL *wine_get_wgl_driver)(PHYSDEV,UINT);
200 const struct vulkan_funcs * (CDECL *wine_get_vulkan_driver)(PHYSDEV,UINT);
202 /* priority order for the driver on the stack */
203 UINT priority;
206 /* increment this when you change the DC function table */
207 #define WINE_GDI_DRIVER_VERSION 51
209 #define GDI_PRIORITY_NULL_DRV 0 /* null driver */
210 #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
211 #define GDI_PRIORITY_GRAPHICS_DRV 200 /* any graphics driver */
212 #define GDI_PRIORITY_DIB_DRV 300 /* the DIB driver */
213 #define GDI_PRIORITY_PATH_DRV 400 /* the path driver */
215 static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
217 while (!((void **)dev->funcs)[offset / sizeof(void *)]) dev = dev->next;
218 return dev;
221 #define GET_NEXT_PHYSDEV(dev,func) \
222 get_physdev_entry_point( (dev)->next, FIELD_OFFSET(struct gdi_dc_funcs,func))
224 static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs )
226 while ((*dev)->funcs->priority > funcs->priority) dev = &(*dev)->next;
227 physdev->funcs = funcs;
228 physdev->next = *dev;
229 physdev->hdc = (*dev)->hdc;
230 *dev = physdev;
233 /* support for window surfaces */
235 struct window_surface;
237 struct window_surface_funcs
239 void (CDECL *lock)( struct window_surface *surface );
240 void (CDECL *unlock)( struct window_surface *surface );
241 void* (CDECL *get_info)( struct window_surface *surface, BITMAPINFO *info );
242 RECT* (CDECL *get_bounds)( struct window_surface *surface );
243 void (CDECL *set_region)( struct window_surface *surface, HRGN region );
244 void (CDECL *flush)( struct window_surface *surface );
245 void (CDECL *destroy)( struct window_surface *surface );
248 struct window_surface
250 const struct window_surface_funcs *funcs; /* driver-specific implementations */
251 struct list entry; /* entry in global list managed by user32 */
252 LONG ref; /* reference count */
253 RECT rect; /* constant, no locking needed */
254 /* driver-specific fields here */
257 static inline ULONG window_surface_add_ref( struct window_surface *surface )
259 return InterlockedIncrement( &surface->ref );
262 static inline ULONG window_surface_release( struct window_surface *surface )
264 ULONG ret = InterlockedDecrement( &surface->ref );
265 if (!ret) surface->funcs->destroy( surface );
266 return ret;
269 /* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */
271 #define DCHC_INVALIDVISRGN 0x0001
272 #define DCHC_DELETEDC 0x0002
273 #define DCHF_INVALIDATEVISRGN 0x0001
274 #define DCHF_VALIDATEVISRGN 0x0002
275 #define DCHF_RESETDC 0x0004 /* Wine extension */
276 #define DCHF_DISABLEDC 0x0008 /* Wine extension */
277 #define DCHF_ENABLEDC 0x0010 /* Wine extension */
279 typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM);
281 WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*);
282 WINGDIAPI BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR);
283 WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD);
285 extern void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
286 extern void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect,
287 const RECT *device_rect, struct window_surface *surface );
288 extern void CDECL __wine_set_display_driver( HMODULE module );
289 extern struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );
290 extern const struct vulkan_funcs * CDECL __wine_get_vulkan_driver( HDC hdc, UINT version );
292 #endif /* __WINE_WINE_GDI_DRIVER_H */