2 * Graphics driver management functions
4 * Copyright 1994 Bob Amstadt
5 * Copyright 1996, 2001 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
32 #include "wine/winbase16.h"
34 #include "gdi_private.h"
35 #include "wine/unicode.h"
36 #include "wine/list.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(driver);
41 struct graphics_driver
44 HMODULE module; /* module handle */
48 static struct list drivers = LIST_INIT( drivers );
49 static struct graphics_driver *display_driver;
51 static CRITICAL_SECTION driver_section;
52 static CRITICAL_SECTION_DEBUG critsect_debug =
54 0, 0, &driver_section,
55 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
56 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
58 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
60 /**********************************************************************
63 * Allocate and fill the driver structure for a given module.
65 static struct graphics_driver *create_driver( HMODULE module )
67 struct graphics_driver *driver;
69 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
70 driver->module = module;
72 /* fill the function table */
75 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
84 GET_FUNC(ChoosePixelFormat);
86 GET_FUNC(CloseFigure);
87 GET_FUNC(CreateBitmap);
89 GET_FUNC(CreateDIBSection);
90 GET_FUNC(DeleteBitmap);
92 GET_FUNC(DescribePixelFormat);
93 GET_FUNC(DeviceCapabilities);
98 GET_FUNC(EnumDeviceFonts);
99 GET_FUNC(EnumICMProfiles);
100 GET_FUNC(ExcludeClipRect);
101 GET_FUNC(ExtDeviceMode);
103 GET_FUNC(ExtFloodFill);
104 GET_FUNC(ExtSelectClipRgn);
105 GET_FUNC(ExtTextOut);
108 GET_FUNC(FlattenPath);
110 GET_FUNC(GdiComment);
111 GET_FUNC(GetBitmapBits);
112 GET_FUNC(GetCharWidth);
114 GET_FUNC(GetDeviceCaps);
115 GET_FUNC(GetDeviceGammaRamp);
116 GET_FUNC(GetICMProfile);
117 GET_FUNC(GetNearestColor);
119 GET_FUNC(GetPixelFormat);
120 GET_FUNC(GetSystemPaletteEntries);
121 GET_FUNC(GetTextExtentExPoint);
122 GET_FUNC(GetTextMetrics);
123 GET_FUNC(IntersectClipRect);
127 GET_FUNC(ModifyWorldTransform);
128 GET_FUNC(OffsetClipRgn);
129 GET_FUNC(OffsetViewportOrgEx);
130 GET_FUNC(OffsetWindowOrgEx);
134 GET_FUNC(PolyBezier);
135 GET_FUNC(PolyBezierTo);
137 GET_FUNC(PolyPolygon);
138 GET_FUNC(PolyPolyline);
141 GET_FUNC(PolylineTo);
142 GET_FUNC(RealizeDefaultPalette);
143 GET_FUNC(RealizePalette);
149 GET_FUNC(ScaleViewportExtEx);
150 GET_FUNC(ScaleWindowExtEx);
151 GET_FUNC(SelectBitmap);
152 GET_FUNC(SelectBrush);
153 GET_FUNC(SelectClipPath);
154 GET_FUNC(SelectFont);
155 GET_FUNC(SelectPalette);
157 GET_FUNC(SetArcDirection);
158 GET_FUNC(SetBitmapBits);
159 GET_FUNC(SetBkColor);
161 GET_FUNC(SetDCBrushColor);
162 GET_FUNC(SetDCPenColor);
163 GET_FUNC(SetDIBColorTable);
165 GET_FUNC(SetDIBitsToDevice);
166 GET_FUNC(SetDeviceClipping);
167 GET_FUNC(SetDeviceGammaRamp);
168 GET_FUNC(SetMapMode);
169 GET_FUNC(SetMapperFlags);
171 GET_FUNC(SetPixelFormat);
172 GET_FUNC(SetPolyFillMode);
175 GET_FUNC(SetStretchBltMode);
176 GET_FUNC(SetTextAlign);
177 GET_FUNC(SetTextCharacterExtra);
178 GET_FUNC(SetTextColor);
179 GET_FUNC(SetTextJustification);
180 GET_FUNC(SetViewportExtEx);
181 GET_FUNC(SetViewportOrgEx);
182 GET_FUNC(SetWindowExtEx);
183 GET_FUNC(SetWindowOrgEx);
184 GET_FUNC(SetWorldTransform);
187 GET_FUNC(StretchBlt);
188 GET_FUNC(StretchDIBits);
189 GET_FUNC(StrokeAndFillPath);
190 GET_FUNC(StrokePath);
191 GET_FUNC(SwapBuffers);
192 GET_FUNC(UnrealizePalette);
196 GET_FUNC(wglCreateContext);
197 GET_FUNC(wglCreateContextAttribsARB);
198 GET_FUNC(wglDeleteContext);
199 GET_FUNC(wglGetProcAddress);
200 GET_FUNC(wglGetPbufferDCARB);
201 GET_FUNC(wglMakeContextCurrentARB);
202 GET_FUNC(wglMakeCurrent);
203 GET_FUNC(wglSetPixelFormatWINE);
204 GET_FUNC(wglShareLists);
205 GET_FUNC(wglUseFontBitmapsA);
206 GET_FUNC(wglUseFontBitmapsW);
209 else memset( &driver->funcs, 0, sizeof(driver->funcs) );
215 /**********************************************************************
216 * DRIVER_get_display_driver
218 * Special case for loading the display driver: get the name from the config file
220 const DC_FUNCTIONS *DRIVER_get_display_driver(void)
222 struct graphics_driver *driver;
223 char buffer[MAX_PATH], libname[32], *name, *next;
227 if (display_driver) return &display_driver->funcs; /* already loaded */
229 strcpy( buffer, "x11" ); /* default value */
230 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
231 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
233 DWORD type, count = sizeof(buffer);
234 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
241 next = strchr( name, ',' );
242 if (next) *next++ = 0;
244 snprintf( libname, sizeof(libname), "wine%s.drv", name );
245 if ((module = LoadLibraryA( libname )) != 0) break;
249 if (!(driver = create_driver( module )))
251 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
252 FreeLibrary( module );
255 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
257 /* somebody beat us to it */
258 FreeLibrary( driver->module );
259 HeapFree( GetProcessHeap(), 0, driver );
261 return &display_driver->funcs;
265 /**********************************************************************
268 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
271 struct graphics_driver *driver, *new_driver;
272 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
273 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
275 /* display driver is a special case */
276 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return DRIVER_get_display_driver();
278 if ((module = GetModuleHandleW( name )))
280 if (display_driver && display_driver->module == module) return &display_driver->funcs;
281 EnterCriticalSection( &driver_section );
282 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
284 if (driver->module == module) goto done;
286 LeaveCriticalSection( &driver_section );
289 if (!(module = LoadLibraryW( name ))) return NULL;
291 if (!(new_driver = create_driver( module )))
293 FreeLibrary( module );
297 /* check if someone else added it in the meantime */
298 EnterCriticalSection( &driver_section );
299 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
301 if (driver->module != module) continue;
302 FreeLibrary( module );
303 HeapFree( GetProcessHeap(), 0, new_driver );
307 list_add_head( &drivers, &driver->entry );
308 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
310 LeaveCriticalSection( &driver_section );
311 return &driver->funcs;
315 static INT CDECL nulldrv_AbortDoc( PHYSDEV dev )
320 static BOOL CDECL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
321 INT xstart, INT ystart, INT xend, INT yend )
326 static INT CDECL nulldrv_ChoosePixelFormat( PHYSDEV dev, const PIXELFORMATDESCRIPTOR *descr )
331 static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
332 INT xstart, INT ystart, INT xend, INT yend )
337 static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
342 static INT CDECL nulldrv_DescribePixelFormat( PHYSDEV dev, INT format,
343 UINT size, PIXELFORMATDESCRIPTOR * descr )
348 static DWORD CDECL nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
349 WORD cap, LPSTR output, DEVMODEA *devmode )
354 static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
359 static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
364 static INT CDECL nulldrv_EndPage( PHYSDEV dev )
369 static INT CDECL nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
374 static INT CDECL nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
375 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
380 static INT CDECL nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
381 INT out_size, void *out_data )
386 static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
391 static BOOL CDECL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
396 static BOOL CDECL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
401 static BOOL CDECL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
406 static COLORREF CDECL nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
411 static INT CDECL nulldrv_GetPixelFormat( PHYSDEV dev )
416 static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
421 static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
426 static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
431 static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
432 INT xstart, INT ystart, INT xend, INT yend )
437 static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
439 /* FIXME: could be implemented with Polygon */
443 static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
445 /* FIXME: could be implemented with Polyline */
449 static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
454 static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
459 static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
464 static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
465 INT ell_width, INT ell_height )
470 static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
475 static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush )
480 static HFONT CDECL nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font )
485 static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
490 static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
495 static INT CDECL nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
500 static COLORREF CDECL nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
505 static INT CDECL nulldrv_SetBkMode( PHYSDEV dev, INT mode )
510 static COLORREF CDECL nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
515 static COLORREF CDECL nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
520 static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
524 static DWORD CDECL nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
529 static BOOL CDECL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
534 static DWORD CDECL nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
539 static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
544 static BOOL CDECL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
549 static INT CDECL nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
554 static INT CDECL nulldrv_SetROP2( PHYSDEV dev, INT rop )
559 static INT CDECL nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
564 static INT CDECL nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
569 static UINT CDECL nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
574 static INT CDECL nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
579 static COLORREF CDECL nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
584 static BOOL CDECL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
589 static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
594 static INT CDECL nulldrv_StartPage( PHYSDEV dev )
599 static BOOL CDECL nulldrv_SwapBuffers( PHYSDEV dev )
604 static BOOL CDECL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
609 static HGLRC CDECL nulldrv_wglCreateContext( PHYSDEV dev )
614 static HGLRC CDECL nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
619 static BOOL CDECL nulldrv_wglDeleteContext( HGLRC ctx )
624 static PROC CDECL nulldrv_wglGetProcAddress( LPCSTR name )
629 static HDC CDECL nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
634 static BOOL CDECL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
639 static BOOL CDECL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
644 static BOOL CDECL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format,
645 const PIXELFORMATDESCRIPTOR *descr )
650 static BOOL CDECL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
655 static BOOL CDECL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
660 static BOOL CDECL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
665 const DC_FUNCTIONS null_driver =
667 nulldrv_AbortDoc, /* pAbortDoc */
668 NULL, /* pAbortPath */
669 NULL, /* pAlphaBlend */
670 nulldrv_AngleArc, /* pAngleArc */
671 nulldrv_Arc, /* pArc */
672 nulldrv_ArcTo, /* pArcTo */
673 NULL, /* pBeginPath */
675 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
676 nulldrv_Chord, /* pChord */
677 NULL, /* pCloseFigure */
678 NULL, /* pCreateBitmap */
679 NULL, /* pCreateDC */
680 NULL, /* pCreateDIBSection */
681 NULL, /* pDeleteBitmap */
682 NULL, /* pDeleteDC */
683 nulldrv_DeleteObject, /* pDeleteObject */
684 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
685 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
686 nulldrv_Ellipse, /* pEllipse */
687 nulldrv_EndDoc, /* pEndDoc */
688 nulldrv_EndPage, /* pEndPage */
690 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
691 NULL, /* pEnumDeviceFonts */
692 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
693 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
694 nulldrv_ExtEscape, /* pExtEscape */
695 nulldrv_ExtFloodFill, /* pExtFloodFill */
696 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
697 NULL, /* pExtTextOut */
698 NULL, /* pFillPath */
699 nulldrv_FillRgn, /* pFillRgn */
700 NULL, /* pFlattenPath */
701 nulldrv_FrameRgn, /* pFrameRgn */
702 nulldrv_GdiComment, /* pGdiComment */
703 NULL, /* pGetBitmapBits */
704 NULL, /* pGetCharWidth */
705 NULL, /* pGetDIBits */
706 NULL, /* pGetDeviceCaps */
707 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
708 nulldrv_GetICMProfile, /* pGetICMProfile */
709 NULL, /* pGetNearestColor */
710 nulldrv_GetPixel, /* pGetPixel */
711 nulldrv_GetPixelFormat, /* pGetPixelFormat */
712 NULL, /* pGetSystemPaletteEntries */
713 NULL, /* pGetTextExtentExPoint */
714 NULL, /* pGetTextMetrics */
715 nulldrv_IntersectClipRect, /* pIntersectClipRect */
716 nulldrv_InvertRgn, /* pInvertRgn */
717 nulldrv_LineTo, /* pLineTo */
718 NULL, /* pModifyWorldTransform */
719 nulldrv_MoveTo, /* pMoveTo */
720 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
721 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
722 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
723 nulldrv_PaintRgn, /* pPaintRgn */
725 nulldrv_Pie, /* pPie */
726 nulldrv_PolyBezier, /* pPolyBezier */
727 nulldrv_PolyBezierTo, /* pPolyBezierTo */
728 nulldrv_PolyDraw, /* pPolyDraw */
729 nulldrv_PolyPolygon, /* pPolyPolygon */
730 nulldrv_PolyPolyline, /* pPolyPolyline */
731 nulldrv_Polygon, /* pPolygon */
732 nulldrv_Polyline, /* pPolyline */
733 nulldrv_PolylineTo, /* pPolylineTo */
734 NULL, /* pRealizeDefaultPalette */
735 NULL, /* pRealizePalette */
736 nulldrv_Rectangle, /* pRectangle */
738 NULL, /* pRestoreDC */
739 nulldrv_RoundRect, /* pRoundRect */
741 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
742 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
743 nulldrv_SelectBitmap, /* pSelectBitmap */
744 nulldrv_SelectBrush, /* pSelectBrush */
745 NULL, /* pSelectClipPath */
746 nulldrv_SelectFont, /* pSelectFont */
747 nulldrv_SelectPalette, /* pSelectPalette */
748 nulldrv_SelectPen, /* pSelectPen */
749 nulldrv_SetArcDirection, /* pSetArcDirection */
750 NULL, /* pSetBitmapBits */
751 nulldrv_SetBkColor, /* pSetBkColor */
752 nulldrv_SetBkMode, /* pSetBkMode */
753 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
754 nulldrv_SetDCPenColor, /* pSetDCPenColor */
755 NULL, /* pSetDIBColorTable */
756 NULL, /* pSetDIBits */
757 NULL, /* pSetDIBitsToDevice */
758 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
759 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
760 nulldrv_SetLayout, /* pSetLayout */
761 nulldrv_SetMapMode, /* pSetMapMode */
762 nulldrv_SetMapperFlags, /* pSetMapperFlags */
763 nulldrv_SetPixel, /* pSetPixel */
764 nulldrv_SetPixelFormat, /* pSetPixelFormat */
765 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
766 nulldrv_SetROP2, /* pSetROP2 */
767 nulldrv_SetRelAbs, /* pSetRelAbs */
768 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
769 nulldrv_SetTextAlign, /* pSetTextAlign */
770 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
771 nulldrv_SetTextColor, /* pSetTextColor */
772 nulldrv_SetTextJustification, /* pSetTextJustification */
773 nulldrv_SetViewportExtEx, /* pSetViewportExt */
774 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
775 nulldrv_SetWindowExtEx, /* pSetWindowExt */
776 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
777 NULL, /* pSetWorldTransform */
778 nulldrv_StartDoc, /* pStartDoc */
779 nulldrv_StartPage, /* pStartPage */
780 NULL, /* pStretchBlt */
781 NULL, /* pStretchDIBits */
782 NULL, /* pStrokeAndFillPath */
783 NULL, /* pStrokePath */
784 nulldrv_SwapBuffers, /* pSwapBuffers */
785 NULL, /* pUnrealizePalette */
786 NULL, /* pWidenPath */
787 nulldrv_wglCopyContext, /* pwglCopyContext */
788 nulldrv_wglCreateContext, /* pwglCreateContext */
789 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
790 nulldrv_wglDeleteContext, /* pwglDeleteContext */
791 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
792 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
793 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
794 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
795 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
796 nulldrv_wglShareLists, /* pwglShareLists */
797 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
798 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
802 /*****************************************************************************
803 * DRIVER_GetDriverName
806 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
808 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
809 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
810 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
811 static const WCHAR empty_strW[] = { 0 };
814 /* display is a special case */
815 if (!strcmpiW( device, displayW ) ||
816 !strcmpiW( device, display1W ))
818 lstrcpynW( driver, displayW, size );
822 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
824 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
827 p = strchrW(driver, ',');
830 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
834 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
839 /***********************************************************************
840 * GdiConvertToDevmodeW (GDI32.@)
842 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
845 WORD dmW_size, dmA_size;
847 dmA_size = dmA->dmSize;
849 /* this is the minimal dmSize that XP accepts */
850 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
853 if (dmA_size > sizeof(DEVMODEA))
854 dmA_size = sizeof(DEVMODEA);
856 dmW_size = dmA_size + CCHDEVICENAME;
857 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
858 dmW_size += CCHFORMNAME;
860 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
861 if (!dmW) return NULL;
863 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
864 dmW->dmDeviceName, CCHDEVICENAME);
865 /* copy slightly more, to avoid long computations */
866 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
868 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
870 if (dmA->dmFields & DM_FORMNAME)
871 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
872 dmW->dmFormName, CCHFORMNAME);
874 dmW->dmFormName[0] = 0;
876 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
877 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
880 if (dmA->dmDriverExtra)
881 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
883 dmW->dmSize = dmW_size;
889 /*****************************************************************************
892 * This should thunk to 16-bit and simply call the proc with the given args.
894 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
895 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
897 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
901 /*****************************************************************************
904 * This should load the correct driver for lpszDevice and calls this driver's
905 * ExtDeviceModePropSheet proc.
907 * Note: The driver calls a callback routine for each property sheet page; these
908 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
909 * The layout of this structure is:
915 * HPROPSHEETPAGE pages[10];
918 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
919 LPCSTR lpszPort, LPVOID lpPropSheet )
921 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
925 /*****************************************************************************
928 * This should load the correct driver for lpszDevice and call this driver's
929 * ExtDeviceMode proc.
931 * FIXME: convert ExtDeviceMode to unicode in the driver interface
933 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
934 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
935 LPSTR lpszPort, LPDEVMODEA lpdmInput,
936 LPSTR lpszProfile, DWORD fwMode )
945 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
946 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
948 if (!lpszDevice) return -1;
949 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
951 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
953 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
955 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
957 if ((dc = get_dc_ptr( hdc )))
959 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
960 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
961 lpdmInput, lpszProfile, fwMode );
962 release_dc_ptr( dc );
968 /****************************************************************************
971 * This should load the correct driver for lpszDevice and calls this driver's
972 * AdvancedSetupDialog proc.
974 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
975 LPDEVMODEA devin, LPDEVMODEA devout )
977 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
981 /*****************************************************************************
984 * This should load the correct driver for lpszDevice and calls this driver's
985 * DeviceCapabilities proc.
987 * FIXME: convert DeviceCapabilities to unicode in the driver interface
989 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
990 WORD fwCapability, LPSTR lpszOutput,
1000 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1002 if (!lpszDevice) return -1;
1003 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1005 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1007 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1009 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1011 if ((dc = get_dc_ptr( hdc )))
1013 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1014 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1015 fwCapability, lpszOutput, lpdm );
1016 release_dc_ptr( dc );
1023 /************************************************************************
1026 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1034 return AbortDoc( hdc );
1037 return EndDoc( hdc );
1039 case GETPHYSPAGESIZE:
1041 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1042 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1045 case GETPRINTINGOFFSET:
1047 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1048 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1051 case GETSCALINGFACTOR:
1053 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1054 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1058 return EndPage( hdc );
1061 return SetAbortProc( hdc, (ABORTPROC)in_data );
1068 /* in_data may not be 0 terminated so we must copy it */
1071 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1072 memcpy( name, in_data, in_count );
1075 /* out_data is actually a pointer to the DocInfo structure and used as
1076 * a second input parameter */
1077 if (out_data) doc = *(DOCINFOA *)out_data;
1080 doc.cbSize = sizeof(doc);
1081 doc.lpszOutput = NULL;
1082 doc.lpszDatatype = NULL;
1085 doc.lpszDocName = name;
1086 ret = StartDocA( hdc, &doc );
1087 HeapFree( GetProcessHeap(), 0, name );
1088 if (ret > 0) ret = StartPage( hdc );
1092 case QUERYESCSUPPORT:
1094 const INT *ptr = (const INT *)in_data;
1095 if (in_count < sizeof(INT)) return 0;
1100 case GETPHYSPAGESIZE:
1101 case GETPRINTINGOFFSET:
1102 case GETSCALINGFACTOR:
1104 case QUERYESCSUPPORT:
1113 /* if not handled internally, pass it to the driver */
1114 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1118 /******************************************************************************
1119 * ExtEscape [GDI32.@]
1121 * Access capabilities of a particular device that are not available through GDI.
1124 * hdc [I] Handle to device context
1125 * nEscape [I] Escape function
1126 * cbInput [I] Number of bytes in input structure
1127 * lpszInData [I] Pointer to input structure
1128 * cbOutput [I] Number of bytes in output structure
1129 * lpszOutData [O] Pointer to output structure
1133 * Not implemented: 0
1136 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1137 INT cbOutput, LPSTR lpszOutData )
1140 DC * dc = get_dc_ptr( hdc );
1144 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1145 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1146 release_dc_ptr( dc );
1152 /*******************************************************************
1153 * DrawEscape [GDI32.@]
1157 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1159 FIXME("DrawEscape, stub\n");
1163 /*******************************************************************
1164 * NamedEscape [GDI32.@]
1166 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1167 INT cbOutput, LPSTR lpszOutData )
1169 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1170 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1175 /*******************************************************************
1176 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1177 * GdiEntry13 [GDI32.@]
1179 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1181 static int warn_once;