gdi32: Add null driver entry points for the various DC settings functions.
[wine.git] / dlls / gdi32 / driver.c
blob9a19cfde5e9b5e0abe83070388c905b50fcb1c9b
1 /*
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
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
26 #include <string.h>
27 #include <stdio.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "ddrawgdi.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
43 struct list entry;
44 HMODULE module; /* module handle */
45 DC_FUNCTIONS funcs;
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 /**********************************************************************
61 * create_driver
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 */
73 if (module)
75 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
76 GET_FUNC(AbortDoc);
77 GET_FUNC(AbortPath);
78 GET_FUNC(AlphaBlend);
79 GET_FUNC(AngleArc);
80 GET_FUNC(Arc);
81 GET_FUNC(ArcTo);
82 GET_FUNC(BeginPath);
83 GET_FUNC(BitBlt);
84 GET_FUNC(ChoosePixelFormat);
85 GET_FUNC(Chord);
86 GET_FUNC(CloseFigure);
87 GET_FUNC(CreateBitmap);
88 GET_FUNC(CreateDC);
89 GET_FUNC(CreateDIBSection);
90 GET_FUNC(DeleteBitmap);
91 GET_FUNC(DeleteDC);
92 GET_FUNC(DescribePixelFormat);
93 GET_FUNC(DeviceCapabilities);
94 GET_FUNC(Ellipse);
95 GET_FUNC(EndDoc);
96 GET_FUNC(EndPage);
97 GET_FUNC(EndPath);
98 GET_FUNC(EnumDeviceFonts);
99 GET_FUNC(EnumICMProfiles);
100 GET_FUNC(ExcludeClipRect);
101 GET_FUNC(ExtDeviceMode);
102 GET_FUNC(ExtEscape);
103 GET_FUNC(ExtFloodFill);
104 GET_FUNC(ExtSelectClipRgn);
105 GET_FUNC(ExtTextOut);
106 GET_FUNC(FillPath);
107 GET_FUNC(FillRgn);
108 GET_FUNC(FlattenPath);
109 GET_FUNC(FrameRgn);
110 GET_FUNC(GdiComment);
111 GET_FUNC(GetBitmapBits);
112 GET_FUNC(GetCharWidth);
113 GET_FUNC(GetDIBits);
114 GET_FUNC(GetDeviceCaps);
115 GET_FUNC(GetDeviceGammaRamp);
116 GET_FUNC(GetICMProfile);
117 GET_FUNC(GetNearestColor);
118 GET_FUNC(GetPixel);
119 GET_FUNC(GetPixelFormat);
120 GET_FUNC(GetSystemPaletteEntries);
121 GET_FUNC(GetTextExtentExPoint);
122 GET_FUNC(GetTextMetrics);
123 GET_FUNC(IntersectClipRect);
124 GET_FUNC(InvertRgn);
125 GET_FUNC(LineTo);
126 GET_FUNC(MoveTo);
127 GET_FUNC(ModifyWorldTransform);
128 GET_FUNC(OffsetClipRgn);
129 GET_FUNC(OffsetViewportOrgEx);
130 GET_FUNC(OffsetWindowOrgEx);
131 GET_FUNC(PaintRgn);
132 GET_FUNC(PatBlt);
133 GET_FUNC(Pie);
134 GET_FUNC(PolyBezier);
135 GET_FUNC(PolyBezierTo);
136 GET_FUNC(PolyDraw);
137 GET_FUNC(PolyPolygon);
138 GET_FUNC(PolyPolyline);
139 GET_FUNC(Polygon);
140 GET_FUNC(Polyline);
141 GET_FUNC(PolylineTo);
142 GET_FUNC(RealizeDefaultPalette);
143 GET_FUNC(RealizePalette);
144 GET_FUNC(Rectangle);
145 GET_FUNC(ResetDC);
146 GET_FUNC(RestoreDC);
147 GET_FUNC(RoundRect);
148 GET_FUNC(SaveDC);
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);
156 GET_FUNC(SelectPen);
157 GET_FUNC(SetArcDirection);
158 GET_FUNC(SetBitmapBits);
159 GET_FUNC(SetBkColor);
160 GET_FUNC(SetBkMode);
161 GET_FUNC(SetDCBrushColor);
162 GET_FUNC(SetDCPenColor);
163 GET_FUNC(SetDIBColorTable);
164 GET_FUNC(SetDIBits);
165 GET_FUNC(SetDIBitsToDevice);
166 GET_FUNC(SetDeviceClipping);
167 GET_FUNC(SetDeviceGammaRamp);
168 GET_FUNC(SetMapMode);
169 GET_FUNC(SetMapperFlags);
170 GET_FUNC(SetPixel);
171 GET_FUNC(SetPixelFormat);
172 GET_FUNC(SetPolyFillMode);
173 GET_FUNC(SetROP2);
174 GET_FUNC(SetRelAbs);
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);
185 GET_FUNC(StartDoc);
186 GET_FUNC(StartPage);
187 GET_FUNC(StretchBlt);
188 GET_FUNC(StretchDIBits);
189 GET_FUNC(StrokeAndFillPath);
190 GET_FUNC(StrokePath);
191 GET_FUNC(SwapBuffers);
192 GET_FUNC(UnrealizePalette);
193 GET_FUNC(WidenPath);
195 /* OpenGL32 */
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);
207 #undef GET_FUNC
209 else memset( &driver->funcs, 0, sizeof(driver->funcs) );
211 return driver;
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;
224 HMODULE module = 0;
225 HKEY hkey;
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 );
235 RegCloseKey( hkey );
238 name = buffer;
239 while (name)
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;
246 name = next;
249 if (!(driver = create_driver( module )))
251 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
252 FreeLibrary( module );
253 ExitProcess(1);
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 /**********************************************************************
266 * DRIVER_load_driver
268 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
270 HMODULE module;
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 );
294 return NULL;
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 );
304 goto done;
306 driver = new_driver;
307 list_add_head( &drivers, &driver->entry );
308 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
309 done:
310 LeaveCriticalSection( &driver_section );
311 return &driver->funcs;
315 static INT CDECL nulldrv_AbortDoc( PHYSDEV dev )
317 return 0;
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 )
323 return TRUE;
326 static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
327 INT xstart, INT ystart, INT xend, INT yend )
329 return TRUE;
332 static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
334 return TRUE;
337 static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
339 return TRUE;
342 static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
344 return 0;
347 static INT CDECL nulldrv_EndPage( PHYSDEV dev )
349 return 0;
352 static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
354 return TRUE;
357 static COLORREF CDECL nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
359 return 0;
362 static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
364 return TRUE;
367 static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
369 return TRUE;
372 static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
374 return TRUE;
377 static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
378 INT xstart, INT ystart, INT xend, INT yend )
380 return TRUE;
383 static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
385 /* FIXME: could be implemented with Polygon */
386 return TRUE;
389 static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
391 /* FIXME: could be implemented with Polyline */
392 return TRUE;
395 static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
397 return TRUE;
400 static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
402 return TRUE;
405 static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
407 return TRUE;
410 static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
411 INT ell_width, INT ell_height )
413 return TRUE;
416 static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
418 return bitmap;
421 static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush )
423 return brush;
426 static HFONT CDECL nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font )
428 return 0;
431 static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
433 return palette;
436 static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
438 return pen;
441 static INT CDECL nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
443 return dir;
446 static COLORREF CDECL nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
448 return color;
451 static INT CDECL nulldrv_SetBkMode( PHYSDEV dev, INT mode )
453 return mode;
456 static COLORREF CDECL nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
458 return color;
461 static COLORREF CDECL nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
463 return color;
466 static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
470 static DWORD CDECL nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
472 return flags;
475 static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
477 return color;
480 static INT CDECL nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
482 return mode;
485 static INT CDECL nulldrv_SetROP2( PHYSDEV dev, INT rop )
487 return rop;
490 static INT CDECL nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
492 return mode;
495 static INT CDECL nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
497 return mode;
500 static UINT CDECL nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
502 return align;
505 static INT CDECL nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
507 return extra;
510 static COLORREF CDECL nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
512 return color;
515 static BOOL CDECL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
517 return TRUE;
520 static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
522 return 0;
525 static INT CDECL nulldrv_StartPage( PHYSDEV dev )
527 return 1;
530 static BOOL CDECL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
532 return FALSE;
535 static HGLRC CDECL nulldrv_wglCreateContext( PHYSDEV dev )
537 return 0;
540 static HGLRC CDECL nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
542 return 0;
545 static BOOL CDECL nulldrv_wglDeleteContext( HGLRC ctx )
547 return FALSE;
550 static PROC CDECL nulldrv_wglGetProcAddress( LPCSTR name )
552 return NULL;
555 static HDC CDECL nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
557 return 0;
560 static BOOL CDECL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
562 return FALSE;
565 static BOOL CDECL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
567 return FALSE;
570 static BOOL CDECL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format,
571 const PIXELFORMATDESCRIPTOR *descr )
573 return FALSE;
576 static BOOL CDECL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
578 return FALSE;
581 static BOOL CDECL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
583 return FALSE;
586 static BOOL CDECL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
588 return FALSE;
591 const DC_FUNCTIONS null_driver =
593 nulldrv_AbortDoc, /* pAbortDoc */
594 NULL, /* pAbortPath */
595 NULL, /* pAlphaBlend */
596 nulldrv_AngleArc, /* pAngleArc */
597 nulldrv_Arc, /* pArc */
598 nulldrv_ArcTo, /* pArcTo */
599 NULL, /* pBeginPath */
600 NULL, /* pBitBlt */
601 NULL, /* pChoosePixelFormat */
602 nulldrv_Chord, /* pChord */
603 NULL, /* pCloseFigure */
604 NULL, /* pCreateBitmap */
605 NULL, /* pCreateDC */
606 NULL, /* pCreateDIBSection */
607 NULL, /* pDeleteBitmap */
608 NULL, /* pDeleteDC */
609 nulldrv_DeleteObject, /* pDeleteObject */
610 NULL, /* pDescribePixelFormat */
611 NULL, /* pDeviceCapabilities */
612 nulldrv_Ellipse, /* pEllipse */
613 nulldrv_EndDoc, /* pEndDoc */
614 nulldrv_EndPage, /* pEndPage */
615 NULL, /* pEndPath */
616 NULL, /* pEnumICMProfiles */
617 NULL, /* pEnumDeviceFonts */
618 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
619 NULL, /* pExtDeviceMode */
620 NULL, /* pExtEscape */
621 nulldrv_ExtFloodFill, /* pExtFloodFill */
622 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
623 NULL, /* pExtTextOut */
624 NULL, /* pFillPath */
625 nulldrv_FillRgn, /* pFillRgn */
626 NULL, /* pFlattenPath */
627 nulldrv_FrameRgn, /* pFrameRgn */
628 NULL, /* pGdiComment */
629 NULL, /* pGetBitmapBits */
630 NULL, /* pGetCharWidth */
631 NULL, /* pGetDIBits */
632 NULL, /* pGetDeviceCaps */
633 NULL, /* pGetDeviceGammaRamp */
634 NULL, /* pGetICMProfile */
635 NULL, /* pGetNearestColor */
636 nulldrv_GetPixel, /* pGetPixel */
637 NULL, /* pGetPixelFormat */
638 NULL, /* pGetSystemPaletteEntries */
639 NULL, /* pGetTextExtentExPoint */
640 NULL, /* pGetTextMetrics */
641 nulldrv_IntersectClipRect, /* pIntersectClipRect */
642 nulldrv_InvertRgn, /* pInvertRgn */
643 nulldrv_LineTo, /* pLineTo */
644 NULL, /* pModifyWorldTransform */
645 nulldrv_MoveTo, /* pMoveTo */
646 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
647 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
648 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
649 nulldrv_PaintRgn, /* pPaintRgn */
650 NULL, /* pPatBlt */
651 nulldrv_Pie, /* pPie */
652 nulldrv_PolyBezier, /* pPolyBezier */
653 nulldrv_PolyBezierTo, /* pPolyBezierTo */
654 nulldrv_PolyDraw, /* pPolyDraw */
655 nulldrv_PolyPolygon, /* pPolyPolygon */
656 nulldrv_PolyPolyline, /* pPolyPolyline */
657 nulldrv_Polygon, /* pPolygon */
658 nulldrv_Polyline, /* pPolyline */
659 nulldrv_PolylineTo, /* pPolylineTo */
660 NULL, /* pRealizeDefaultPalette */
661 NULL, /* pRealizePalette */
662 nulldrv_Rectangle, /* pRectangle */
663 NULL, /* pResetDC */
664 NULL, /* pRestoreDC */
665 nulldrv_RoundRect, /* pRoundRect */
666 NULL, /* pSaveDC */
667 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
668 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
669 nulldrv_SelectBitmap, /* pSelectBitmap */
670 nulldrv_SelectBrush, /* pSelectBrush */
671 NULL, /* pSelectClipPath */
672 nulldrv_SelectFont, /* pSelectFont */
673 nulldrv_SelectPalette, /* pSelectPalette */
674 nulldrv_SelectPen, /* pSelectPen */
675 nulldrv_SetArcDirection, /* pSetArcDirection */
676 NULL, /* pSetBitmapBits */
677 nulldrv_SetBkColor, /* pSetBkColor */
678 nulldrv_SetBkMode, /* pSetBkMode */
679 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
680 nulldrv_SetDCPenColor, /* pSetDCPenColor */
681 NULL, /* pSetDIBColorTable */
682 NULL, /* pSetDIBits */
683 NULL, /* pSetDIBitsToDevice */
684 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
685 NULL, /* pSetDeviceGammaRamp */
686 nulldrv_SetMapMode, /* pSetMapMode */
687 nulldrv_SetMapperFlags, /* pSetMapperFlags */
688 nulldrv_SetPixel, /* pSetPixel */
689 NULL, /* pSetPixelFormat */
690 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
691 nulldrv_SetROP2, /* pSetROP2 */
692 nulldrv_SetRelAbs, /* pSetRelAbs */
693 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
694 nulldrv_SetTextAlign, /* pSetTextAlign */
695 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
696 nulldrv_SetTextColor, /* pSetTextColor */
697 nulldrv_SetTextJustification, /* pSetTextJustification */
698 nulldrv_SetViewportExtEx, /* pSetViewportExt */
699 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
700 nulldrv_SetWindowExtEx, /* pSetWindowExt */
701 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
702 NULL, /* pSetWorldTransform */
703 nulldrv_StartDoc, /* pStartDoc */
704 nulldrv_StartPage, /* pStartPage */
705 NULL, /* pStretchBlt */
706 NULL, /* pStretchDIBits */
707 NULL, /* pStrokeAndFillPath */
708 NULL, /* pStrokePath */
709 NULL, /* pSwapBuffers */
710 NULL, /* pUnrealizePalette */
711 NULL, /* pWidenPath */
712 nulldrv_wglCopyContext, /* pwglCopyContext */
713 nulldrv_wglCreateContext, /* pwglCreateContext */
714 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
715 nulldrv_wglDeleteContext, /* pwglDeleteContext */
716 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
717 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
718 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
719 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
720 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
721 nulldrv_wglShareLists, /* pwglShareLists */
722 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
723 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
727 /*****************************************************************************
728 * DRIVER_GetDriverName
731 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
733 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
734 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
735 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
736 static const WCHAR empty_strW[] = { 0 };
737 WCHAR *p;
739 /* display is a special case */
740 if (!strcmpiW( device, displayW ) ||
741 !strcmpiW( device, display1W ))
743 lstrcpynW( driver, displayW, size );
744 return TRUE;
747 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
748 if(!size) {
749 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
750 return FALSE;
752 p = strchrW(driver, ',');
753 if(!p)
755 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
756 return FALSE;
758 *p = 0;
759 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
760 return TRUE;
764 /***********************************************************************
765 * GdiConvertToDevmodeW (GDI32.@)
767 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
769 DEVMODEW *dmW;
770 WORD dmW_size, dmA_size;
772 dmA_size = dmA->dmSize;
774 /* this is the minimal dmSize that XP accepts */
775 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
776 return NULL;
778 if (dmA_size > sizeof(DEVMODEA))
779 dmA_size = sizeof(DEVMODEA);
781 dmW_size = dmA_size + CCHDEVICENAME;
782 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
783 dmW_size += CCHFORMNAME;
785 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
786 if (!dmW) return NULL;
788 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
789 dmW->dmDeviceName, CCHDEVICENAME);
790 /* copy slightly more, to avoid long computations */
791 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
793 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
795 if (dmA->dmFields & DM_FORMNAME)
796 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
797 dmW->dmFormName, CCHFORMNAME);
798 else
799 dmW->dmFormName[0] = 0;
801 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
802 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
805 if (dmA->dmDriverExtra)
806 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
808 dmW->dmSize = dmW_size;
810 return dmW;
814 /*****************************************************************************
815 * @ [GDI32.100]
817 * This should thunk to 16-bit and simply call the proc with the given args.
819 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
820 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
822 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
823 return -1;
826 /*****************************************************************************
827 * @ [GDI32.101]
829 * This should load the correct driver for lpszDevice and calls this driver's
830 * ExtDeviceModePropSheet proc.
832 * Note: The driver calls a callback routine for each property sheet page; these
833 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
834 * The layout of this structure is:
836 * struct
838 * DWORD nPages;
839 * DWORD unknown;
840 * HPROPSHEETPAGE pages[10];
841 * };
843 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
844 LPCSTR lpszPort, LPVOID lpPropSheet )
846 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
847 return -1;
850 /*****************************************************************************
851 * @ [GDI32.102]
853 * This should load the correct driver for lpszDevice and call this driver's
854 * ExtDeviceMode proc.
856 * FIXME: convert ExtDeviceMode to unicode in the driver interface
858 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
859 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
860 LPSTR lpszPort, LPDEVMODEA lpdmInput,
861 LPSTR lpszProfile, DWORD fwMode )
863 WCHAR deviceW[300];
864 WCHAR bufW[300];
865 char buf[300];
866 HDC hdc;
867 DC *dc;
868 INT ret = -1;
870 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
871 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
873 if (!lpszDevice) return -1;
874 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
876 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
878 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
880 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
882 if ((dc = get_dc_ptr( hdc )))
884 if (dc->funcs->pExtDeviceMode)
885 ret = dc->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
886 lpdmInput, lpszProfile, fwMode );
887 release_dc_ptr( dc );
889 DeleteDC( hdc );
890 return ret;
893 /****************************************************************************
894 * @ [GDI32.103]
896 * This should load the correct driver for lpszDevice and calls this driver's
897 * AdvancedSetupDialog proc.
899 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
900 LPDEVMODEA devin, LPDEVMODEA devout )
902 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
903 return -1;
906 /*****************************************************************************
907 * @ [GDI32.104]
909 * This should load the correct driver for lpszDevice and calls this driver's
910 * DeviceCapabilities proc.
912 * FIXME: convert DeviceCapabilities to unicode in the driver interface
914 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
915 WORD fwCapability, LPSTR lpszOutput,
916 LPDEVMODEA lpdm )
918 WCHAR deviceW[300];
919 WCHAR bufW[300];
920 char buf[300];
921 HDC hdc;
922 DC *dc;
923 INT ret = -1;
925 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
927 if (!lpszDevice) return -1;
928 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
930 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
932 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
934 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
936 if ((dc = get_dc_ptr( hdc )))
938 if (dc->funcs->pDeviceCapabilities)
939 ret = dc->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
940 fwCapability, lpszOutput, lpdm );
941 release_dc_ptr( dc );
943 DeleteDC( hdc );
944 return ret;
948 /************************************************************************
949 * Escape [GDI32.@]
951 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
953 INT ret;
954 POINT *pt;
956 switch (escape)
958 case ABORTDOC:
959 return AbortDoc( hdc );
961 case ENDDOC:
962 return EndDoc( hdc );
964 case GETPHYSPAGESIZE:
965 pt = out_data;
966 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
967 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
968 return 1;
970 case GETPRINTINGOFFSET:
971 pt = out_data;
972 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
973 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
974 return 1;
976 case GETSCALINGFACTOR:
977 pt = out_data;
978 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
979 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
980 return 1;
982 case NEWFRAME:
983 return EndPage( hdc );
985 case SETABORTPROC:
986 return SetAbortProc( hdc, (ABORTPROC)in_data );
988 case STARTDOC:
990 DOCINFOA doc;
991 char *name = NULL;
993 /* in_data may not be 0 terminated so we must copy it */
994 if (in_data)
996 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
997 memcpy( name, in_data, in_count );
998 name[in_count] = 0;
1000 /* out_data is actually a pointer to the DocInfo structure and used as
1001 * a second input parameter */
1002 if (out_data) doc = *(DOCINFOA *)out_data;
1003 else
1005 doc.cbSize = sizeof(doc);
1006 doc.lpszOutput = NULL;
1007 doc.lpszDatatype = NULL;
1008 doc.fwType = 0;
1010 doc.lpszDocName = name;
1011 ret = StartDocA( hdc, &doc );
1012 HeapFree( GetProcessHeap(), 0, name );
1013 if (ret > 0) ret = StartPage( hdc );
1014 return ret;
1017 case QUERYESCSUPPORT:
1019 const INT *ptr = (const INT *)in_data;
1020 if (in_count < sizeof(INT)) return 0;
1021 switch(*ptr)
1023 case ABORTDOC:
1024 case ENDDOC:
1025 case GETPHYSPAGESIZE:
1026 case GETPRINTINGOFFSET:
1027 case GETSCALINGFACTOR:
1028 case NEWFRAME:
1029 case QUERYESCSUPPORT:
1030 case SETABORTPROC:
1031 case STARTDOC:
1032 return TRUE;
1034 break;
1038 /* if not handled internally, pass it to the driver */
1039 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1043 /******************************************************************************
1044 * ExtEscape [GDI32.@]
1046 * Access capabilities of a particular device that are not available through GDI.
1048 * PARAMS
1049 * hdc [I] Handle to device context
1050 * nEscape [I] Escape function
1051 * cbInput [I] Number of bytes in input structure
1052 * lpszInData [I] Pointer to input structure
1053 * cbOutput [I] Number of bytes in output structure
1054 * lpszOutData [O] Pointer to output structure
1056 * RETURNS
1057 * Success: >0
1058 * Not implemented: 0
1059 * Failure: <0
1061 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1062 INT cbOutput, LPSTR lpszOutData )
1064 INT ret = 0;
1065 DC * dc = get_dc_ptr( hdc );
1066 if (dc)
1068 if (dc->funcs->pExtEscape)
1069 ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1070 release_dc_ptr( dc );
1072 return ret;
1076 /*******************************************************************
1077 * DrawEscape [GDI32.@]
1081 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1083 FIXME("DrawEscape, stub\n");
1084 return 0;
1087 /*******************************************************************
1088 * NamedEscape [GDI32.@]
1090 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1091 INT cbOutput, LPSTR lpszOutData )
1093 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1094 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1095 lpszOutData);
1096 return 0;
1099 /*******************************************************************
1100 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1101 * GdiEntry13 [GDI32.@]
1103 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1105 static int warn_once;
1107 if (!warn_once++)
1108 FIXME("stub\n");
1109 return 0;