kernel32: Add more tracing to GetDiskFreeSpaceW.
[wine/multimedia.git] / dlls / gdi32 / driver.c
blob2b8059a57cb4ee396ba9b3814e5e4e7077f7c649
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 <assert.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winreg.h"
32 #include "ddrawgdi.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
44 struct list entry;
45 HMODULE module; /* module handle */
46 const struct gdi_dc_funcs *funcs;
49 static struct list drivers = LIST_INIT( drivers );
50 static struct graphics_driver *display_driver;
52 const struct gdi_dc_funcs *font_driver = NULL;
54 static CRITICAL_SECTION driver_section;
55 static CRITICAL_SECTION_DEBUG critsect_debug =
57 0, 0, &driver_section,
58 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
59 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
61 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
63 /**********************************************************************
64 * create_driver
66 * Allocate and fill the driver structure for a given module.
68 static struct graphics_driver *create_driver( HMODULE module )
70 static const struct gdi_dc_funcs empty_funcs;
71 const struct gdi_dc_funcs *funcs = NULL;
72 struct graphics_driver *driver;
74 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
75 driver->module = module;
77 if (module)
79 const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int version );
81 if ((wine_get_gdi_driver = (void *)GetProcAddress( module, "wine_get_gdi_driver" )))
82 funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
84 if (!funcs) funcs = &empty_funcs;
85 driver->funcs = funcs;
86 return driver;
90 /**********************************************************************
91 * get_display_driver
93 * Special case for loading the display driver: get the name from the config file
95 static const struct gdi_dc_funcs *get_display_driver(void)
97 struct graphics_driver *driver;
98 char buffer[MAX_PATH], libname[32], *name, *next;
99 HMODULE module = 0;
100 HKEY hkey;
102 if (display_driver) return display_driver->funcs; /* already loaded */
104 strcpy( buffer, "x11" ); /* default value */
105 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
106 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
108 DWORD type, count = sizeof(buffer);
109 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
110 RegCloseKey( hkey );
113 name = buffer;
114 while (name)
116 next = strchr( name, ',' );
117 if (next) *next++ = 0;
119 snprintf( libname, sizeof(libname), "wine%s.drv", name );
120 if ((module = LoadLibraryA( libname )) != 0) break;
121 name = next;
124 if (!(driver = create_driver( module )))
126 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
127 FreeLibrary( module );
128 ExitProcess(1);
130 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
132 /* somebody beat us to it */
133 FreeLibrary( driver->module );
134 HeapFree( GetProcessHeap(), 0, driver );
136 return display_driver->funcs;
140 /**********************************************************************
141 * DRIVER_load_driver
143 const struct gdi_dc_funcs *DRIVER_load_driver( LPCWSTR name )
145 HMODULE module;
146 struct graphics_driver *driver, *new_driver;
147 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
148 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
150 /* display driver is a special case */
151 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return get_display_driver();
153 if ((module = GetModuleHandleW( name )))
155 if (display_driver && display_driver->module == module) return display_driver->funcs;
156 EnterCriticalSection( &driver_section );
157 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
159 if (driver->module == module) goto done;
161 LeaveCriticalSection( &driver_section );
164 if (!(module = LoadLibraryW( name ))) return NULL;
166 if (!(new_driver = create_driver( module )))
168 FreeLibrary( module );
169 return NULL;
172 /* check if someone else added it in the meantime */
173 EnterCriticalSection( &driver_section );
174 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
176 if (driver->module != module) continue;
177 FreeLibrary( module );
178 HeapFree( GetProcessHeap(), 0, new_driver );
179 goto done;
181 driver = new_driver;
182 list_add_head( &drivers, &driver->entry );
183 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
184 done:
185 LeaveCriticalSection( &driver_section );
186 return driver->funcs;
190 static INT nulldrv_AbortDoc( PHYSDEV dev )
192 return 0;
195 static BOOL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
196 INT xstart, INT ystart, INT xend, INT yend )
198 return TRUE;
201 static INT nulldrv_ChoosePixelFormat( PHYSDEV dev, const PIXELFORMATDESCRIPTOR *descr )
203 return 0;
206 static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
207 INT xstart, INT ystart, INT xend, INT yend )
209 return TRUE;
212 static BOOL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
214 if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
215 return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
218 static BOOL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
219 LPCWSTR output, const DEVMODEW *devmode )
221 assert(0); /* should never be called */
222 return FALSE;
225 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
227 assert(0); /* should never be called */
228 return TRUE;
231 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
233 return TRUE;
236 static INT nulldrv_DescribePixelFormat( PHYSDEV dev, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr )
238 return 0;
241 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
242 WORD cap, LPSTR output, DEVMODEA *devmode )
244 return -1;
247 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
249 return TRUE;
252 static INT nulldrv_EndDoc( PHYSDEV dev )
254 return 0;
257 static INT nulldrv_EndPage( PHYSDEV dev )
259 return 0;
262 static BOOL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
264 return TRUE;
267 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
269 return -1;
272 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
273 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
275 return -1;
278 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
279 INT out_size, void *out_data )
281 return 0;
284 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
286 return TRUE;
289 static BOOL nulldrv_FontIsLinked( PHYSDEV dev )
291 return FALSE;
294 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
296 return FALSE;
299 static BOOL nulldrv_GdiRealizationInfo( PHYSDEV dev, void *info )
301 return FALSE;
304 static UINT nulldrv_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
306 return DCB_RESET;
309 static BOOL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
311 return FALSE;
314 static BOOL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
316 return FALSE;
319 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
321 return FALSE;
324 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
326 switch (cap) /* return meaningful values for some entries */
328 case HORZRES: return 640;
329 case VERTRES: return 480;
330 case BITSPIXEL: return 1;
331 case PLANES: return 1;
332 case NUMCOLORS: return 2;
333 case ASPECTX: return 36;
334 case ASPECTY: return 36;
335 case ASPECTXY: return 51;
336 case LOGPIXELSX: return 72;
337 case LOGPIXELSY: return 72;
338 case SIZEPALETTE: return 2;
339 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
340 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
341 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
342 default: return 0;
346 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
348 SetLastError( ERROR_INVALID_PARAMETER );
349 return FALSE;
352 static DWORD nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
354 return FALSE;
357 static DWORD nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
359 return 0;
362 static DWORD nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
364 return GDI_ERROR;
367 static DWORD nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
368 DWORD size, LPVOID buffer, const MAT2 *mat )
370 return GDI_ERROR;
373 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
375 return FALSE;
378 static DWORD nulldrv_GetImage( PHYSDEV dev, BITMAPINFO *info, struct gdi_image_bits *bits,
379 struct bitblt_coords *src )
381 return ERROR_NOT_SUPPORTED;
384 static DWORD nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
386 return 0;
389 static UINT nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
391 return 0;
394 static INT nulldrv_GetPixelFormat( PHYSDEV dev )
396 return 0;
399 static UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
401 return 0;
404 static UINT nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
406 return DEFAULT_CHARSET;
409 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
410 INT *fit, INT *dx, SIZE *size )
412 return FALSE;
415 static BOOL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT max_ext,
416 INT *fit, INT *dx, SIZE *size )
418 return FALSE;
421 static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
423 INT ret = 0;
424 LOGFONTW font;
425 HFONT hfont = GetCurrentObject( dev->hdc, OBJ_FONT );
427 if (GetObjectW( hfont, sizeof(font), &font ))
429 ret = strlenW( font.lfFaceName ) + 1;
430 if (name)
432 lstrcpynW( name, font.lfFaceName, size );
433 ret = min( size, ret );
436 return ret;
439 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
441 return FALSE;
444 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
446 return TRUE;
449 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
451 return TRUE;
454 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
456 return TRUE;
459 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
461 return TRUE;
464 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
465 INT xstart, INT ystart, INT xend, INT yend )
467 return TRUE;
470 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
472 return TRUE;
475 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
477 return TRUE;
480 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
482 INT counts[1] = { count };
484 return PolyPolygon( dev->hdc, points, counts, 1 );
487 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
489 DWORD counts[1] = { count };
491 if (count < 0) return FALSE;
492 return PolyPolyline( dev->hdc, points, counts, 1 );
495 static DWORD nulldrv_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
496 const struct gdi_image_bits *bits, struct bitblt_coords *src,
497 struct bitblt_coords *dst, DWORD rop )
499 return ERROR_SUCCESS;
502 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
504 return 0;
507 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
509 return 0;
512 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
514 return TRUE;
517 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
519 return 0;
522 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
523 INT ell_width, INT ell_height )
525 return TRUE;
528 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
530 return bitmap;
533 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
535 return brush;
538 static HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font )
540 return 0;
543 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
545 return palette;
548 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen, const struct brush_pattern *pattern )
550 return pen;
553 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
555 return dir;
558 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
560 return color;
563 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
565 return mode;
568 static UINT nulldrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
570 return DCB_RESET;
573 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
575 return color;
578 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
580 return color;
583 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
587 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
589 return layout;
592 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
594 SetLastError( ERROR_INVALID_PARAMETER );
595 return FALSE;
598 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
600 return flags;
603 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
605 return color;
608 static BOOL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
610 return FALSE;
613 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
615 return mode;
618 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
620 return rop;
623 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
625 return mode;
628 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
630 return mode;
633 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
635 return align;
638 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
640 return extra;
643 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
645 return color;
648 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
650 return TRUE;
653 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
655 return 0;
658 static INT nulldrv_StartPage( PHYSDEV dev )
660 return 1;
663 static BOOL nulldrv_SwapBuffers( PHYSDEV dev )
665 return TRUE;
668 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
670 return FALSE;
673 static BOOL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
675 return FALSE;
678 static HGLRC nulldrv_wglCreateContext( PHYSDEV dev )
680 return 0;
683 static HGLRC nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
685 return 0;
688 static BOOL nulldrv_wglDeleteContext( HGLRC ctx )
690 return FALSE;
693 static PROC nulldrv_wglGetProcAddress( LPCSTR name )
695 return NULL;
698 static BOOL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
700 return FALSE;
703 static BOOL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
705 return FALSE;
708 static BOOL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
710 return FALSE;
713 static BOOL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
715 return FALSE;
718 static BOOL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
720 return FALSE;
723 static BOOL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
725 return FALSE;
728 const struct gdi_dc_funcs null_driver =
730 nulldrv_AbortDoc, /* pAbortDoc */
731 nulldrv_AbortPath, /* pAbortPath */
732 nulldrv_AlphaBlend, /* pAlphaBlend */
733 nulldrv_AngleArc, /* pAngleArc */
734 nulldrv_Arc, /* pArc */
735 nulldrv_ArcTo, /* pArcTo */
736 nulldrv_BeginPath, /* pBeginPath */
737 nulldrv_BlendImage, /* pBlendImage */
738 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
739 nulldrv_Chord, /* pChord */
740 nulldrv_CloseFigure, /* pCloseFigure */
741 nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
742 nulldrv_CreateDC, /* pCreateDC */
743 nulldrv_DeleteDC, /* pDeleteDC */
744 nulldrv_DeleteObject, /* pDeleteObject */
745 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
746 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
747 nulldrv_Ellipse, /* pEllipse */
748 nulldrv_EndDoc, /* pEndDoc */
749 nulldrv_EndPage, /* pEndPage */
750 nulldrv_EndPath, /* pEndPath */
751 nulldrv_EnumFonts, /* pEnumFonts */
752 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
753 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
754 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
755 nulldrv_ExtEscape, /* pExtEscape */
756 nulldrv_ExtFloodFill, /* pExtFloodFill */
757 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
758 nulldrv_ExtTextOut, /* pExtTextOut */
759 nulldrv_FillPath, /* pFillPath */
760 nulldrv_FillRgn, /* pFillRgn */
761 nulldrv_FlattenPath, /* pFlattenPath */
762 nulldrv_FontIsLinked, /* pFontIsLinked */
763 nulldrv_FrameRgn, /* pFrameRgn */
764 nulldrv_GdiComment, /* pGdiComment */
765 nulldrv_GdiRealizationInfo, /* pGdiRealizationInfo */
766 nulldrv_GetBoundsRect, /* pGetBoundsRect */
767 nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
768 nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
769 nulldrv_GetCharWidth, /* pGetCharWidth */
770 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
771 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
772 nulldrv_GetFontData, /* pGetFontData */
773 nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
774 nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
775 nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
776 nulldrv_GetICMProfile, /* pGetICMProfile */
777 nulldrv_GetImage, /* pGetImage */
778 nulldrv_GetKerningPairs, /* pGetKerningPairs */
779 nulldrv_GetNearestColor, /* pGetNearestColor */
780 nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
781 nulldrv_GetPixel, /* pGetPixel */
782 nulldrv_GetPixelFormat, /* pGetPixelFormat */
783 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
784 nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
785 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
786 nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
787 nulldrv_GetTextFace, /* pGetTextFace */
788 nulldrv_GetTextMetrics, /* pGetTextMetrics */
789 nulldrv_GradientFill, /* pGradientFill */
790 nulldrv_IntersectClipRect, /* pIntersectClipRect */
791 nulldrv_InvertRgn, /* pInvertRgn */
792 nulldrv_LineTo, /* pLineTo */
793 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
794 nulldrv_MoveTo, /* pMoveTo */
795 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
796 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
797 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
798 nulldrv_PaintRgn, /* pPaintRgn */
799 nulldrv_PatBlt, /* pPatBlt */
800 nulldrv_Pie, /* pPie */
801 nulldrv_PolyBezier, /* pPolyBezier */
802 nulldrv_PolyBezierTo, /* pPolyBezierTo */
803 nulldrv_PolyDraw, /* pPolyDraw */
804 nulldrv_PolyPolygon, /* pPolyPolygon */
805 nulldrv_PolyPolyline, /* pPolyPolyline */
806 nulldrv_Polygon, /* pPolygon */
807 nulldrv_Polyline, /* pPolyline */
808 nulldrv_PolylineTo, /* pPolylineTo */
809 nulldrv_PutImage, /* pPutImage */
810 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
811 nulldrv_RealizePalette, /* pRealizePalette */
812 nulldrv_Rectangle, /* pRectangle */
813 nulldrv_ResetDC, /* pResetDC */
814 nulldrv_RestoreDC, /* pRestoreDC */
815 nulldrv_RoundRect, /* pRoundRect */
816 nulldrv_SaveDC, /* pSaveDC */
817 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
818 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
819 nulldrv_SelectBitmap, /* pSelectBitmap */
820 nulldrv_SelectBrush, /* pSelectBrush */
821 nulldrv_SelectClipPath, /* pSelectClipPath */
822 nulldrv_SelectFont, /* pSelectFont */
823 nulldrv_SelectPalette, /* pSelectPalette */
824 nulldrv_SelectPen, /* pSelectPen */
825 nulldrv_SetArcDirection, /* pSetArcDirection */
826 nulldrv_SetBkColor, /* pSetBkColor */
827 nulldrv_SetBkMode, /* pSetBkMode */
828 nulldrv_SetBoundsRect, /* pSetBoundsRect */
829 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
830 nulldrv_SetDCPenColor, /* pSetDCPenColor */
831 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
832 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
833 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
834 nulldrv_SetLayout, /* pSetLayout */
835 nulldrv_SetMapMode, /* pSetMapMode */
836 nulldrv_SetMapperFlags, /* pSetMapperFlags */
837 nulldrv_SetPixel, /* pSetPixel */
838 nulldrv_SetPixelFormat, /* pSetPixelFormat */
839 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
840 nulldrv_SetROP2, /* pSetROP2 */
841 nulldrv_SetRelAbs, /* pSetRelAbs */
842 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
843 nulldrv_SetTextAlign, /* pSetTextAlign */
844 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
845 nulldrv_SetTextColor, /* pSetTextColor */
846 nulldrv_SetTextJustification, /* pSetTextJustification */
847 nulldrv_SetViewportExtEx, /* pSetViewportExt */
848 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
849 nulldrv_SetWindowExtEx, /* pSetWindowExt */
850 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
851 nulldrv_SetWorldTransform, /* pSetWorldTransform */
852 nulldrv_StartDoc, /* pStartDoc */
853 nulldrv_StartPage, /* pStartPage */
854 nulldrv_StretchBlt, /* pStretchBlt */
855 nulldrv_StretchDIBits, /* pStretchDIBits */
856 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
857 nulldrv_StrokePath, /* pStrokePath */
858 nulldrv_SwapBuffers, /* pSwapBuffers */
859 nulldrv_UnrealizePalette, /* pUnrealizePalette */
860 nulldrv_WidenPath, /* pWidenPath */
861 nulldrv_wglCopyContext, /* pwglCopyContext */
862 nulldrv_wglCreateContext, /* pwglCreateContext */
863 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
864 nulldrv_wglDeleteContext, /* pwglDeleteContext */
865 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
866 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
867 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
868 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
869 nulldrv_wglShareLists, /* pwglShareLists */
870 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
871 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
873 GDI_PRIORITY_NULL_DRV /* priority */
877 /*****************************************************************************
878 * DRIVER_GetDriverName
881 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
883 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
884 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
885 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
886 static const WCHAR empty_strW[] = { 0 };
887 WCHAR *p;
889 /* display is a special case */
890 if (!strcmpiW( device, displayW ) ||
891 !strcmpiW( device, display1W ))
893 lstrcpynW( driver, displayW, size );
894 return TRUE;
897 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
898 if(!size) {
899 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
900 return FALSE;
902 p = strchrW(driver, ',');
903 if(!p)
905 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
906 return FALSE;
908 *p = 0;
909 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
910 return TRUE;
914 /***********************************************************************
915 * GdiConvertToDevmodeW (GDI32.@)
917 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
919 DEVMODEW *dmW;
920 WORD dmW_size, dmA_size;
922 dmA_size = dmA->dmSize;
924 /* this is the minimal dmSize that XP accepts */
925 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
926 return NULL;
928 if (dmA_size > sizeof(DEVMODEA))
929 dmA_size = sizeof(DEVMODEA);
931 dmW_size = dmA_size + CCHDEVICENAME;
932 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
933 dmW_size += CCHFORMNAME;
935 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
936 if (!dmW) return NULL;
938 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
939 dmW->dmDeviceName, CCHDEVICENAME);
940 /* copy slightly more, to avoid long computations */
941 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
943 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
945 if (dmA->dmFields & DM_FORMNAME)
946 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
947 dmW->dmFormName, CCHFORMNAME);
948 else
949 dmW->dmFormName[0] = 0;
951 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
952 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
955 if (dmA->dmDriverExtra)
956 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
958 dmW->dmSize = dmW_size;
960 return dmW;
964 /*****************************************************************************
965 * @ [GDI32.100]
967 * This should thunk to 16-bit and simply call the proc with the given args.
969 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
970 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
972 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
973 return -1;
976 /*****************************************************************************
977 * @ [GDI32.101]
979 * This should load the correct driver for lpszDevice and calls this driver's
980 * ExtDeviceModePropSheet proc.
982 * Note: The driver calls a callback routine for each property sheet page; these
983 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
984 * The layout of this structure is:
986 * struct
988 * DWORD nPages;
989 * DWORD unknown;
990 * HPROPSHEETPAGE pages[10];
991 * };
993 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
994 LPCSTR lpszPort, LPVOID lpPropSheet )
996 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
997 return -1;
1000 /*****************************************************************************
1001 * @ [GDI32.102]
1003 * This should load the correct driver for lpszDevice and call this driver's
1004 * ExtDeviceMode proc.
1006 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1008 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
1009 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
1010 LPSTR lpszPort, LPDEVMODEA lpdmInput,
1011 LPSTR lpszProfile, DWORD fwMode )
1013 WCHAR deviceW[300];
1014 WCHAR bufW[300];
1015 char buf[300];
1016 HDC hdc;
1017 DC *dc;
1018 INT ret = -1;
1020 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1021 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
1023 if (!lpszDevice) return -1;
1024 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1026 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1028 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1030 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1032 if ((dc = get_dc_ptr( hdc )))
1034 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
1035 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
1036 lpdmInput, lpszProfile, fwMode );
1037 release_dc_ptr( dc );
1039 DeleteDC( hdc );
1040 return ret;
1043 /****************************************************************************
1044 * @ [GDI32.103]
1046 * This should load the correct driver for lpszDevice and calls this driver's
1047 * AdvancedSetupDialog proc.
1049 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
1050 LPDEVMODEA devin, LPDEVMODEA devout )
1052 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
1053 return -1;
1056 /*****************************************************************************
1057 * @ [GDI32.104]
1059 * This should load the correct driver for lpszDevice and calls this driver's
1060 * DeviceCapabilities proc.
1062 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1064 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1065 WORD fwCapability, LPSTR lpszOutput,
1066 LPDEVMODEA lpdm )
1068 WCHAR deviceW[300];
1069 WCHAR bufW[300];
1070 char buf[300];
1071 HDC hdc;
1072 DC *dc;
1073 INT ret = -1;
1075 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1077 if (!lpszDevice) return -1;
1078 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1080 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1082 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1084 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1086 if ((dc = get_dc_ptr( hdc )))
1088 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1089 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1090 fwCapability, lpszOutput, lpdm );
1091 release_dc_ptr( dc );
1093 DeleteDC( hdc );
1094 return ret;
1098 /************************************************************************
1099 * Escape [GDI32.@]
1101 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1103 INT ret;
1104 POINT *pt;
1106 switch (escape)
1108 case ABORTDOC:
1109 return AbortDoc( hdc );
1111 case ENDDOC:
1112 return EndDoc( hdc );
1114 case GETPHYSPAGESIZE:
1115 pt = out_data;
1116 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1117 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1118 return 1;
1120 case GETPRINTINGOFFSET:
1121 pt = out_data;
1122 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1123 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1124 return 1;
1126 case GETSCALINGFACTOR:
1127 pt = out_data;
1128 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1129 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1130 return 1;
1132 case NEWFRAME:
1133 return EndPage( hdc );
1135 case SETABORTPROC:
1136 return SetAbortProc( hdc, (ABORTPROC)in_data );
1138 case STARTDOC:
1140 DOCINFOA doc;
1141 char *name = NULL;
1143 /* in_data may not be 0 terminated so we must copy it */
1144 if (in_data)
1146 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1147 memcpy( name, in_data, in_count );
1148 name[in_count] = 0;
1150 /* out_data is actually a pointer to the DocInfo structure and used as
1151 * a second input parameter */
1152 if (out_data) doc = *(DOCINFOA *)out_data;
1153 else
1155 doc.cbSize = sizeof(doc);
1156 doc.lpszOutput = NULL;
1157 doc.lpszDatatype = NULL;
1158 doc.fwType = 0;
1160 doc.lpszDocName = name;
1161 ret = StartDocA( hdc, &doc );
1162 HeapFree( GetProcessHeap(), 0, name );
1163 if (ret > 0) ret = StartPage( hdc );
1164 return ret;
1167 case QUERYESCSUPPORT:
1169 const INT *ptr = (const INT *)in_data;
1170 if (in_count < sizeof(INT)) return 0;
1171 switch(*ptr)
1173 case ABORTDOC:
1174 case ENDDOC:
1175 case GETPHYSPAGESIZE:
1176 case GETPRINTINGOFFSET:
1177 case GETSCALINGFACTOR:
1178 case NEWFRAME:
1179 case QUERYESCSUPPORT:
1180 case SETABORTPROC:
1181 case STARTDOC:
1182 return TRUE;
1184 break;
1188 /* if not handled internally, pass it to the driver */
1189 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1193 /******************************************************************************
1194 * ExtEscape [GDI32.@]
1196 * Access capabilities of a particular device that are not available through GDI.
1198 * PARAMS
1199 * hdc [I] Handle to device context
1200 * nEscape [I] Escape function
1201 * cbInput [I] Number of bytes in input structure
1202 * lpszInData [I] Pointer to input structure
1203 * cbOutput [I] Number of bytes in output structure
1204 * lpszOutData [O] Pointer to output structure
1206 * RETURNS
1207 * Success: >0
1208 * Not implemented: 0
1209 * Failure: <0
1211 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1212 INT cbOutput, LPSTR lpszOutData )
1214 INT ret = 0;
1215 DC * dc = get_dc_ptr( hdc );
1217 if (dc)
1219 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1220 update_dc( dc );
1221 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1222 release_dc_ptr( dc );
1224 return ret;
1228 /*******************************************************************
1229 * DrawEscape [GDI32.@]
1233 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1235 FIXME("DrawEscape, stub\n");
1236 return 0;
1239 /*******************************************************************
1240 * NamedEscape [GDI32.@]
1242 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1243 INT cbOutput, LPSTR lpszOutData )
1245 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1246 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1247 lpszOutData);
1248 return 0;
1251 /*******************************************************************
1252 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1253 * GdiEntry13 [GDI32.@]
1255 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1257 static int warn_once;
1259 if (!warn_once++)
1260 FIXME("stub\n");
1261 return 0;