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 */
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 struct graphics_driver *driver;
70 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
71 driver->module = module;
73 /* fill the function table */
76 #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_CreateBitmap( PHYSDEV dev, HBITMAP bitmap, LPVOID bits )
342 static BOOL CDECL nulldrv_CreateDC( HDC hdc, PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
343 LPCWSTR output, const DEVMODEW *devmode )
345 assert(0); /* should never be called */
349 static HBITMAP CDECL nulldrv_CreateDIBSection( PHYSDEV dev, HBITMAP bitmap,
350 const BITMAPINFO *info, UINT usage )
355 static BOOL CDECL nulldrv_DeleteBitmap( HBITMAP bitmap )
360 static BOOL CDECL nulldrv_DeleteDC( PHYSDEV dev )
362 assert(0); /* should never be called */
366 static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
371 static INT CDECL nulldrv_DescribePixelFormat( PHYSDEV dev, INT format,
372 UINT size, PIXELFORMATDESCRIPTOR * descr )
377 static DWORD CDECL nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
378 WORD cap, LPSTR output, DEVMODEA *devmode )
383 static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
388 static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
393 static INT CDECL nulldrv_EndPage( PHYSDEV dev )
398 static BOOL CDECL nulldrv_EnumDeviceFonts( PHYSDEV dev, LOGFONTW *logfont,
399 FONTENUMPROCW proc, LPARAM lParam )
404 static INT CDECL nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
409 static INT CDECL nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
410 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
415 static INT CDECL nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
416 INT out_size, void *out_data )
421 static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
426 static BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect,
427 LPCWSTR str, UINT count, const INT *dx )
432 static BOOL CDECL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
437 static BOOL CDECL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
442 static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
444 switch (cap) /* return meaningful values for some entries */
446 case HORZRES: return 640;
447 case VERTRES: return 480;
448 case BITSPIXEL: return 1;
449 case PLANES: return 1;
450 case NUMCOLORS: return 2;
451 case ASPECTX: return 36;
452 case ASPECTY: return 36;
453 case ASPECTXY: return 51;
454 case LOGPIXELSX: return 72;
455 case LOGPIXELSY: return 72;
456 case SIZEPALETTE: return 2;
457 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
458 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
459 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
464 static BOOL CDECL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
469 static BOOL CDECL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
474 static COLORREF CDECL nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
479 static INT CDECL nulldrv_GetPixelFormat( PHYSDEV dev )
484 static UINT CDECL nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start,
485 UINT count, PALETTEENTRY *entries )
490 static BOOL CDECL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
491 INT *fit, INT *dx, SIZE *size )
496 static BOOL CDECL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
501 static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
506 static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
511 static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
516 static BOOL CDECL nulldrv_PatBlt( PHYSDEV dev, INT x, INT y, INT width, INT height, DWORD rop )
521 static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
522 INT xstart, INT ystart, INT xend, INT yend )
527 static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
529 /* FIXME: could be implemented with Polygon */
533 static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
535 /* FIXME: could be implemented with Polyline */
539 static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
544 static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
549 static UINT CDECL nulldrv_RealizeDefaultPalette( PHYSDEV dev )
554 static UINT CDECL nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
559 static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
564 static HDC CDECL nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
569 static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
570 INT ell_width, INT ell_height )
575 static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
580 static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush )
585 static HFONT CDECL nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font )
590 static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
595 static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
600 static INT CDECL nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
605 static COLORREF CDECL nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
610 static INT CDECL nulldrv_SetBkMode( PHYSDEV dev, INT mode )
615 static COLORREF CDECL nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
620 static COLORREF CDECL nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
625 static UINT CDECL nulldrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RGBQUAD *colors )
630 static INT CDECL nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD width, DWORD height,
631 INT x_src, INT y_src, UINT start, UINT lines,
632 const void *bits, const BITMAPINFO *info, UINT coloruse )
637 static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
641 static DWORD CDECL nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
646 static BOOL CDECL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
651 static DWORD CDECL nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
656 static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
661 static BOOL CDECL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
666 static INT CDECL nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
671 static INT CDECL nulldrv_SetROP2( PHYSDEV dev, INT rop )
676 static INT CDECL nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
681 static INT CDECL nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
686 static UINT CDECL nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
691 static INT CDECL nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
696 static COLORREF CDECL nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
701 static BOOL CDECL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
706 static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
711 static INT CDECL nulldrv_StartPage( PHYSDEV dev )
716 static BOOL CDECL nulldrv_SwapBuffers( PHYSDEV dev )
721 static BOOL CDECL nulldrv_UnrealizePalette( HPALETTE palette )
726 static BOOL CDECL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
731 static HGLRC CDECL nulldrv_wglCreateContext( PHYSDEV dev )
736 static HGLRC CDECL nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
741 static BOOL CDECL nulldrv_wglDeleteContext( HGLRC ctx )
746 static PROC CDECL nulldrv_wglGetProcAddress( LPCSTR name )
751 static HDC CDECL nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
756 static BOOL CDECL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
761 static BOOL CDECL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
766 static BOOL CDECL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format,
767 const PIXELFORMATDESCRIPTOR *descr )
772 static BOOL CDECL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
777 static BOOL CDECL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
782 static BOOL CDECL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
787 const DC_FUNCTIONS null_driver =
789 nulldrv_AbortDoc, /* pAbortDoc */
790 nulldrv_AbortPath, /* pAbortPath */
791 NULL, /* pAlphaBlend */
792 nulldrv_AngleArc, /* pAngleArc */
793 nulldrv_Arc, /* pArc */
794 nulldrv_ArcTo, /* pArcTo */
795 nulldrv_BeginPath, /* pBeginPath */
796 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
797 nulldrv_Chord, /* pChord */
798 nulldrv_CloseFigure, /* pCloseFigure */
799 nulldrv_CreateBitmap, /* pCreateBitmap */
800 nulldrv_CreateDC, /* pCreateDC */
801 nulldrv_CreateDIBSection, /* pCreateDIBSection */
802 nulldrv_DeleteBitmap, /* pDeleteBitmap */
803 nulldrv_DeleteDC, /* pDeleteDC */
804 nulldrv_DeleteObject, /* pDeleteObject */
805 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
806 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
807 nulldrv_Ellipse, /* pEllipse */
808 nulldrv_EndDoc, /* pEndDoc */
809 nulldrv_EndPage, /* pEndPage */
810 nulldrv_EndPath, /* pEndPath */
811 nulldrv_EnumDeviceFonts, /* pEnumDeviceFonts */
812 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
813 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
814 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
815 nulldrv_ExtEscape, /* pExtEscape */
816 nulldrv_ExtFloodFill, /* pExtFloodFill */
817 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
818 nulldrv_ExtTextOut, /* pExtTextOut */
819 nulldrv_FillPath, /* pFillPath */
820 nulldrv_FillRgn, /* pFillRgn */
821 nulldrv_FlattenPath, /* pFlattenPath */
822 nulldrv_FrameRgn, /* pFrameRgn */
823 nulldrv_GdiComment, /* pGdiComment */
824 nulldrv_GetBitmapBits, /* pGetBitmapBits */
825 nulldrv_GetCharWidth, /* pGetCharWidth */
826 nulldrv_GetDIBits, /* pGetDIBits */
827 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
828 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
829 nulldrv_GetICMProfile, /* pGetICMProfile */
830 nulldrv_GetNearestColor, /* pGetNearestColor */
831 nulldrv_GetPixel, /* pGetPixel */
832 nulldrv_GetPixelFormat, /* pGetPixelFormat */
833 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
834 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
835 nulldrv_GetTextMetrics, /* pGetTextMetrics */
836 nulldrv_IntersectClipRect, /* pIntersectClipRect */
837 nulldrv_InvertRgn, /* pInvertRgn */
838 nulldrv_LineTo, /* pLineTo */
839 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
840 nulldrv_MoveTo, /* pMoveTo */
841 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
842 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
843 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
844 nulldrv_PaintRgn, /* pPaintRgn */
845 nulldrv_PatBlt, /* pPatBlt */
846 nulldrv_Pie, /* pPie */
847 nulldrv_PolyBezier, /* pPolyBezier */
848 nulldrv_PolyBezierTo, /* pPolyBezierTo */
849 nulldrv_PolyDraw, /* pPolyDraw */
850 nulldrv_PolyPolygon, /* pPolyPolygon */
851 nulldrv_PolyPolyline, /* pPolyPolyline */
852 nulldrv_Polygon, /* pPolygon */
853 nulldrv_Polyline, /* pPolyline */
854 nulldrv_PolylineTo, /* pPolylineTo */
855 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
856 nulldrv_RealizePalette, /* pRealizePalette */
857 nulldrv_Rectangle, /* pRectangle */
858 nulldrv_ResetDC, /* pResetDC */
859 nulldrv_RestoreDC, /* pRestoreDC */
860 nulldrv_RoundRect, /* pRoundRect */
861 nulldrv_SaveDC, /* pSaveDC */
862 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
863 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
864 nulldrv_SelectBitmap, /* pSelectBitmap */
865 nulldrv_SelectBrush, /* pSelectBrush */
866 nulldrv_SelectClipPath, /* pSelectClipPath */
867 nulldrv_SelectFont, /* pSelectFont */
868 nulldrv_SelectPalette, /* pSelectPalette */
869 nulldrv_SelectPen, /* pSelectPen */
870 nulldrv_SetArcDirection, /* pSetArcDirection */
871 nulldrv_SetBitmapBits, /* pSetBitmapBits */
872 nulldrv_SetBkColor, /* pSetBkColor */
873 nulldrv_SetBkMode, /* pSetBkMode */
874 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
875 nulldrv_SetDCPenColor, /* pSetDCPenColor */
876 nulldrv_SetDIBColorTable, /* pSetDIBColorTable */
877 nulldrv_SetDIBits, /* pSetDIBits */
878 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
879 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
880 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
881 nulldrv_SetLayout, /* pSetLayout */
882 nulldrv_SetMapMode, /* pSetMapMode */
883 nulldrv_SetMapperFlags, /* pSetMapperFlags */
884 nulldrv_SetPixel, /* pSetPixel */
885 nulldrv_SetPixelFormat, /* pSetPixelFormat */
886 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
887 nulldrv_SetROP2, /* pSetROP2 */
888 nulldrv_SetRelAbs, /* pSetRelAbs */
889 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
890 nulldrv_SetTextAlign, /* pSetTextAlign */
891 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
892 nulldrv_SetTextColor, /* pSetTextColor */
893 nulldrv_SetTextJustification, /* pSetTextJustification */
894 nulldrv_SetViewportExtEx, /* pSetViewportExt */
895 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
896 nulldrv_SetWindowExtEx, /* pSetWindowExt */
897 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
898 nulldrv_SetWorldTransform, /* pSetWorldTransform */
899 nulldrv_StartDoc, /* pStartDoc */
900 nulldrv_StartPage, /* pStartPage */
901 NULL, /* pStretchBlt */
902 NULL, /* pStretchDIBits */
903 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
904 nulldrv_StrokePath, /* pStrokePath */
905 nulldrv_SwapBuffers, /* pSwapBuffers */
906 nulldrv_UnrealizePalette, /* pUnrealizePalette */
907 nulldrv_WidenPath, /* pWidenPath */
908 nulldrv_wglCopyContext, /* pwglCopyContext */
909 nulldrv_wglCreateContext, /* pwglCreateContext */
910 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
911 nulldrv_wglDeleteContext, /* pwglDeleteContext */
912 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
913 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
914 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
915 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
916 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
917 nulldrv_wglShareLists, /* pwglShareLists */
918 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
919 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
923 /*****************************************************************************
924 * DRIVER_GetDriverName
927 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
929 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
930 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
931 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
932 static const WCHAR empty_strW[] = { 0 };
935 /* display is a special case */
936 if (!strcmpiW( device, displayW ) ||
937 !strcmpiW( device, display1W ))
939 lstrcpynW( driver, displayW, size );
943 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
945 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
948 p = strchrW(driver, ',');
951 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
955 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
960 /***********************************************************************
961 * GdiConvertToDevmodeW (GDI32.@)
963 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
966 WORD dmW_size, dmA_size;
968 dmA_size = dmA->dmSize;
970 /* this is the minimal dmSize that XP accepts */
971 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
974 if (dmA_size > sizeof(DEVMODEA))
975 dmA_size = sizeof(DEVMODEA);
977 dmW_size = dmA_size + CCHDEVICENAME;
978 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
979 dmW_size += CCHFORMNAME;
981 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
982 if (!dmW) return NULL;
984 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
985 dmW->dmDeviceName, CCHDEVICENAME);
986 /* copy slightly more, to avoid long computations */
987 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
989 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
991 if (dmA->dmFields & DM_FORMNAME)
992 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
993 dmW->dmFormName, CCHFORMNAME);
995 dmW->dmFormName[0] = 0;
997 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
998 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
1001 if (dmA->dmDriverExtra)
1002 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
1004 dmW->dmSize = dmW_size;
1010 /*****************************************************************************
1013 * This should thunk to 16-bit and simply call the proc with the given args.
1015 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
1016 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
1018 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
1022 /*****************************************************************************
1025 * This should load the correct driver for lpszDevice and calls this driver's
1026 * ExtDeviceModePropSheet proc.
1028 * Note: The driver calls a callback routine for each property sheet page; these
1029 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1030 * The layout of this structure is:
1036 * HPROPSHEETPAGE pages[10];
1039 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
1040 LPCSTR lpszPort, LPVOID lpPropSheet )
1042 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
1046 /*****************************************************************************
1049 * This should load the correct driver for lpszDevice and call this driver's
1050 * ExtDeviceMode proc.
1052 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1054 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
1055 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
1056 LPSTR lpszPort, LPDEVMODEA lpdmInput,
1057 LPSTR lpszProfile, DWORD fwMode )
1066 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1067 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
1069 if (!lpszDevice) return -1;
1070 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1072 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1074 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1076 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1078 if ((dc = get_dc_ptr( hdc )))
1080 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
1081 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
1082 lpdmInput, lpszProfile, fwMode );
1083 release_dc_ptr( dc );
1089 /****************************************************************************
1092 * This should load the correct driver for lpszDevice and calls this driver's
1093 * AdvancedSetupDialog proc.
1095 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
1096 LPDEVMODEA devin, LPDEVMODEA devout )
1098 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
1102 /*****************************************************************************
1105 * This should load the correct driver for lpszDevice and calls this driver's
1106 * DeviceCapabilities proc.
1108 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1110 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1111 WORD fwCapability, LPSTR lpszOutput,
1121 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1123 if (!lpszDevice) return -1;
1124 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1126 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1128 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1130 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1132 if ((dc = get_dc_ptr( hdc )))
1134 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1135 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1136 fwCapability, lpszOutput, lpdm );
1137 release_dc_ptr( dc );
1144 /************************************************************************
1147 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1155 return AbortDoc( hdc );
1158 return EndDoc( hdc );
1160 case GETPHYSPAGESIZE:
1162 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1163 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1166 case GETPRINTINGOFFSET:
1168 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1169 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1172 case GETSCALINGFACTOR:
1174 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1175 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1179 return EndPage( hdc );
1182 return SetAbortProc( hdc, (ABORTPROC)in_data );
1189 /* in_data may not be 0 terminated so we must copy it */
1192 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1193 memcpy( name, in_data, in_count );
1196 /* out_data is actually a pointer to the DocInfo structure and used as
1197 * a second input parameter */
1198 if (out_data) doc = *(DOCINFOA *)out_data;
1201 doc.cbSize = sizeof(doc);
1202 doc.lpszOutput = NULL;
1203 doc.lpszDatatype = NULL;
1206 doc.lpszDocName = name;
1207 ret = StartDocA( hdc, &doc );
1208 HeapFree( GetProcessHeap(), 0, name );
1209 if (ret > 0) ret = StartPage( hdc );
1213 case QUERYESCSUPPORT:
1215 const INT *ptr = (const INT *)in_data;
1216 if (in_count < sizeof(INT)) return 0;
1221 case GETPHYSPAGESIZE:
1222 case GETPRINTINGOFFSET:
1223 case GETSCALINGFACTOR:
1225 case QUERYESCSUPPORT:
1234 /* if not handled internally, pass it to the driver */
1235 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1239 /******************************************************************************
1240 * ExtEscape [GDI32.@]
1242 * Access capabilities of a particular device that are not available through GDI.
1245 * hdc [I] Handle to device context
1246 * nEscape [I] Escape function
1247 * cbInput [I] Number of bytes in input structure
1248 * lpszInData [I] Pointer to input structure
1249 * cbOutput [I] Number of bytes in output structure
1250 * lpszOutData [O] Pointer to output structure
1254 * Not implemented: 0
1257 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1258 INT cbOutput, LPSTR lpszOutData )
1261 DC * dc = get_dc_ptr( hdc );
1265 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1266 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1267 release_dc_ptr( dc );
1273 /*******************************************************************
1274 * DrawEscape [GDI32.@]
1278 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1280 FIXME("DrawEscape, stub\n");
1284 /*******************************************************************
1285 * NamedEscape [GDI32.@]
1287 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1288 INT cbOutput, LPSTR lpszOutData )
1290 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1291 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1296 /*******************************************************************
1297 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1298 * GdiEntry13 [GDI32.@]
1300 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1302 static int warn_once;