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"
33 #include "wine/winbase16.h"
35 #include "gdi_private.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(driver);
42 struct graphics_driver
45 HMODULE module; /* module handle */
46 const struct gdi_dc_funcs *funcs;
49 static struct list drivers = LIST_INIT( drivers );
50 static struct graphics_driver *display_driver;
52 static CRITICAL_SECTION driver_section;
53 static CRITICAL_SECTION_DEBUG critsect_debug =
55 0, 0, &driver_section,
56 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
57 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
59 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
61 /**********************************************************************
64 * Allocate and fill the driver structure for a given module.
66 static struct graphics_driver *create_driver( HMODULE module )
68 static const struct gdi_dc_funcs empty_funcs;
69 const struct gdi_dc_funcs *funcs = NULL;
70 struct graphics_driver *driver;
72 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
73 driver->module = module;
77 const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int version );
79 if ((wine_get_gdi_driver = (void *)GetProcAddress( module, "wine_get_gdi_driver" )))
80 funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
82 if (!funcs) funcs = &empty_funcs;
83 driver->funcs = funcs;
88 /**********************************************************************
89 * DRIVER_get_display_driver
91 * Special case for loading the display driver: get the name from the config file
93 const DC_FUNCTIONS *DRIVER_get_display_driver(void)
95 struct graphics_driver *driver;
96 char buffer[MAX_PATH], libname[32], *name, *next;
100 if (display_driver) return display_driver->funcs; /* already loaded */
102 strcpy( buffer, "x11" ); /* default value */
103 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
104 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
106 DWORD type, count = sizeof(buffer);
107 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
114 next = strchr( name, ',' );
115 if (next) *next++ = 0;
117 snprintf( libname, sizeof(libname), "wine%s.drv", name );
118 if ((module = LoadLibraryA( libname )) != 0) break;
122 if (!(driver = create_driver( module )))
124 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
125 FreeLibrary( module );
128 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
130 /* somebody beat us to it */
131 FreeLibrary( driver->module );
132 HeapFree( GetProcessHeap(), 0, driver );
134 return display_driver->funcs;
138 /**********************************************************************
141 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
144 struct graphics_driver *driver, *new_driver;
145 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
146 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
148 /* display driver is a special case */
149 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return DRIVER_get_display_driver();
151 if ((module = GetModuleHandleW( name )))
153 if (display_driver && display_driver->module == module) return display_driver->funcs;
154 EnterCriticalSection( &driver_section );
155 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
157 if (driver->module == module) goto done;
159 LeaveCriticalSection( &driver_section );
162 if (!(module = LoadLibraryW( name ))) return NULL;
164 if (!(new_driver = create_driver( module )))
166 FreeLibrary( module );
170 /* check if someone else added it in the meantime */
171 EnterCriticalSection( &driver_section );
172 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
174 if (driver->module != module) continue;
175 FreeLibrary( module );
176 HeapFree( GetProcessHeap(), 0, new_driver );
180 list_add_head( &drivers, &driver->entry );
181 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
183 LeaveCriticalSection( &driver_section );
184 return driver->funcs;
188 static INT nulldrv_AbortDoc( PHYSDEV dev )
193 static BOOL nulldrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
194 PHYSDEV src_dev, struct bitblt_coords *src, BLENDFUNCTION func)
199 static BOOL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
200 INT xstart, INT ystart, INT xend, INT yend )
205 static INT nulldrv_ChoosePixelFormat( PHYSDEV dev, const PIXELFORMATDESCRIPTOR *descr )
210 static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
211 INT xstart, INT ystart, INT xend, INT yend )
216 static BOOL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap )
221 static BOOL nulldrv_CreateDC( HDC hdc, PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
222 LPCWSTR output, const DEVMODEW *devmode )
224 assert(0); /* should never be called */
228 static HBITMAP nulldrv_CreateDIBSection( PHYSDEV dev, HBITMAP bitmap, const BITMAPINFO *info, UINT usage )
233 static BOOL nulldrv_DeleteBitmap( HBITMAP bitmap )
238 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
240 assert(0); /* should never be called */
244 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
249 static INT nulldrv_DescribePixelFormat( PHYSDEV dev, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr )
254 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
255 WORD cap, LPSTR output, DEVMODEA *devmode )
260 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
265 static INT nulldrv_EndDoc( PHYSDEV dev )
270 static INT nulldrv_EndPage( PHYSDEV dev )
275 static BOOL nulldrv_EnumDeviceFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
280 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
285 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
286 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
291 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
292 INT out_size, void *out_data )
297 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
302 static BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect,
303 LPCWSTR str, UINT count, const INT *dx )
308 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
313 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
318 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
320 switch (cap) /* return meaningful values for some entries */
322 case HORZRES: return 640;
323 case VERTRES: return 480;
324 case BITSPIXEL: return 1;
325 case PLANES: return 1;
326 case NUMCOLORS: return 2;
327 case ASPECTX: return 36;
328 case ASPECTY: return 36;
329 case ASPECTXY: return 51;
330 case LOGPIXELSX: return 72;
331 case LOGPIXELSY: return 72;
332 case SIZEPALETTE: return 2;
333 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
334 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
335 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
340 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
345 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
350 static COLORREF nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
355 static INT nulldrv_GetPixelFormat( PHYSDEV dev )
360 static UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
365 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
366 INT *fit, INT *dx, SIZE *size )
371 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
376 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
381 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
386 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
391 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
396 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
397 INT xstart, INT ystart, INT xend, INT yend )
402 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
404 /* FIXME: could be implemented with Polygon */
408 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
410 /* FIXME: could be implemented with Polyline */
414 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
419 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
424 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
429 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
434 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
439 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
444 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
445 INT ell_width, INT ell_height )
450 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
455 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush )
460 static HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font )
465 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
470 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
475 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
480 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
485 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
490 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
495 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
500 static UINT nulldrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RGBQUAD *colors )
505 static INT nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD width, DWORD height,
506 INT x_src, INT y_src, UINT start, UINT lines,
507 const void *bits, const BITMAPINFO *info, UINT coloruse )
512 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
516 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
521 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
526 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
531 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
536 static BOOL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
541 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
546 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
551 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
556 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
561 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
566 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
571 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
576 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
581 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
586 static INT nulldrv_StartPage( PHYSDEV dev )
591 static BOOL nulldrv_SwapBuffers( PHYSDEV dev )
596 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
601 static BOOL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
606 static HGLRC nulldrv_wglCreateContext( PHYSDEV dev )
611 static HGLRC nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
616 static BOOL nulldrv_wglDeleteContext( HGLRC ctx )
621 static PROC nulldrv_wglGetProcAddress( LPCSTR name )
626 static HDC nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
631 static BOOL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
636 static BOOL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
641 static BOOL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
646 static BOOL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
651 static BOOL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
656 static BOOL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
661 const DC_FUNCTIONS null_driver =
663 nulldrv_AbortDoc, /* pAbortDoc */
664 nulldrv_AbortPath, /* pAbortPath */
665 nulldrv_AlphaBlend, /* pAlphaBlend */
666 nulldrv_AngleArc, /* pAngleArc */
667 nulldrv_Arc, /* pArc */
668 nulldrv_ArcTo, /* pArcTo */
669 nulldrv_BeginPath, /* pBeginPath */
670 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
671 nulldrv_Chord, /* pChord */
672 nulldrv_CloseFigure, /* pCloseFigure */
673 nulldrv_CreateBitmap, /* pCreateBitmap */
674 nulldrv_CreateDC, /* pCreateDC */
675 nulldrv_CreateDIBSection, /* pCreateDIBSection */
676 nulldrv_DeleteBitmap, /* pDeleteBitmap */
677 nulldrv_DeleteDC, /* pDeleteDC */
678 nulldrv_DeleteObject, /* pDeleteObject */
679 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
680 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
681 nulldrv_Ellipse, /* pEllipse */
682 nulldrv_EndDoc, /* pEndDoc */
683 nulldrv_EndPage, /* pEndPage */
684 nulldrv_EndPath, /* pEndPath */
685 nulldrv_EnumDeviceFonts, /* pEnumDeviceFonts */
686 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
687 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
688 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
689 nulldrv_ExtEscape, /* pExtEscape */
690 nulldrv_ExtFloodFill, /* pExtFloodFill */
691 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
692 nulldrv_ExtTextOut, /* pExtTextOut */
693 nulldrv_FillPath, /* pFillPath */
694 nulldrv_FillRgn, /* pFillRgn */
695 nulldrv_FlattenPath, /* pFlattenPath */
696 nulldrv_FrameRgn, /* pFrameRgn */
697 nulldrv_GdiComment, /* pGdiComment */
698 nulldrv_GetCharWidth, /* pGetCharWidth */
699 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
700 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
701 nulldrv_GetICMProfile, /* pGetICMProfile */
702 nulldrv_GetImage, /* pGetImage */
703 nulldrv_GetNearestColor, /* pGetNearestColor */
704 nulldrv_GetPixel, /* pGetPixel */
705 nulldrv_GetPixelFormat, /* pGetPixelFormat */
706 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
707 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
708 nulldrv_GetTextMetrics, /* pGetTextMetrics */
709 nulldrv_IntersectClipRect, /* pIntersectClipRect */
710 nulldrv_InvertRgn, /* pInvertRgn */
711 nulldrv_LineTo, /* pLineTo */
712 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
713 nulldrv_MoveTo, /* pMoveTo */
714 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
715 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
716 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
717 nulldrv_PaintRgn, /* pPaintRgn */
718 nulldrv_PatBlt, /* pPatBlt */
719 nulldrv_Pie, /* pPie */
720 nulldrv_PolyBezier, /* pPolyBezier */
721 nulldrv_PolyBezierTo, /* pPolyBezierTo */
722 nulldrv_PolyDraw, /* pPolyDraw */
723 nulldrv_PolyPolygon, /* pPolyPolygon */
724 nulldrv_PolyPolyline, /* pPolyPolyline */
725 nulldrv_Polygon, /* pPolygon */
726 nulldrv_Polyline, /* pPolyline */
727 nulldrv_PolylineTo, /* pPolylineTo */
728 nulldrv_PutImage, /* pPutImage */
729 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
730 nulldrv_RealizePalette, /* pRealizePalette */
731 nulldrv_Rectangle, /* pRectangle */
732 nulldrv_ResetDC, /* pResetDC */
733 nulldrv_RestoreDC, /* pRestoreDC */
734 nulldrv_RoundRect, /* pRoundRect */
735 nulldrv_SaveDC, /* pSaveDC */
736 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
737 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
738 nulldrv_SelectBitmap, /* pSelectBitmap */
739 nulldrv_SelectBrush, /* pSelectBrush */
740 nulldrv_SelectClipPath, /* pSelectClipPath */
741 nulldrv_SelectFont, /* pSelectFont */
742 nulldrv_SelectPalette, /* pSelectPalette */
743 nulldrv_SelectPen, /* pSelectPen */
744 nulldrv_SetArcDirection, /* pSetArcDirection */
745 nulldrv_SetBkColor, /* pSetBkColor */
746 nulldrv_SetBkMode, /* pSetBkMode */
747 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
748 nulldrv_SetDCPenColor, /* pSetDCPenColor */
749 nulldrv_SetDIBColorTable, /* pSetDIBColorTable */
750 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
751 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
752 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
753 nulldrv_SetLayout, /* pSetLayout */
754 nulldrv_SetMapMode, /* pSetMapMode */
755 nulldrv_SetMapperFlags, /* pSetMapperFlags */
756 nulldrv_SetPixel, /* pSetPixel */
757 nulldrv_SetPixelFormat, /* pSetPixelFormat */
758 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
759 nulldrv_SetROP2, /* pSetROP2 */
760 nulldrv_SetRelAbs, /* pSetRelAbs */
761 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
762 nulldrv_SetTextAlign, /* pSetTextAlign */
763 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
764 nulldrv_SetTextColor, /* pSetTextColor */
765 nulldrv_SetTextJustification, /* pSetTextJustification */
766 nulldrv_SetViewportExtEx, /* pSetViewportExt */
767 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
768 nulldrv_SetWindowExtEx, /* pSetWindowExt */
769 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
770 nulldrv_SetWorldTransform, /* pSetWorldTransform */
771 nulldrv_StartDoc, /* pStartDoc */
772 nulldrv_StartPage, /* pStartPage */
773 nulldrv_StretchBlt, /* pStretchBlt */
774 nulldrv_StretchDIBits, /* pStretchDIBits */
775 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
776 nulldrv_StrokePath, /* pStrokePath */
777 nulldrv_SwapBuffers, /* pSwapBuffers */
778 nulldrv_UnrealizePalette, /* pUnrealizePalette */
779 nulldrv_WidenPath, /* pWidenPath */
780 nulldrv_wglCopyContext, /* pwglCopyContext */
781 nulldrv_wglCreateContext, /* pwglCreateContext */
782 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
783 nulldrv_wglDeleteContext, /* pwglDeleteContext */
784 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
785 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
786 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
787 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
788 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
789 nulldrv_wglShareLists, /* pwglShareLists */
790 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
791 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
795 /*****************************************************************************
796 * DRIVER_GetDriverName
799 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
801 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
802 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
803 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
804 static const WCHAR empty_strW[] = { 0 };
807 /* display is a special case */
808 if (!strcmpiW( device, displayW ) ||
809 !strcmpiW( device, display1W ))
811 lstrcpynW( driver, displayW, size );
815 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
817 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
820 p = strchrW(driver, ',');
823 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
827 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
832 /***********************************************************************
833 * GdiConvertToDevmodeW (GDI32.@)
835 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
838 WORD dmW_size, dmA_size;
840 dmA_size = dmA->dmSize;
842 /* this is the minimal dmSize that XP accepts */
843 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
846 if (dmA_size > sizeof(DEVMODEA))
847 dmA_size = sizeof(DEVMODEA);
849 dmW_size = dmA_size + CCHDEVICENAME;
850 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
851 dmW_size += CCHFORMNAME;
853 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
854 if (!dmW) return NULL;
856 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
857 dmW->dmDeviceName, CCHDEVICENAME);
858 /* copy slightly more, to avoid long computations */
859 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
861 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
863 if (dmA->dmFields & DM_FORMNAME)
864 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
865 dmW->dmFormName, CCHFORMNAME);
867 dmW->dmFormName[0] = 0;
869 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
870 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
873 if (dmA->dmDriverExtra)
874 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
876 dmW->dmSize = dmW_size;
882 /*****************************************************************************
885 * This should thunk to 16-bit and simply call the proc with the given args.
887 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
888 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
890 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
894 /*****************************************************************************
897 * This should load the correct driver for lpszDevice and calls this driver's
898 * ExtDeviceModePropSheet proc.
900 * Note: The driver calls a callback routine for each property sheet page; these
901 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
902 * The layout of this structure is:
908 * HPROPSHEETPAGE pages[10];
911 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
912 LPCSTR lpszPort, LPVOID lpPropSheet )
914 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
918 /*****************************************************************************
921 * This should load the correct driver for lpszDevice and call this driver's
922 * ExtDeviceMode proc.
924 * FIXME: convert ExtDeviceMode to unicode in the driver interface
926 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
927 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
928 LPSTR lpszPort, LPDEVMODEA lpdmInput,
929 LPSTR lpszProfile, DWORD fwMode )
938 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
939 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
941 if (!lpszDevice) return -1;
942 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
944 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
946 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
948 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
950 if ((dc = get_dc_ptr( hdc )))
952 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
953 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
954 lpdmInput, lpszProfile, fwMode );
955 release_dc_ptr( dc );
961 /****************************************************************************
964 * This should load the correct driver for lpszDevice and calls this driver's
965 * AdvancedSetupDialog proc.
967 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
968 LPDEVMODEA devin, LPDEVMODEA devout )
970 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
974 /*****************************************************************************
977 * This should load the correct driver for lpszDevice and calls this driver's
978 * DeviceCapabilities proc.
980 * FIXME: convert DeviceCapabilities to unicode in the driver interface
982 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
983 WORD fwCapability, LPSTR lpszOutput,
993 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
995 if (!lpszDevice) return -1;
996 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
998 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1000 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1002 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1004 if ((dc = get_dc_ptr( hdc )))
1006 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1007 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1008 fwCapability, lpszOutput, lpdm );
1009 release_dc_ptr( dc );
1016 /************************************************************************
1019 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1027 return AbortDoc( hdc );
1030 return EndDoc( hdc );
1032 case GETPHYSPAGESIZE:
1034 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1035 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1038 case GETPRINTINGOFFSET:
1040 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1041 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1044 case GETSCALINGFACTOR:
1046 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1047 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1051 return EndPage( hdc );
1054 return SetAbortProc( hdc, (ABORTPROC)in_data );
1061 /* in_data may not be 0 terminated so we must copy it */
1064 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1065 memcpy( name, in_data, in_count );
1068 /* out_data is actually a pointer to the DocInfo structure and used as
1069 * a second input parameter */
1070 if (out_data) doc = *(DOCINFOA *)out_data;
1073 doc.cbSize = sizeof(doc);
1074 doc.lpszOutput = NULL;
1075 doc.lpszDatatype = NULL;
1078 doc.lpszDocName = name;
1079 ret = StartDocA( hdc, &doc );
1080 HeapFree( GetProcessHeap(), 0, name );
1081 if (ret > 0) ret = StartPage( hdc );
1085 case QUERYESCSUPPORT:
1087 const INT *ptr = (const INT *)in_data;
1088 if (in_count < sizeof(INT)) return 0;
1093 case GETPHYSPAGESIZE:
1094 case GETPRINTINGOFFSET:
1095 case GETSCALINGFACTOR:
1097 case QUERYESCSUPPORT:
1106 /* if not handled internally, pass it to the driver */
1107 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1111 /******************************************************************************
1112 * ExtEscape [GDI32.@]
1114 * Access capabilities of a particular device that are not available through GDI.
1117 * hdc [I] Handle to device context
1118 * nEscape [I] Escape function
1119 * cbInput [I] Number of bytes in input structure
1120 * lpszInData [I] Pointer to input structure
1121 * cbOutput [I] Number of bytes in output structure
1122 * lpszOutData [O] Pointer to output structure
1126 * Not implemented: 0
1129 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1130 INT cbOutput, LPSTR lpszOutData )
1133 DC * dc = get_dc_ptr( hdc );
1137 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1138 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1139 release_dc_ptr( dc );
1145 /*******************************************************************
1146 * DrawEscape [GDI32.@]
1150 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1152 FIXME("DrawEscape, stub\n");
1156 /*******************************************************************
1157 * NamedEscape [GDI32.@]
1159 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1160 INT cbOutput, LPSTR lpszOutData )
1162 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1163 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1168 /*******************************************************************
1169 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1170 * GdiEntry13 [GDI32.@]
1172 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1174 static int warn_once;