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 )
85 GET_FUNC(ChoosePixelFormat
);
87 GET_FUNC(CloseFigure
);
88 GET_FUNC(CreateBitmap
);
90 GET_FUNC(CreateDIBSection
);
91 GET_FUNC(DeleteBitmap
);
93 GET_FUNC(DescribePixelFormat
);
94 GET_FUNC(DeviceCapabilities
);
99 GET_FUNC(EnumDeviceFonts
);
100 GET_FUNC(EnumICMProfiles
);
101 GET_FUNC(ExcludeClipRect
);
102 GET_FUNC(ExtDeviceMode
);
104 GET_FUNC(ExtFloodFill
);
105 GET_FUNC(ExtSelectClipRgn
);
106 GET_FUNC(ExtTextOut
);
109 GET_FUNC(FlattenPath
);
111 GET_FUNC(GdiComment
);
112 GET_FUNC(GetBitmapBits
);
113 GET_FUNC(GetCharWidth
);
115 GET_FUNC(GetDeviceCaps
);
116 GET_FUNC(GetDeviceGammaRamp
);
117 GET_FUNC(GetICMProfile
);
118 GET_FUNC(GetNearestColor
);
120 GET_FUNC(GetPixelFormat
);
121 GET_FUNC(GetSystemPaletteEntries
);
122 GET_FUNC(GetTextExtentExPoint
);
123 GET_FUNC(GetTextMetrics
);
124 GET_FUNC(IntersectClipRect
);
128 GET_FUNC(ModifyWorldTransform
);
129 GET_FUNC(OffsetClipRgn
);
130 GET_FUNC(OffsetViewportOrgEx
);
131 GET_FUNC(OffsetWindowOrgEx
);
135 GET_FUNC(PolyBezier
);
136 GET_FUNC(PolyBezierTo
);
138 GET_FUNC(PolyPolygon
);
139 GET_FUNC(PolyPolyline
);
142 GET_FUNC(PolylineTo
);
143 GET_FUNC(RealizeDefaultPalette
);
144 GET_FUNC(RealizePalette
);
150 GET_FUNC(ScaleViewportExtEx
);
151 GET_FUNC(ScaleWindowExtEx
);
152 GET_FUNC(SelectBitmap
);
153 GET_FUNC(SelectBrush
);
154 GET_FUNC(SelectClipPath
);
155 GET_FUNC(SelectFont
);
156 GET_FUNC(SelectPalette
);
158 GET_FUNC(SetArcDirection
);
159 GET_FUNC(SetBitmapBits
);
160 GET_FUNC(SetBkColor
);
162 GET_FUNC(SetDCBrushColor
);
163 GET_FUNC(SetDCPenColor
);
164 GET_FUNC(SetDIBColorTable
);
166 GET_FUNC(SetDIBitsToDevice
);
167 GET_FUNC(SetDeviceClipping
);
168 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_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
322 INT xstart
, INT ystart
, INT xend
, INT yend
)
327 static INT CDECL
nulldrv_ChoosePixelFormat( PHYSDEV dev
, const PIXELFORMATDESCRIPTOR
*descr
)
332 static BOOL CDECL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
333 INT xstart
, INT ystart
, INT xend
, INT yend
)
338 static BOOL CDECL
nulldrv_CreateBitmap( PHYSDEV dev
, HBITMAP bitmap
, LPVOID bits
)
343 static BOOL CDECL
nulldrv_CreateDC( HDC hdc
, PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
344 LPCWSTR output
, const DEVMODEW
*devmode
)
346 assert(0); /* should never be called */
350 static HBITMAP CDECL
nulldrv_CreateDIBSection( PHYSDEV dev
, HBITMAP bitmap
,
351 const BITMAPINFO
*info
, UINT usage
)
356 static BOOL CDECL
nulldrv_DeleteBitmap( HBITMAP bitmap
)
361 static BOOL CDECL
nulldrv_DeleteDC( PHYSDEV dev
)
363 assert(0); /* should never be called */
367 static BOOL CDECL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
372 static INT CDECL
nulldrv_DescribePixelFormat( PHYSDEV dev
, INT format
,
373 UINT size
, PIXELFORMATDESCRIPTOR
* descr
)
378 static DWORD CDECL
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
379 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
384 static BOOL CDECL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
389 static INT CDECL
nulldrv_EndDoc( PHYSDEV dev
)
394 static INT CDECL
nulldrv_EndPage( PHYSDEV dev
)
399 static BOOL CDECL
nulldrv_EnumDeviceFonts( PHYSDEV dev
, LOGFONTW
*logfont
,
400 FONTENUMPROCW proc
, LPARAM lParam
)
405 static INT CDECL
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
410 static INT CDECL
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
411 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
416 static INT CDECL
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
417 INT out_size
, void *out_data
)
422 static BOOL CDECL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
427 static BOOL CDECL
nulldrv_ExtTextOut( PHYSDEV dev
, INT x
, INT y
, UINT flags
, const RECT
*rect
,
428 LPCWSTR str
, UINT count
, const INT
*dx
)
433 static BOOL CDECL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
438 static BOOL CDECL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
443 static BOOL CDECL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
448 static BOOL CDECL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
453 static COLORREF CDECL
nulldrv_GetPixel( PHYSDEV dev
, INT x
, INT y
)
458 static INT CDECL
nulldrv_GetPixelFormat( PHYSDEV dev
)
463 static UINT CDECL
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
,
464 UINT count
, PALETTEENTRY
*entries
)
469 static BOOL CDECL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT max_ext
,
470 INT
*fit
, INT
*dx
, SIZE
*size
)
475 static BOOL CDECL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
480 static BOOL CDECL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
485 static BOOL CDECL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
490 static BOOL CDECL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
495 static BOOL CDECL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
496 INT xstart
, INT ystart
, INT xend
, INT yend
)
501 static BOOL CDECL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
503 /* FIXME: could be implemented with Polygon */
507 static BOOL CDECL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
509 /* FIXME: could be implemented with Polyline */
513 static BOOL CDECL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
518 static BOOL CDECL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
523 static UINT CDECL
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
528 static UINT CDECL
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
533 static BOOL CDECL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
538 static HDC CDECL
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
543 static BOOL CDECL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
544 INT ell_width
, INT ell_height
)
549 static HBITMAP CDECL
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
554 static HBRUSH CDECL
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
)
559 static HFONT CDECL
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
, HANDLE gdi_font
)
564 static HPALETTE CDECL
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
569 static HPEN CDECL
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
)
574 static INT CDECL
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
579 static COLORREF CDECL
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
584 static INT CDECL
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
589 static COLORREF CDECL
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
594 static COLORREF CDECL
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
599 static UINT CDECL
nulldrv_SetDIBColorTable( PHYSDEV dev
, UINT pos
, UINT count
, const RGBQUAD
*colors
)
604 static INT CDECL
nulldrv_SetDIBitsToDevice( PHYSDEV dev
, INT x_dst
, INT y_dst
, DWORD width
, DWORD height
,
605 INT x_src
, INT y_src
, UINT start
, UINT lines
,
606 const void *bits
, const BITMAPINFO
*info
, UINT coloruse
)
611 static void CDECL
nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN vis_rgn
, HRGN clip_rgn
)
615 static DWORD CDECL
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
620 static BOOL CDECL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
625 static DWORD CDECL
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
630 static COLORREF CDECL
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
635 static BOOL CDECL
nulldrv_SetPixelFormat( PHYSDEV dev
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
640 static INT CDECL
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
645 static INT CDECL
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
650 static INT CDECL
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
655 static INT CDECL
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
660 static UINT CDECL
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
665 static INT CDECL
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
670 static COLORREF CDECL
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
675 static BOOL CDECL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
680 static INT CDECL
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
685 static INT CDECL
nulldrv_StartPage( PHYSDEV dev
)
690 static BOOL CDECL
nulldrv_SwapBuffers( PHYSDEV dev
)
695 static BOOL CDECL
nulldrv_wglCopyContext( HGLRC ctx_src
, HGLRC ctx_dst
, UINT mask
)
700 static HGLRC CDECL
nulldrv_wglCreateContext( PHYSDEV dev
)
705 static HGLRC CDECL
nulldrv_wglCreateContextAttribsARB( PHYSDEV dev
, HGLRC share_ctx
, const int *attribs
)
710 static BOOL CDECL
nulldrv_wglDeleteContext( HGLRC ctx
)
715 static PROC CDECL
nulldrv_wglGetProcAddress( LPCSTR name
)
720 static HDC CDECL
nulldrv_wglGetPbufferDCARB( PHYSDEV dev
, void *pbuffer
)
725 static BOOL CDECL
nulldrv_wglMakeCurrent( PHYSDEV dev
, HGLRC ctx
)
730 static BOOL CDECL
nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw
, PHYSDEV dev_read
, HGLRC ctx
)
735 static BOOL CDECL
nulldrv_wglSetPixelFormatWINE( PHYSDEV dev
, INT format
,
736 const PIXELFORMATDESCRIPTOR
*descr
)
741 static BOOL CDECL
nulldrv_wglShareLists( HGLRC ctx1
, HGLRC ctx2
)
746 static BOOL CDECL
nulldrv_wglUseFontBitmapsA( PHYSDEV dev
, DWORD start
, DWORD count
, DWORD base
)
751 static BOOL CDECL
nulldrv_wglUseFontBitmapsW( PHYSDEV dev
, DWORD start
, DWORD count
, DWORD base
)
756 const DC_FUNCTIONS null_driver
=
758 nulldrv_AbortDoc
, /* pAbortDoc */
759 nulldrv_AbortPath
, /* pAbortPath */
760 NULL
, /* pAlphaBlend */
761 nulldrv_AngleArc
, /* pAngleArc */
762 nulldrv_Arc
, /* pArc */
763 nulldrv_ArcTo
, /* pArcTo */
764 nulldrv_BeginPath
, /* pBeginPath */
766 nulldrv_ChoosePixelFormat
, /* pChoosePixelFormat */
767 nulldrv_Chord
, /* pChord */
768 nulldrv_CloseFigure
, /* pCloseFigure */
769 nulldrv_CreateBitmap
, /* pCreateBitmap */
770 nulldrv_CreateDC
, /* pCreateDC */
771 nulldrv_CreateDIBSection
, /* pCreateDIBSection */
772 nulldrv_DeleteBitmap
, /* pDeleteBitmap */
773 nulldrv_DeleteDC
, /* pDeleteDC */
774 nulldrv_DeleteObject
, /* pDeleteObject */
775 nulldrv_DescribePixelFormat
, /* pDescribePixelFormat */
776 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
777 nulldrv_Ellipse
, /* pEllipse */
778 nulldrv_EndDoc
, /* pEndDoc */
779 nulldrv_EndPage
, /* pEndPage */
780 nulldrv_EndPath
, /* pEndPath */
781 nulldrv_EnumDeviceFonts
, /* pEnumDeviceFonts */
782 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
783 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
784 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
785 nulldrv_ExtEscape
, /* pExtEscape */
786 nulldrv_ExtFloodFill
, /* pExtFloodFill */
787 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
788 nulldrv_ExtTextOut
, /* pExtTextOut */
789 nulldrv_FillPath
, /* pFillPath */
790 nulldrv_FillRgn
, /* pFillRgn */
791 nulldrv_FlattenPath
, /* pFlattenPath */
792 nulldrv_FrameRgn
, /* pFrameRgn */
793 nulldrv_GdiComment
, /* pGdiComment */
794 nulldrv_GetBitmapBits
, /* pGetBitmapBits */
795 nulldrv_GetCharWidth
, /* pGetCharWidth */
796 nulldrv_GetDIBits
, /* pGetDIBits */
797 NULL
, /* pGetDeviceCaps */
798 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
799 nulldrv_GetICMProfile
, /* pGetICMProfile */
800 nulldrv_GetNearestColor
, /* pGetNearestColor */
801 nulldrv_GetPixel
, /* pGetPixel */
802 nulldrv_GetPixelFormat
, /* pGetPixelFormat */
803 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
804 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
805 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
806 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
807 nulldrv_InvertRgn
, /* pInvertRgn */
808 nulldrv_LineTo
, /* pLineTo */
809 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
810 nulldrv_MoveTo
, /* pMoveTo */
811 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
812 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
813 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
814 nulldrv_PaintRgn
, /* pPaintRgn */
816 nulldrv_Pie
, /* pPie */
817 nulldrv_PolyBezier
, /* pPolyBezier */
818 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
819 nulldrv_PolyDraw
, /* pPolyDraw */
820 nulldrv_PolyPolygon
, /* pPolyPolygon */
821 nulldrv_PolyPolyline
, /* pPolyPolyline */
822 nulldrv_Polygon
, /* pPolygon */
823 nulldrv_Polyline
, /* pPolyline */
824 nulldrv_PolylineTo
, /* pPolylineTo */
825 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
826 nulldrv_RealizePalette
, /* pRealizePalette */
827 nulldrv_Rectangle
, /* pRectangle */
828 nulldrv_ResetDC
, /* pResetDC */
829 nulldrv_RestoreDC
, /* pRestoreDC */
830 nulldrv_RoundRect
, /* pRoundRect */
831 nulldrv_SaveDC
, /* pSaveDC */
832 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
833 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
834 nulldrv_SelectBitmap
, /* pSelectBitmap */
835 nulldrv_SelectBrush
, /* pSelectBrush */
836 nulldrv_SelectClipPath
, /* pSelectClipPath */
837 nulldrv_SelectFont
, /* pSelectFont */
838 nulldrv_SelectPalette
, /* pSelectPalette */
839 nulldrv_SelectPen
, /* pSelectPen */
840 nulldrv_SetArcDirection
, /* pSetArcDirection */
841 nulldrv_SetBitmapBits
, /* pSetBitmapBits */
842 nulldrv_SetBkColor
, /* pSetBkColor */
843 nulldrv_SetBkMode
, /* pSetBkMode */
844 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
845 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
846 nulldrv_SetDIBColorTable
, /* pSetDIBColorTable */
847 nulldrv_SetDIBits
, /* pSetDIBits */
848 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
849 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
850 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
851 nulldrv_SetLayout
, /* pSetLayout */
852 nulldrv_SetMapMode
, /* pSetMapMode */
853 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
854 nulldrv_SetPixel
, /* pSetPixel */
855 nulldrv_SetPixelFormat
, /* pSetPixelFormat */
856 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
857 nulldrv_SetROP2
, /* pSetROP2 */
858 nulldrv_SetRelAbs
, /* pSetRelAbs */
859 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
860 nulldrv_SetTextAlign
, /* pSetTextAlign */
861 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
862 nulldrv_SetTextColor
, /* pSetTextColor */
863 nulldrv_SetTextJustification
, /* pSetTextJustification */
864 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
865 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
866 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
867 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
868 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
869 nulldrv_StartDoc
, /* pStartDoc */
870 nulldrv_StartPage
, /* pStartPage */
871 NULL
, /* pStretchBlt */
872 NULL
, /* pStretchDIBits */
873 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
874 nulldrv_StrokePath
, /* pStrokePath */
875 nulldrv_SwapBuffers
, /* pSwapBuffers */
876 NULL
, /* pUnrealizePalette */
877 nulldrv_WidenPath
, /* pWidenPath */
878 nulldrv_wglCopyContext
, /* pwglCopyContext */
879 nulldrv_wglCreateContext
, /* pwglCreateContext */
880 nulldrv_wglCreateContextAttribsARB
, /* pwglCreateContextAttribsARB */
881 nulldrv_wglDeleteContext
, /* pwglDeleteContext */
882 nulldrv_wglGetProcAddress
, /* pwglGetProcAddress */
883 nulldrv_wglGetPbufferDCARB
, /* pwglGetPbufferDCARB */
884 nulldrv_wglMakeCurrent
, /* pwglMakeCurrent */
885 nulldrv_wglMakeContextCurrentARB
, /* pwglMakeContextCurrentARB */
886 nulldrv_wglSetPixelFormatWINE
, /* pwglSetPixelFormatWINE */
887 nulldrv_wglShareLists
, /* pwglShareLists */
888 nulldrv_wglUseFontBitmapsA
, /* pwglUseFontBitmapsA */
889 nulldrv_wglUseFontBitmapsW
, /* pwglUseFontBitmapsW */
893 /*****************************************************************************
894 * DRIVER_GetDriverName
897 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
899 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
900 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
901 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
902 static const WCHAR empty_strW
[] = { 0 };
905 /* display is a special case */
906 if (!strcmpiW( device
, displayW
) ||
907 !strcmpiW( device
, display1W
))
909 lstrcpynW( driver
, displayW
, size
);
913 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
915 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
918 p
= strchrW(driver
, ',');
921 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
925 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
930 /***********************************************************************
931 * GdiConvertToDevmodeW (GDI32.@)
933 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
936 WORD dmW_size
, dmA_size
;
938 dmA_size
= dmA
->dmSize
;
940 /* this is the minimal dmSize that XP accepts */
941 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
944 if (dmA_size
> sizeof(DEVMODEA
))
945 dmA_size
= sizeof(DEVMODEA
);
947 dmW_size
= dmA_size
+ CCHDEVICENAME
;
948 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
949 dmW_size
+= CCHFORMNAME
;
951 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
952 if (!dmW
) return NULL
;
954 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
955 dmW
->dmDeviceName
, CCHDEVICENAME
);
956 /* copy slightly more, to avoid long computations */
957 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
959 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
961 if (dmA
->dmFields
& DM_FORMNAME
)
962 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
963 dmW
->dmFormName
, CCHFORMNAME
);
965 dmW
->dmFormName
[0] = 0;
967 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
968 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
971 if (dmA
->dmDriverExtra
)
972 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
974 dmW
->dmSize
= dmW_size
;
980 /*****************************************************************************
983 * This should thunk to 16-bit and simply call the proc with the given args.
985 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
986 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
988 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
992 /*****************************************************************************
995 * This should load the correct driver for lpszDevice and calls this driver's
996 * ExtDeviceModePropSheet proc.
998 * Note: The driver calls a callback routine for each property sheet page; these
999 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1000 * The layout of this structure is:
1006 * HPROPSHEETPAGE pages[10];
1009 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
1010 LPCSTR lpszPort
, LPVOID lpPropSheet
)
1012 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
1016 /*****************************************************************************
1019 * This should load the correct driver for lpszDevice and call this driver's
1020 * ExtDeviceMode proc.
1022 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1024 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
1025 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
1026 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
1027 LPSTR lpszProfile
, DWORD fwMode
)
1036 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1037 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
1039 if (!lpszDevice
) return -1;
1040 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1042 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1044 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1046 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1048 if ((dc
= get_dc_ptr( hdc
)))
1050 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
1051 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1052 lpdmInput
, lpszProfile
, fwMode
);
1053 release_dc_ptr( dc
);
1059 /****************************************************************************
1062 * This should load the correct driver for lpszDevice and calls this driver's
1063 * AdvancedSetupDialog proc.
1065 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1066 LPDEVMODEA devin
, LPDEVMODEA devout
)
1068 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1072 /*****************************************************************************
1075 * This should load the correct driver for lpszDevice and calls this driver's
1076 * DeviceCapabilities proc.
1078 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1080 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1081 WORD fwCapability
, LPSTR lpszOutput
,
1091 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1093 if (!lpszDevice
) return -1;
1094 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1096 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1098 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1100 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1102 if ((dc
= get_dc_ptr( hdc
)))
1104 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1105 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1106 fwCapability
, lpszOutput
, lpdm
);
1107 release_dc_ptr( dc
);
1114 /************************************************************************
1117 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1125 return AbortDoc( hdc
);
1128 return EndDoc( hdc
);
1130 case GETPHYSPAGESIZE
:
1132 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1133 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1136 case GETPRINTINGOFFSET
:
1138 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1139 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1142 case GETSCALINGFACTOR
:
1144 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1145 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1149 return EndPage( hdc
);
1152 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1159 /* in_data may not be 0 terminated so we must copy it */
1162 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1163 memcpy( name
, in_data
, in_count
);
1166 /* out_data is actually a pointer to the DocInfo structure and used as
1167 * a second input parameter */
1168 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1171 doc
.cbSize
= sizeof(doc
);
1172 doc
.lpszOutput
= NULL
;
1173 doc
.lpszDatatype
= NULL
;
1176 doc
.lpszDocName
= name
;
1177 ret
= StartDocA( hdc
, &doc
);
1178 HeapFree( GetProcessHeap(), 0, name
);
1179 if (ret
> 0) ret
= StartPage( hdc
);
1183 case QUERYESCSUPPORT
:
1185 const INT
*ptr
= (const INT
*)in_data
;
1186 if (in_count
< sizeof(INT
)) return 0;
1191 case GETPHYSPAGESIZE
:
1192 case GETPRINTINGOFFSET
:
1193 case GETSCALINGFACTOR
:
1195 case QUERYESCSUPPORT
:
1204 /* if not handled internally, pass it to the driver */
1205 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1209 /******************************************************************************
1210 * ExtEscape [GDI32.@]
1212 * Access capabilities of a particular device that are not available through GDI.
1215 * hdc [I] Handle to device context
1216 * nEscape [I] Escape function
1217 * cbInput [I] Number of bytes in input structure
1218 * lpszInData [I] Pointer to input structure
1219 * cbOutput [I] Number of bytes in output structure
1220 * lpszOutData [O] Pointer to output structure
1224 * Not implemented: 0
1227 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1228 INT cbOutput
, LPSTR lpszOutData
)
1231 DC
* dc
= get_dc_ptr( hdc
);
1235 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1236 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1237 release_dc_ptr( dc
);
1243 /*******************************************************************
1244 * DrawEscape [GDI32.@]
1248 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1250 FIXME("DrawEscape, stub\n");
1254 /*******************************************************************
1255 * NamedEscape [GDI32.@]
1257 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1258 INT cbOutput
, LPSTR lpszOutData
)
1260 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1261 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1266 /*******************************************************************
1267 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1268 * GdiEntry13 [GDI32.@]
1270 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1272 static int warn_once
;