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);
169 GET_FUNC(SetMapMode);
170 GET_FUNC(SetMapperFlags);
172 GET_FUNC(SetPixelFormat);
173 GET_FUNC(SetPolyFillMode);
176 GET_FUNC(SetStretchBltMode);
177 GET_FUNC(SetTextAlign);
178 GET_FUNC(SetTextCharacterExtra);
179 GET_FUNC(SetTextColor);
180 GET_FUNC(SetTextJustification);
181 GET_FUNC(SetViewportExtEx);
182 GET_FUNC(SetViewportOrgEx);
183 GET_FUNC(SetWindowExtEx);
184 GET_FUNC(SetWindowOrgEx);
185 GET_FUNC(SetWorldTransform);
188 GET_FUNC(StretchBlt);
189 GET_FUNC(StretchDIBits);
190 GET_FUNC(StrokeAndFillPath);
191 GET_FUNC(StrokePath);
192 GET_FUNC(SwapBuffers);
193 GET_FUNC(UnrealizePalette);
197 GET_FUNC(wglCreateContext);
198 GET_FUNC(wglCreateContextAttribsARB);
199 GET_FUNC(wglDeleteContext);
200 GET_FUNC(wglGetProcAddress);
201 GET_FUNC(wglGetPbufferDCARB);
202 GET_FUNC(wglMakeContextCurrentARB);
203 GET_FUNC(wglMakeCurrent);
204 GET_FUNC(wglSetPixelFormatWINE);
205 GET_FUNC(wglShareLists);
206 GET_FUNC(wglUseFontBitmapsA);
207 GET_FUNC(wglUseFontBitmapsW);
210 else memset( &driver->funcs, 0, sizeof(driver->funcs) );
216 /**********************************************************************
217 * DRIVER_get_display_driver
219 * Special case for loading the display driver: get the name from the config file
221 const DC_FUNCTIONS *DRIVER_get_display_driver(void)
223 struct graphics_driver *driver;
224 char buffer[MAX_PATH], libname[32], *name, *next;
228 if (display_driver) return &display_driver->funcs; /* already loaded */
230 strcpy( buffer, "x11" ); /* default value */
231 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
232 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
234 DWORD type, count = sizeof(buffer);
235 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
242 next = strchr( name, ',' );
243 if (next) *next++ = 0;
245 snprintf( libname, sizeof(libname), "wine%s.drv", name );
246 if ((module = LoadLibraryA( libname )) != 0) break;
250 if (!(driver = create_driver( module )))
252 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
253 FreeLibrary( module );
256 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
258 /* somebody beat us to it */
259 FreeLibrary( driver->module );
260 HeapFree( GetProcessHeap(), 0, driver );
262 return &display_driver->funcs;
266 /**********************************************************************
269 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
272 struct graphics_driver *driver, *new_driver;
273 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
274 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
276 /* display driver is a special case */
277 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return DRIVER_get_display_driver();
279 if ((module = GetModuleHandleW( name )))
281 if (display_driver && display_driver->module == module) return &display_driver->funcs;
282 EnterCriticalSection( &driver_section );
283 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
285 if (driver->module == module) goto done;
287 LeaveCriticalSection( &driver_section );
290 if (!(module = LoadLibraryW( name ))) return NULL;
292 if (!(new_driver = create_driver( module )))
294 FreeLibrary( module );
298 /* check if someone else added it in the meantime */
299 EnterCriticalSection( &driver_section );
300 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
302 if (driver->module != module) continue;
303 FreeLibrary( module );
304 HeapFree( GetProcessHeap(), 0, new_driver );
308 list_add_head( &drivers, &driver->entry );
309 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
311 LeaveCriticalSection( &driver_section );
312 return &driver->funcs;
316 static INT CDECL nulldrv_AbortDoc( PHYSDEV dev )
321 static BOOL CDECL nulldrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
322 PHYSDEV src_dev, struct bitblt_coords *src, BLENDFUNCTION func)
327 static BOOL CDECL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
328 INT xstart, INT ystart, INT xend, INT yend )
333 static INT CDECL nulldrv_ChoosePixelFormat( PHYSDEV dev, const PIXELFORMATDESCRIPTOR *descr )
338 static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
339 INT xstart, INT ystart, INT xend, INT yend )
344 static BOOL CDECL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap, LPVOID bits )
349 static BOOL CDECL nulldrv_CreateDC( HDC hdc, PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
350 LPCWSTR output, const DEVMODEW *devmode )
352 assert(0); /* should never be called */
356 static HBITMAP CDECL nulldrv_CreateDIBSection( PHYSDEV dev, HBITMAP bitmap,
357 const BITMAPINFO *info, UINT usage )
362 static BOOL CDECL nulldrv_DeleteBitmap( HBITMAP bitmap )
367 static BOOL CDECL nulldrv_DeleteDC( PHYSDEV dev )
369 assert(0); /* should never be called */
373 static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
378 static INT CDECL nulldrv_DescribePixelFormat( PHYSDEV dev, INT format,
379 UINT size, PIXELFORMATDESCRIPTOR * descr )
384 static DWORD CDECL nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
385 WORD cap, LPSTR output, DEVMODEA *devmode )
390 static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
395 static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
400 static INT CDECL nulldrv_EndPage( PHYSDEV dev )
405 static BOOL CDECL nulldrv_EnumDeviceFonts( PHYSDEV dev, LOGFONTW *logfont,
406 FONTENUMPROCW proc, LPARAM lParam )
411 static INT CDECL nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
416 static INT CDECL nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
417 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
422 static INT CDECL nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
423 INT out_size, void *out_data )
428 static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
433 static BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect,
434 LPCWSTR str, UINT count, const INT *dx )
439 static BOOL CDECL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
444 static BOOL CDECL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
449 static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
451 switch (cap) /* return meaningful values for some entries */
453 case HORZRES: return 640;
454 case VERTRES: return 480;
455 case BITSPIXEL: return 1;
456 case PLANES: return 1;
457 case NUMCOLORS: return 2;
458 case ASPECTX: return 36;
459 case ASPECTY: return 36;
460 case ASPECTXY: return 51;
461 case LOGPIXELSX: return 72;
462 case LOGPIXELSY: return 72;
463 case SIZEPALETTE: return 2;
464 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
465 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
466 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
471 static BOOL CDECL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
476 static BOOL CDECL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
481 static COLORREF CDECL nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
486 static INT CDECL nulldrv_GetPixelFormat( PHYSDEV dev )
491 static UINT CDECL nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start,
492 UINT count, PALETTEENTRY *entries )
497 static BOOL CDECL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
498 INT *fit, INT *dx, SIZE *size )
503 static BOOL CDECL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
508 static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
513 static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
518 static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
523 static BOOL CDECL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
528 static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
529 INT xstart, INT ystart, INT xend, INT yend )
534 static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
536 /* FIXME: could be implemented with Polygon */
540 static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
542 /* FIXME: could be implemented with Polyline */
546 static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
551 static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
556 static UINT CDECL nulldrv_RealizeDefaultPalette( PHYSDEV dev )
561 static UINT CDECL nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
566 static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
571 static HDC CDECL nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
576 static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
577 INT ell_width, INT ell_height )
582 static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
587 static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush )
592 static HFONT CDECL nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font )
597 static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
602 static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
607 static INT CDECL nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
612 static COLORREF CDECL nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
617 static INT CDECL nulldrv_SetBkMode( PHYSDEV dev, INT mode )
622 static COLORREF CDECL nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
627 static COLORREF CDECL nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
632 static UINT CDECL nulldrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RGBQUAD *colors )
637 static INT CDECL nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD width, DWORD height,
638 INT x_src, INT y_src, UINT start, UINT lines,
639 const void *bits, const BITMAPINFO *info, UINT coloruse )
644 static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
648 static DWORD CDECL nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
653 static BOOL CDECL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
658 static DWORD CDECL nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
663 static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
668 static BOOL CDECL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
673 static INT CDECL nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
678 static INT CDECL nulldrv_SetROP2( PHYSDEV dev, INT rop )
683 static INT CDECL nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
688 static INT CDECL nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
693 static UINT CDECL nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
698 static INT CDECL nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
703 static COLORREF CDECL nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
708 static BOOL CDECL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
713 static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
718 static INT CDECL nulldrv_StartPage( PHYSDEV dev )
723 static BOOL CDECL nulldrv_SwapBuffers( PHYSDEV dev )
728 static BOOL CDECL nulldrv_UnrealizePalette( HPALETTE palette )
733 static BOOL CDECL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
738 static HGLRC CDECL nulldrv_wglCreateContext( PHYSDEV dev )
743 static HGLRC CDECL nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
748 static BOOL CDECL nulldrv_wglDeleteContext( HGLRC ctx )
753 static PROC CDECL nulldrv_wglGetProcAddress( LPCSTR name )
758 static HDC CDECL nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
763 static BOOL CDECL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
768 static BOOL CDECL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
773 static BOOL CDECL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format,
774 const PIXELFORMATDESCRIPTOR *descr )
779 static BOOL CDECL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
784 static BOOL CDECL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
789 static BOOL CDECL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
794 const DC_FUNCTIONS null_driver =
796 nulldrv_AbortDoc, /* pAbortDoc */
797 nulldrv_AbortPath, /* pAbortPath */
798 nulldrv_AlphaBlend, /* pAlphaBlend */
799 nulldrv_AngleArc, /* pAngleArc */
800 nulldrv_Arc, /* pArc */
801 nulldrv_ArcTo, /* pArcTo */
802 nulldrv_BeginPath, /* pBeginPath */
803 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
804 nulldrv_Chord, /* pChord */
805 nulldrv_CloseFigure, /* pCloseFigure */
806 nulldrv_CreateBitmap, /* pCreateBitmap */
807 nulldrv_CreateDC, /* pCreateDC */
808 nulldrv_CreateDIBSection, /* pCreateDIBSection */
809 nulldrv_DeleteBitmap, /* pDeleteBitmap */
810 nulldrv_DeleteDC, /* pDeleteDC */
811 nulldrv_DeleteObject, /* pDeleteObject */
812 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
813 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
814 nulldrv_Ellipse, /* pEllipse */
815 nulldrv_EndDoc, /* pEndDoc */
816 nulldrv_EndPage, /* pEndPage */
817 nulldrv_EndPath, /* pEndPath */
818 nulldrv_EnumDeviceFonts, /* pEnumDeviceFonts */
819 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
820 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
821 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
822 nulldrv_ExtEscape, /* pExtEscape */
823 nulldrv_ExtFloodFill, /* pExtFloodFill */
824 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
825 nulldrv_ExtTextOut, /* pExtTextOut */
826 nulldrv_FillPath, /* pFillPath */
827 nulldrv_FillRgn, /* pFillRgn */
828 nulldrv_FlattenPath, /* pFlattenPath */
829 nulldrv_FrameRgn, /* pFrameRgn */
830 nulldrv_GdiComment, /* pGdiComment */
831 nulldrv_GetBitmapBits, /* pGetBitmapBits */
832 nulldrv_GetCharWidth, /* pGetCharWidth */
833 nulldrv_GetDIBits, /* pGetDIBits */
834 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
835 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
836 nulldrv_GetICMProfile, /* pGetICMProfile */
837 nulldrv_GetNearestColor, /* pGetNearestColor */
838 nulldrv_GetPixel, /* pGetPixel */
839 nulldrv_GetPixelFormat, /* pGetPixelFormat */
840 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
841 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
842 nulldrv_GetTextMetrics, /* pGetTextMetrics */
843 nulldrv_IntersectClipRect, /* pIntersectClipRect */
844 nulldrv_InvertRgn, /* pInvertRgn */
845 nulldrv_LineTo, /* pLineTo */
846 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
847 nulldrv_MoveTo, /* pMoveTo */
848 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
849 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
850 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
851 nulldrv_PaintRgn, /* pPaintRgn */
852 nulldrv_PatBlt, /* pPatBlt */
853 nulldrv_Pie, /* pPie */
854 nulldrv_PolyBezier, /* pPolyBezier */
855 nulldrv_PolyBezierTo, /* pPolyBezierTo */
856 nulldrv_PolyDraw, /* pPolyDraw */
857 nulldrv_PolyPolygon, /* pPolyPolygon */
858 nulldrv_PolyPolyline, /* pPolyPolyline */
859 nulldrv_Polygon, /* pPolygon */
860 nulldrv_Polyline, /* pPolyline */
861 nulldrv_PolylineTo, /* pPolylineTo */
862 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
863 nulldrv_RealizePalette, /* pRealizePalette */
864 nulldrv_Rectangle, /* pRectangle */
865 nulldrv_ResetDC, /* pResetDC */
866 nulldrv_RestoreDC, /* pRestoreDC */
867 nulldrv_RoundRect, /* pRoundRect */
868 nulldrv_SaveDC, /* pSaveDC */
869 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
870 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
871 nulldrv_SelectBitmap, /* pSelectBitmap */
872 nulldrv_SelectBrush, /* pSelectBrush */
873 nulldrv_SelectClipPath, /* pSelectClipPath */
874 nulldrv_SelectFont, /* pSelectFont */
875 nulldrv_SelectPalette, /* pSelectPalette */
876 nulldrv_SelectPen, /* pSelectPen */
877 nulldrv_SetArcDirection, /* pSetArcDirection */
878 nulldrv_SetBitmapBits, /* pSetBitmapBits */
879 nulldrv_SetBkColor, /* pSetBkColor */
880 nulldrv_SetBkMode, /* pSetBkMode */
881 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
882 nulldrv_SetDCPenColor, /* pSetDCPenColor */
883 nulldrv_SetDIBColorTable, /* pSetDIBColorTable */
884 nulldrv_SetDIBits, /* pSetDIBits */
885 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
886 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
887 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
888 nulldrv_SetLayout, /* pSetLayout */
889 nulldrv_SetMapMode, /* pSetMapMode */
890 nulldrv_SetMapperFlags, /* pSetMapperFlags */
891 nulldrv_SetPixel, /* pSetPixel */
892 nulldrv_SetPixelFormat, /* pSetPixelFormat */
893 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
894 nulldrv_SetROP2, /* pSetROP2 */
895 nulldrv_SetRelAbs, /* pSetRelAbs */
896 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
897 nulldrv_SetTextAlign, /* pSetTextAlign */
898 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
899 nulldrv_SetTextColor, /* pSetTextColor */
900 nulldrv_SetTextJustification, /* pSetTextJustification */
901 nulldrv_SetViewportExtEx, /* pSetViewportExt */
902 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
903 nulldrv_SetWindowExtEx, /* pSetWindowExt */
904 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
905 nulldrv_SetWorldTransform, /* pSetWorldTransform */
906 nulldrv_StartDoc, /* pStartDoc */
907 nulldrv_StartPage, /* pStartPage */
908 nulldrv_StretchBlt, /* pStretchBlt */
909 nulldrv_StretchDIBits, /* pStretchDIBits */
910 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
911 nulldrv_StrokePath, /* pStrokePath */
912 nulldrv_SwapBuffers, /* pSwapBuffers */
913 nulldrv_UnrealizePalette, /* pUnrealizePalette */
914 nulldrv_WidenPath, /* pWidenPath */
915 nulldrv_wglCopyContext, /* pwglCopyContext */
916 nulldrv_wglCreateContext, /* pwglCreateContext */
917 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
918 nulldrv_wglDeleteContext, /* pwglDeleteContext */
919 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
920 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
921 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
922 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
923 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
924 nulldrv_wglShareLists, /* pwglShareLists */
925 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
926 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
930 /*****************************************************************************
931 * DRIVER_GetDriverName
934 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
936 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
937 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
938 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
939 static const WCHAR empty_strW[] = { 0 };
942 /* display is a special case */
943 if (!strcmpiW( device, displayW ) ||
944 !strcmpiW( device, display1W ))
946 lstrcpynW( driver, displayW, size );
950 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
952 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
955 p = strchrW(driver, ',');
958 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
962 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
967 /***********************************************************************
968 * GdiConvertToDevmodeW (GDI32.@)
970 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
973 WORD dmW_size, dmA_size;
975 dmA_size = dmA->dmSize;
977 /* this is the minimal dmSize that XP accepts */
978 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
981 if (dmA_size > sizeof(DEVMODEA))
982 dmA_size = sizeof(DEVMODEA);
984 dmW_size = dmA_size + CCHDEVICENAME;
985 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
986 dmW_size += CCHFORMNAME;
988 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
989 if (!dmW) return NULL;
991 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
992 dmW->dmDeviceName, CCHDEVICENAME);
993 /* copy slightly more, to avoid long computations */
994 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
996 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
998 if (dmA->dmFields & DM_FORMNAME)
999 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
1000 dmW->dmFormName, CCHFORMNAME);
1002 dmW->dmFormName[0] = 0;
1004 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
1005 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
1008 if (dmA->dmDriverExtra)
1009 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
1011 dmW->dmSize = dmW_size;
1017 /*****************************************************************************
1020 * This should thunk to 16-bit and simply call the proc with the given args.
1022 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
1023 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
1025 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
1029 /*****************************************************************************
1032 * This should load the correct driver for lpszDevice and calls this driver's
1033 * ExtDeviceModePropSheet proc.
1035 * Note: The driver calls a callback routine for each property sheet page; these
1036 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1037 * The layout of this structure is:
1043 * HPROPSHEETPAGE pages[10];
1046 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
1047 LPCSTR lpszPort, LPVOID lpPropSheet )
1049 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
1053 /*****************************************************************************
1056 * This should load the correct driver for lpszDevice and call this driver's
1057 * ExtDeviceMode proc.
1059 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1061 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
1062 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
1063 LPSTR lpszPort, LPDEVMODEA lpdmInput,
1064 LPSTR lpszProfile, DWORD fwMode )
1073 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1074 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
1076 if (!lpszDevice) return -1;
1077 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1079 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1081 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1083 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1085 if ((dc = get_dc_ptr( hdc )))
1087 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
1088 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
1089 lpdmInput, lpszProfile, fwMode );
1090 release_dc_ptr( dc );
1096 /****************************************************************************
1099 * This should load the correct driver for lpszDevice and calls this driver's
1100 * AdvancedSetupDialog proc.
1102 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
1103 LPDEVMODEA devin, LPDEVMODEA devout )
1105 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
1109 /*****************************************************************************
1112 * This should load the correct driver for lpszDevice and calls this driver's
1113 * DeviceCapabilities proc.
1115 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1117 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1118 WORD fwCapability, LPSTR lpszOutput,
1128 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1130 if (!lpszDevice) return -1;
1131 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1133 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1135 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1137 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1139 if ((dc = get_dc_ptr( hdc )))
1141 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1142 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1143 fwCapability, lpszOutput, lpdm );
1144 release_dc_ptr( dc );
1151 /************************************************************************
1154 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1162 return AbortDoc( hdc );
1165 return EndDoc( hdc );
1167 case GETPHYSPAGESIZE:
1169 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1170 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1173 case GETPRINTINGOFFSET:
1175 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1176 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1179 case GETSCALINGFACTOR:
1181 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1182 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1186 return EndPage( hdc );
1189 return SetAbortProc( hdc, (ABORTPROC)in_data );
1196 /* in_data may not be 0 terminated so we must copy it */
1199 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1200 memcpy( name, in_data, in_count );
1203 /* out_data is actually a pointer to the DocInfo structure and used as
1204 * a second input parameter */
1205 if (out_data) doc = *(DOCINFOA *)out_data;
1208 doc.cbSize = sizeof(doc);
1209 doc.lpszOutput = NULL;
1210 doc.lpszDatatype = NULL;
1213 doc.lpszDocName = name;
1214 ret = StartDocA( hdc, &doc );
1215 HeapFree( GetProcessHeap(), 0, name );
1216 if (ret > 0) ret = StartPage( hdc );
1220 case QUERYESCSUPPORT:
1222 const INT *ptr = (const INT *)in_data;
1223 if (in_count < sizeof(INT)) return 0;
1228 case GETPHYSPAGESIZE:
1229 case GETPRINTINGOFFSET:
1230 case GETSCALINGFACTOR:
1232 case QUERYESCSUPPORT:
1241 /* if not handled internally, pass it to the driver */
1242 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1246 /******************************************************************************
1247 * ExtEscape [GDI32.@]
1249 * Access capabilities of a particular device that are not available through GDI.
1252 * hdc [I] Handle to device context
1253 * nEscape [I] Escape function
1254 * cbInput [I] Number of bytes in input structure
1255 * lpszInData [I] Pointer to input structure
1256 * cbOutput [I] Number of bytes in output structure
1257 * lpszOutData [O] Pointer to output structure
1261 * Not implemented: 0
1264 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1265 INT cbOutput, LPSTR lpszOutData )
1268 DC * dc = get_dc_ptr( hdc );
1272 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1273 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1274 release_dc_ptr( dc );
1280 /*******************************************************************
1281 * DrawEscape [GDI32.@]
1285 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1287 FIXME("DrawEscape, stub\n");
1291 /*******************************************************************
1292 * NamedEscape [GDI32.@]
1294 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1295 INT cbOutput, LPSTR lpszOutData )
1297 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1298 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1303 /*******************************************************************
1304 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1305 * GdiEntry13 [GDI32.@]
1307 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1309 static int warn_once;