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 HWND (WINAPI
*pGetDesktopWindow
)(void);
85 static INT (WINAPI
*pGetSystemMetrics
)(INT
);
86 static DPI_AWARENESS_CONTEXT (WINAPI
*pSetThreadDpiAwarenessContext
)(DPI_AWARENESS_CONTEXT
);
88 /**********************************************************************
91 * Allocate and fill the driver structure for a given module.
93 static struct graphics_driver
*create_driver( HMODULE module
)
95 static const struct gdi_dc_funcs empty_funcs
;
96 const struct gdi_dc_funcs
*funcs
= NULL
;
97 struct graphics_driver
*driver
;
99 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
100 driver
->module
= module
;
104 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
106 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
107 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
109 if (!funcs
) funcs
= &empty_funcs
;
110 driver
->funcs
= funcs
;
115 /**********************************************************************
118 * Special case for loading the display driver: get the name from the config file
120 static const struct gdi_dc_funcs
*get_display_driver(void)
124 HMODULE user32
= LoadLibraryA( "user32.dll" );
125 pGetDesktopWindow
= (void *)GetProcAddress( user32
, "GetDesktopWindow" );
127 if (!pGetDesktopWindow() || !display_driver
)
129 WARN( "failed to load the display driver, falling back to null driver\n" );
130 __wine_set_display_driver( 0 );
133 return display_driver
->funcs
;
137 /**********************************************************************
140 static BOOL
is_display_device( LPCWSTR name
)
142 const WCHAR
*p
= name
;
144 if (wcsnicmp( name
, L
"\\\\.\\DISPLAY", lstrlenW(L
"\\\\.\\DISPLAY") )) return FALSE
;
146 p
+= lstrlenW(L
"\\\\.\\DISPLAY");
148 if (!iswdigit( *p
++ ))
160 static HANDLE
get_display_device_init_mutex( void )
162 HANDLE mutex
= CreateMutexW( NULL
, FALSE
, L
"display_device_init" );
164 WaitForSingleObject( mutex
, INFINITE
);
168 static void release_display_device_init_mutex( HANDLE mutex
)
170 ReleaseMutex( mutex
);
171 CloseHandle( mutex
);
174 /**********************************************************************
177 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
180 struct graphics_driver
*driver
, *new_driver
;
182 /* display driver is a special case */
183 if (!wcsicmp( name
, L
"display" ) || is_display_device( name
)) return get_display_driver();
185 if ((module
= GetModuleHandleW( name
)))
187 if (display_driver
&& display_driver
->module
== module
) return display_driver
->funcs
;
189 EnterCriticalSection( &driver_section
);
190 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
192 if (driver
->module
== module
) goto done
;
194 LeaveCriticalSection( &driver_section
);
197 if (!(module
= LoadLibraryW( name
))) return NULL
;
199 if (!(new_driver
= create_driver( module
)))
201 FreeLibrary( module
);
205 /* check if someone else added it in the meantime */
206 EnterCriticalSection( &driver_section
);
207 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
209 if (driver
->module
!= module
) continue;
210 FreeLibrary( module
);
211 HeapFree( GetProcessHeap(), 0, new_driver
);
215 list_add_head( &drivers
, &driver
->entry
);
216 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
218 LeaveCriticalSection( &driver_section
);
219 return driver
->funcs
;
223 /***********************************************************************
224 * __wine_set_display_driver (GDI32.@)
226 void CDECL
__wine_set_display_driver( HMODULE module
)
228 struct graphics_driver
*driver
;
231 if (!(driver
= create_driver( module
)))
233 ERR( "Could not create graphics driver\n" );
236 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
237 HeapFree( GetProcessHeap(), 0, driver
);
239 user32
= LoadLibraryA( "user32.dll" );
240 pGetSystemMetrics
= (void *)GetProcAddress( user32
, "GetSystemMetrics" );
241 pSetThreadDpiAwarenessContext
= (void *)GetProcAddress( user32
, "SetThreadDpiAwarenessContext" );
245 static INT CDECL
nulldrv_AbortDoc( PHYSDEV dev
)
250 static BOOL CDECL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
251 INT xstart
, INT ystart
, INT xend
, INT yend
)
256 static BOOL CDECL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
257 INT xstart
, INT ystart
, INT xend
, INT yend
)
262 static BOOL CDECL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
264 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
265 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
268 static BOOL CDECL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
269 LPCWSTR output
, const DEVMODEW
*devmode
)
271 assert(0); /* should never be called */
275 static BOOL CDECL
nulldrv_DeleteDC( PHYSDEV dev
)
277 assert(0); /* should never be called */
281 static BOOL CDECL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
286 static DWORD CDECL
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
287 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
292 static BOOL CDECL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
297 static INT CDECL
nulldrv_EndDoc( PHYSDEV dev
)
302 static INT CDECL
nulldrv_EndPage( PHYSDEV dev
)
307 static BOOL CDECL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
312 static INT CDECL
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
317 static INT CDECL
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
318 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
323 static INT CDECL
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
324 INT out_size
, void *out_data
)
329 static BOOL CDECL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
334 static BOOL CDECL
nulldrv_FontIsLinked( PHYSDEV dev
)
339 static BOOL CDECL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
344 static UINT CDECL
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
349 static BOOL CDECL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
354 static BOOL CDECL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
359 static BOOL CDECL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
364 static BOOL CDECL
nulldrv_GetCharWidthInfo( PHYSDEV dev
, void *info
)
369 static INT CDECL
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
375 case DRIVERVERSION
: return 0x4000;
376 case TECHNOLOGY
: return DT_RASDISPLAY
;
377 case HORZSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, HORZRES
), 254,
378 GetDeviceCaps( dev
->hdc
, LOGPIXELSX
) * 10 );
379 case VERTSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, VERTRES
), 254,
380 GetDeviceCaps( dev
->hdc
, LOGPIXELSY
) * 10 );
381 case HORZRES
: return pGetSystemMetrics
? pGetSystemMetrics( SM_CXSCREEN
) : 640;
382 case VERTRES
: return pGetSystemMetrics
? pGetSystemMetrics( SM_CYSCREEN
) : 480;
383 case BITSPIXEL
: return 32;
384 case PLANES
: return 1;
385 case NUMBRUSHES
: return -1;
386 case NUMPENS
: return -1;
387 case NUMMARKERS
: return 0;
388 case NUMFONTS
: return 0;
389 case PDEVICESIZE
: return 0;
390 case CURVECAPS
: return (CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
| CC_WIDE
|
391 CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
);
392 case LINECAPS
: return (LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
393 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
);
394 case POLYGONALCAPS
: return (PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
| PC_SCANLINE
|
395 PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
);
396 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
397 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
398 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
399 case CLIPCAPS
: return CP_RECTANGLE
;
400 case RASTERCAPS
: return (RC_BITBLT
| RC_BITMAP64
| RC_GDI20_OUTPUT
| RC_DI_BITMAP
| RC_DIBTODEV
|
401 RC_BIGFONT
| RC_STRETCHBLT
| RC_FLOODFILL
| RC_STRETCHDIB
| RC_DEVBITS
|
402 (GetDeviceCaps( dev
->hdc
, SIZEPALETTE
) ? RC_PALETTE
: 0));
403 case ASPECTX
: return 36;
404 case ASPECTY
: return 36;
405 case ASPECTXY
: return (int)(hypot( GetDeviceCaps( dev
->hdc
, ASPECTX
),
406 GetDeviceCaps( dev
->hdc
, ASPECTY
)) + 0.5);
407 case CAPS1
: return 0;
408 case SIZEPALETTE
: return 0;
409 case NUMRESERVED
: return 20;
410 case PHYSICALWIDTH
: return 0;
411 case PHYSICALHEIGHT
: return 0;
412 case PHYSICALOFFSETX
: return 0;
413 case PHYSICALOFFSETY
: return 0;
414 case SCALINGFACTORX
: return 0;
415 case SCALINGFACTORY
: return 0;
416 case VREFRESH
: return GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
? 1 : 0;
418 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
420 DPI_AWARENESS_CONTEXT context
;
422 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
423 ret
= pGetSystemMetrics( SM_CXVIRTUALSCREEN
);
424 pSetThreadDpiAwarenessContext( context
);
427 return GetDeviceCaps( dev
->hdc
, HORZRES
);
429 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
431 DPI_AWARENESS_CONTEXT context
;
433 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
434 ret
= pGetSystemMetrics( SM_CYVIRTUALSCREEN
);
435 pSetThreadDpiAwarenessContext( context
);
438 return GetDeviceCaps( dev
->hdc
, VERTRES
);
439 case BLTALIGNMENT
: return 0;
440 case SHADEBLENDCAPS
: return 0;
441 case COLORMGMTCAPS
: return 0;
443 case LOGPIXELSY
: return get_system_dpi();
445 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
446 return (bpp
> 8) ? -1 : (1 << bpp
);
448 /* The observed correspondence between BITSPIXEL and COLORRES is:
449 * BITSPIXEL: 8 -> COLORRES: 18
450 * BITSPIXEL: 16 -> COLORRES: 16
451 * BITSPIXEL: 24 -> COLORRES: 24
452 * BITSPIXEL: 32 -> COLORRES: 24 */
453 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
454 return (bpp
<= 8) ? 18 : min( 24, bpp
);
456 FIXME("(%p): unsupported capability %d, will return 0\n", dev
->hdc
, cap
);
461 static BOOL CDECL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
463 SetLastError( ERROR_INVALID_PARAMETER
);
467 static DWORD CDECL
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
472 static BOOL CDECL
nulldrv_GetFontRealizationInfo( PHYSDEV dev
, void *info
)
477 static DWORD CDECL
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
482 static DWORD CDECL
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
487 static DWORD CDECL
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
488 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
493 static BOOL CDECL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
498 static DWORD CDECL
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
499 struct bitblt_coords
*src
)
501 return ERROR_NOT_SUPPORTED
;
504 static DWORD CDECL
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
509 static UINT CDECL
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
514 static UINT CDECL
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
516 return DEFAULT_CHARSET
;
519 static BOOL CDECL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
524 static BOOL CDECL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
529 static INT CDECL
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
533 DC
*dc
= get_nulldrv_dc( dev
);
535 if (GetObjectW( dc
->hFont
, sizeof(font
), &font
))
537 ret
= lstrlenW( font
.lfFaceName
) + 1;
540 lstrcpynW( name
, font
.lfFaceName
, size
);
541 ret
= min( size
, ret
);
547 static BOOL CDECL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
552 static BOOL CDECL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
557 static BOOL CDECL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
562 static BOOL CDECL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
567 static BOOL CDECL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
572 static BOOL CDECL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
573 INT xstart
, INT ystart
, INT xend
, INT yend
)
578 static BOOL CDECL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
583 static BOOL CDECL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
588 static BOOL CDECL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
590 INT counts
[1] = { count
};
592 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
595 static BOOL CDECL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
597 DWORD counts
[1] = { count
};
599 if (count
< 0) return FALSE
;
600 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
603 static DWORD CDECL
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
604 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
605 struct bitblt_coords
*dst
, DWORD rop
)
607 return ERROR_SUCCESS
;
610 static UINT CDECL
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
615 static UINT CDECL
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
620 static BOOL CDECL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
625 static HDC CDECL
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
630 static BOOL CDECL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
631 INT ell_width
, INT ell_height
)
636 static HBITMAP CDECL
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
641 static HBRUSH CDECL
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
646 static HFONT CDECL
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
, UINT
*aa_flags
)
651 static HPALETTE CDECL
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
656 static HPEN CDECL
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
661 static INT CDECL
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
666 static COLORREF CDECL
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
671 static INT CDECL
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
676 static UINT CDECL
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
681 static COLORREF CDECL
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
686 static COLORREF CDECL
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
691 static void CDECL
nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
695 static DWORD CDECL
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
700 static BOOL CDECL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
702 SetLastError( ERROR_INVALID_PARAMETER
);
706 static DWORD CDECL
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
711 static COLORREF CDECL
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
716 static INT CDECL
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
721 static INT CDECL
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
726 static INT CDECL
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
731 static INT CDECL
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
736 static UINT CDECL
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
741 static INT CDECL
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
746 static COLORREF CDECL
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
751 static BOOL CDECL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
756 static INT CDECL
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
761 static INT CDECL
nulldrv_StartPage( PHYSDEV dev
)
766 static BOOL CDECL
nulldrv_UnrealizePalette( HPALETTE palette
)
771 static NTSTATUS CDECL
nulldrv_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP
*desc
)
773 return STATUS_PROCEDURE_NOT_FOUND
;
776 static NTSTATUS CDECL
nulldrv_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER
*desc
)
778 return STATUS_PROCEDURE_NOT_FOUND
;
781 static struct opengl_funcs
* CDECL
nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
786 static const struct vulkan_funcs
* CDECL
nulldrv_wine_get_vulkan_driver( PHYSDEV dev
, UINT version
)
791 const struct gdi_dc_funcs null_driver
=
793 nulldrv_AbortDoc
, /* pAbortDoc */
794 nulldrv_AbortPath
, /* pAbortPath */
795 nulldrv_AlphaBlend
, /* pAlphaBlend */
796 nulldrv_AngleArc
, /* pAngleArc */
797 nulldrv_Arc
, /* pArc */
798 nulldrv_ArcTo
, /* pArcTo */
799 nulldrv_BeginPath
, /* pBeginPath */
800 nulldrv_BlendImage
, /* pBlendImage */
801 nulldrv_Chord
, /* pChord */
802 nulldrv_CloseFigure
, /* pCloseFigure */
803 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
804 nulldrv_CreateDC
, /* pCreateDC */
805 nulldrv_DeleteDC
, /* pDeleteDC */
806 nulldrv_DeleteObject
, /* pDeleteObject */
807 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
808 nulldrv_Ellipse
, /* pEllipse */
809 nulldrv_EndDoc
, /* pEndDoc */
810 nulldrv_EndPage
, /* pEndPage */
811 nulldrv_EndPath
, /* pEndPath */
812 nulldrv_EnumFonts
, /* pEnumFonts */
813 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
814 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
815 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
816 nulldrv_ExtEscape
, /* pExtEscape */
817 nulldrv_ExtFloodFill
, /* pExtFloodFill */
818 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
819 nulldrv_ExtTextOut
, /* pExtTextOut */
820 nulldrv_FillPath
, /* pFillPath */
821 nulldrv_FillRgn
, /* pFillRgn */
822 nulldrv_FlattenPath
, /* pFlattenPath */
823 nulldrv_FontIsLinked
, /* pFontIsLinked */
824 nulldrv_FrameRgn
, /* pFrameRgn */
825 nulldrv_GdiComment
, /* pGdiComment */
826 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
827 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
828 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
829 nulldrv_GetCharWidth
, /* pGetCharWidth */
830 nulldrv_GetCharWidthInfo
, /* pGetCharWidthInfo */
831 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
832 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
833 nulldrv_GetFontData
, /* pGetFontData */
834 nulldrv_GetFontRealizationInfo
, /* pGetFontRealizationInfo */
835 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
836 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
837 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
838 nulldrv_GetICMProfile
, /* pGetICMProfile */
839 nulldrv_GetImage
, /* pGetImage */
840 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
841 nulldrv_GetNearestColor
, /* pGetNearestColor */
842 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
843 nulldrv_GetPixel
, /* pGetPixel */
844 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
845 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
846 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
847 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
848 nulldrv_GetTextFace
, /* pGetTextFace */
849 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
850 nulldrv_GradientFill
, /* pGradientFill */
851 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
852 nulldrv_InvertRgn
, /* pInvertRgn */
853 nulldrv_LineTo
, /* pLineTo */
854 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
855 nulldrv_MoveTo
, /* pMoveTo */
856 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
857 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
858 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
859 nulldrv_PaintRgn
, /* pPaintRgn */
860 nulldrv_PatBlt
, /* pPatBlt */
861 nulldrv_Pie
, /* pPie */
862 nulldrv_PolyBezier
, /* pPolyBezier */
863 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
864 nulldrv_PolyDraw
, /* pPolyDraw */
865 nulldrv_PolyPolygon
, /* pPolyPolygon */
866 nulldrv_PolyPolyline
, /* pPolyPolyline */
867 nulldrv_Polygon
, /* pPolygon */
868 nulldrv_Polyline
, /* pPolyline */
869 nulldrv_PolylineTo
, /* pPolylineTo */
870 nulldrv_PutImage
, /* pPutImage */
871 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
872 nulldrv_RealizePalette
, /* pRealizePalette */
873 nulldrv_Rectangle
, /* pRectangle */
874 nulldrv_ResetDC
, /* pResetDC */
875 nulldrv_RestoreDC
, /* pRestoreDC */
876 nulldrv_RoundRect
, /* pRoundRect */
877 nulldrv_SaveDC
, /* pSaveDC */
878 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
879 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
880 nulldrv_SelectBitmap
, /* pSelectBitmap */
881 nulldrv_SelectBrush
, /* pSelectBrush */
882 nulldrv_SelectClipPath
, /* pSelectClipPath */
883 nulldrv_SelectFont
, /* pSelectFont */
884 nulldrv_SelectPalette
, /* pSelectPalette */
885 nulldrv_SelectPen
, /* pSelectPen */
886 nulldrv_SetArcDirection
, /* pSetArcDirection */
887 nulldrv_SetBkColor
, /* pSetBkColor */
888 nulldrv_SetBkMode
, /* pSetBkMode */
889 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
890 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
891 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
892 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
893 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
894 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
895 nulldrv_SetLayout
, /* pSetLayout */
896 nulldrv_SetMapMode
, /* pSetMapMode */
897 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
898 nulldrv_SetPixel
, /* pSetPixel */
899 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
900 nulldrv_SetROP2
, /* pSetROP2 */
901 nulldrv_SetRelAbs
, /* pSetRelAbs */
902 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
903 nulldrv_SetTextAlign
, /* pSetTextAlign */
904 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
905 nulldrv_SetTextColor
, /* pSetTextColor */
906 nulldrv_SetTextJustification
, /* pSetTextJustification */
907 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
908 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
909 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
910 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
911 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
912 nulldrv_StartDoc
, /* pStartDoc */
913 nulldrv_StartPage
, /* pStartPage */
914 nulldrv_StretchBlt
, /* pStretchBlt */
915 nulldrv_StretchDIBits
, /* pStretchDIBits */
916 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
917 nulldrv_StrokePath
, /* pStrokePath */
918 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
919 nulldrv_WidenPath
, /* pWidenPath */
920 nulldrv_D3DKMTCheckVidPnExclusiveOwnership
, /* pD3DKMTCheckVidPnExclusiveOwnership */
921 nulldrv_D3DKMTSetVidPnSourceOwner
, /* pD3DKMTSetVidPnSourceOwner */
922 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
923 nulldrv_wine_get_vulkan_driver
, /* wine_get_vulkan_driver */
925 GDI_PRIORITY_NULL_DRV
/* priority */
929 /*****************************************************************************
930 * DRIVER_GetDriverName
933 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
937 /* display is a special case */
938 if (!wcsicmp( device
, L
"display" ) || is_display_device( device
))
940 lstrcpynW( driver
, L
"display", size
);
944 size
= GetProfileStringW(L
"devices", device
, L
"", driver
, size
);
946 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
949 p
= wcschr(driver
, ',');
952 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
956 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
961 /***********************************************************************
962 * GdiConvertToDevmodeW (GDI32.@)
964 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
967 WORD dmW_size
, dmA_size
;
969 dmA_size
= dmA
->dmSize
;
971 /* this is the minimal dmSize that XP accepts */
972 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
975 if (dmA_size
> sizeof(DEVMODEA
))
976 dmA_size
= sizeof(DEVMODEA
);
978 dmW_size
= dmA_size
+ CCHDEVICENAME
;
979 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
980 dmW_size
+= CCHFORMNAME
;
982 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
983 if (!dmW
) return NULL
;
985 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
986 dmW
->dmDeviceName
, CCHDEVICENAME
);
987 /* copy slightly more, to avoid long computations */
988 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
990 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
992 if (dmA
->dmFields
& DM_FORMNAME
)
993 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
994 dmW
->dmFormName
, CCHFORMNAME
);
996 dmW
->dmFormName
[0] = 0;
998 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
999 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
1002 if (dmA
->dmDriverExtra
)
1003 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
1005 dmW
->dmSize
= dmW_size
;
1011 /*****************************************************************************
1014 * This should thunk to 16-bit and simply call the proc with the given args.
1016 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
1017 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
1019 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
1023 /*****************************************************************************
1026 * This should load the correct driver for lpszDevice and calls this driver's
1027 * ExtDeviceModePropSheet proc.
1029 * Note: The driver calls a callback routine for each property sheet page; these
1030 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1031 * The layout of this structure is:
1037 * HPROPSHEETPAGE pages[10];
1040 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
1041 LPCSTR lpszPort
, LPVOID lpPropSheet
)
1043 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
1047 /*****************************************************************************
1050 * This should load the correct driver for lpszDevice and call this driver's
1051 * ExtDeviceMode proc.
1053 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1055 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
1056 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
1057 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
1058 LPSTR lpszProfile
, DWORD fwMode
)
1067 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1068 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
1070 if (!lpszDevice
) return -1;
1071 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1073 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1075 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1077 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1079 if ((dc
= get_dc_ptr( hdc
)))
1081 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
1082 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1083 lpdmInput
, lpszProfile
, fwMode
);
1084 release_dc_ptr( dc
);
1090 /****************************************************************************
1093 * This should load the correct driver for lpszDevice and calls this driver's
1094 * AdvancedSetupDialog proc.
1096 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1097 LPDEVMODEA devin
, LPDEVMODEA devout
)
1099 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1103 /*****************************************************************************
1106 * This should load the correct driver for lpszDevice and calls this driver's
1107 * DeviceCapabilities proc.
1109 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1111 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1112 WORD fwCapability
, LPSTR lpszOutput
,
1122 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1124 if (!lpszDevice
) return -1;
1125 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1127 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1129 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1131 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1133 if ((dc
= get_dc_ptr( hdc
)))
1135 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1136 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1137 fwCapability
, lpszOutput
, lpdm
);
1138 release_dc_ptr( dc
);
1145 /************************************************************************
1148 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1156 return AbortDoc( hdc
);
1159 return EndDoc( hdc
);
1161 case GETPHYSPAGESIZE
:
1163 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1164 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1167 case GETPRINTINGOFFSET
:
1169 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1170 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1173 case GETSCALINGFACTOR
:
1175 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1176 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1180 return EndPage( hdc
);
1183 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1190 /* in_data may not be 0 terminated so we must copy it */
1193 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1194 memcpy( name
, in_data
, in_count
);
1197 /* out_data is actually a pointer to the DocInfo structure and used as
1198 * a second input parameter */
1199 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1202 doc
.cbSize
= sizeof(doc
);
1203 doc
.lpszOutput
= NULL
;
1204 doc
.lpszDatatype
= NULL
;
1207 doc
.lpszDocName
= name
;
1208 ret
= StartDocA( hdc
, &doc
);
1209 HeapFree( GetProcessHeap(), 0, name
);
1210 if (ret
> 0) ret
= StartPage( hdc
);
1214 case QUERYESCSUPPORT
:
1218 if (in_count
< sizeof(SHORT
)) return 0;
1219 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1224 case GETPHYSPAGESIZE
:
1225 case GETPRINTINGOFFSET
:
1226 case GETSCALINGFACTOR
:
1228 case QUERYESCSUPPORT
:
1237 /* if not handled internally, pass it to the driver */
1238 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1242 /******************************************************************************
1243 * ExtEscape [GDI32.@]
1245 * Access capabilities of a particular device that are not available through GDI.
1248 * hdc [I] Handle to device context
1249 * nEscape [I] Escape function
1250 * cbInput [I] Number of bytes in input structure
1251 * lpszInData [I] Pointer to input structure
1252 * cbOutput [I] Number of bytes in output structure
1253 * lpszOutData [O] Pointer to output structure
1257 * Not implemented: 0
1260 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1261 INT cbOutput
, LPSTR lpszOutData
)
1265 DC
* dc
= get_dc_ptr( hdc
);
1269 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1270 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1271 release_dc_ptr( dc
);
1276 /*******************************************************************
1277 * DrawEscape [GDI32.@]
1281 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1283 FIXME("DrawEscape, stub\n");
1287 /*******************************************************************
1288 * NamedEscape [GDI32.@]
1290 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1291 INT cbOutput
, LPSTR lpszOutData
)
1293 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1294 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1299 /*******************************************************************
1300 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1301 * GdiEntry13 [GDI32.@]
1303 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1305 static int warn_once
;
1312 /******************************************************************************
1313 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1315 NTSTATUS WINAPI
D3DKMTOpenAdapterFromHdc( void *pData
)
1317 FIXME("(%p): stub\n", pData
);
1318 return STATUS_NO_MEMORY
;
1321 /******************************************************************************
1322 * D3DKMTEscape [GDI32.@]
1324 NTSTATUS WINAPI
D3DKMTEscape( const void *pData
)
1326 FIXME("(%p): stub\n", pData
);
1327 return STATUS_NO_MEMORY
;
1330 /******************************************************************************
1331 * D3DKMTCloseAdapter [GDI32.@]
1333 NTSTATUS WINAPI
D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER
*desc
)
1335 NTSTATUS status
= STATUS_INVALID_PARAMETER
;
1336 struct d3dkmt_adapter
*adapter
;
1338 TRACE("(%p)\n", desc
);
1340 if (!desc
|| !desc
->hAdapter
)
1341 return STATUS_INVALID_PARAMETER
;
1343 EnterCriticalSection( &driver_section
);
1344 LIST_FOR_EACH_ENTRY( adapter
, &d3dkmt_adapters
, struct d3dkmt_adapter
, entry
)
1346 if (adapter
->handle
== desc
->hAdapter
)
1348 list_remove( &adapter
->entry
);
1349 heap_free( adapter
);
1350 status
= STATUS_SUCCESS
;
1354 LeaveCriticalSection( &driver_section
);
1359 /******************************************************************************
1360 * D3DKMTOpenAdapterFromGdiDisplayName [GDI32.@]
1362 NTSTATUS WINAPI
D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME
*desc
)
1364 WCHAR
*end
, key_nameW
[MAX_PATH
], bufferW
[MAX_PATH
];
1365 HDEVINFO devinfo
= INVALID_HANDLE_VALUE
;
1366 NTSTATUS status
= STATUS_UNSUCCESSFUL
;
1367 static D3DKMT_HANDLE handle_start
= 0;
1368 struct d3dkmt_adapter
*adapter
;
1369 SP_DEVINFO_DATA device_data
;
1370 DWORD size
, state_flags
;
1376 TRACE("(%p)\n", desc
);
1379 return STATUS_UNSUCCESSFUL
;
1381 TRACE("DeviceName: %s\n", wine_dbgstr_w( desc
->DeviceName
));
1382 if (wcsnicmp( desc
->DeviceName
, L
"\\\\.\\DISPLAY", lstrlenW(L
"\\\\.\\DISPLAY") ))
1383 return STATUS_UNSUCCESSFUL
;
1385 index
= wcstol( desc
->DeviceName
+ lstrlenW(L
"\\\\.\\DISPLAY"), &end
, 10 ) - 1;
1387 return STATUS_UNSUCCESSFUL
;
1389 adapter
= heap_alloc( sizeof( *adapter
) );
1391 return STATUS_NO_MEMORY
;
1393 /* Get adapter LUID from SetupAPI */
1394 mutex
= get_display_device_init_mutex();
1396 size
= sizeof( bufferW
);
1397 swprintf( key_nameW
, MAX_PATH
, L
"\\Device\\Video%d", index
);
1398 if (RegGetValueW( HKEY_LOCAL_MACHINE
, L
"HARDWARE\\DEVICEMAP\\VIDEO", key_nameW
, RRF_RT_REG_SZ
, NULL
, bufferW
, &size
))
1401 /* Strip \Registry\Machine\ prefix and retrieve Wine specific data set by the display driver */
1402 lstrcpyW( key_nameW
, bufferW
+ 18 );
1403 size
= sizeof( state_flags
);
1404 if (RegGetValueW( HKEY_CURRENT_CONFIG
, key_nameW
, L
"StateFlags", RRF_RT_REG_DWORD
, NULL
,
1405 &state_flags
, &size
))
1408 if (!(state_flags
& DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
))
1411 size
= sizeof( bufferW
);
1412 if (RegGetValueW( HKEY_CURRENT_CONFIG
, key_nameW
, L
"GPUID", RRF_RT_REG_SZ
, NULL
, bufferW
, &size
))
1415 devinfo
= SetupDiCreateDeviceInfoList( &GUID_DEVCLASS_DISPLAY
, NULL
);
1416 device_data
.cbSize
= sizeof( device_data
);
1417 SetupDiOpenDeviceInfoW( devinfo
, bufferW
, NULL
, 0, &device_data
);
1418 if (!SetupDiGetDevicePropertyW( devinfo
, &device_data
, &DEVPROPKEY_GPU_LUID
, &type
,
1419 (BYTE
*)&luid
, sizeof( luid
), NULL
, 0))
1422 EnterCriticalSection( &driver_section
);
1423 /* D3DKMT_HANDLE is UINT, so we can't use pointer as handle */
1424 adapter
->handle
= ++handle_start
;
1425 list_add_tail( &d3dkmt_adapters
, &adapter
->entry
);
1426 LeaveCriticalSection( &driver_section
);
1428 desc
->hAdapter
= handle_start
;
1429 desc
->AdapterLuid
= luid
;
1430 desc
->VidPnSourceId
= index
;
1431 status
= STATUS_SUCCESS
;
1434 SetupDiDestroyDeviceInfoList( devinfo
);
1435 release_display_device_init_mutex( mutex
);
1436 if (status
!= STATUS_SUCCESS
)
1437 heap_free( adapter
);
1441 /******************************************************************************
1442 * D3DKMTCreateDevice [GDI32.@]
1444 NTSTATUS WINAPI
D3DKMTCreateDevice( D3DKMT_CREATEDEVICE
*desc
)
1446 static D3DKMT_HANDLE handle_start
= 0;
1447 struct d3dkmt_adapter
*adapter
;
1448 struct d3dkmt_device
*device
;
1451 TRACE("(%p)\n", desc
);
1454 return STATUS_INVALID_PARAMETER
;
1456 EnterCriticalSection( &driver_section
);
1457 LIST_FOR_EACH_ENTRY( adapter
, &d3dkmt_adapters
, struct d3dkmt_adapter
, entry
)
1459 if (adapter
->handle
== desc
->hAdapter
)
1465 LeaveCriticalSection( &driver_section
);
1468 return STATUS_INVALID_PARAMETER
;
1470 if (desc
->Flags
.LegacyMode
|| desc
->Flags
.RequestVSync
|| desc
->Flags
.DisableGpuTimeout
)
1471 FIXME("Flags unsupported.\n");
1473 device
= heap_alloc_zero( sizeof( *device
) );
1475 return STATUS_NO_MEMORY
;
1477 EnterCriticalSection( &driver_section
);
1478 device
->handle
= ++handle_start
;
1479 list_add_tail( &d3dkmt_devices
, &device
->entry
);
1480 LeaveCriticalSection( &driver_section
);
1482 desc
->hDevice
= device
->handle
;
1483 return STATUS_SUCCESS
;
1486 /******************************************************************************
1487 * D3DKMTDestroyDevice [GDI32.@]
1489 NTSTATUS WINAPI
D3DKMTDestroyDevice( const D3DKMT_DESTROYDEVICE
*desc
)
1491 NTSTATUS status
= STATUS_INVALID_PARAMETER
;
1492 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc
;
1493 struct d3dkmt_device
*device
;
1495 TRACE("(%p)\n", desc
);
1497 if (!desc
|| !desc
->hDevice
)
1498 return STATUS_INVALID_PARAMETER
;
1500 EnterCriticalSection( &driver_section
);
1501 LIST_FOR_EACH_ENTRY( device
, &d3dkmt_devices
, struct d3dkmt_device
, entry
)
1503 if (device
->handle
== desc
->hDevice
)
1505 memset( &set_owner_desc
, 0, sizeof(set_owner_desc
) );
1506 set_owner_desc
.hDevice
= desc
->hDevice
;
1507 D3DKMTSetVidPnSourceOwner( &set_owner_desc
);
1508 list_remove( &device
->entry
);
1509 heap_free( device
);
1510 status
= STATUS_SUCCESS
;
1514 LeaveCriticalSection( &driver_section
);
1519 /******************************************************************************
1520 * D3DKMTQueryStatistics [GDI32.@]
1522 NTSTATUS WINAPI
D3DKMTQueryStatistics(D3DKMT_QUERYSTATISTICS
*stats
)
1524 FIXME("(%p): stub\n", stats
);
1525 return STATUS_SUCCESS
;
1528 /******************************************************************************
1529 * D3DKMTSetQueuedLimit [GDI32.@]
1531 NTSTATUS WINAPI
D3DKMTSetQueuedLimit( D3DKMT_SETQUEUEDLIMIT
*desc
)
1533 FIXME( "(%p): stub\n", desc
);
1534 return STATUS_NOT_IMPLEMENTED
;
1537 /******************************************************************************
1538 * D3DKMTSetVidPnSourceOwner [GDI32.@]
1540 NTSTATUS WINAPI
D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER
*desc
)
1542 TRACE("(%p)\n", desc
);
1544 if (!get_display_driver()->pD3DKMTSetVidPnSourceOwner
)
1545 return STATUS_PROCEDURE_NOT_FOUND
;
1547 if (!desc
|| !desc
->hDevice
|| (desc
->VidPnSourceCount
&& (!desc
->pType
|| !desc
->pVidPnSourceId
)))
1548 return STATUS_INVALID_PARAMETER
;
1550 /* Store the VidPN source ownership info in the graphics driver because
1551 * the graphics driver needs to change ownership sometimes. For example,
1552 * when a new window is moved to a VidPN source with an exclusive owner,
1553 * such an exclusive owner will be released before showing the new window */
1554 return get_display_driver()->pD3DKMTSetVidPnSourceOwner( desc
);
1557 /******************************************************************************
1558 * D3DKMTCheckVidPnExclusiveOwnership [GDI32.@]
1560 NTSTATUS WINAPI
D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP
*desc
)
1562 TRACE("(%p)\n", desc
);
1564 if (!get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership
)
1565 return STATUS_PROCEDURE_NOT_FOUND
;
1567 if (!desc
|| !desc
->hAdapter
)
1568 return STATUS_INVALID_PARAMETER
;
1570 return get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership( desc
);