2 * Graphics driver management functions
4 * Copyright 1994 Bob Amstadt
5 * Copyright 1996, 2001 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
33 #include "wine/winbase16.h"
35 #include "gdi_private.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(driver
);
42 struct graphics_driver
45 HMODULE module
; /* module handle */
49 static struct list drivers
= LIST_INIT( drivers
);
50 static struct graphics_driver
*display_driver
;
52 static CRITICAL_SECTION driver_section
;
53 static CRITICAL_SECTION_DEBUG critsect_debug
=
55 0, 0, &driver_section
,
56 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
57 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
59 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
61 /**********************************************************************
64 * Allocate and fill the driver structure for a given module.
66 static struct graphics_driver
*create_driver( HMODULE module
)
68 struct graphics_driver
*driver
;
70 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
71 driver
->module
= module
;
73 /* fill the function table */
76 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
84 GET_FUNC(ChoosePixelFormat
);
86 GET_FUNC(CloseFigure
);
87 GET_FUNC(CreateBitmap
);
89 GET_FUNC(CreateDIBSection
);
90 GET_FUNC(DeleteBitmap
);
92 GET_FUNC(DescribePixelFormat
);
93 GET_FUNC(DeviceCapabilities
);
98 GET_FUNC(EnumDeviceFonts
);
99 GET_FUNC(EnumICMProfiles
);
100 GET_FUNC(ExcludeClipRect
);
101 GET_FUNC(ExtDeviceMode
);
103 GET_FUNC(ExtFloodFill
);
104 GET_FUNC(ExtSelectClipRgn
);
105 GET_FUNC(ExtTextOut
);
108 GET_FUNC(FlattenPath
);
110 GET_FUNC(GdiComment
);
111 GET_FUNC(GetBitmapBits
);
112 GET_FUNC(GetCharWidth
);
114 GET_FUNC(GetDeviceCaps
);
115 GET_FUNC(GetDeviceGammaRamp
);
116 GET_FUNC(GetICMProfile
);
117 GET_FUNC(GetNearestColor
);
119 GET_FUNC(GetPixelFormat
);
120 GET_FUNC(GetSystemPaletteEntries
);
121 GET_FUNC(GetTextExtentExPoint
);
122 GET_FUNC(GetTextMetrics
);
123 GET_FUNC(IntersectClipRect
);
127 GET_FUNC(ModifyWorldTransform
);
128 GET_FUNC(OffsetClipRgn
);
129 GET_FUNC(OffsetViewportOrgEx
);
130 GET_FUNC(OffsetWindowOrgEx
);
134 GET_FUNC(PolyBezier
);
135 GET_FUNC(PolyBezierTo
);
137 GET_FUNC(PolyPolygon
);
138 GET_FUNC(PolyPolyline
);
141 GET_FUNC(PolylineTo
);
142 GET_FUNC(RealizeDefaultPalette
);
143 GET_FUNC(RealizePalette
);
149 GET_FUNC(ScaleViewportExtEx
);
150 GET_FUNC(ScaleWindowExtEx
);
151 GET_FUNC(SelectBitmap
);
152 GET_FUNC(SelectBrush
);
153 GET_FUNC(SelectClipPath
);
154 GET_FUNC(SelectFont
);
155 GET_FUNC(SelectPalette
);
157 GET_FUNC(SetArcDirection
);
158 GET_FUNC(SetBitmapBits
);
159 GET_FUNC(SetBkColor
);
161 GET_FUNC(SetDCBrushColor
);
162 GET_FUNC(SetDCPenColor
);
163 GET_FUNC(SetDIBColorTable
);
165 GET_FUNC(SetDIBitsToDevice
);
166 GET_FUNC(SetDeviceClipping
);
167 GET_FUNC(SetDeviceGammaRamp
);
169 GET_FUNC(SetMapMode
);
170 GET_FUNC(SetMapperFlags
);
172 GET_FUNC(SetPixelFormat
);
173 GET_FUNC(SetPolyFillMode
);
176 GET_FUNC(SetStretchBltMode
);
177 GET_FUNC(SetTextAlign
);
178 GET_FUNC(SetTextCharacterExtra
);
179 GET_FUNC(SetTextColor
);
180 GET_FUNC(SetTextJustification
);
181 GET_FUNC(SetViewportExtEx
);
182 GET_FUNC(SetViewportOrgEx
);
183 GET_FUNC(SetWindowExtEx
);
184 GET_FUNC(SetWindowOrgEx
);
185 GET_FUNC(SetWorldTransform
);
188 GET_FUNC(StretchBlt
);
189 GET_FUNC(StretchDIBits
);
190 GET_FUNC(StrokeAndFillPath
);
191 GET_FUNC(StrokePath
);
192 GET_FUNC(SwapBuffers
);
193 GET_FUNC(UnrealizePalette
);
197 GET_FUNC(wglCreateContext
);
198 GET_FUNC(wglCreateContextAttribsARB
);
199 GET_FUNC(wglDeleteContext
);
200 GET_FUNC(wglGetProcAddress
);
201 GET_FUNC(wglGetPbufferDCARB
);
202 GET_FUNC(wglMakeContextCurrentARB
);
203 GET_FUNC(wglMakeCurrent
);
204 GET_FUNC(wglSetPixelFormatWINE
);
205 GET_FUNC(wglShareLists
);
206 GET_FUNC(wglUseFontBitmapsA
);
207 GET_FUNC(wglUseFontBitmapsW
);
210 else memset( &driver
->funcs
, 0, sizeof(driver
->funcs
) );
216 /**********************************************************************
217 * DRIVER_get_display_driver
219 * Special case for loading the display driver: get the name from the config file
221 const DC_FUNCTIONS
*DRIVER_get_display_driver(void)
223 struct graphics_driver
*driver
;
224 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
228 if (display_driver
) return &display_driver
->funcs
; /* already loaded */
230 strcpy( buffer
, "x11" ); /* default value */
231 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
232 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
234 DWORD type
, count
= sizeof(buffer
);
235 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
242 next
= strchr( name
, ',' );
243 if (next
) *next
++ = 0;
245 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
246 if ((module
= LoadLibraryA( libname
)) != 0) break;
250 if (!(driver
= create_driver( module
)))
252 MESSAGE( "Could not create graphics driver '%s'\n", buffer
);
253 FreeLibrary( module
);
256 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
258 /* somebody beat us to it */
259 FreeLibrary( driver
->module
);
260 HeapFree( GetProcessHeap(), 0, driver
);
262 return &display_driver
->funcs
;
266 /**********************************************************************
269 const DC_FUNCTIONS
*DRIVER_load_driver( LPCWSTR name
)
272 struct graphics_driver
*driver
, *new_driver
;
273 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
274 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
276 /* display driver is a special case */
277 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
)) return DRIVER_get_display_driver();
279 if ((module
= GetModuleHandleW( name
)))
281 if (display_driver
&& display_driver
->module
== module
) return &display_driver
->funcs
;
282 EnterCriticalSection( &driver_section
);
283 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
285 if (driver
->module
== module
) goto done
;
287 LeaveCriticalSection( &driver_section
);
290 if (!(module
= LoadLibraryW( name
))) return NULL
;
292 if (!(new_driver
= create_driver( module
)))
294 FreeLibrary( module
);
298 /* check if someone else added it in the meantime */
299 EnterCriticalSection( &driver_section
);
300 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
302 if (driver
->module
!= module
) continue;
303 FreeLibrary( module
);
304 HeapFree( GetProcessHeap(), 0, new_driver
);
308 list_add_head( &drivers
, &driver
->entry
);
309 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
311 LeaveCriticalSection( &driver_section
);
312 return &driver
->funcs
;
316 static INT CDECL
nulldrv_AbortDoc( PHYSDEV dev
)
321 static BOOL CDECL
nulldrv_AlphaBlend( PHYSDEV dst_dev
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
322 PHYSDEV src_dev
, INT x_src
, INT y_src
, INT width_src
, INT height_src
,
328 static BOOL CDECL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
329 INT xstart
, INT ystart
, INT xend
, INT yend
)
334 static INT CDECL
nulldrv_ChoosePixelFormat( PHYSDEV dev
, const PIXELFORMATDESCRIPTOR
*descr
)
339 static BOOL CDECL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
340 INT xstart
, INT ystart
, INT xend
, INT yend
)
345 static BOOL CDECL
nulldrv_CreateBitmap( PHYSDEV dev
, HBITMAP bitmap
, LPVOID bits
)
350 static BOOL CDECL
nulldrv_CreateDC( HDC hdc
, PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
351 LPCWSTR output
, const DEVMODEW
*devmode
)
353 assert(0); /* should never be called */
357 static HBITMAP CDECL
nulldrv_CreateDIBSection( PHYSDEV dev
, HBITMAP bitmap
,
358 const BITMAPINFO
*info
, UINT usage
)
363 static BOOL CDECL
nulldrv_DeleteBitmap( HBITMAP bitmap
)
368 static BOOL CDECL
nulldrv_DeleteDC( PHYSDEV dev
)
370 assert(0); /* should never be called */
374 static BOOL CDECL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
379 static INT CDECL
nulldrv_DescribePixelFormat( PHYSDEV dev
, INT format
,
380 UINT size
, PIXELFORMATDESCRIPTOR
* descr
)
385 static DWORD CDECL
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
386 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
391 static BOOL CDECL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
396 static INT CDECL
nulldrv_EndDoc( PHYSDEV dev
)
401 static INT CDECL
nulldrv_EndPage( PHYSDEV dev
)
406 static BOOL CDECL
nulldrv_EnumDeviceFonts( PHYSDEV dev
, LOGFONTW
*logfont
,
407 FONTENUMPROCW proc
, LPARAM lParam
)
412 static INT CDECL
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
417 static INT CDECL
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
418 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
423 static INT CDECL
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
424 INT out_size
, void *out_data
)
429 static BOOL CDECL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
434 static BOOL CDECL
nulldrv_ExtTextOut( PHYSDEV dev
, INT x
, INT y
, UINT flags
, const RECT
*rect
,
435 LPCWSTR str
, UINT count
, const INT
*dx
)
440 static BOOL CDECL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
445 static BOOL CDECL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
450 static INT CDECL
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
452 switch (cap
) /* return meaningful values for some entries */
454 case HORZRES
: return 640;
455 case VERTRES
: return 480;
456 case BITSPIXEL
: return 1;
457 case PLANES
: return 1;
458 case NUMCOLORS
: return 2;
459 case ASPECTX
: return 36;
460 case ASPECTY
: return 36;
461 case ASPECTXY
: return 51;
462 case LOGPIXELSX
: return 72;
463 case LOGPIXELSY
: return 72;
464 case SIZEPALETTE
: return 2;
465 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
466 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
467 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
472 static BOOL CDECL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
477 static BOOL CDECL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
482 static COLORREF CDECL
nulldrv_GetPixel( PHYSDEV dev
, INT x
, INT y
)
487 static INT CDECL
nulldrv_GetPixelFormat( PHYSDEV dev
)
492 static UINT CDECL
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
,
493 UINT count
, PALETTEENTRY
*entries
)
498 static BOOL CDECL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT max_ext
,
499 INT
*fit
, INT
*dx
, SIZE
*size
)
504 static BOOL CDECL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
509 static BOOL CDECL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
514 static BOOL CDECL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
519 static BOOL CDECL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
524 static BOOL CDECL
nulldrv_PatBlt( PHYSDEV dev
, INT x
, INT y
, INT width
, INT height
, DWORD rop
)
529 static BOOL CDECL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
530 INT xstart
, INT ystart
, INT xend
, INT yend
)
535 static BOOL CDECL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
537 /* FIXME: could be implemented with Polygon */
541 static BOOL CDECL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
543 /* FIXME: could be implemented with Polyline */
547 static BOOL CDECL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
552 static BOOL CDECL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
557 static UINT CDECL
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
562 static UINT CDECL
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
567 static BOOL CDECL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
572 static HDC CDECL
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
577 static BOOL CDECL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
578 INT ell_width
, INT ell_height
)
583 static HBITMAP CDECL
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
588 static HBRUSH CDECL
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
)
593 static HFONT CDECL
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
, HANDLE gdi_font
)
598 static HPALETTE CDECL
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
603 static HPEN CDECL
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
)
608 static INT CDECL
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
613 static COLORREF CDECL
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
618 static INT CDECL
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
623 static COLORREF CDECL
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
628 static COLORREF CDECL
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
633 static UINT CDECL
nulldrv_SetDIBColorTable( PHYSDEV dev
, UINT pos
, UINT count
, const RGBQUAD
*colors
)
638 static INT CDECL
nulldrv_SetDIBitsToDevice( PHYSDEV dev
, INT x_dst
, INT y_dst
, DWORD width
, DWORD height
,
639 INT x_src
, INT y_src
, UINT start
, UINT lines
,
640 const void *bits
, const BITMAPINFO
*info
, UINT coloruse
)
645 static void CDECL
nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN vis_rgn
, HRGN clip_rgn
)
649 static DWORD CDECL
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
654 static BOOL CDECL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
659 static DWORD CDECL
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
664 static COLORREF CDECL
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
669 static BOOL CDECL
nulldrv_SetPixelFormat( PHYSDEV dev
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
674 static INT CDECL
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
679 static INT CDECL
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
684 static INT CDECL
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
689 static INT CDECL
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
694 static UINT CDECL
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
699 static INT CDECL
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
704 static COLORREF CDECL
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
709 static BOOL CDECL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
714 static INT CDECL
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
719 static INT CDECL
nulldrv_StartPage( PHYSDEV dev
)
724 static BOOL CDECL
nulldrv_SwapBuffers( PHYSDEV dev
)
729 static BOOL CDECL
nulldrv_UnrealizePalette( HPALETTE palette
)
734 static BOOL CDECL
nulldrv_wglCopyContext( HGLRC ctx_src
, HGLRC ctx_dst
, UINT mask
)
739 static HGLRC CDECL
nulldrv_wglCreateContext( PHYSDEV dev
)
744 static HGLRC CDECL
nulldrv_wglCreateContextAttribsARB( PHYSDEV dev
, HGLRC share_ctx
, const int *attribs
)
749 static BOOL CDECL
nulldrv_wglDeleteContext( HGLRC ctx
)
754 static PROC CDECL
nulldrv_wglGetProcAddress( LPCSTR name
)
759 static HDC CDECL
nulldrv_wglGetPbufferDCARB( PHYSDEV dev
, void *pbuffer
)
764 static BOOL CDECL
nulldrv_wglMakeCurrent( PHYSDEV dev
, HGLRC ctx
)
769 static BOOL CDECL
nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw
, PHYSDEV dev_read
, HGLRC ctx
)
774 static BOOL CDECL
nulldrv_wglSetPixelFormatWINE( PHYSDEV dev
, INT format
,
775 const PIXELFORMATDESCRIPTOR
*descr
)
780 static BOOL CDECL
nulldrv_wglShareLists( HGLRC ctx1
, HGLRC ctx2
)
785 static BOOL CDECL
nulldrv_wglUseFontBitmapsA( PHYSDEV dev
, DWORD start
, DWORD count
, DWORD base
)
790 static BOOL CDECL
nulldrv_wglUseFontBitmapsW( PHYSDEV dev
, DWORD start
, DWORD count
, DWORD base
)
795 const DC_FUNCTIONS null_driver
=
797 nulldrv_AbortDoc
, /* pAbortDoc */
798 nulldrv_AbortPath
, /* pAbortPath */
799 nulldrv_AlphaBlend
, /* pAlphaBlend */
800 nulldrv_AngleArc
, /* pAngleArc */
801 nulldrv_Arc
, /* pArc */
802 nulldrv_ArcTo
, /* pArcTo */
803 nulldrv_BeginPath
, /* pBeginPath */
804 nulldrv_ChoosePixelFormat
, /* pChoosePixelFormat */
805 nulldrv_Chord
, /* pChord */
806 nulldrv_CloseFigure
, /* pCloseFigure */
807 nulldrv_CreateBitmap
, /* pCreateBitmap */
808 nulldrv_CreateDC
, /* pCreateDC */
809 nulldrv_CreateDIBSection
, /* pCreateDIBSection */
810 nulldrv_DeleteBitmap
, /* pDeleteBitmap */
811 nulldrv_DeleteDC
, /* pDeleteDC */
812 nulldrv_DeleteObject
, /* pDeleteObject */
813 nulldrv_DescribePixelFormat
, /* pDescribePixelFormat */
814 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
815 nulldrv_Ellipse
, /* pEllipse */
816 nulldrv_EndDoc
, /* pEndDoc */
817 nulldrv_EndPage
, /* pEndPage */
818 nulldrv_EndPath
, /* pEndPath */
819 nulldrv_EnumDeviceFonts
, /* pEnumDeviceFonts */
820 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
821 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
822 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
823 nulldrv_ExtEscape
, /* pExtEscape */
824 nulldrv_ExtFloodFill
, /* pExtFloodFill */
825 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
826 nulldrv_ExtTextOut
, /* pExtTextOut */
827 nulldrv_FillPath
, /* pFillPath */
828 nulldrv_FillRgn
, /* pFillRgn */
829 nulldrv_FlattenPath
, /* pFlattenPath */
830 nulldrv_FrameRgn
, /* pFrameRgn */
831 nulldrv_GdiComment
, /* pGdiComment */
832 nulldrv_GetBitmapBits
, /* pGetBitmapBits */
833 nulldrv_GetCharWidth
, /* pGetCharWidth */
834 nulldrv_GetDIBits
, /* pGetDIBits */
835 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
836 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
837 nulldrv_GetICMProfile
, /* pGetICMProfile */
838 nulldrv_GetNearestColor
, /* pGetNearestColor */
839 nulldrv_GetPixel
, /* pGetPixel */
840 nulldrv_GetPixelFormat
, /* pGetPixelFormat */
841 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
842 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
843 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
844 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
845 nulldrv_InvertRgn
, /* pInvertRgn */
846 nulldrv_LineTo
, /* pLineTo */
847 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
848 nulldrv_MoveTo
, /* pMoveTo */
849 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
850 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
851 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
852 nulldrv_PaintRgn
, /* pPaintRgn */
853 nulldrv_PatBlt
, /* pPatBlt */
854 nulldrv_Pie
, /* pPie */
855 nulldrv_PolyBezier
, /* pPolyBezier */
856 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
857 nulldrv_PolyDraw
, /* pPolyDraw */
858 nulldrv_PolyPolygon
, /* pPolyPolygon */
859 nulldrv_PolyPolyline
, /* pPolyPolyline */
860 nulldrv_Polygon
, /* pPolygon */
861 nulldrv_Polyline
, /* pPolyline */
862 nulldrv_PolylineTo
, /* pPolylineTo */
863 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
864 nulldrv_RealizePalette
, /* pRealizePalette */
865 nulldrv_Rectangle
, /* pRectangle */
866 nulldrv_ResetDC
, /* pResetDC */
867 nulldrv_RestoreDC
, /* pRestoreDC */
868 nulldrv_RoundRect
, /* pRoundRect */
869 nulldrv_SaveDC
, /* pSaveDC */
870 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
871 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
872 nulldrv_SelectBitmap
, /* pSelectBitmap */
873 nulldrv_SelectBrush
, /* pSelectBrush */
874 nulldrv_SelectClipPath
, /* pSelectClipPath */
875 nulldrv_SelectFont
, /* pSelectFont */
876 nulldrv_SelectPalette
, /* pSelectPalette */
877 nulldrv_SelectPen
, /* pSelectPen */
878 nulldrv_SetArcDirection
, /* pSetArcDirection */
879 nulldrv_SetBitmapBits
, /* pSetBitmapBits */
880 nulldrv_SetBkColor
, /* pSetBkColor */
881 nulldrv_SetBkMode
, /* pSetBkMode */
882 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
883 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
884 nulldrv_SetDIBColorTable
, /* pSetDIBColorTable */
885 nulldrv_SetDIBits
, /* pSetDIBits */
886 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
887 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
888 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
889 nulldrv_SetLayout
, /* pSetLayout */
890 nulldrv_SetMapMode
, /* pSetMapMode */
891 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
892 nulldrv_SetPixel
, /* pSetPixel */
893 nulldrv_SetPixelFormat
, /* pSetPixelFormat */
894 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
895 nulldrv_SetROP2
, /* pSetROP2 */
896 nulldrv_SetRelAbs
, /* pSetRelAbs */
897 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
898 nulldrv_SetTextAlign
, /* pSetTextAlign */
899 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
900 nulldrv_SetTextColor
, /* pSetTextColor */
901 nulldrv_SetTextJustification
, /* pSetTextJustification */
902 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
903 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
904 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
905 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
906 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
907 nulldrv_StartDoc
, /* pStartDoc */
908 nulldrv_StartPage
, /* pStartPage */
909 nulldrv_StretchBlt
, /* pStretchBlt */
910 nulldrv_StretchDIBits
, /* pStretchDIBits */
911 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
912 nulldrv_StrokePath
, /* pStrokePath */
913 nulldrv_SwapBuffers
, /* pSwapBuffers */
914 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
915 nulldrv_WidenPath
, /* pWidenPath */
916 nulldrv_wglCopyContext
, /* pwglCopyContext */
917 nulldrv_wglCreateContext
, /* pwglCreateContext */
918 nulldrv_wglCreateContextAttribsARB
, /* pwglCreateContextAttribsARB */
919 nulldrv_wglDeleteContext
, /* pwglDeleteContext */
920 nulldrv_wglGetProcAddress
, /* pwglGetProcAddress */
921 nulldrv_wglGetPbufferDCARB
, /* pwglGetPbufferDCARB */
922 nulldrv_wglMakeCurrent
, /* pwglMakeCurrent */
923 nulldrv_wglMakeContextCurrentARB
, /* pwglMakeContextCurrentARB */
924 nulldrv_wglSetPixelFormatWINE
, /* pwglSetPixelFormatWINE */
925 nulldrv_wglShareLists
, /* pwglShareLists */
926 nulldrv_wglUseFontBitmapsA
, /* pwglUseFontBitmapsA */
927 nulldrv_wglUseFontBitmapsW
, /* pwglUseFontBitmapsW */
931 /*****************************************************************************
932 * DRIVER_GetDriverName
935 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
937 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
938 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
939 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
940 static const WCHAR empty_strW
[] = { 0 };
943 /* display is a special case */
944 if (!strcmpiW( device
, displayW
) ||
945 !strcmpiW( device
, display1W
))
947 lstrcpynW( driver
, displayW
, size
);
951 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
953 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
956 p
= strchrW(driver
, ',');
959 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
963 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
968 /***********************************************************************
969 * GdiConvertToDevmodeW (GDI32.@)
971 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
974 WORD dmW_size
, dmA_size
;
976 dmA_size
= dmA
->dmSize
;
978 /* this is the minimal dmSize that XP accepts */
979 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
982 if (dmA_size
> sizeof(DEVMODEA
))
983 dmA_size
= sizeof(DEVMODEA
);
985 dmW_size
= dmA_size
+ CCHDEVICENAME
;
986 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
987 dmW_size
+= CCHFORMNAME
;
989 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
990 if (!dmW
) return NULL
;
992 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
993 dmW
->dmDeviceName
, CCHDEVICENAME
);
994 /* copy slightly more, to avoid long computations */
995 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
997 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
999 if (dmA
->dmFields
& DM_FORMNAME
)
1000 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
1001 dmW
->dmFormName
, CCHFORMNAME
);
1003 dmW
->dmFormName
[0] = 0;
1005 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
1006 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
1009 if (dmA
->dmDriverExtra
)
1010 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
1012 dmW
->dmSize
= dmW_size
;
1018 /*****************************************************************************
1021 * This should thunk to 16-bit and simply call the proc with the given args.
1023 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
1024 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
1026 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
1030 /*****************************************************************************
1033 * This should load the correct driver for lpszDevice and calls this driver's
1034 * ExtDeviceModePropSheet proc.
1036 * Note: The driver calls a callback routine for each property sheet page; these
1037 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1038 * The layout of this structure is:
1044 * HPROPSHEETPAGE pages[10];
1047 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
1048 LPCSTR lpszPort
, LPVOID lpPropSheet
)
1050 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
1054 /*****************************************************************************
1057 * This should load the correct driver for lpszDevice and call this driver's
1058 * ExtDeviceMode proc.
1060 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1062 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
1063 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
1064 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
1065 LPSTR lpszProfile
, DWORD fwMode
)
1074 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1075 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
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
, pExtDeviceMode
);
1089 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1090 lpdmInput
, lpszProfile
, fwMode
);
1091 release_dc_ptr( dc
);
1097 /****************************************************************************
1100 * This should load the correct driver for lpszDevice and calls this driver's
1101 * AdvancedSetupDialog proc.
1103 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1104 LPDEVMODEA devin
, LPDEVMODEA devout
)
1106 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1110 /*****************************************************************************
1113 * This should load the correct driver for lpszDevice and calls this driver's
1114 * DeviceCapabilities proc.
1116 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1118 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1119 WORD fwCapability
, LPSTR lpszOutput
,
1129 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1131 if (!lpszDevice
) return -1;
1132 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1134 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1136 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1138 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1140 if ((dc
= get_dc_ptr( hdc
)))
1142 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1143 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1144 fwCapability
, lpszOutput
, lpdm
);
1145 release_dc_ptr( dc
);
1152 /************************************************************************
1155 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1163 return AbortDoc( hdc
);
1166 return EndDoc( hdc
);
1168 case GETPHYSPAGESIZE
:
1170 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1171 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1174 case GETPRINTINGOFFSET
:
1176 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1177 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1180 case GETSCALINGFACTOR
:
1182 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1183 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1187 return EndPage( hdc
);
1190 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1197 /* in_data may not be 0 terminated so we must copy it */
1200 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1201 memcpy( name
, in_data
, in_count
);
1204 /* out_data is actually a pointer to the DocInfo structure and used as
1205 * a second input parameter */
1206 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1209 doc
.cbSize
= sizeof(doc
);
1210 doc
.lpszOutput
= NULL
;
1211 doc
.lpszDatatype
= NULL
;
1214 doc
.lpszDocName
= name
;
1215 ret
= StartDocA( hdc
, &doc
);
1216 HeapFree( GetProcessHeap(), 0, name
);
1217 if (ret
> 0) ret
= StartPage( hdc
);
1221 case QUERYESCSUPPORT
:
1223 const INT
*ptr
= (const INT
*)in_data
;
1224 if (in_count
< sizeof(INT
)) return 0;
1229 case GETPHYSPAGESIZE
:
1230 case GETPRINTINGOFFSET
:
1231 case GETSCALINGFACTOR
:
1233 case QUERYESCSUPPORT
:
1242 /* if not handled internally, pass it to the driver */
1243 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1247 /******************************************************************************
1248 * ExtEscape [GDI32.@]
1250 * Access capabilities of a particular device that are not available through GDI.
1253 * hdc [I] Handle to device context
1254 * nEscape [I] Escape function
1255 * cbInput [I] Number of bytes in input structure
1256 * lpszInData [I] Pointer to input structure
1257 * cbOutput [I] Number of bytes in output structure
1258 * lpszOutData [O] Pointer to output structure
1262 * Not implemented: 0
1265 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1266 INT cbOutput
, LPSTR lpszOutData
)
1269 DC
* dc
= get_dc_ptr( hdc
);
1273 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1274 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1275 release_dc_ptr( dc
);
1281 /*******************************************************************
1282 * DrawEscape [GDI32.@]
1286 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1288 FIXME("DrawEscape, stub\n");
1292 /*******************************************************************
1293 * NamedEscape [GDI32.@]
1295 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1296 INT cbOutput
, LPSTR lpszOutData
)
1298 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1299 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1304 /*******************************************************************
1305 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1306 * GdiEntry13 [GDI32.@]
1308 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1310 static int warn_once
;