2 * Access to display driver
4 * Copyright 2009 Massimo Del Fedele
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
22 #include "wine/port.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv
);
30 * Allocate and fill the function pointer structure for a given module. */
31 static DC_FUNCTIONS
*CreateDriver( HMODULE module
)
35 if (!(funcs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*funcs
))))
38 /* fill the function table */
41 #define GET_FUNC(name) funcs->p##name = (void*)GetProcAddress( module, #name )
50 GET_FUNC(ChoosePixelFormat
);
52 GET_FUNC(CloseFigure
);
53 GET_FUNC(CreateBitmap
);
55 GET_FUNC(CreateDIBSection
);
56 GET_FUNC(DeleteBitmap
);
58 GET_FUNC(DescribePixelFormat
);
59 GET_FUNC(DeviceCapabilities
);
64 GET_FUNC(EnumDeviceFonts
);
65 GET_FUNC(ExcludeClipRect
);
66 GET_FUNC(ExtDeviceMode
);
68 GET_FUNC(ExtFloodFill
);
69 GET_FUNC(ExtSelectClipRgn
);
73 GET_FUNC(FlattenPath
);
76 GET_FUNC(GetBitmapBits
);
77 GET_FUNC(GetCharWidth
);
79 GET_FUNC(GetDIBColorTable
);
81 GET_FUNC(GetDeviceCaps
);
82 GET_FUNC(GetDeviceGammaRamp
);
83 GET_FUNC(GetICMProfile
);
84 GET_FUNC(GetNearestColor
);
86 GET_FUNC(GetPixelFormat
);
87 GET_FUNC(GetSystemPaletteEntries
);
88 GET_FUNC(GetTextExtentExPoint
);
89 GET_FUNC(GetTextMetrics
);
90 GET_FUNC(IntersectClipRect
);
94 GET_FUNC(ModifyWorldTransform
);
95 GET_FUNC(OffsetClipRgn
);
96 GET_FUNC(OffsetViewportOrg
);
97 GET_FUNC(OffsetWindowOrg
);
101 GET_FUNC(PolyBezier
);
102 GET_FUNC(PolyBezierTo
);
104 GET_FUNC(PolyPolygon
);
105 GET_FUNC(PolyPolyline
);
108 GET_FUNC(PolylineTo
);
109 GET_FUNC(RealizeDefaultPalette
);
110 GET_FUNC(RealizePalette
);
116 GET_FUNC(ScaleViewportExt
);
117 GET_FUNC(ScaleWindowExt
);
118 GET_FUNC(SelectBitmap
);
119 GET_FUNC(SelectBrush
);
120 GET_FUNC(SelectClipPath
);
121 GET_FUNC(SelectFont
);
122 GET_FUNC(SelectPalette
);
124 GET_FUNC(SetArcDirection
);
125 GET_FUNC(SetBitmapBits
);
126 GET_FUNC(SetBkColor
);
128 GET_FUNC(SetDCBrushColor
);
130 GET_FUNC(SetDCPenColor
);
131 GET_FUNC(SetDIBColorTable
);
133 GET_FUNC(SetDIBitsToDevice
);
134 GET_FUNC(SetDeviceClipping
);
135 GET_FUNC(SetDeviceGammaRamp
);
136 GET_FUNC(SetMapMode
);
137 GET_FUNC(SetMapperFlags
);
139 GET_FUNC(SetPixelFormat
);
140 GET_FUNC(SetPolyFillMode
);
143 GET_FUNC(SetStretchBltMode
);
144 GET_FUNC(SetTextAlign
);
145 GET_FUNC(SetTextCharacterExtra
);
146 GET_FUNC(SetTextColor
);
147 GET_FUNC(SetTextJustification
);
148 GET_FUNC(SetViewportExt
);
149 GET_FUNC(SetViewportOrg
);
150 GET_FUNC(SetWindowExt
);
151 GET_FUNC(SetWindowOrg
);
152 GET_FUNC(SetWorldTransform
);
155 GET_FUNC(StretchBlt
);
156 GET_FUNC(StretchDIBits
);
157 GET_FUNC(StrokeAndFillPath
);
158 GET_FUNC(StrokePath
);
159 GET_FUNC(SwapBuffers
);
160 GET_FUNC(UnrealizePalette
);
164 GET_FUNC(wglCreateContext
);
165 GET_FUNC(wglDeleteContext
);
166 GET_FUNC(wglGetProcAddress
);
167 GET_FUNC(wglGetPbufferDCARB
);
168 GET_FUNC(wglMakeContextCurrentARB
);
169 GET_FUNC(wglMakeCurrent
);
170 GET_FUNC(wglSetPixelFormatWINE
);
171 GET_FUNC(wglShareLists
);
172 GET_FUNC(wglUseFontBitmapsA
);
173 GET_FUNC(wglUseFontBitmapsW
);
177 memset( funcs
, 0, sizeof(*funcs
) );
179 /* add it to the list */
185 * Loads display driver - partially grabbed from gdi32 */
186 static DC_FUNCTIONS
*X11DrvFuncs
= NULL
;
187 static HMODULE X11DrvModule
= 0;
188 DC_FUNCTIONS
*_DIBDRV_LoadDisplayDriver(void)
190 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
194 if (X11DrvFuncs
) /* already loaded */
197 strcpy( buffer
, "x11" ); /* default value */
198 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
199 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
201 DWORD type
, count
= sizeof(buffer
);
202 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
209 next
= strchr( name
, ',' );
213 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
214 if ((module
= LoadLibraryA( libname
)) != 0)
219 if (!(X11DrvFuncs
= CreateDriver(module
)))
221 ERR( "Could not create graphics driver '%s'\n", buffer
);
222 FreeLibrary( module
);
226 X11DrvModule
= module
;
231 Frees resources allocated by Display driver */
232 void _DIBDRV_FreeDisplayDriver(void)
234 /* frees function table */
237 HeapFree(GetProcessHeap(), 0, X11DrvFuncs
);
240 /* and unload the module */
243 FreeLibrary(X11DrvModule
);
249 Gets a pointer to display drives'function table */
250 inline DC_FUNCTIONS
*_DIBDRV_GetDisplayDriver(void)