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"
30 #define WIN32_NO_STATUS
35 #include "wine/winbase16.h"
38 #include "ddk/d3dkmthk.h"
40 #include "gdi_private.h"
41 #include "wine/unicode.h"
42 #include "wine/list.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(driver
);
47 struct graphics_driver
50 HMODULE module
; /* module handle */
51 const struct gdi_dc_funcs
*funcs
;
54 static struct list drivers
= LIST_INIT( drivers
);
55 static struct graphics_driver
*display_driver
;
57 const struct gdi_dc_funcs
*font_driver
= NULL
;
59 static CRITICAL_SECTION driver_section
;
60 static CRITICAL_SECTION_DEBUG critsect_debug
=
62 0, 0, &driver_section
,
63 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
64 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
66 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
68 static HWND (WINAPI
*pGetDesktopWindow
)(void);
69 static INT (WINAPI
*pGetSystemMetrics
)(INT
);
70 static DPI_AWARENESS_CONTEXT (WINAPI
*pSetThreadDpiAwarenessContext
)(DPI_AWARENESS_CONTEXT
);
72 /**********************************************************************
75 * Allocate and fill the driver structure for a given module.
77 static struct graphics_driver
*create_driver( HMODULE module
)
79 static const struct gdi_dc_funcs empty_funcs
;
80 const struct gdi_dc_funcs
*funcs
= NULL
;
81 struct graphics_driver
*driver
;
83 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
84 driver
->module
= module
;
88 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
90 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
91 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
93 if (!funcs
) funcs
= &empty_funcs
;
94 driver
->funcs
= funcs
;
99 /**********************************************************************
102 * Special case for loading the display driver: get the name from the config file
104 static const struct gdi_dc_funcs
*get_display_driver(void)
108 HMODULE user32
= LoadLibraryA( "user32.dll" );
109 pGetDesktopWindow
= (void *)GetProcAddress( user32
, "GetDesktopWindow" );
111 if (!pGetDesktopWindow() || !display_driver
)
113 WARN( "failed to load the display driver, falling back to null driver\n" );
114 __wine_set_display_driver( 0 );
117 return display_driver
->funcs
;
121 /**********************************************************************
124 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
127 struct graphics_driver
*driver
, *new_driver
;
128 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
129 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
131 /* display driver is a special case */
132 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
)) return get_display_driver();
134 if ((module
= GetModuleHandleW( name
)))
136 if (display_driver
&& display_driver
->module
== module
) return display_driver
->funcs
;
138 EnterCriticalSection( &driver_section
);
139 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
141 if (driver
->module
== module
) goto done
;
143 LeaveCriticalSection( &driver_section
);
146 if (!(module
= LoadLibraryW( name
))) return NULL
;
148 if (!(new_driver
= create_driver( module
)))
150 FreeLibrary( module
);
154 /* check if someone else added it in the meantime */
155 EnterCriticalSection( &driver_section
);
156 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
158 if (driver
->module
!= module
) continue;
159 FreeLibrary( module
);
160 HeapFree( GetProcessHeap(), 0, new_driver
);
164 list_add_head( &drivers
, &driver
->entry
);
165 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
167 LeaveCriticalSection( &driver_section
);
168 return driver
->funcs
;
172 /***********************************************************************
173 * __wine_set_display_driver (GDI32.@)
175 void CDECL
__wine_set_display_driver( HMODULE module
)
177 struct graphics_driver
*driver
;
180 if (!(driver
= create_driver( module
)))
182 ERR( "Could not create graphics driver\n" );
185 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
186 HeapFree( GetProcessHeap(), 0, driver
);
188 user32
= LoadLibraryA( "user32.dll" );
189 pGetSystemMetrics
= (void *)GetProcAddress( user32
, "GetSystemMetrics" );
190 pSetThreadDpiAwarenessContext
= (void *)GetProcAddress( user32
, "SetThreadDpiAwarenessContext" );
194 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
199 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
200 INT xstart
, INT ystart
, INT xend
, INT yend
)
205 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
206 INT xstart
, INT ystart
, INT xend
, INT yend
)
211 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
213 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
214 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
217 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
218 LPCWSTR output
, const DEVMODEW
*devmode
)
220 assert(0); /* should never be called */
224 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
226 assert(0); /* should never be called */
230 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
235 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
236 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
241 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
246 static INT
nulldrv_EndDoc( PHYSDEV dev
)
251 static INT
nulldrv_EndPage( PHYSDEV dev
)
256 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
261 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
266 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
267 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
272 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
273 INT out_size
, void *out_data
)
278 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
283 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
288 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
293 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
298 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
303 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
308 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
313 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
319 case DRIVERVERSION
: return 0x4000;
320 case TECHNOLOGY
: return DT_RASDISPLAY
;
321 case HORZSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, HORZRES
), 254,
322 GetDeviceCaps( dev
->hdc
, LOGPIXELSX
) * 10 );
323 case VERTSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, VERTRES
), 254,
324 GetDeviceCaps( dev
->hdc
, LOGPIXELSY
) * 10 );
325 case HORZRES
: return pGetSystemMetrics
? pGetSystemMetrics( SM_CXSCREEN
) : 640;
326 case VERTRES
: return pGetSystemMetrics
? pGetSystemMetrics( SM_CYSCREEN
) : 480;
327 case BITSPIXEL
: return 32;
328 case PLANES
: return 1;
329 case NUMBRUSHES
: return -1;
330 case NUMPENS
: return -1;
331 case NUMMARKERS
: return 0;
332 case NUMFONTS
: return 0;
333 case PDEVICESIZE
: return 0;
334 case CURVECAPS
: return (CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
| CC_WIDE
|
335 CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
);
336 case LINECAPS
: return (LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
337 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
);
338 case POLYGONALCAPS
: return (PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
| PC_SCANLINE
|
339 PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
);
340 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
341 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
342 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
343 case CLIPCAPS
: return CP_RECTANGLE
;
344 case RASTERCAPS
: return (RC_BITBLT
| RC_BITMAP64
| RC_GDI20_OUTPUT
| RC_DI_BITMAP
| RC_DIBTODEV
|
345 RC_BIGFONT
| RC_STRETCHBLT
| RC_FLOODFILL
| RC_STRETCHDIB
| RC_DEVBITS
|
346 (GetDeviceCaps( dev
->hdc
, SIZEPALETTE
) ? RC_PALETTE
: 0));
347 case ASPECTX
: return 36;
348 case ASPECTY
: return 36;
349 case ASPECTXY
: return (int)(hypot( GetDeviceCaps( dev
->hdc
, ASPECTX
),
350 GetDeviceCaps( dev
->hdc
, ASPECTY
)) + 0.5);
351 case CAPS1
: return 0;
352 case SIZEPALETTE
: return 0;
353 case NUMRESERVED
: return 20;
354 case PHYSICALWIDTH
: return 0;
355 case PHYSICALHEIGHT
: return 0;
356 case PHYSICALOFFSETX
: return 0;
357 case PHYSICALOFFSETY
: return 0;
358 case SCALINGFACTORX
: return 0;
359 case SCALINGFACTORY
: return 0;
360 case VREFRESH
: return GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
? 1 : 0;
362 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
364 DPI_AWARENESS_CONTEXT context
;
366 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
367 ret
= pGetSystemMetrics( SM_CXVIRTUALSCREEN
);
368 pSetThreadDpiAwarenessContext( context
);
371 return GetDeviceCaps( dev
->hdc
, HORZRES
);
373 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
375 DPI_AWARENESS_CONTEXT context
;
377 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
378 ret
= pGetSystemMetrics( SM_CYVIRTUALSCREEN
);
379 pSetThreadDpiAwarenessContext( context
);
382 return GetDeviceCaps( dev
->hdc
, VERTRES
);
383 case BLTALIGNMENT
: return 0;
384 case SHADEBLENDCAPS
: return 0;
385 case COLORMGMTCAPS
: return 0;
387 case LOGPIXELSY
: return get_system_dpi();
389 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
390 return (bpp
> 8) ? -1 : (1 << bpp
);
392 /* The observed correspondence between BITSPIXEL and COLORRES is:
393 * BITSPIXEL: 8 -> COLORRES: 18
394 * BITSPIXEL: 16 -> COLORRES: 16
395 * BITSPIXEL: 24 -> COLORRES: 24
396 * BITSPIXEL: 32 -> COLORRES: 24 */
397 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
398 return (bpp
<= 8) ? 18 : min( 24, bpp
);
400 FIXME("(%p): unsupported capability %d, will return 0\n", dev
->hdc
, cap
);
405 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
407 SetLastError( ERROR_INVALID_PARAMETER
);
411 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
416 static BOOL
nulldrv_GetFontRealizationInfo( PHYSDEV dev
, void *info
)
421 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
426 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
431 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
432 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
437 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
442 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
443 struct bitblt_coords
*src
)
445 return ERROR_NOT_SUPPORTED
;
448 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
453 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
458 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
460 return DEFAULT_CHARSET
;
463 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
468 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
473 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
477 DC
*dc
= get_nulldrv_dc( dev
);
479 if (GetObjectW( dc
->hFont
, sizeof(font
), &font
))
481 ret
= strlenW( font
.lfFaceName
) + 1;
484 lstrcpynW( name
, font
.lfFaceName
, size
);
485 ret
= min( size
, ret
);
491 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
496 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
501 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
506 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
511 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
516 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
517 INT xstart
, INT ystart
, INT xend
, INT yend
)
522 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
527 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
532 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
534 INT counts
[1] = { count
};
536 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
539 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
541 DWORD counts
[1] = { count
};
543 if (count
< 0) return FALSE
;
544 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
547 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
548 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
549 struct bitblt_coords
*dst
, DWORD rop
)
551 return ERROR_SUCCESS
;
554 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
559 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
564 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
569 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
574 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
575 INT ell_width
, INT ell_height
)
580 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
585 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
590 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
595 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
600 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
605 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
610 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
615 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
620 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
625 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
630 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
634 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
639 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
641 SetLastError( ERROR_INVALID_PARAMETER
);
645 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
650 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
655 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
660 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
665 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
670 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
675 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
680 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
685 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
690 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
695 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
700 static INT
nulldrv_StartPage( PHYSDEV dev
)
705 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
710 static struct opengl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
715 static const struct vulkan_funcs
*nulldrv_wine_get_vulkan_driver( PHYSDEV dev
, UINT version
)
720 const struct gdi_dc_funcs null_driver
=
722 nulldrv_AbortDoc
, /* pAbortDoc */
723 nulldrv_AbortPath
, /* pAbortPath */
724 nulldrv_AlphaBlend
, /* pAlphaBlend */
725 nulldrv_AngleArc
, /* pAngleArc */
726 nulldrv_Arc
, /* pArc */
727 nulldrv_ArcTo
, /* pArcTo */
728 nulldrv_BeginPath
, /* pBeginPath */
729 nulldrv_BlendImage
, /* pBlendImage */
730 nulldrv_Chord
, /* pChord */
731 nulldrv_CloseFigure
, /* pCloseFigure */
732 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
733 nulldrv_CreateDC
, /* pCreateDC */
734 nulldrv_DeleteDC
, /* pDeleteDC */
735 nulldrv_DeleteObject
, /* pDeleteObject */
736 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
737 nulldrv_Ellipse
, /* pEllipse */
738 nulldrv_EndDoc
, /* pEndDoc */
739 nulldrv_EndPage
, /* pEndPage */
740 nulldrv_EndPath
, /* pEndPath */
741 nulldrv_EnumFonts
, /* pEnumFonts */
742 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
743 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
744 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
745 nulldrv_ExtEscape
, /* pExtEscape */
746 nulldrv_ExtFloodFill
, /* pExtFloodFill */
747 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
748 nulldrv_ExtTextOut
, /* pExtTextOut */
749 nulldrv_FillPath
, /* pFillPath */
750 nulldrv_FillRgn
, /* pFillRgn */
751 nulldrv_FlattenPath
, /* pFlattenPath */
752 nulldrv_FontIsLinked
, /* pFontIsLinked */
753 nulldrv_FrameRgn
, /* pFrameRgn */
754 nulldrv_GdiComment
, /* pGdiComment */
755 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
756 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
757 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
758 nulldrv_GetCharWidth
, /* pGetCharWidth */
759 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
760 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
761 nulldrv_GetFontData
, /* pGetFontData */
762 nulldrv_GetFontRealizationInfo
, /* pGetFontRealizationInfo */
763 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
764 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
765 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
766 nulldrv_GetICMProfile
, /* pGetICMProfile */
767 nulldrv_GetImage
, /* pGetImage */
768 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
769 nulldrv_GetNearestColor
, /* pGetNearestColor */
770 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
771 nulldrv_GetPixel
, /* pGetPixel */
772 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
773 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
774 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
775 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
776 nulldrv_GetTextFace
, /* pGetTextFace */
777 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
778 nulldrv_GradientFill
, /* pGradientFill */
779 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
780 nulldrv_InvertRgn
, /* pInvertRgn */
781 nulldrv_LineTo
, /* pLineTo */
782 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
783 nulldrv_MoveTo
, /* pMoveTo */
784 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
785 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
786 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
787 nulldrv_PaintRgn
, /* pPaintRgn */
788 nulldrv_PatBlt
, /* pPatBlt */
789 nulldrv_Pie
, /* pPie */
790 nulldrv_PolyBezier
, /* pPolyBezier */
791 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
792 nulldrv_PolyDraw
, /* pPolyDraw */
793 nulldrv_PolyPolygon
, /* pPolyPolygon */
794 nulldrv_PolyPolyline
, /* pPolyPolyline */
795 nulldrv_Polygon
, /* pPolygon */
796 nulldrv_Polyline
, /* pPolyline */
797 nulldrv_PolylineTo
, /* pPolylineTo */
798 nulldrv_PutImage
, /* pPutImage */
799 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
800 nulldrv_RealizePalette
, /* pRealizePalette */
801 nulldrv_Rectangle
, /* pRectangle */
802 nulldrv_ResetDC
, /* pResetDC */
803 nulldrv_RestoreDC
, /* pRestoreDC */
804 nulldrv_RoundRect
, /* pRoundRect */
805 nulldrv_SaveDC
, /* pSaveDC */
806 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
807 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
808 nulldrv_SelectBitmap
, /* pSelectBitmap */
809 nulldrv_SelectBrush
, /* pSelectBrush */
810 nulldrv_SelectClipPath
, /* pSelectClipPath */
811 nulldrv_SelectFont
, /* pSelectFont */
812 nulldrv_SelectPalette
, /* pSelectPalette */
813 nulldrv_SelectPen
, /* pSelectPen */
814 nulldrv_SetArcDirection
, /* pSetArcDirection */
815 nulldrv_SetBkColor
, /* pSetBkColor */
816 nulldrv_SetBkMode
, /* pSetBkMode */
817 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
818 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
819 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
820 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
821 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
822 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
823 nulldrv_SetLayout
, /* pSetLayout */
824 nulldrv_SetMapMode
, /* pSetMapMode */
825 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
826 nulldrv_SetPixel
, /* pSetPixel */
827 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
828 nulldrv_SetROP2
, /* pSetROP2 */
829 nulldrv_SetRelAbs
, /* pSetRelAbs */
830 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
831 nulldrv_SetTextAlign
, /* pSetTextAlign */
832 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
833 nulldrv_SetTextColor
, /* pSetTextColor */
834 nulldrv_SetTextJustification
, /* pSetTextJustification */
835 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
836 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
837 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
838 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
839 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
840 nulldrv_StartDoc
, /* pStartDoc */
841 nulldrv_StartPage
, /* pStartPage */
842 nulldrv_StretchBlt
, /* pStretchBlt */
843 nulldrv_StretchDIBits
, /* pStretchDIBits */
844 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
845 nulldrv_StrokePath
, /* pStrokePath */
846 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
847 nulldrv_WidenPath
, /* pWidenPath */
848 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
849 nulldrv_wine_get_vulkan_driver
, /* wine_get_vulkan_driver */
851 GDI_PRIORITY_NULL_DRV
/* priority */
855 /*****************************************************************************
856 * DRIVER_GetDriverName
859 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
861 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
862 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
863 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
864 static const WCHAR empty_strW
[] = { 0 };
867 /* display is a special case */
868 if (!strcmpiW( device
, displayW
) ||
869 !strcmpiW( device
, display1W
))
871 lstrcpynW( driver
, displayW
, size
);
875 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
877 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
880 p
= strchrW(driver
, ',');
883 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
887 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
892 /***********************************************************************
893 * GdiConvertToDevmodeW (GDI32.@)
895 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
898 WORD dmW_size
, dmA_size
;
900 dmA_size
= dmA
->dmSize
;
902 /* this is the minimal dmSize that XP accepts */
903 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
906 if (dmA_size
> sizeof(DEVMODEA
))
907 dmA_size
= sizeof(DEVMODEA
);
909 dmW_size
= dmA_size
+ CCHDEVICENAME
;
910 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
911 dmW_size
+= CCHFORMNAME
;
913 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
914 if (!dmW
) return NULL
;
916 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
917 dmW
->dmDeviceName
, CCHDEVICENAME
);
918 /* copy slightly more, to avoid long computations */
919 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
921 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
923 if (dmA
->dmFields
& DM_FORMNAME
)
924 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
925 dmW
->dmFormName
, CCHFORMNAME
);
927 dmW
->dmFormName
[0] = 0;
929 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
930 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
933 if (dmA
->dmDriverExtra
)
934 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
936 dmW
->dmSize
= dmW_size
;
942 /*****************************************************************************
945 * This should thunk to 16-bit and simply call the proc with the given args.
947 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
948 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
950 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
954 /*****************************************************************************
957 * This should load the correct driver for lpszDevice and calls this driver's
958 * ExtDeviceModePropSheet proc.
960 * Note: The driver calls a callback routine for each property sheet page; these
961 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
962 * The layout of this structure is:
968 * HPROPSHEETPAGE pages[10];
971 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
972 LPCSTR lpszPort
, LPVOID lpPropSheet
)
974 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
978 /*****************************************************************************
981 * This should load the correct driver for lpszDevice and call this driver's
982 * ExtDeviceMode proc.
984 * FIXME: convert ExtDeviceMode to unicode in the driver interface
986 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
987 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
988 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
989 LPSTR lpszProfile
, DWORD fwMode
)
998 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
999 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
1001 if (!lpszDevice
) return -1;
1002 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1004 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1006 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1008 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1010 if ((dc
= get_dc_ptr( hdc
)))
1012 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
1013 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1014 lpdmInput
, lpszProfile
, fwMode
);
1015 release_dc_ptr( dc
);
1021 /****************************************************************************
1024 * This should load the correct driver for lpszDevice and calls this driver's
1025 * AdvancedSetupDialog proc.
1027 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1028 LPDEVMODEA devin
, LPDEVMODEA devout
)
1030 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1034 /*****************************************************************************
1037 * This should load the correct driver for lpszDevice and calls this driver's
1038 * DeviceCapabilities proc.
1040 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1042 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1043 WORD fwCapability
, LPSTR lpszOutput
,
1053 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1055 if (!lpszDevice
) return -1;
1056 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1058 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1060 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1062 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1064 if ((dc
= get_dc_ptr( hdc
)))
1066 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1067 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1068 fwCapability
, lpszOutput
, lpdm
);
1069 release_dc_ptr( dc
);
1076 /************************************************************************
1079 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1087 return AbortDoc( hdc
);
1090 return EndDoc( hdc
);
1092 case GETPHYSPAGESIZE
:
1094 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1095 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1098 case GETPRINTINGOFFSET
:
1100 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1101 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1104 case GETSCALINGFACTOR
:
1106 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1107 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1111 return EndPage( hdc
);
1114 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1121 /* in_data may not be 0 terminated so we must copy it */
1124 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1125 memcpy( name
, in_data
, in_count
);
1128 /* out_data is actually a pointer to the DocInfo structure and used as
1129 * a second input parameter */
1130 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1133 doc
.cbSize
= sizeof(doc
);
1134 doc
.lpszOutput
= NULL
;
1135 doc
.lpszDatatype
= NULL
;
1138 doc
.lpszDocName
= name
;
1139 ret
= StartDocA( hdc
, &doc
);
1140 HeapFree( GetProcessHeap(), 0, name
);
1141 if (ret
> 0) ret
= StartPage( hdc
);
1145 case QUERYESCSUPPORT
:
1149 if (in_count
< sizeof(SHORT
)) return 0;
1150 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1155 case GETPHYSPAGESIZE
:
1156 case GETPRINTINGOFFSET
:
1157 case GETSCALINGFACTOR
:
1159 case QUERYESCSUPPORT
:
1168 /* if not handled internally, pass it to the driver */
1169 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1173 /******************************************************************************
1174 * ExtEscape [GDI32.@]
1176 * Access capabilities of a particular device that are not available through GDI.
1179 * hdc [I] Handle to device context
1180 * nEscape [I] Escape function
1181 * cbInput [I] Number of bytes in input structure
1182 * lpszInData [I] Pointer to input structure
1183 * cbOutput [I] Number of bytes in output structure
1184 * lpszOutData [O] Pointer to output structure
1188 * Not implemented: 0
1191 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1192 INT cbOutput
, LPSTR lpszOutData
)
1196 DC
* dc
= get_dc_ptr( hdc
);
1200 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1201 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1202 release_dc_ptr( dc
);
1207 /*******************************************************************
1208 * DrawEscape [GDI32.@]
1212 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1214 FIXME("DrawEscape, stub\n");
1218 /*******************************************************************
1219 * NamedEscape [GDI32.@]
1221 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1222 INT cbOutput
, LPSTR lpszOutData
)
1224 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1225 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1230 /*******************************************************************
1231 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1232 * GdiEntry13 [GDI32.@]
1234 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1236 static int warn_once
;
1243 /******************************************************************************
1244 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1246 NTSTATUS WINAPI
D3DKMTOpenAdapterFromHdc( void *pData
)
1248 FIXME("(%p): stub\n", pData
);
1249 return STATUS_NO_MEMORY
;
1252 /******************************************************************************
1253 * D3DKMTEscape [GDI32.@]
1255 NTSTATUS WINAPI
D3DKMTEscape( const void *pData
)
1257 FIXME("(%p): stub\n", pData
);
1258 return STATUS_NO_MEMORY
;
1261 /******************************************************************************
1262 * D3DKMTCloseAdapter [GDI32.@]
1264 NTSTATUS WINAPI
D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER
*desc
)
1266 FIXME("(%p): stub\n", desc
);
1267 return STATUS_SUCCESS
;