gdi32: Add driver entry points for GetImage and PutImage.
[wine/wine-gecko.git] / dlls / gdi32 / driver.c
blob6cdf35d70408ae16415f92b2f255f939462817c3
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 static CRITICAL_SECTION driver_section;
53 static CRITICAL_SECTION_DEBUG critsect_debug =
55 0, 0, &driver_section,
56 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
57 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
59 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
61 /**********************************************************************
62 * create_driver
64 * Allocate and fill the driver structure for a given module.
66 static struct graphics_driver *create_driver( HMODULE module )
68 static const struct gdi_dc_funcs empty_funcs;
69 const struct gdi_dc_funcs *funcs = NULL;
70 struct graphics_driver *driver;
72 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
73 driver->module = module;
75 if (module)
77 const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int version );
79 if ((wine_get_gdi_driver = (void *)GetProcAddress( module, "wine_get_gdi_driver" )))
80 funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
82 if (!funcs) funcs = &empty_funcs;
83 driver->funcs = funcs;
84 return driver;
88 /**********************************************************************
89 * DRIVER_get_display_driver
91 * Special case for loading the display driver: get the name from the config file
93 const DC_FUNCTIONS *DRIVER_get_display_driver(void)
95 struct graphics_driver *driver;
96 char buffer[MAX_PATH], libname[32], *name, *next;
97 HMODULE module = 0;
98 HKEY hkey;
100 if (display_driver) return display_driver->funcs; /* already loaded */
102 strcpy( buffer, "x11" ); /* default value */
103 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
104 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
106 DWORD type, count = sizeof(buffer);
107 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
108 RegCloseKey( hkey );
111 name = buffer;
112 while (name)
114 next = strchr( name, ',' );
115 if (next) *next++ = 0;
117 snprintf( libname, sizeof(libname), "wine%s.drv", name );
118 if ((module = LoadLibraryA( libname )) != 0) break;
119 name = next;
122 if (!(driver = create_driver( module )))
124 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
125 FreeLibrary( module );
126 ExitProcess(1);
128 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
130 /* somebody beat us to it */
131 FreeLibrary( driver->module );
132 HeapFree( GetProcessHeap(), 0, driver );
134 return display_driver->funcs;
138 /**********************************************************************
139 * DRIVER_load_driver
141 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
143 HMODULE module;
144 struct graphics_driver *driver, *new_driver;
145 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
146 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
148 /* display driver is a special case */
149 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return DRIVER_get_display_driver();
151 if ((module = GetModuleHandleW( name )))
153 if (display_driver && display_driver->module == module) return display_driver->funcs;
154 EnterCriticalSection( &driver_section );
155 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
157 if (driver->module == module) goto done;
159 LeaveCriticalSection( &driver_section );
162 if (!(module = LoadLibraryW( name ))) return NULL;
164 if (!(new_driver = create_driver( module )))
166 FreeLibrary( module );
167 return NULL;
170 /* check if someone else added it in the meantime */
171 EnterCriticalSection( &driver_section );
172 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
174 if (driver->module != module) continue;
175 FreeLibrary( module );
176 HeapFree( GetProcessHeap(), 0, new_driver );
177 goto done;
179 driver = new_driver;
180 list_add_head( &drivers, &driver->entry );
181 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
182 done:
183 LeaveCriticalSection( &driver_section );
184 return driver->funcs;
188 static INT nulldrv_AbortDoc( PHYSDEV dev )
190 return 0;
193 static BOOL nulldrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
194 PHYSDEV src_dev, struct bitblt_coords *src, BLENDFUNCTION func)
196 return TRUE;
199 static BOOL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
200 INT xstart, INT ystart, INT xend, INT yend )
202 return TRUE;
205 static INT nulldrv_ChoosePixelFormat( PHYSDEV dev, const PIXELFORMATDESCRIPTOR *descr )
207 return 0;
210 static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
211 INT xstart, INT ystart, INT xend, INT yend )
213 return TRUE;
216 static BOOL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap, LPVOID bits )
218 return TRUE;
221 static BOOL nulldrv_CreateDC( HDC hdc, PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
222 LPCWSTR output, const DEVMODEW *devmode )
224 assert(0); /* should never be called */
225 return FALSE;
228 static HBITMAP nulldrv_CreateDIBSection( PHYSDEV dev, HBITMAP bitmap, const BITMAPINFO *info, UINT usage )
230 return bitmap;
233 static BOOL nulldrv_DeleteBitmap( HBITMAP bitmap )
235 return TRUE;
238 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
240 assert(0); /* should never be called */
241 return TRUE;
244 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
246 return TRUE;
249 static INT nulldrv_DescribePixelFormat( PHYSDEV dev, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr )
251 return 0;
254 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
255 WORD cap, LPSTR output, DEVMODEA *devmode )
257 return -1;
260 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
262 return TRUE;
265 static INT nulldrv_EndDoc( PHYSDEV dev )
267 return 0;
270 static INT nulldrv_EndPage( PHYSDEV dev )
272 return 0;
275 static BOOL nulldrv_EnumDeviceFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
277 return FALSE;
280 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
282 return -1;
285 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
286 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
288 return -1;
291 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
292 INT out_size, void *out_data )
294 return 0;
297 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
299 return TRUE;
302 static BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect,
303 LPCWSTR str, UINT count, const INT *dx )
305 return TRUE;
308 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
310 return FALSE;
313 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
315 return FALSE;
318 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
320 switch (cap) /* return meaningful values for some entries */
322 case HORZRES: return 640;
323 case VERTRES: return 480;
324 case BITSPIXEL: return 1;
325 case PLANES: return 1;
326 case NUMCOLORS: return 2;
327 case ASPECTX: return 36;
328 case ASPECTY: return 36;
329 case ASPECTXY: return 51;
330 case LOGPIXELSX: return 72;
331 case LOGPIXELSY: return 72;
332 case SIZEPALETTE: return 2;
333 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
334 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
335 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
336 default: return 0;
340 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
342 return FALSE;
345 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
347 return FALSE;
350 static DWORD nulldrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
351 struct gdi_image_bits *bits, const RECT *rect )
353 return ERROR_NOT_SUPPORTED;
356 static COLORREF nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
358 return 0;
361 static INT nulldrv_GetPixelFormat( PHYSDEV dev )
363 return 0;
366 static UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
368 return 0;
371 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
372 INT *fit, INT *dx, SIZE *size )
374 return FALSE;
377 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
379 return FALSE;
382 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
384 return TRUE;
387 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
389 return TRUE;
392 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
394 return TRUE;
397 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
399 return TRUE;
402 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
403 INT xstart, INT ystart, INT xend, INT yend )
405 return TRUE;
408 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
410 /* FIXME: could be implemented with Polygon */
411 return TRUE;
414 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
416 /* FIXME: could be implemented with Polyline */
417 return TRUE;
420 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
422 return TRUE;
425 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
427 return TRUE;
430 static DWORD nulldrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
431 const struct gdi_image_bits *bits, const RECT *rect, DWORD rop )
433 return ERROR_SUCCESS;
436 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
438 return 0;
441 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
443 return 0;
446 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
448 return TRUE;
451 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
453 return 0;
456 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
457 INT ell_width, INT ell_height )
459 return TRUE;
462 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
464 return bitmap;
467 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush )
469 return brush;
472 static HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font )
474 return 0;
477 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
479 return palette;
482 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
484 return pen;
487 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
489 return dir;
492 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
494 return color;
497 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
499 return mode;
502 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
504 return color;
507 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
509 return color;
512 static UINT nulldrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RGBQUAD *colors )
514 return 0;
517 static INT nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD width, DWORD height,
518 INT x_src, INT y_src, UINT start, UINT lines,
519 const void *bits, const BITMAPINFO *info, UINT coloruse )
521 return 0;
524 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
528 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
530 return layout;
533 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
535 return FALSE;
538 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
540 return flags;
543 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
545 return color;
548 static BOOL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
550 return FALSE;
553 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
555 return mode;
558 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
560 return rop;
563 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
565 return mode;
568 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
570 return mode;
573 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
575 return align;
578 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
580 return extra;
583 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
585 return color;
588 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
590 return TRUE;
593 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
595 return 0;
598 static INT nulldrv_StartPage( PHYSDEV dev )
600 return 1;
603 static BOOL nulldrv_SwapBuffers( PHYSDEV dev )
605 return TRUE;
608 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
610 return FALSE;
613 static BOOL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
615 return FALSE;
618 static HGLRC nulldrv_wglCreateContext( PHYSDEV dev )
620 return 0;
623 static HGLRC nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
625 return 0;
628 static BOOL nulldrv_wglDeleteContext( HGLRC ctx )
630 return FALSE;
633 static PROC nulldrv_wglGetProcAddress( LPCSTR name )
635 return NULL;
638 static HDC nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
640 return 0;
643 static BOOL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
645 return FALSE;
648 static BOOL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
650 return FALSE;
653 static BOOL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
655 return FALSE;
658 static BOOL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
660 return FALSE;
663 static BOOL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
665 return FALSE;
668 static BOOL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
670 return FALSE;
673 const DC_FUNCTIONS null_driver =
675 nulldrv_AbortDoc, /* pAbortDoc */
676 nulldrv_AbortPath, /* pAbortPath */
677 nulldrv_AlphaBlend, /* pAlphaBlend */
678 nulldrv_AngleArc, /* pAngleArc */
679 nulldrv_Arc, /* pArc */
680 nulldrv_ArcTo, /* pArcTo */
681 nulldrv_BeginPath, /* pBeginPath */
682 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
683 nulldrv_Chord, /* pChord */
684 nulldrv_CloseFigure, /* pCloseFigure */
685 nulldrv_CreateBitmap, /* pCreateBitmap */
686 nulldrv_CreateDC, /* pCreateDC */
687 nulldrv_CreateDIBSection, /* pCreateDIBSection */
688 nulldrv_DeleteBitmap, /* pDeleteBitmap */
689 nulldrv_DeleteDC, /* pDeleteDC */
690 nulldrv_DeleteObject, /* pDeleteObject */
691 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
692 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
693 nulldrv_Ellipse, /* pEllipse */
694 nulldrv_EndDoc, /* pEndDoc */
695 nulldrv_EndPage, /* pEndPage */
696 nulldrv_EndPath, /* pEndPath */
697 nulldrv_EnumDeviceFonts, /* pEnumDeviceFonts */
698 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
699 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
700 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
701 nulldrv_ExtEscape, /* pExtEscape */
702 nulldrv_ExtFloodFill, /* pExtFloodFill */
703 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
704 nulldrv_ExtTextOut, /* pExtTextOut */
705 nulldrv_FillPath, /* pFillPath */
706 nulldrv_FillRgn, /* pFillRgn */
707 nulldrv_FlattenPath, /* pFlattenPath */
708 nulldrv_FrameRgn, /* pFrameRgn */
709 nulldrv_GdiComment, /* pGdiComment */
710 nulldrv_GetBitmapBits, /* pGetBitmapBits */
711 nulldrv_GetCharWidth, /* pGetCharWidth */
712 nulldrv_GetDIBits, /* pGetDIBits */
713 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
714 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
715 nulldrv_GetICMProfile, /* pGetICMProfile */
716 nulldrv_GetImage, /* pGetImage */
717 nulldrv_GetNearestColor, /* pGetNearestColor */
718 nulldrv_GetPixel, /* pGetPixel */
719 nulldrv_GetPixelFormat, /* pGetPixelFormat */
720 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
721 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
722 nulldrv_GetTextMetrics, /* pGetTextMetrics */
723 nulldrv_IntersectClipRect, /* pIntersectClipRect */
724 nulldrv_InvertRgn, /* pInvertRgn */
725 nulldrv_LineTo, /* pLineTo */
726 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
727 nulldrv_MoveTo, /* pMoveTo */
728 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
729 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
730 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
731 nulldrv_PaintRgn, /* pPaintRgn */
732 nulldrv_PatBlt, /* pPatBlt */
733 nulldrv_Pie, /* pPie */
734 nulldrv_PolyBezier, /* pPolyBezier */
735 nulldrv_PolyBezierTo, /* pPolyBezierTo */
736 nulldrv_PolyDraw, /* pPolyDraw */
737 nulldrv_PolyPolygon, /* pPolyPolygon */
738 nulldrv_PolyPolyline, /* pPolyPolyline */
739 nulldrv_Polygon, /* pPolygon */
740 nulldrv_Polyline, /* pPolyline */
741 nulldrv_PolylineTo, /* pPolylineTo */
742 nulldrv_PutImage, /* pPutImage */
743 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
744 nulldrv_RealizePalette, /* pRealizePalette */
745 nulldrv_Rectangle, /* pRectangle */
746 nulldrv_ResetDC, /* pResetDC */
747 nulldrv_RestoreDC, /* pRestoreDC */
748 nulldrv_RoundRect, /* pRoundRect */
749 nulldrv_SaveDC, /* pSaveDC */
750 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
751 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
752 nulldrv_SelectBitmap, /* pSelectBitmap */
753 nulldrv_SelectBrush, /* pSelectBrush */
754 nulldrv_SelectClipPath, /* pSelectClipPath */
755 nulldrv_SelectFont, /* pSelectFont */
756 nulldrv_SelectPalette, /* pSelectPalette */
757 nulldrv_SelectPen, /* pSelectPen */
758 nulldrv_SetArcDirection, /* pSetArcDirection */
759 nulldrv_SetBitmapBits, /* pSetBitmapBits */
760 nulldrv_SetBkColor, /* pSetBkColor */
761 nulldrv_SetBkMode, /* pSetBkMode */
762 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
763 nulldrv_SetDCPenColor, /* pSetDCPenColor */
764 nulldrv_SetDIBColorTable, /* pSetDIBColorTable */
765 nulldrv_SetDIBits, /* pSetDIBits */
766 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
767 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
768 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
769 nulldrv_SetLayout, /* pSetLayout */
770 nulldrv_SetMapMode, /* pSetMapMode */
771 nulldrv_SetMapperFlags, /* pSetMapperFlags */
772 nulldrv_SetPixel, /* pSetPixel */
773 nulldrv_SetPixelFormat, /* pSetPixelFormat */
774 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
775 nulldrv_SetROP2, /* pSetROP2 */
776 nulldrv_SetRelAbs, /* pSetRelAbs */
777 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
778 nulldrv_SetTextAlign, /* pSetTextAlign */
779 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
780 nulldrv_SetTextColor, /* pSetTextColor */
781 nulldrv_SetTextJustification, /* pSetTextJustification */
782 nulldrv_SetViewportExtEx, /* pSetViewportExt */
783 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
784 nulldrv_SetWindowExtEx, /* pSetWindowExt */
785 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
786 nulldrv_SetWorldTransform, /* pSetWorldTransform */
787 nulldrv_StartDoc, /* pStartDoc */
788 nulldrv_StartPage, /* pStartPage */
789 nulldrv_StretchBlt, /* pStretchBlt */
790 nulldrv_StretchDIBits, /* pStretchDIBits */
791 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
792 nulldrv_StrokePath, /* pStrokePath */
793 nulldrv_SwapBuffers, /* pSwapBuffers */
794 nulldrv_UnrealizePalette, /* pUnrealizePalette */
795 nulldrv_WidenPath, /* pWidenPath */
796 nulldrv_wglCopyContext, /* pwglCopyContext */
797 nulldrv_wglCreateContext, /* pwglCreateContext */
798 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
799 nulldrv_wglDeleteContext, /* pwglDeleteContext */
800 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
801 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
802 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
803 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
804 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
805 nulldrv_wglShareLists, /* pwglShareLists */
806 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
807 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
811 /*****************************************************************************
812 * DRIVER_GetDriverName
815 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
817 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
818 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
819 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
820 static const WCHAR empty_strW[] = { 0 };
821 WCHAR *p;
823 /* display is a special case */
824 if (!strcmpiW( device, displayW ) ||
825 !strcmpiW( device, display1W ))
827 lstrcpynW( driver, displayW, size );
828 return TRUE;
831 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
832 if(!size) {
833 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
834 return FALSE;
836 p = strchrW(driver, ',');
837 if(!p)
839 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
840 return FALSE;
842 *p = 0;
843 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
844 return TRUE;
848 /***********************************************************************
849 * GdiConvertToDevmodeW (GDI32.@)
851 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
853 DEVMODEW *dmW;
854 WORD dmW_size, dmA_size;
856 dmA_size = dmA->dmSize;
858 /* this is the minimal dmSize that XP accepts */
859 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
860 return NULL;
862 if (dmA_size > sizeof(DEVMODEA))
863 dmA_size = sizeof(DEVMODEA);
865 dmW_size = dmA_size + CCHDEVICENAME;
866 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
867 dmW_size += CCHFORMNAME;
869 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
870 if (!dmW) return NULL;
872 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
873 dmW->dmDeviceName, CCHDEVICENAME);
874 /* copy slightly more, to avoid long computations */
875 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
877 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
879 if (dmA->dmFields & DM_FORMNAME)
880 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
881 dmW->dmFormName, CCHFORMNAME);
882 else
883 dmW->dmFormName[0] = 0;
885 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
886 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
889 if (dmA->dmDriverExtra)
890 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
892 dmW->dmSize = dmW_size;
894 return dmW;
898 /*****************************************************************************
899 * @ [GDI32.100]
901 * This should thunk to 16-bit and simply call the proc with the given args.
903 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
904 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
906 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
907 return -1;
910 /*****************************************************************************
911 * @ [GDI32.101]
913 * This should load the correct driver for lpszDevice and calls this driver's
914 * ExtDeviceModePropSheet proc.
916 * Note: The driver calls a callback routine for each property sheet page; these
917 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
918 * The layout of this structure is:
920 * struct
922 * DWORD nPages;
923 * DWORD unknown;
924 * HPROPSHEETPAGE pages[10];
925 * };
927 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
928 LPCSTR lpszPort, LPVOID lpPropSheet )
930 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
931 return -1;
934 /*****************************************************************************
935 * @ [GDI32.102]
937 * This should load the correct driver for lpszDevice and call this driver's
938 * ExtDeviceMode proc.
940 * FIXME: convert ExtDeviceMode to unicode in the driver interface
942 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
943 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
944 LPSTR lpszPort, LPDEVMODEA lpdmInput,
945 LPSTR lpszProfile, DWORD fwMode )
947 WCHAR deviceW[300];
948 WCHAR bufW[300];
949 char buf[300];
950 HDC hdc;
951 DC *dc;
952 INT ret = -1;
954 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
955 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
957 if (!lpszDevice) return -1;
958 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
960 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
962 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
964 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
966 if ((dc = get_dc_ptr( hdc )))
968 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
969 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
970 lpdmInput, lpszProfile, fwMode );
971 release_dc_ptr( dc );
973 DeleteDC( hdc );
974 return ret;
977 /****************************************************************************
978 * @ [GDI32.103]
980 * This should load the correct driver for lpszDevice and calls this driver's
981 * AdvancedSetupDialog proc.
983 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
984 LPDEVMODEA devin, LPDEVMODEA devout )
986 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
987 return -1;
990 /*****************************************************************************
991 * @ [GDI32.104]
993 * This should load the correct driver for lpszDevice and calls this driver's
994 * DeviceCapabilities proc.
996 * FIXME: convert DeviceCapabilities to unicode in the driver interface
998 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
999 WORD fwCapability, LPSTR lpszOutput,
1000 LPDEVMODEA lpdm )
1002 WCHAR deviceW[300];
1003 WCHAR bufW[300];
1004 char buf[300];
1005 HDC hdc;
1006 DC *dc;
1007 INT ret = -1;
1009 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1011 if (!lpszDevice) return -1;
1012 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1014 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1016 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1018 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1020 if ((dc = get_dc_ptr( hdc )))
1022 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1023 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1024 fwCapability, lpszOutput, lpdm );
1025 release_dc_ptr( dc );
1027 DeleteDC( hdc );
1028 return ret;
1032 /************************************************************************
1033 * Escape [GDI32.@]
1035 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1037 INT ret;
1038 POINT *pt;
1040 switch (escape)
1042 case ABORTDOC:
1043 return AbortDoc( hdc );
1045 case ENDDOC:
1046 return EndDoc( hdc );
1048 case GETPHYSPAGESIZE:
1049 pt = out_data;
1050 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1051 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1052 return 1;
1054 case GETPRINTINGOFFSET:
1055 pt = out_data;
1056 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1057 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1058 return 1;
1060 case GETSCALINGFACTOR:
1061 pt = out_data;
1062 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1063 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1064 return 1;
1066 case NEWFRAME:
1067 return EndPage( hdc );
1069 case SETABORTPROC:
1070 return SetAbortProc( hdc, (ABORTPROC)in_data );
1072 case STARTDOC:
1074 DOCINFOA doc;
1075 char *name = NULL;
1077 /* in_data may not be 0 terminated so we must copy it */
1078 if (in_data)
1080 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1081 memcpy( name, in_data, in_count );
1082 name[in_count] = 0;
1084 /* out_data is actually a pointer to the DocInfo structure and used as
1085 * a second input parameter */
1086 if (out_data) doc = *(DOCINFOA *)out_data;
1087 else
1089 doc.cbSize = sizeof(doc);
1090 doc.lpszOutput = NULL;
1091 doc.lpszDatatype = NULL;
1092 doc.fwType = 0;
1094 doc.lpszDocName = name;
1095 ret = StartDocA( hdc, &doc );
1096 HeapFree( GetProcessHeap(), 0, name );
1097 if (ret > 0) ret = StartPage( hdc );
1098 return ret;
1101 case QUERYESCSUPPORT:
1103 const INT *ptr = (const INT *)in_data;
1104 if (in_count < sizeof(INT)) return 0;
1105 switch(*ptr)
1107 case ABORTDOC:
1108 case ENDDOC:
1109 case GETPHYSPAGESIZE:
1110 case GETPRINTINGOFFSET:
1111 case GETSCALINGFACTOR:
1112 case NEWFRAME:
1113 case QUERYESCSUPPORT:
1114 case SETABORTPROC:
1115 case STARTDOC:
1116 return TRUE;
1118 break;
1122 /* if not handled internally, pass it to the driver */
1123 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1127 /******************************************************************************
1128 * ExtEscape [GDI32.@]
1130 * Access capabilities of a particular device that are not available through GDI.
1132 * PARAMS
1133 * hdc [I] Handle to device context
1134 * nEscape [I] Escape function
1135 * cbInput [I] Number of bytes in input structure
1136 * lpszInData [I] Pointer to input structure
1137 * cbOutput [I] Number of bytes in output structure
1138 * lpszOutData [O] Pointer to output structure
1140 * RETURNS
1141 * Success: >0
1142 * Not implemented: 0
1143 * Failure: <0
1145 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1146 INT cbOutput, LPSTR lpszOutData )
1148 INT ret = 0;
1149 DC * dc = get_dc_ptr( hdc );
1151 if (dc)
1153 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1154 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1155 release_dc_ptr( dc );
1157 return ret;
1161 /*******************************************************************
1162 * DrawEscape [GDI32.@]
1166 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1168 FIXME("DrawEscape, stub\n");
1169 return 0;
1172 /*******************************************************************
1173 * NamedEscape [GDI32.@]
1175 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1176 INT cbOutput, LPSTR lpszOutData )
1178 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1179 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1180 lpszOutData);
1181 return 0;
1184 /*******************************************************************
1185 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1186 * GdiEntry13 [GDI32.@]
1188 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1190 static int warn_once;
1192 if (!warn_once++)
1193 FIXME("stub\n");
1194 return 0;