gdi32: Add a SetBoundsRect driver entry point.
[wine/multimedia.git] / dlls / gdi32 / driver.c
blob862f715d2fd34c6e19fd2662aac3a258836c00a9
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_CreateBitmap( PHYSDEV dev, HBITMAP bitmap )
214 return TRUE;
217 static BOOL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
219 if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
220 return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
223 static BOOL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
224 LPCWSTR output, const DEVMODEW *devmode )
226 assert(0); /* should never be called */
227 return FALSE;
230 static BOOL nulldrv_DeleteBitmap( HBITMAP bitmap )
232 return TRUE;
235 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
237 assert(0); /* should never be called */
238 return TRUE;
241 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
243 return TRUE;
246 static INT nulldrv_DescribePixelFormat( PHYSDEV dev, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr )
248 return 0;
251 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
252 WORD cap, LPSTR output, DEVMODEA *devmode )
254 return -1;
257 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
259 return TRUE;
262 static INT nulldrv_EndDoc( PHYSDEV dev )
264 return 0;
267 static INT nulldrv_EndPage( PHYSDEV dev )
269 return 0;
272 static BOOL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
274 return TRUE;
277 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
279 return -1;
282 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
283 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
285 return -1;
288 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
289 INT out_size, void *out_data )
291 return 0;
294 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
296 return TRUE;
299 static BOOL nulldrv_FontIsLinked( PHYSDEV dev )
301 return FALSE;
304 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
306 return FALSE;
309 static BOOL nulldrv_GdiRealizationInfo( PHYSDEV dev, void *info )
311 return FALSE;
314 static UINT nulldrv_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
316 return DCB_RESET;
319 static BOOL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
321 return FALSE;
324 static BOOL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
326 return FALSE;
329 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
331 return FALSE;
334 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
336 switch (cap) /* return meaningful values for some entries */
338 case HORZRES: return 640;
339 case VERTRES: return 480;
340 case BITSPIXEL: return 1;
341 case PLANES: return 1;
342 case NUMCOLORS: return 2;
343 case ASPECTX: return 36;
344 case ASPECTY: return 36;
345 case ASPECTXY: return 51;
346 case LOGPIXELSX: return 72;
347 case LOGPIXELSY: return 72;
348 case SIZEPALETTE: return 2;
349 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
350 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
351 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
352 default: return 0;
356 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
358 SetLastError( ERROR_INVALID_PARAMETER );
359 return FALSE;
362 static DWORD nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
364 return FALSE;
367 static DWORD nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
369 return 0;
372 static DWORD nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
374 return GDI_ERROR;
377 static DWORD nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
378 DWORD size, LPVOID buffer, const MAT2 *mat )
380 return GDI_ERROR;
383 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
385 return FALSE;
388 static DWORD nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
390 return 0;
393 static UINT nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
395 return 0;
398 static INT nulldrv_GetPixelFormat( PHYSDEV dev )
400 return 0;
403 static UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
405 return 0;
408 static UINT nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
410 return DEFAULT_CHARSET;
413 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
414 INT *fit, INT *dx, SIZE *size )
416 return FALSE;
419 static BOOL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT max_ext,
420 INT *fit, INT *dx, SIZE *size )
422 return FALSE;
425 static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
427 INT ret = 0;
428 LOGFONTW font;
429 HFONT hfont = GetCurrentObject( dev->hdc, OBJ_FONT );
431 if (GetObjectW( hfont, sizeof(font), &font ))
433 ret = strlenW( font.lfFaceName ) + 1;
434 if (name)
436 lstrcpynW( name, font.lfFaceName, size );
437 ret = min( size, ret );
440 return ret;
443 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
445 return FALSE;
448 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
450 return TRUE;
453 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
455 return TRUE;
458 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
460 return TRUE;
463 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
465 return TRUE;
468 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
469 INT xstart, INT ystart, INT xend, INT yend )
471 return TRUE;
474 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
476 return TRUE;
479 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
481 return TRUE;
484 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
486 INT counts[1] = { count };
488 return PolyPolygon( dev->hdc, points, counts, 1 );
491 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
493 DWORD counts[1] = { count };
495 if (count < 0) return FALSE;
496 return PolyPolyline( dev->hdc, points, counts, 1 );
499 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
501 return 0;
504 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
506 return 0;
509 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
511 return TRUE;
514 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
516 return 0;
519 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
520 INT ell_width, INT ell_height )
522 return TRUE;
525 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
527 return bitmap;
530 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
532 return brush;
535 static HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font )
537 return 0;
540 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
542 return palette;
545 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen, const struct brush_pattern *pattern )
547 return pen;
550 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
552 return dir;
555 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
557 return color;
560 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
562 return mode;
565 static UINT nulldrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
567 return DCB_RESET;
570 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
572 return color;
575 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
577 return color;
580 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
584 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
586 return layout;
589 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
591 SetLastError( ERROR_INVALID_PARAMETER );
592 return FALSE;
595 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
597 return flags;
600 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
602 return color;
605 static BOOL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
607 return FALSE;
610 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
612 return mode;
615 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
617 return rop;
620 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
622 return mode;
625 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
627 return mode;
630 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
632 return align;
635 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
637 return extra;
640 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
642 return color;
645 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
647 return TRUE;
650 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
652 return 0;
655 static INT nulldrv_StartPage( PHYSDEV dev )
657 return 1;
660 static BOOL nulldrv_SwapBuffers( PHYSDEV dev )
662 return TRUE;
665 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
667 return FALSE;
670 static BOOL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
672 return FALSE;
675 static HGLRC nulldrv_wglCreateContext( PHYSDEV dev )
677 return 0;
680 static HGLRC nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
682 return 0;
685 static BOOL nulldrv_wglDeleteContext( HGLRC ctx )
687 return FALSE;
690 static PROC nulldrv_wglGetProcAddress( LPCSTR name )
692 return NULL;
695 static HDC nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
697 return 0;
700 static BOOL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
702 return FALSE;
705 static BOOL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
707 return FALSE;
710 static BOOL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
712 return FALSE;
715 static BOOL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
717 return FALSE;
720 static BOOL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
722 return FALSE;
725 static BOOL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
727 return FALSE;
730 const struct gdi_dc_funcs null_driver =
732 nulldrv_AbortDoc, /* pAbortDoc */
733 nulldrv_AbortPath, /* pAbortPath */
734 nulldrv_AlphaBlend, /* pAlphaBlend */
735 nulldrv_AngleArc, /* pAngleArc */
736 nulldrv_Arc, /* pArc */
737 nulldrv_ArcTo, /* pArcTo */
738 nulldrv_BeginPath, /* pBeginPath */
739 nulldrv_BlendImage, /* pBlendImage */
740 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
741 nulldrv_Chord, /* pChord */
742 nulldrv_CloseFigure, /* pCloseFigure */
743 nulldrv_CopyBitmap, /* pCopyBitmap */
744 nulldrv_CreateBitmap, /* pCreateBitmap */
745 nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
746 nulldrv_CreateDC, /* pCreateDC */
747 nulldrv_DeleteBitmap, /* pDeleteBitmap */
748 nulldrv_DeleteDC, /* pDeleteDC */
749 nulldrv_DeleteObject, /* pDeleteObject */
750 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
751 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
752 nulldrv_Ellipse, /* pEllipse */
753 nulldrv_EndDoc, /* pEndDoc */
754 nulldrv_EndPage, /* pEndPage */
755 nulldrv_EndPath, /* pEndPath */
756 nulldrv_EnumFonts, /* pEnumFonts */
757 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
758 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
759 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
760 nulldrv_ExtEscape, /* pExtEscape */
761 nulldrv_ExtFloodFill, /* pExtFloodFill */
762 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
763 nulldrv_ExtTextOut, /* pExtTextOut */
764 nulldrv_FillPath, /* pFillPath */
765 nulldrv_FillRgn, /* pFillRgn */
766 nulldrv_FlattenPath, /* pFlattenPath */
767 nulldrv_FontIsLinked, /* pFontIsLinked */
768 nulldrv_FrameRgn, /* pFrameRgn */
769 nulldrv_GdiComment, /* pGdiComment */
770 nulldrv_GdiRealizationInfo, /* pGdiRealizationInfo */
771 nulldrv_GetBoundsRect, /* pGetBoundsRect */
772 nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
773 nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
774 nulldrv_GetCharWidth, /* pGetCharWidth */
775 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
776 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
777 nulldrv_GetFontData, /* pGetFontData */
778 nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
779 nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
780 nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
781 nulldrv_GetICMProfile, /* pGetICMProfile */
782 nulldrv_GetImage, /* pGetImage */
783 nulldrv_GetKerningPairs, /* pGetKerningPairs */
784 nulldrv_GetNearestColor, /* pGetNearestColor */
785 nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
786 nulldrv_GetPixel, /* pGetPixel */
787 nulldrv_GetPixelFormat, /* pGetPixelFormat */
788 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
789 nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
790 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
791 nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
792 nulldrv_GetTextFace, /* pGetTextFace */
793 nulldrv_GetTextMetrics, /* pGetTextMetrics */
794 nulldrv_GradientFill, /* pGradientFill */
795 nulldrv_IntersectClipRect, /* pIntersectClipRect */
796 nulldrv_InvertRgn, /* pInvertRgn */
797 nulldrv_LineTo, /* pLineTo */
798 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
799 nulldrv_MoveTo, /* pMoveTo */
800 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
801 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
802 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
803 nulldrv_PaintRgn, /* pPaintRgn */
804 nulldrv_PatBlt, /* pPatBlt */
805 nulldrv_Pie, /* pPie */
806 nulldrv_PolyBezier, /* pPolyBezier */
807 nulldrv_PolyBezierTo, /* pPolyBezierTo */
808 nulldrv_PolyDraw, /* pPolyDraw */
809 nulldrv_PolyPolygon, /* pPolyPolygon */
810 nulldrv_PolyPolyline, /* pPolyPolyline */
811 nulldrv_Polygon, /* pPolygon */
812 nulldrv_Polyline, /* pPolyline */
813 nulldrv_PolylineTo, /* pPolylineTo */
814 nulldrv_PutImage, /* pPutImage */
815 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
816 nulldrv_RealizePalette, /* pRealizePalette */
817 nulldrv_Rectangle, /* pRectangle */
818 nulldrv_ResetDC, /* pResetDC */
819 nulldrv_RestoreDC, /* pRestoreDC */
820 nulldrv_RoundRect, /* pRoundRect */
821 nulldrv_SaveDC, /* pSaveDC */
822 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
823 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
824 nulldrv_SelectBitmap, /* pSelectBitmap */
825 nulldrv_SelectBrush, /* pSelectBrush */
826 nulldrv_SelectClipPath, /* pSelectClipPath */
827 nulldrv_SelectFont, /* pSelectFont */
828 nulldrv_SelectPalette, /* pSelectPalette */
829 nulldrv_SelectPen, /* pSelectPen */
830 nulldrv_SetArcDirection, /* pSetArcDirection */
831 nulldrv_SetBkColor, /* pSetBkColor */
832 nulldrv_SetBkMode, /* pSetBkMode */
833 nulldrv_SetBoundsRect, /* pSetBoundsRect */
834 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
835 nulldrv_SetDCPenColor, /* pSetDCPenColor */
836 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
837 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
838 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
839 nulldrv_SetLayout, /* pSetLayout */
840 nulldrv_SetMapMode, /* pSetMapMode */
841 nulldrv_SetMapperFlags, /* pSetMapperFlags */
842 nulldrv_SetPixel, /* pSetPixel */
843 nulldrv_SetPixelFormat, /* pSetPixelFormat */
844 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
845 nulldrv_SetROP2, /* pSetROP2 */
846 nulldrv_SetRelAbs, /* pSetRelAbs */
847 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
848 nulldrv_SetTextAlign, /* pSetTextAlign */
849 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
850 nulldrv_SetTextColor, /* pSetTextColor */
851 nulldrv_SetTextJustification, /* pSetTextJustification */
852 nulldrv_SetViewportExtEx, /* pSetViewportExt */
853 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
854 nulldrv_SetWindowExtEx, /* pSetWindowExt */
855 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
856 nulldrv_SetWorldTransform, /* pSetWorldTransform */
857 nulldrv_StartDoc, /* pStartDoc */
858 nulldrv_StartPage, /* pStartPage */
859 nulldrv_StretchBlt, /* pStretchBlt */
860 nulldrv_StretchDIBits, /* pStretchDIBits */
861 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
862 nulldrv_StrokePath, /* pStrokePath */
863 nulldrv_SwapBuffers, /* pSwapBuffers */
864 nulldrv_UnrealizePalette, /* pUnrealizePalette */
865 nulldrv_WidenPath, /* pWidenPath */
866 nulldrv_wglCopyContext, /* pwglCopyContext */
867 nulldrv_wglCreateContext, /* pwglCreateContext */
868 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
869 nulldrv_wglDeleteContext, /* pwglDeleteContext */
870 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
871 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
872 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
873 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
874 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
875 nulldrv_wglShareLists, /* pwglShareLists */
876 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
877 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
881 /*****************************************************************************
882 * DRIVER_GetDriverName
885 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
887 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
888 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
889 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
890 static const WCHAR empty_strW[] = { 0 };
891 WCHAR *p;
893 /* display is a special case */
894 if (!strcmpiW( device, displayW ) ||
895 !strcmpiW( device, display1W ))
897 lstrcpynW( driver, displayW, size );
898 return TRUE;
901 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
902 if(!size) {
903 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
904 return FALSE;
906 p = strchrW(driver, ',');
907 if(!p)
909 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
910 return FALSE;
912 *p = 0;
913 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
914 return TRUE;
918 /***********************************************************************
919 * GdiConvertToDevmodeW (GDI32.@)
921 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
923 DEVMODEW *dmW;
924 WORD dmW_size, dmA_size;
926 dmA_size = dmA->dmSize;
928 /* this is the minimal dmSize that XP accepts */
929 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
930 return NULL;
932 if (dmA_size > sizeof(DEVMODEA))
933 dmA_size = sizeof(DEVMODEA);
935 dmW_size = dmA_size + CCHDEVICENAME;
936 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
937 dmW_size += CCHFORMNAME;
939 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
940 if (!dmW) return NULL;
942 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
943 dmW->dmDeviceName, CCHDEVICENAME);
944 /* copy slightly more, to avoid long computations */
945 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
947 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
949 if (dmA->dmFields & DM_FORMNAME)
950 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
951 dmW->dmFormName, CCHFORMNAME);
952 else
953 dmW->dmFormName[0] = 0;
955 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
956 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
959 if (dmA->dmDriverExtra)
960 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
962 dmW->dmSize = dmW_size;
964 return dmW;
968 /*****************************************************************************
969 * @ [GDI32.100]
971 * This should thunk to 16-bit and simply call the proc with the given args.
973 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
974 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
976 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
977 return -1;
980 /*****************************************************************************
981 * @ [GDI32.101]
983 * This should load the correct driver for lpszDevice and calls this driver's
984 * ExtDeviceModePropSheet proc.
986 * Note: The driver calls a callback routine for each property sheet page; these
987 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
988 * The layout of this structure is:
990 * struct
992 * DWORD nPages;
993 * DWORD unknown;
994 * HPROPSHEETPAGE pages[10];
995 * };
997 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
998 LPCSTR lpszPort, LPVOID lpPropSheet )
1000 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
1001 return -1;
1004 /*****************************************************************************
1005 * @ [GDI32.102]
1007 * This should load the correct driver for lpszDevice and call this driver's
1008 * ExtDeviceMode proc.
1010 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1012 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
1013 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
1014 LPSTR lpszPort, LPDEVMODEA lpdmInput,
1015 LPSTR lpszProfile, DWORD fwMode )
1017 WCHAR deviceW[300];
1018 WCHAR bufW[300];
1019 char buf[300];
1020 HDC hdc;
1021 DC *dc;
1022 INT ret = -1;
1024 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1025 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
1027 if (!lpszDevice) return -1;
1028 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1030 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1032 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1034 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1036 if ((dc = get_dc_ptr( hdc )))
1038 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
1039 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
1040 lpdmInput, lpszProfile, fwMode );
1041 release_dc_ptr( dc );
1043 DeleteDC( hdc );
1044 return ret;
1047 /****************************************************************************
1048 * @ [GDI32.103]
1050 * This should load the correct driver for lpszDevice and calls this driver's
1051 * AdvancedSetupDialog proc.
1053 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
1054 LPDEVMODEA devin, LPDEVMODEA devout )
1056 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
1057 return -1;
1060 /*****************************************************************************
1061 * @ [GDI32.104]
1063 * This should load the correct driver for lpszDevice and calls this driver's
1064 * DeviceCapabilities proc.
1066 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1068 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1069 WORD fwCapability, LPSTR lpszOutput,
1070 LPDEVMODEA lpdm )
1072 WCHAR deviceW[300];
1073 WCHAR bufW[300];
1074 char buf[300];
1075 HDC hdc;
1076 DC *dc;
1077 INT ret = -1;
1079 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1081 if (!lpszDevice) return -1;
1082 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1084 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1086 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1088 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1090 if ((dc = get_dc_ptr( hdc )))
1092 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1093 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1094 fwCapability, lpszOutput, lpdm );
1095 release_dc_ptr( dc );
1097 DeleteDC( hdc );
1098 return ret;
1102 /************************************************************************
1103 * Escape [GDI32.@]
1105 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1107 INT ret;
1108 POINT *pt;
1110 switch (escape)
1112 case ABORTDOC:
1113 return AbortDoc( hdc );
1115 case ENDDOC:
1116 return EndDoc( hdc );
1118 case GETPHYSPAGESIZE:
1119 pt = out_data;
1120 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1121 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1122 return 1;
1124 case GETPRINTINGOFFSET:
1125 pt = out_data;
1126 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1127 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1128 return 1;
1130 case GETSCALINGFACTOR:
1131 pt = out_data;
1132 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1133 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1134 return 1;
1136 case NEWFRAME:
1137 return EndPage( hdc );
1139 case SETABORTPROC:
1140 return SetAbortProc( hdc, (ABORTPROC)in_data );
1142 case STARTDOC:
1144 DOCINFOA doc;
1145 char *name = NULL;
1147 /* in_data may not be 0 terminated so we must copy it */
1148 if (in_data)
1150 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1151 memcpy( name, in_data, in_count );
1152 name[in_count] = 0;
1154 /* out_data is actually a pointer to the DocInfo structure and used as
1155 * a second input parameter */
1156 if (out_data) doc = *(DOCINFOA *)out_data;
1157 else
1159 doc.cbSize = sizeof(doc);
1160 doc.lpszOutput = NULL;
1161 doc.lpszDatatype = NULL;
1162 doc.fwType = 0;
1164 doc.lpszDocName = name;
1165 ret = StartDocA( hdc, &doc );
1166 HeapFree( GetProcessHeap(), 0, name );
1167 if (ret > 0) ret = StartPage( hdc );
1168 return ret;
1171 case QUERYESCSUPPORT:
1173 const INT *ptr = (const INT *)in_data;
1174 if (in_count < sizeof(INT)) return 0;
1175 switch(*ptr)
1177 case ABORTDOC:
1178 case ENDDOC:
1179 case GETPHYSPAGESIZE:
1180 case GETPRINTINGOFFSET:
1181 case GETSCALINGFACTOR:
1182 case NEWFRAME:
1183 case QUERYESCSUPPORT:
1184 case SETABORTPROC:
1185 case STARTDOC:
1186 return TRUE;
1188 break;
1192 /* if not handled internally, pass it to the driver */
1193 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1197 /******************************************************************************
1198 * ExtEscape [GDI32.@]
1200 * Access capabilities of a particular device that are not available through GDI.
1202 * PARAMS
1203 * hdc [I] Handle to device context
1204 * nEscape [I] Escape function
1205 * cbInput [I] Number of bytes in input structure
1206 * lpszInData [I] Pointer to input structure
1207 * cbOutput [I] Number of bytes in output structure
1208 * lpszOutData [O] Pointer to output structure
1210 * RETURNS
1211 * Success: >0
1212 * Not implemented: 0
1213 * Failure: <0
1215 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1216 INT cbOutput, LPSTR lpszOutData )
1218 INT ret = 0;
1219 DC * dc = get_dc_ptr( hdc );
1221 if (dc)
1223 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1224 update_dc( dc );
1225 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1226 release_dc_ptr( dc );
1228 return ret;
1232 /*******************************************************************
1233 * DrawEscape [GDI32.@]
1237 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1239 FIXME("DrawEscape, stub\n");
1240 return 0;
1243 /*******************************************************************
1244 * NamedEscape [GDI32.@]
1246 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1247 INT cbOutput, LPSTR lpszOutData )
1249 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1250 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1251 lpszOutData);
1252 return 0;
1255 /*******************************************************************
1256 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1257 * GdiEntry13 [GDI32.@]
1259 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1261 static int warn_once;
1263 if (!warn_once++)
1264 FIXME("stub\n");
1265 return 0;