ntdll: Only use sysinfo function when present.
[wine.git] / include / wine / gdi_driver.h
blob13aac87887fc08aa01d9859aca54d91f969b625f
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 *pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
92 INT (CDECL *pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
93 BOOL (CDECL *pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
94 BOOL (CDECL *pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
95 BOOL (CDECL *pFillPath)(PHYSDEV);
96 BOOL (CDECL *pFillRgn)(PHYSDEV,HRGN,HBRUSH);
97 BOOL (CDECL *pFlattenPath)(PHYSDEV);
98 BOOL (CDECL *pFontIsLinked)(PHYSDEV);
99 BOOL (CDECL *pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
100 BOOL (CDECL *pGdiComment)(PHYSDEV,UINT,const BYTE*);
101 UINT (CDECL *pGetBoundsRect)(PHYSDEV,RECT*,UINT);
102 BOOL (CDECL *pGetCharABCWidths)(PHYSDEV,UINT,UINT,LPABC);
103 BOOL (CDECL *pGetCharABCWidthsI)(PHYSDEV,UINT,UINT,WORD*,LPABC);
104 BOOL (CDECL *pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
105 BOOL (CDECL *pGetCharWidthInfo)(PHYSDEV,void*);
106 INT (CDECL *pGetDeviceCaps)(PHYSDEV,INT);
107 BOOL (CDECL *pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
108 DWORD (CDECL *pGetFontData)(PHYSDEV,DWORD,DWORD,LPVOID,DWORD);
109 BOOL (CDECL *pGetFontRealizationInfo)(PHYSDEV,void*);
110 DWORD (CDECL *pGetFontUnicodeRanges)(PHYSDEV,LPGLYPHSET);
111 DWORD (CDECL *pGetGlyphIndices)(PHYSDEV,LPCWSTR,INT,LPWORD,DWORD);
112 DWORD (CDECL *pGetGlyphOutline)(PHYSDEV,UINT,UINT,LPGLYPHMETRICS,DWORD,LPVOID,const MAT2*);
113 BOOL (CDECL *pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR);
114 DWORD (CDECL *pGetImage)(PHYSDEV,BITMAPINFO*,struct gdi_image_bits*,struct bitblt_coords*);
115 DWORD (CDECL *pGetKerningPairs)(PHYSDEV,DWORD,LPKERNINGPAIR);
116 COLORREF (CDECL *pGetNearestColor)(PHYSDEV,COLORREF);
117 UINT (CDECL *pGetOutlineTextMetrics)(PHYSDEV,UINT,LPOUTLINETEXTMETRICW);
118 COLORREF (CDECL *pGetPixel)(PHYSDEV,INT,INT);
119 UINT (CDECL *pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
120 UINT (CDECL *pGetTextCharsetInfo)(PHYSDEV,LPFONTSIGNATURE,DWORD);
121 BOOL (CDECL *pGetTextExtentExPoint)(PHYSDEV,LPCWSTR,INT,LPINT);
122 BOOL (CDECL *pGetTextExtentExPointI)(PHYSDEV,const WORD*,INT,LPINT);
123 INT (CDECL *pGetTextFace)(PHYSDEV,INT,LPWSTR);
124 BOOL (CDECL *pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
125 BOOL (CDECL *pGradientFill)(PHYSDEV,TRIVERTEX*,ULONG,void*,ULONG,ULONG);
126 BOOL (CDECL *pInvertRgn)(PHYSDEV,HRGN);
127 BOOL (CDECL *pLineTo)(PHYSDEV,INT,INT);
128 BOOL (CDECL *pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD);
129 BOOL (CDECL *pMoveTo)(PHYSDEV,INT,INT);
130 BOOL (CDECL *pPaintRgn)(PHYSDEV,HRGN);
131 BOOL (CDECL *pPatBlt)(PHYSDEV,struct bitblt_coords*,DWORD);
132 BOOL (CDECL *pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
133 BOOL (CDECL *pPolyBezier)(PHYSDEV,const POINT*,DWORD);
134 BOOL (CDECL *pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
135 BOOL (CDECL *pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
136 BOOL (CDECL *pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
137 BOOL (CDECL *pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
138 BOOL (CDECL *pPolylineTo)(PHYSDEV,const POINT*,INT);
139 DWORD (CDECL *pPutImage)(PHYSDEV,HRGN,BITMAPINFO*,const struct gdi_image_bits*,struct bitblt_coords*,struct bitblt_coords*,DWORD);
140 UINT (CDECL *pRealizeDefaultPalette)(PHYSDEV);
141 UINT (CDECL *pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
142 BOOL (CDECL *pRectangle)(PHYSDEV,INT,INT,INT,INT);
143 HDC (CDECL *pResetDC)(PHYSDEV,const DEVMODEW*);
144 BOOL (CDECL *pRestoreDC)(PHYSDEV,INT);
145 BOOL (CDECL *pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
146 HBITMAP (CDECL *pSelectBitmap)(PHYSDEV,HBITMAP);
147 HBRUSH (CDECL *pSelectBrush)(PHYSDEV,HBRUSH,const struct brush_pattern*);
148 BOOL (CDECL *pSelectClipPath)(PHYSDEV,INT);
149 HFONT (CDECL *pSelectFont)(PHYSDEV,HFONT,UINT*);
150 HPEN (CDECL *pSelectPen)(PHYSDEV,HPEN,const struct brush_pattern*);
151 COLORREF (CDECL *pSetBkColor)(PHYSDEV,COLORREF);
152 UINT (CDECL *pSetBoundsRect)(PHYSDEV,RECT*,UINT);
153 COLORREF (CDECL *pSetDCBrushColor)(PHYSDEV, COLORREF);
154 COLORREF (CDECL *pSetDCPenColor)(PHYSDEV, COLORREF);
155 INT (CDECL *pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,BITMAPINFO*,UINT);
156 VOID (CDECL *pSetDeviceClipping)(PHYSDEV,HRGN);
157 BOOL (CDECL *pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
158 COLORREF (CDECL *pSetPixel)(PHYSDEV,INT,INT,COLORREF);
159 COLORREF (CDECL *pSetTextColor)(PHYSDEV,COLORREF);
160 BOOL (CDECL *pSetWorldTransform)(PHYSDEV,const XFORM*);
161 INT (CDECL *pStartDoc)(PHYSDEV,const DOCINFOW*);
162 INT (CDECL *pStartPage)(PHYSDEV);
163 BOOL (CDECL *pStretchBlt)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,DWORD);
164 INT (CDECL *pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void*,BITMAPINFO*,UINT,DWORD);
165 BOOL (CDECL *pStrokeAndFillPath)(PHYSDEV);
166 BOOL (CDECL *pStrokePath)(PHYSDEV);
167 BOOL (CDECL *pUnrealizePalette)(HPALETTE);
168 BOOL (CDECL *pWidenPath)(PHYSDEV);
169 NTSTATUS (CDECL *pD3DKMTCheckVidPnExclusiveOwnership)(const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *);
170 NTSTATUS (CDECL *pD3DKMTSetVidPnSourceOwner)(const D3DKMT_SETVIDPNSOURCEOWNER *);
171 struct opengl_funcs * (CDECL *wine_get_wgl_driver)(PHYSDEV,UINT);
172 const struct vulkan_funcs * (CDECL *wine_get_vulkan_driver)(PHYSDEV,UINT);
174 /* priority order for the driver on the stack */
175 UINT priority;
178 /* increment this when you change the DC function table */
179 #define WINE_GDI_DRIVER_VERSION 59
181 #define GDI_PRIORITY_NULL_DRV 0 /* null driver */
182 #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
183 #define GDI_PRIORITY_GRAPHICS_DRV 200 /* any graphics driver */
184 #define GDI_PRIORITY_DIB_DRV 300 /* the DIB driver */
185 #define GDI_PRIORITY_PATH_DRV 400 /* the path driver */
187 static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
189 while (!((void **)dev->funcs)[offset / sizeof(void *)]) dev = dev->next;
190 return dev;
193 #define GET_NEXT_PHYSDEV(dev,func) \
194 get_physdev_entry_point( (dev)->next, FIELD_OFFSET(struct gdi_dc_funcs,func))
196 static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs )
198 while ((*dev)->funcs->priority > funcs->priority) dev = &(*dev)->next;
199 physdev->funcs = funcs;
200 physdev->next = *dev;
201 physdev->hdc = (*dev)->hdc;
202 *dev = physdev;
205 /* support for window surfaces */
207 struct window_surface;
209 struct window_surface_funcs
211 void (CDECL *lock)( struct window_surface *surface );
212 void (CDECL *unlock)( struct window_surface *surface );
213 void* (CDECL *get_info)( struct window_surface *surface, BITMAPINFO *info );
214 RECT* (CDECL *get_bounds)( struct window_surface *surface );
215 void (CDECL *set_region)( struct window_surface *surface, HRGN region );
216 void (CDECL *flush)( struct window_surface *surface );
217 void (CDECL *destroy)( struct window_surface *surface );
220 struct window_surface
222 const struct window_surface_funcs *funcs; /* driver-specific implementations */
223 struct list entry; /* entry in global list managed by user32 */
224 LONG ref; /* reference count */
225 RECT rect; /* constant, no locking needed */
226 /* driver-specific fields here */
229 static inline ULONG window_surface_add_ref( struct window_surface *surface )
231 return InterlockedIncrement( &surface->ref );
234 static inline ULONG window_surface_release( struct window_surface *surface )
236 ULONG ret = InterlockedDecrement( &surface->ref );
237 if (!ret) surface->funcs->destroy( surface );
238 return ret;
241 /* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */
243 #define DCHC_INVALIDVISRGN 0x0001
244 #define DCHC_DELETEDC 0x0002
245 #define DCHF_INVALIDATEVISRGN 0x0001
246 #define DCHF_VALIDATEVISRGN 0x0002
247 #define DCHF_RESETDC 0x0004 /* Wine extension */
248 #define DCHF_DISABLEDC 0x0008 /* Wine extension */
249 #define DCHF_ENABLEDC 0x0010 /* Wine extension */
251 typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM);
253 WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*);
254 WINGDIAPI BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR);
255 WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD);
257 extern void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
258 extern void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect,
259 const RECT *device_rect, struct window_surface *surface );
260 extern void CDECL __wine_set_display_driver( HMODULE module );
261 extern struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );
262 extern const struct vulkan_funcs * CDECL __wine_get_vulkan_driver( HDC hdc, UINT version );
264 #endif /* __WINE_WINE_GDI_DRIVER_H */