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
27 #define WIN32_NO_STATUS
33 #include "wine/winbase16.h"
39 #include "ddk/d3dkmthk.h"
41 #include "gdi_private.h"
42 #include "wine/list.h"
43 #include "wine/debug.h"
44 #include "wine/heap.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(driver
);
48 DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID
, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
50 struct graphics_driver
53 HMODULE module
; /* module handle */
54 const struct gdi_dc_funcs
*funcs
;
59 D3DKMT_HANDLE handle
; /* Kernel mode graphics adapter handle */
60 struct list entry
; /* List entry */
65 D3DKMT_HANDLE handle
; /* Kernel mode graphics device handle*/
66 struct list entry
; /* List entry */
69 static struct list drivers
= LIST_INIT( drivers
);
70 static struct graphics_driver
*display_driver
;
72 static struct list d3dkmt_adapters
= LIST_INIT( d3dkmt_adapters
);
73 static struct list d3dkmt_devices
= LIST_INIT( d3dkmt_devices
);
75 static CRITICAL_SECTION driver_section
;
76 static CRITICAL_SECTION_DEBUG critsect_debug
=
78 0, 0, &driver_section
,
79 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
80 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
82 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
84 static BOOL (WINAPI
*pEnumDisplayMonitors
)(HDC
, LPRECT
, MONITORENUMPROC
, LPARAM
);
85 static BOOL (WINAPI
*pEnumDisplaySettingsW
)(LPCWSTR
, DWORD
, LPDEVMODEW
);
86 static HWND (WINAPI
*pGetDesktopWindow
)(void);
87 static BOOL (WINAPI
*pGetMonitorInfoW
)(HMONITOR
, LPMONITORINFO
);
88 static INT (WINAPI
*pGetSystemMetrics
)(INT
);
89 static DPI_AWARENESS_CONTEXT (WINAPI
*pSetThreadDpiAwarenessContext
)(DPI_AWARENESS_CONTEXT
);
91 /**********************************************************************
94 * Allocate and fill the driver structure for a given module.
96 static struct graphics_driver
*create_driver( HMODULE module
)
98 static const struct gdi_dc_funcs empty_funcs
;
99 const struct gdi_dc_funcs
*funcs
= NULL
;
100 struct graphics_driver
*driver
;
102 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
103 driver
->module
= module
;
107 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
109 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
110 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
112 if (!funcs
) funcs
= &empty_funcs
;
113 driver
->funcs
= funcs
;
118 /**********************************************************************
121 * Special case for loading the display driver: get the name from the config file
123 static const struct gdi_dc_funcs
*get_display_driver(void)
127 HMODULE user32
= LoadLibraryA( "user32.dll" );
128 pGetDesktopWindow
= (void *)GetProcAddress( user32
, "GetDesktopWindow" );
130 if (!pGetDesktopWindow() || !display_driver
)
132 WARN( "failed to load the display driver, falling back to null driver\n" );
133 __wine_set_display_driver( 0 );
136 return display_driver
->funcs
;
140 /**********************************************************************
143 BOOL
is_display_device( LPCWSTR name
)
145 const WCHAR
*p
= name
;
150 if (wcsnicmp( name
, L
"\\\\.\\DISPLAY", lstrlenW(L
"\\\\.\\DISPLAY") )) return FALSE
;
152 p
+= lstrlenW(L
"\\\\.\\DISPLAY");
154 if (!iswdigit( *p
++ ))
166 static HANDLE
get_display_device_init_mutex( void )
168 HANDLE mutex
= CreateMutexW( NULL
, FALSE
, L
"display_device_init" );
170 WaitForSingleObject( mutex
, INFINITE
);
174 static void release_display_device_init_mutex( HANDLE mutex
)
176 ReleaseMutex( mutex
);
177 CloseHandle( mutex
);
180 /**********************************************************************
183 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
186 struct graphics_driver
*driver
, *new_driver
;
188 /* display driver is a special case */
189 if (!wcsicmp( name
, L
"display" ) || is_display_device( name
)) return get_display_driver();
191 if ((module
= GetModuleHandleW( name
)))
193 if (display_driver
&& display_driver
->module
== module
) return display_driver
->funcs
;
195 EnterCriticalSection( &driver_section
);
196 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
198 if (driver
->module
== module
) goto done
;
200 LeaveCriticalSection( &driver_section
);
203 if (!(module
= LoadLibraryW( name
))) return NULL
;
205 if (!(new_driver
= create_driver( module
)))
207 FreeLibrary( module
);
211 /* check if someone else added it in the meantime */
212 EnterCriticalSection( &driver_section
);
213 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
215 if (driver
->module
!= module
) continue;
216 FreeLibrary( module
);
217 HeapFree( GetProcessHeap(), 0, new_driver
);
221 list_add_head( &drivers
, &driver
->entry
);
222 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
224 LeaveCriticalSection( &driver_section
);
225 return driver
->funcs
;
229 /***********************************************************************
230 * __wine_set_display_driver (GDI32.@)
232 void CDECL
__wine_set_display_driver( HMODULE module
)
234 struct graphics_driver
*driver
;
237 if (!(driver
= create_driver( module
)))
239 ERR( "Could not create graphics driver\n" );
242 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
243 HeapFree( GetProcessHeap(), 0, driver
);
245 user32
= LoadLibraryA( "user32.dll" );
246 pGetMonitorInfoW
= (void *)GetProcAddress( user32
, "GetMonitorInfoW" );
247 pGetSystemMetrics
= (void *)GetProcAddress( user32
, "GetSystemMetrics" );
248 pEnumDisplayMonitors
= (void *)GetProcAddress( user32
, "EnumDisplayMonitors" );
249 pEnumDisplaySettingsW
= (void *)GetProcAddress( user32
, "EnumDisplaySettingsW" );
250 pSetThreadDpiAwarenessContext
= (void *)GetProcAddress( user32
, "SetThreadDpiAwarenessContext" );
259 static BOOL CALLBACK
monitor_enum_proc( HMONITOR monitor
, HDC hdc
, LPRECT rect
, LPARAM lparam
)
261 struct monitor_info
*info
= (struct monitor_info
*)lparam
;
264 mi
.cbSize
= sizeof(mi
);
265 pGetMonitorInfoW( monitor
, (MONITORINFO
*)&mi
);
266 if (!lstrcmpiW( info
->name
, mi
.szDevice
))
268 info
->rect
= mi
.rcMonitor
;
275 static INT CDECL
nulldrv_AbortDoc( PHYSDEV dev
)
280 static BOOL CDECL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
281 INT xstart
, INT ystart
, INT xend
, INT yend
)
286 static BOOL CDECL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
287 INT xstart
, INT ystart
, INT xend
, INT yend
)
292 static BOOL CDECL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
294 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
295 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
298 static BOOL CDECL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
299 LPCWSTR output
, const DEVMODEW
*devmode
)
301 assert(0); /* should never be called */
305 static BOOL CDECL
nulldrv_DeleteDC( PHYSDEV dev
)
307 assert(0); /* should never be called */
311 static BOOL CDECL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
316 static DWORD CDECL
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
317 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
322 static BOOL CDECL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
327 static INT CDECL
nulldrv_EndDoc( PHYSDEV dev
)
332 static INT CDECL
nulldrv_EndPage( PHYSDEV dev
)
337 static BOOL CDECL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
342 static INT CDECL
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
347 static INT CDECL
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
348 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
353 static INT CDECL
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
354 INT out_size
, void *out_data
)
359 static BOOL CDECL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
364 static BOOL CDECL
nulldrv_FontIsLinked( PHYSDEV dev
)
369 static BOOL CDECL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
374 static UINT CDECL
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
379 static BOOL CDECL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
384 static BOOL CDECL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
389 static BOOL CDECL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
394 static BOOL CDECL
nulldrv_GetCharWidthInfo( PHYSDEV dev
, void *info
)
399 static INT CDECL
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
405 case DRIVERVERSION
: return 0x4000;
406 case TECHNOLOGY
: return DT_RASDISPLAY
;
407 case HORZSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, HORZRES
), 254,
408 GetDeviceCaps( dev
->hdc
, LOGPIXELSX
) * 10 );
409 case VERTSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, VERTRES
), 254,
410 GetDeviceCaps( dev
->hdc
, LOGPIXELSY
) * 10 );
413 DC
*dc
= get_nulldrv_dc( dev
);
414 struct monitor_info info
;
416 if (dc
->display
[0] && pEnumDisplayMonitors
&& pGetMonitorInfoW
)
418 info
.name
= dc
->display
;
419 SetRectEmpty( &info
.rect
);
420 pEnumDisplayMonitors( NULL
, NULL
, monitor_enum_proc
, (LPARAM
)&info
);
421 if (!IsRectEmpty( &info
.rect
))
422 return info
.rect
.right
- info
.rect
.left
;
425 return pGetSystemMetrics
? pGetSystemMetrics( SM_CXSCREEN
) : 640;
429 DC
*dc
= get_nulldrv_dc( dev
);
430 struct monitor_info info
;
432 if (dc
->display
[0] && pEnumDisplayMonitors
&& pGetMonitorInfoW
)
434 info
.name
= dc
->display
;
435 SetRectEmpty( &info
.rect
);
436 pEnumDisplayMonitors( NULL
, NULL
, monitor_enum_proc
, (LPARAM
)&info
);
437 if (!IsRectEmpty( &info
.rect
))
438 return info
.rect
.bottom
- info
.rect
.top
;
441 return pGetSystemMetrics
? pGetSystemMetrics( SM_CYSCREEN
) : 480;
443 case BITSPIXEL
: return 32;
444 case PLANES
: return 1;
445 case NUMBRUSHES
: return -1;
446 case NUMPENS
: return -1;
447 case NUMMARKERS
: return 0;
448 case NUMFONTS
: return 0;
449 case PDEVICESIZE
: return 0;
450 case CURVECAPS
: return (CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
| CC_WIDE
|
451 CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
);
452 case LINECAPS
: return (LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
453 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
);
454 case POLYGONALCAPS
: return (PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
| PC_SCANLINE
|
455 PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
);
456 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
457 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
458 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
459 case CLIPCAPS
: return CP_RECTANGLE
;
460 case RASTERCAPS
: return (RC_BITBLT
| RC_BITMAP64
| RC_GDI20_OUTPUT
| RC_DI_BITMAP
| RC_DIBTODEV
|
461 RC_BIGFONT
| RC_STRETCHBLT
| RC_FLOODFILL
| RC_STRETCHDIB
| RC_DEVBITS
|
462 (GetDeviceCaps( dev
->hdc
, SIZEPALETTE
) ? RC_PALETTE
: 0));
463 case ASPECTX
: return 36;
464 case ASPECTY
: return 36;
465 case ASPECTXY
: return (int)(hypot( GetDeviceCaps( dev
->hdc
, ASPECTX
),
466 GetDeviceCaps( dev
->hdc
, ASPECTY
)) + 0.5);
467 case CAPS1
: return 0;
468 case SIZEPALETTE
: return 0;
469 case NUMRESERVED
: return 20;
470 case PHYSICALWIDTH
: return 0;
471 case PHYSICALHEIGHT
: return 0;
472 case PHYSICALOFFSETX
: return 0;
473 case PHYSICALOFFSETY
: return 0;
474 case SCALINGFACTORX
: return 0;
475 case SCALINGFACTORY
: return 0;
482 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) != DT_RASDISPLAY
)
485 if (pEnumDisplaySettingsW
)
487 dc
= get_nulldrv_dc( dev
);
489 memset( &devmode
, 0, sizeof(devmode
) );
490 devmode
.dmSize
= sizeof(devmode
);
491 display
= dc
->display
[0] ? dc
->display
: NULL
;
492 if (pEnumDisplaySettingsW( display
, ENUM_CURRENT_SETTINGS
, &devmode
))
493 return devmode
.dmDisplayFrequency
? devmode
.dmDisplayFrequency
: 1;
499 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
501 DPI_AWARENESS_CONTEXT context
;
503 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
504 ret
= pGetSystemMetrics( SM_CXVIRTUALSCREEN
);
505 pSetThreadDpiAwarenessContext( context
);
508 return GetDeviceCaps( dev
->hdc
, HORZRES
);
510 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
512 DPI_AWARENESS_CONTEXT context
;
514 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
515 ret
= pGetSystemMetrics( SM_CYVIRTUALSCREEN
);
516 pSetThreadDpiAwarenessContext( context
);
519 return GetDeviceCaps( dev
->hdc
, VERTRES
);
520 case BLTALIGNMENT
: return 0;
521 case SHADEBLENDCAPS
: return 0;
522 case COLORMGMTCAPS
: return 0;
524 case LOGPIXELSY
: return get_system_dpi();
526 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
527 return (bpp
> 8) ? -1 : (1 << bpp
);
529 /* The observed correspondence between BITSPIXEL and COLORRES is:
530 * BITSPIXEL: 8 -> COLORRES: 18
531 * BITSPIXEL: 16 -> COLORRES: 16
532 * BITSPIXEL: 24 -> COLORRES: 24
533 * BITSPIXEL: 32 -> COLORRES: 24 */
534 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
535 return (bpp
<= 8) ? 18 : min( 24, bpp
);
537 FIXME("(%p): unsupported capability %d, will return 0\n", dev
->hdc
, cap
);
542 static BOOL CDECL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
544 SetLastError( ERROR_INVALID_PARAMETER
);
548 static DWORD CDECL
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
553 static BOOL CDECL
nulldrv_GetFontRealizationInfo( PHYSDEV dev
, void *info
)
558 static DWORD CDECL
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
563 static DWORD CDECL
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
568 static DWORD CDECL
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
569 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
574 static BOOL CDECL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
579 static DWORD CDECL
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
580 struct bitblt_coords
*src
)
582 return ERROR_NOT_SUPPORTED
;
585 static DWORD CDECL
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
590 static UINT CDECL
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
595 static UINT CDECL
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
597 return DEFAULT_CHARSET
;
600 static BOOL CDECL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
605 static BOOL CDECL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
610 static INT CDECL
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
614 DC
*dc
= get_nulldrv_dc( dev
);
616 if (GetObjectW( dc
->hFont
, sizeof(font
), &font
))
618 ret
= lstrlenW( font
.lfFaceName
) + 1;
621 lstrcpynW( name
, font
.lfFaceName
, size
);
622 ret
= min( size
, ret
);
628 static BOOL CDECL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
633 static BOOL CDECL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
638 static BOOL CDECL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
643 static BOOL CDECL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
648 static BOOL CDECL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
653 static BOOL CDECL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
654 INT xstart
, INT ystart
, INT xend
, INT yend
)
659 static BOOL CDECL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
664 static BOOL CDECL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
669 static BOOL CDECL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
671 INT counts
[1] = { count
};
673 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
676 static BOOL CDECL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
678 DWORD counts
[1] = { count
};
680 if (count
< 0) return FALSE
;
681 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
684 static DWORD CDECL
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
685 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
686 struct bitblt_coords
*dst
, DWORD rop
)
688 return ERROR_SUCCESS
;
691 static UINT CDECL
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
696 static UINT CDECL
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
701 static BOOL CDECL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
706 static HDC CDECL
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
711 static BOOL CDECL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
712 INT ell_width
, INT ell_height
)
717 static HBITMAP CDECL
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
722 static HBRUSH CDECL
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
727 static HFONT CDECL
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
, UINT
*aa_flags
)
732 static HPALETTE CDECL
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
737 static HPEN CDECL
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
742 static INT CDECL
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
747 static COLORREF CDECL
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
752 static INT CDECL
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
757 static UINT CDECL
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
762 static COLORREF CDECL
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
767 static COLORREF CDECL
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
772 static void CDECL
nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
776 static DWORD CDECL
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
781 static BOOL CDECL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
783 SetLastError( ERROR_INVALID_PARAMETER
);
787 static DWORD CDECL
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
792 static COLORREF CDECL
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
797 static INT CDECL
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
802 static INT CDECL
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
807 static INT CDECL
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
812 static INT CDECL
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
817 static UINT CDECL
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
822 static INT CDECL
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
827 static COLORREF CDECL
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
832 static BOOL CDECL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
837 static INT CDECL
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
842 static INT CDECL
nulldrv_StartPage( PHYSDEV dev
)
847 static BOOL CDECL
nulldrv_UnrealizePalette( HPALETTE palette
)
852 static NTSTATUS CDECL
nulldrv_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP
*desc
)
854 return STATUS_PROCEDURE_NOT_FOUND
;
857 static NTSTATUS CDECL
nulldrv_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER
*desc
)
859 return STATUS_PROCEDURE_NOT_FOUND
;
862 static struct opengl_funcs
* CDECL
nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
867 static const struct vulkan_funcs
* CDECL
nulldrv_wine_get_vulkan_driver( PHYSDEV dev
, UINT version
)
872 const struct gdi_dc_funcs null_driver
=
874 nulldrv_AbortDoc
, /* pAbortDoc */
875 nulldrv_AbortPath
, /* pAbortPath */
876 nulldrv_AlphaBlend
, /* pAlphaBlend */
877 nulldrv_AngleArc
, /* pAngleArc */
878 nulldrv_Arc
, /* pArc */
879 nulldrv_ArcTo
, /* pArcTo */
880 nulldrv_BeginPath
, /* pBeginPath */
881 nulldrv_BlendImage
, /* pBlendImage */
882 nulldrv_Chord
, /* pChord */
883 nulldrv_CloseFigure
, /* pCloseFigure */
884 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
885 nulldrv_CreateDC
, /* pCreateDC */
886 nulldrv_DeleteDC
, /* pDeleteDC */
887 nulldrv_DeleteObject
, /* pDeleteObject */
888 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
889 nulldrv_Ellipse
, /* pEllipse */
890 nulldrv_EndDoc
, /* pEndDoc */
891 nulldrv_EndPage
, /* pEndPage */
892 nulldrv_EndPath
, /* pEndPath */
893 nulldrv_EnumFonts
, /* pEnumFonts */
894 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
895 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
896 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
897 nulldrv_ExtEscape
, /* pExtEscape */
898 nulldrv_ExtFloodFill
, /* pExtFloodFill */
899 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
900 nulldrv_ExtTextOut
, /* pExtTextOut */
901 nulldrv_FillPath
, /* pFillPath */
902 nulldrv_FillRgn
, /* pFillRgn */
903 nulldrv_FlattenPath
, /* pFlattenPath */
904 nulldrv_FontIsLinked
, /* pFontIsLinked */
905 nulldrv_FrameRgn
, /* pFrameRgn */
906 nulldrv_GdiComment
, /* pGdiComment */
907 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
908 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
909 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
910 nulldrv_GetCharWidth
, /* pGetCharWidth */
911 nulldrv_GetCharWidthInfo
, /* pGetCharWidthInfo */
912 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
913 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
914 nulldrv_GetFontData
, /* pGetFontData */
915 nulldrv_GetFontRealizationInfo
, /* pGetFontRealizationInfo */
916 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
917 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
918 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
919 nulldrv_GetICMProfile
, /* pGetICMProfile */
920 nulldrv_GetImage
, /* pGetImage */
921 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
922 nulldrv_GetNearestColor
, /* pGetNearestColor */
923 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
924 nulldrv_GetPixel
, /* pGetPixel */
925 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
926 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
927 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
928 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
929 nulldrv_GetTextFace
, /* pGetTextFace */
930 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
931 nulldrv_GradientFill
, /* pGradientFill */
932 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
933 nulldrv_InvertRgn
, /* pInvertRgn */
934 nulldrv_LineTo
, /* pLineTo */
935 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
936 nulldrv_MoveTo
, /* pMoveTo */
937 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
938 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
939 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
940 nulldrv_PaintRgn
, /* pPaintRgn */
941 nulldrv_PatBlt
, /* pPatBlt */
942 nulldrv_Pie
, /* pPie */
943 nulldrv_PolyBezier
, /* pPolyBezier */
944 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
945 nulldrv_PolyDraw
, /* pPolyDraw */
946 nulldrv_PolyPolygon
, /* pPolyPolygon */
947 nulldrv_PolyPolyline
, /* pPolyPolyline */
948 nulldrv_Polygon
, /* pPolygon */
949 nulldrv_Polyline
, /* pPolyline */
950 nulldrv_PolylineTo
, /* pPolylineTo */
951 nulldrv_PutImage
, /* pPutImage */
952 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
953 nulldrv_RealizePalette
, /* pRealizePalette */
954 nulldrv_Rectangle
, /* pRectangle */
955 nulldrv_ResetDC
, /* pResetDC */
956 nulldrv_RestoreDC
, /* pRestoreDC */
957 nulldrv_RoundRect
, /* pRoundRect */
958 nulldrv_SaveDC
, /* pSaveDC */
959 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
960 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
961 nulldrv_SelectBitmap
, /* pSelectBitmap */
962 nulldrv_SelectBrush
, /* pSelectBrush */
963 nulldrv_SelectClipPath
, /* pSelectClipPath */
964 nulldrv_SelectFont
, /* pSelectFont */
965 nulldrv_SelectPalette
, /* pSelectPalette */
966 nulldrv_SelectPen
, /* pSelectPen */
967 nulldrv_SetArcDirection
, /* pSetArcDirection */
968 nulldrv_SetBkColor
, /* pSetBkColor */
969 nulldrv_SetBkMode
, /* pSetBkMode */
970 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
971 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
972 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
973 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
974 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
975 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
976 nulldrv_SetLayout
, /* pSetLayout */
977 nulldrv_SetMapMode
, /* pSetMapMode */
978 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
979 nulldrv_SetPixel
, /* pSetPixel */
980 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
981 nulldrv_SetROP2
, /* pSetROP2 */
982 nulldrv_SetRelAbs
, /* pSetRelAbs */
983 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
984 nulldrv_SetTextAlign
, /* pSetTextAlign */
985 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
986 nulldrv_SetTextColor
, /* pSetTextColor */
987 nulldrv_SetTextJustification
, /* pSetTextJustification */
988 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
989 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
990 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
991 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
992 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
993 nulldrv_StartDoc
, /* pStartDoc */
994 nulldrv_StartPage
, /* pStartPage */
995 nulldrv_StretchBlt
, /* pStretchBlt */
996 nulldrv_StretchDIBits
, /* pStretchDIBits */
997 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
998 nulldrv_StrokePath
, /* pStrokePath */
999 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
1000 nulldrv_WidenPath
, /* pWidenPath */
1001 nulldrv_D3DKMTCheckVidPnExclusiveOwnership
, /* pD3DKMTCheckVidPnExclusiveOwnership */
1002 nulldrv_D3DKMTSetVidPnSourceOwner
, /* pD3DKMTSetVidPnSourceOwner */
1003 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
1004 nulldrv_wine_get_vulkan_driver
, /* wine_get_vulkan_driver */
1006 GDI_PRIORITY_NULL_DRV
/* priority */
1010 /*****************************************************************************
1011 * DRIVER_GetDriverName
1014 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
1018 /* display is a special case */
1019 if (!wcsicmp( device
, L
"display" ) || is_display_device( device
))
1021 lstrcpynW( driver
, L
"display", size
);
1025 size
= GetProfileStringW(L
"devices", device
, L
"", driver
, size
);
1027 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
1030 p
= wcschr(driver
, ',');
1033 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
1037 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
1042 /***********************************************************************
1043 * GdiConvertToDevmodeW (GDI32.@)
1045 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
1048 WORD dmW_size
, dmA_size
;
1050 dmA_size
= dmA
->dmSize
;
1052 /* this is the minimal dmSize that XP accepts */
1053 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
1056 if (dmA_size
> sizeof(DEVMODEA
))
1057 dmA_size
= sizeof(DEVMODEA
);
1059 dmW_size
= dmA_size
+ CCHDEVICENAME
;
1060 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
1061 dmW_size
+= CCHFORMNAME
;
1063 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
1064 if (!dmW
) return NULL
;
1066 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
1067 dmW
->dmDeviceName
, CCHDEVICENAME
);
1068 /* copy slightly more, to avoid long computations */
1069 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
1071 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
1073 if (dmA
->dmFields
& DM_FORMNAME
)
1074 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
1075 dmW
->dmFormName
, CCHFORMNAME
);
1077 dmW
->dmFormName
[0] = 0;
1079 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
1080 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
1083 if (dmA
->dmDriverExtra
)
1084 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
1086 dmW
->dmSize
= dmW_size
;
1092 /*****************************************************************************
1095 * This should thunk to 16-bit and simply call the proc with the given args.
1097 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
1098 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
1100 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
1104 /*****************************************************************************
1107 * This should load the correct driver for lpszDevice and calls this driver's
1108 * ExtDeviceModePropSheet proc.
1110 * Note: The driver calls a callback routine for each property sheet page; these
1111 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1112 * The layout of this structure is:
1118 * HPROPSHEETPAGE pages[10];
1121 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
1122 LPCSTR lpszPort
, LPVOID lpPropSheet
)
1124 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
1128 /*****************************************************************************
1131 * This should load the correct driver for lpszDevice and call this driver's
1132 * ExtDeviceMode proc.
1134 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1136 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
1137 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
1138 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
1139 LPSTR lpszProfile
, DWORD fwMode
)
1148 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1149 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
1151 if (!lpszDevice
) return -1;
1152 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1154 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1156 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1158 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1160 if ((dc
= get_dc_ptr( hdc
)))
1162 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
1163 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1164 lpdmInput
, lpszProfile
, fwMode
);
1165 release_dc_ptr( dc
);
1171 /****************************************************************************
1174 * This should load the correct driver for lpszDevice and calls this driver's
1175 * AdvancedSetupDialog proc.
1177 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1178 LPDEVMODEA devin
, LPDEVMODEA devout
)
1180 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1184 /*****************************************************************************
1187 * This should load the correct driver for lpszDevice and calls this driver's
1188 * DeviceCapabilities proc.
1190 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1192 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1193 WORD fwCapability
, LPSTR lpszOutput
,
1203 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1205 if (!lpszDevice
) return -1;
1206 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1208 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1210 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1212 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1214 if ((dc
= get_dc_ptr( hdc
)))
1216 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1217 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1218 fwCapability
, lpszOutput
, lpdm
);
1219 release_dc_ptr( dc
);
1226 /************************************************************************
1229 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1237 return AbortDoc( hdc
);
1240 return EndDoc( hdc
);
1242 case GETPHYSPAGESIZE
:
1244 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1245 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1248 case GETPRINTINGOFFSET
:
1250 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1251 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1254 case GETSCALINGFACTOR
:
1256 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1257 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1261 return EndPage( hdc
);
1264 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1271 /* in_data may not be 0 terminated so we must copy it */
1274 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1275 memcpy( name
, in_data
, in_count
);
1278 /* out_data is actually a pointer to the DocInfo structure and used as
1279 * a second input parameter */
1280 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1283 doc
.cbSize
= sizeof(doc
);
1284 doc
.lpszOutput
= NULL
;
1285 doc
.lpszDatatype
= NULL
;
1288 doc
.lpszDocName
= name
;
1289 ret
= StartDocA( hdc
, &doc
);
1290 HeapFree( GetProcessHeap(), 0, name
);
1291 if (ret
> 0) ret
= StartPage( hdc
);
1295 case QUERYESCSUPPORT
:
1299 if (in_count
< sizeof(SHORT
)) return 0;
1300 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1305 case GETPHYSPAGESIZE
:
1306 case GETPRINTINGOFFSET
:
1307 case GETSCALINGFACTOR
:
1309 case QUERYESCSUPPORT
:
1318 /* if not handled internally, pass it to the driver */
1319 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1323 /******************************************************************************
1324 * ExtEscape [GDI32.@]
1326 * Access capabilities of a particular device that are not available through GDI.
1329 * hdc [I] Handle to device context
1330 * nEscape [I] Escape function
1331 * cbInput [I] Number of bytes in input structure
1332 * lpszInData [I] Pointer to input structure
1333 * cbOutput [I] Number of bytes in output structure
1334 * lpszOutData [O] Pointer to output structure
1338 * Not implemented: 0
1341 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1342 INT cbOutput
, LPSTR lpszOutData
)
1346 DC
* dc
= get_dc_ptr( hdc
);
1350 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1351 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1352 release_dc_ptr( dc
);
1357 /*******************************************************************
1358 * DrawEscape [GDI32.@]
1362 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1364 FIXME("DrawEscape, stub\n");
1368 /*******************************************************************
1369 * NamedEscape [GDI32.@]
1371 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1372 INT cbOutput
, LPSTR lpszOutData
)
1374 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1375 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1380 /*******************************************************************
1381 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1382 * GdiEntry13 [GDI32.@]
1384 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1386 static int warn_once
;
1393 /******************************************************************************
1394 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1396 NTSTATUS WINAPI
D3DKMTOpenAdapterFromHdc( void *pData
)
1398 FIXME("(%p): stub\n", pData
);
1399 return STATUS_NO_MEMORY
;
1402 /******************************************************************************
1403 * D3DKMTEscape [GDI32.@]
1405 NTSTATUS WINAPI
D3DKMTEscape( const void *pData
)
1407 FIXME("(%p): stub\n", pData
);
1408 return STATUS_NO_MEMORY
;
1411 /******************************************************************************
1412 * D3DKMTCloseAdapter [GDI32.@]
1414 NTSTATUS WINAPI
D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER
*desc
)
1416 NTSTATUS status
= STATUS_INVALID_PARAMETER
;
1417 struct d3dkmt_adapter
*adapter
;
1419 TRACE("(%p)\n", desc
);
1421 if (!desc
|| !desc
->hAdapter
)
1422 return STATUS_INVALID_PARAMETER
;
1424 EnterCriticalSection( &driver_section
);
1425 LIST_FOR_EACH_ENTRY( adapter
, &d3dkmt_adapters
, struct d3dkmt_adapter
, entry
)
1427 if (adapter
->handle
== desc
->hAdapter
)
1429 list_remove( &adapter
->entry
);
1430 heap_free( adapter
);
1431 status
= STATUS_SUCCESS
;
1435 LeaveCriticalSection( &driver_section
);
1440 /******************************************************************************
1441 * D3DKMTOpenAdapterFromGdiDisplayName [GDI32.@]
1443 NTSTATUS WINAPI
D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME
*desc
)
1445 WCHAR
*end
, key_nameW
[MAX_PATH
], bufferW
[MAX_PATH
];
1446 HDEVINFO devinfo
= INVALID_HANDLE_VALUE
;
1447 NTSTATUS status
= STATUS_UNSUCCESSFUL
;
1448 static D3DKMT_HANDLE handle_start
= 0;
1449 struct d3dkmt_adapter
*adapter
;
1450 SP_DEVINFO_DATA device_data
;
1451 DWORD size
, state_flags
;
1457 TRACE("(%p)\n", desc
);
1460 return STATUS_UNSUCCESSFUL
;
1462 TRACE("DeviceName: %s\n", wine_dbgstr_w( desc
->DeviceName
));
1463 if (wcsnicmp( desc
->DeviceName
, L
"\\\\.\\DISPLAY", lstrlenW(L
"\\\\.\\DISPLAY") ))
1464 return STATUS_UNSUCCESSFUL
;
1466 index
= wcstol( desc
->DeviceName
+ lstrlenW(L
"\\\\.\\DISPLAY"), &end
, 10 ) - 1;
1468 return STATUS_UNSUCCESSFUL
;
1470 adapter
= heap_alloc( sizeof( *adapter
) );
1472 return STATUS_NO_MEMORY
;
1474 /* Get adapter LUID from SetupAPI */
1475 mutex
= get_display_device_init_mutex();
1477 size
= sizeof( bufferW
);
1478 swprintf( key_nameW
, MAX_PATH
, L
"\\Device\\Video%d", index
);
1479 if (RegGetValueW( HKEY_LOCAL_MACHINE
, L
"HARDWARE\\DEVICEMAP\\VIDEO", key_nameW
, RRF_RT_REG_SZ
, NULL
, bufferW
, &size
))
1482 /* Strip \Registry\Machine\ prefix and retrieve Wine specific data set by the display driver */
1483 lstrcpyW( key_nameW
, bufferW
+ 18 );
1484 size
= sizeof( state_flags
);
1485 if (RegGetValueW( HKEY_CURRENT_CONFIG
, key_nameW
, L
"StateFlags", RRF_RT_REG_DWORD
, NULL
,
1486 &state_flags
, &size
))
1489 if (!(state_flags
& DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
))
1492 size
= sizeof( bufferW
);
1493 if (RegGetValueW( HKEY_CURRENT_CONFIG
, key_nameW
, L
"GPUID", RRF_RT_REG_SZ
, NULL
, bufferW
, &size
))
1496 devinfo
= SetupDiCreateDeviceInfoList( &GUID_DEVCLASS_DISPLAY
, NULL
);
1497 device_data
.cbSize
= sizeof( device_data
);
1498 SetupDiOpenDeviceInfoW( devinfo
, bufferW
, NULL
, 0, &device_data
);
1499 if (!SetupDiGetDevicePropertyW( devinfo
, &device_data
, &DEVPROPKEY_GPU_LUID
, &type
,
1500 (BYTE
*)&luid
, sizeof( luid
), NULL
, 0))
1503 EnterCriticalSection( &driver_section
);
1504 /* D3DKMT_HANDLE is UINT, so we can't use pointer as handle */
1505 adapter
->handle
= ++handle_start
;
1506 list_add_tail( &d3dkmt_adapters
, &adapter
->entry
);
1507 LeaveCriticalSection( &driver_section
);
1509 desc
->hAdapter
= handle_start
;
1510 desc
->AdapterLuid
= luid
;
1511 desc
->VidPnSourceId
= index
;
1512 status
= STATUS_SUCCESS
;
1515 SetupDiDestroyDeviceInfoList( devinfo
);
1516 release_display_device_init_mutex( mutex
);
1517 if (status
!= STATUS_SUCCESS
)
1518 heap_free( adapter
);
1522 /******************************************************************************
1523 * D3DKMTCreateDevice [GDI32.@]
1525 NTSTATUS WINAPI
D3DKMTCreateDevice( D3DKMT_CREATEDEVICE
*desc
)
1527 static D3DKMT_HANDLE handle_start
= 0;
1528 struct d3dkmt_adapter
*adapter
;
1529 struct d3dkmt_device
*device
;
1532 TRACE("(%p)\n", desc
);
1535 return STATUS_INVALID_PARAMETER
;
1537 EnterCriticalSection( &driver_section
);
1538 LIST_FOR_EACH_ENTRY( adapter
, &d3dkmt_adapters
, struct d3dkmt_adapter
, entry
)
1540 if (adapter
->handle
== desc
->hAdapter
)
1546 LeaveCriticalSection( &driver_section
);
1549 return STATUS_INVALID_PARAMETER
;
1551 if (desc
->Flags
.LegacyMode
|| desc
->Flags
.RequestVSync
|| desc
->Flags
.DisableGpuTimeout
)
1552 FIXME("Flags unsupported.\n");
1554 device
= heap_alloc_zero( sizeof( *device
) );
1556 return STATUS_NO_MEMORY
;
1558 EnterCriticalSection( &driver_section
);
1559 device
->handle
= ++handle_start
;
1560 list_add_tail( &d3dkmt_devices
, &device
->entry
);
1561 LeaveCriticalSection( &driver_section
);
1563 desc
->hDevice
= device
->handle
;
1564 return STATUS_SUCCESS
;
1567 /******************************************************************************
1568 * D3DKMTDestroyDevice [GDI32.@]
1570 NTSTATUS WINAPI
D3DKMTDestroyDevice( const D3DKMT_DESTROYDEVICE
*desc
)
1572 NTSTATUS status
= STATUS_INVALID_PARAMETER
;
1573 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc
;
1574 struct d3dkmt_device
*device
;
1576 TRACE("(%p)\n", desc
);
1578 if (!desc
|| !desc
->hDevice
)
1579 return STATUS_INVALID_PARAMETER
;
1581 EnterCriticalSection( &driver_section
);
1582 LIST_FOR_EACH_ENTRY( device
, &d3dkmt_devices
, struct d3dkmt_device
, entry
)
1584 if (device
->handle
== desc
->hDevice
)
1586 memset( &set_owner_desc
, 0, sizeof(set_owner_desc
) );
1587 set_owner_desc
.hDevice
= desc
->hDevice
;
1588 D3DKMTSetVidPnSourceOwner( &set_owner_desc
);
1589 list_remove( &device
->entry
);
1590 heap_free( device
);
1591 status
= STATUS_SUCCESS
;
1595 LeaveCriticalSection( &driver_section
);
1600 /******************************************************************************
1601 * D3DKMTQueryStatistics [GDI32.@]
1603 NTSTATUS WINAPI
D3DKMTQueryStatistics(D3DKMT_QUERYSTATISTICS
*stats
)
1605 FIXME("(%p): stub\n", stats
);
1606 return STATUS_SUCCESS
;
1609 /******************************************************************************
1610 * D3DKMTSetQueuedLimit [GDI32.@]
1612 NTSTATUS WINAPI
D3DKMTSetQueuedLimit( D3DKMT_SETQUEUEDLIMIT
*desc
)
1614 FIXME( "(%p): stub\n", desc
);
1615 return STATUS_NOT_IMPLEMENTED
;
1618 /******************************************************************************
1619 * D3DKMTSetVidPnSourceOwner [GDI32.@]
1621 NTSTATUS WINAPI
D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER
*desc
)
1623 TRACE("(%p)\n", desc
);
1625 if (!get_display_driver()->pD3DKMTSetVidPnSourceOwner
)
1626 return STATUS_PROCEDURE_NOT_FOUND
;
1628 if (!desc
|| !desc
->hDevice
|| (desc
->VidPnSourceCount
&& (!desc
->pType
|| !desc
->pVidPnSourceId
)))
1629 return STATUS_INVALID_PARAMETER
;
1631 /* Store the VidPN source ownership info in the graphics driver because
1632 * the graphics driver needs to change ownership sometimes. For example,
1633 * when a new window is moved to a VidPN source with an exclusive owner,
1634 * such an exclusive owner will be released before showing the new window */
1635 return get_display_driver()->pD3DKMTSetVidPnSourceOwner( desc
);
1638 /******************************************************************************
1639 * D3DKMTCheckVidPnExclusiveOwnership [GDI32.@]
1641 NTSTATUS WINAPI
D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP
*desc
)
1643 TRACE("(%p)\n", desc
);
1645 if (!get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership
)
1646 return STATUS_PROCEDURE_NOT_FOUND
;
1648 if (!desc
|| !desc
->hAdapter
)
1649 return STATUS_INVALID_PARAMETER
;
1651 return get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership( desc
);