ntoskrnl.exe: Add KeQueryActiveProcessorCountEx() function.
[wine.git] / dlls / gdi32 / driver.c
blob90977383a58fdd5a108f08354864c3c056eba2a6
1 /*
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
22 #include "config.h"
23 #include "wine/port.h"
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include "ntstatus.h"
30 #define WIN32_NO_STATUS
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "ddrawgdi.h"
35 #include "wine/winbase16.h"
36 #include "winuser.h"
37 #include "winternl.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"
44 #include "wine/heap.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(driver);
48 struct graphics_driver
50 struct list entry;
51 HMODULE module; /* module handle */
52 const struct gdi_dc_funcs *funcs;
55 struct d3dkmt_adapter
57 D3DKMT_HANDLE handle; /* Kernel mode graphics adapter handle */
58 struct list entry; /* List entry */
61 struct d3dkmt_device
63 D3DKMT_HANDLE handle; /* Kernel mode graphics device handle*/
64 struct list entry; /* List entry */
67 static struct list drivers = LIST_INIT( drivers );
68 static struct graphics_driver *display_driver;
70 static struct list d3dkmt_adapters = LIST_INIT( d3dkmt_adapters );
71 static struct list d3dkmt_devices = LIST_INIT( d3dkmt_devices );
73 const struct gdi_dc_funcs *font_driver = NULL;
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 /**********************************************************************
89 * create_driver
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;
102 if (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;
111 return driver;
115 /**********************************************************************
116 * get_display_driver
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)
122 if (!display_driver)
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 /**********************************************************************
138 * is_display_device
140 static BOOL is_display_device( LPCWSTR name )
142 static const WCHAR display_deviceW[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y'};
143 const WCHAR *p = name;
145 if (strncmpiW( name, display_deviceW, sizeof(display_deviceW) / sizeof(WCHAR) ))
146 return FALSE;
148 p += sizeof(display_deviceW) / sizeof(WCHAR);
150 if (!isdigitW( *p++ ))
151 return FALSE;
153 for (; *p; p++)
155 if (!isdigitW( *p ))
156 return FALSE;
159 return TRUE;
163 /**********************************************************************
164 * DRIVER_load_driver
166 const struct gdi_dc_funcs *DRIVER_load_driver( LPCWSTR name )
168 HMODULE module;
169 struct graphics_driver *driver, *new_driver;
170 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
172 /* display driver is a special case */
173 if (!strcmpiW( name, displayW ) || is_display_device( name )) return get_display_driver();
175 if ((module = GetModuleHandleW( name )))
177 if (display_driver && display_driver->module == module) return display_driver->funcs;
179 EnterCriticalSection( &driver_section );
180 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
182 if (driver->module == module) goto done;
184 LeaveCriticalSection( &driver_section );
187 if (!(module = LoadLibraryW( name ))) return NULL;
189 if (!(new_driver = create_driver( module )))
191 FreeLibrary( module );
192 return NULL;
195 /* check if someone else added it in the meantime */
196 EnterCriticalSection( &driver_section );
197 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
199 if (driver->module != module) continue;
200 FreeLibrary( module );
201 HeapFree( GetProcessHeap(), 0, new_driver );
202 goto done;
204 driver = new_driver;
205 list_add_head( &drivers, &driver->entry );
206 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
207 done:
208 LeaveCriticalSection( &driver_section );
209 return driver->funcs;
213 /***********************************************************************
214 * __wine_set_display_driver (GDI32.@)
216 void CDECL __wine_set_display_driver( HMODULE module )
218 struct graphics_driver *driver;
219 HMODULE user32;
221 if (!(driver = create_driver( module )))
223 ERR( "Could not create graphics driver\n" );
224 ExitProcess(1);
226 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
227 HeapFree( GetProcessHeap(), 0, driver );
229 user32 = LoadLibraryA( "user32.dll" );
230 pGetSystemMetrics = (void *)GetProcAddress( user32, "GetSystemMetrics" );
231 pSetThreadDpiAwarenessContext = (void *)GetProcAddress( user32, "SetThreadDpiAwarenessContext" );
235 static INT CDECL nulldrv_AbortDoc( PHYSDEV dev )
237 return 0;
240 static BOOL CDECL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
241 INT xstart, INT ystart, INT xend, INT yend )
243 return TRUE;
246 static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
247 INT xstart, INT ystart, INT xend, INT yend )
249 return TRUE;
252 static BOOL CDECL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
254 if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
255 return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
258 static BOOL CDECL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
259 LPCWSTR output, const DEVMODEW *devmode )
261 assert(0); /* should never be called */
262 return FALSE;
265 static BOOL CDECL nulldrv_DeleteDC( PHYSDEV dev )
267 assert(0); /* should never be called */
268 return TRUE;
271 static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
273 return TRUE;
276 static DWORD CDECL nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
277 WORD cap, LPSTR output, DEVMODEA *devmode )
279 return -1;
282 static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
284 return TRUE;
287 static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
289 return 0;
292 static INT CDECL nulldrv_EndPage( PHYSDEV dev )
294 return 0;
297 static BOOL CDECL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
299 return TRUE;
302 static INT CDECL nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
304 return -1;
307 static INT CDECL nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
308 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
310 return -1;
313 static INT CDECL nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
314 INT out_size, void *out_data )
316 return 0;
319 static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
321 return TRUE;
324 static BOOL CDECL nulldrv_FontIsLinked( PHYSDEV dev )
326 return FALSE;
329 static BOOL CDECL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
331 return FALSE;
334 static UINT CDECL nulldrv_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
336 return DCB_RESET;
339 static BOOL CDECL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
341 return FALSE;
344 static BOOL CDECL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
346 return FALSE;
349 static BOOL CDECL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
351 return FALSE;
354 static BOOL CDECL nulldrv_GetCharWidthInfo( PHYSDEV dev, void *info )
356 return FALSE;
359 static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
361 int bpp;
363 switch (cap)
365 case DRIVERVERSION: return 0x4000;
366 case TECHNOLOGY: return DT_RASDISPLAY;
367 case HORZSIZE: return MulDiv( GetDeviceCaps( dev->hdc, HORZRES ), 254,
368 GetDeviceCaps( dev->hdc, LOGPIXELSX ) * 10 );
369 case VERTSIZE: return MulDiv( GetDeviceCaps( dev->hdc, VERTRES ), 254,
370 GetDeviceCaps( dev->hdc, LOGPIXELSY ) * 10 );
371 case HORZRES: return pGetSystemMetrics ? pGetSystemMetrics( SM_CXSCREEN ) : 640;
372 case VERTRES: return pGetSystemMetrics ? pGetSystemMetrics( SM_CYSCREEN ) : 480;
373 case BITSPIXEL: return 32;
374 case PLANES: return 1;
375 case NUMBRUSHES: return -1;
376 case NUMPENS: return -1;
377 case NUMMARKERS: return 0;
378 case NUMFONTS: return 0;
379 case PDEVICESIZE: return 0;
380 case CURVECAPS: return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
381 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
382 case LINECAPS: return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
383 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
384 case POLYGONALCAPS: return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
385 PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
386 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
387 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
388 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
389 case CLIPCAPS: return CP_RECTANGLE;
390 case RASTERCAPS: return (RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT | RC_DI_BITMAP | RC_DIBTODEV |
391 RC_BIGFONT | RC_STRETCHBLT | RC_FLOODFILL | RC_STRETCHDIB | RC_DEVBITS |
392 (GetDeviceCaps( dev->hdc, SIZEPALETTE ) ? RC_PALETTE : 0));
393 case ASPECTX: return 36;
394 case ASPECTY: return 36;
395 case ASPECTXY: return (int)(hypot( GetDeviceCaps( dev->hdc, ASPECTX ),
396 GetDeviceCaps( dev->hdc, ASPECTY )) + 0.5);
397 case CAPS1: return 0;
398 case SIZEPALETTE: return 0;
399 case NUMRESERVED: return 20;
400 case PHYSICALWIDTH: return 0;
401 case PHYSICALHEIGHT: return 0;
402 case PHYSICALOFFSETX: return 0;
403 case PHYSICALOFFSETY: return 0;
404 case SCALINGFACTORX: return 0;
405 case SCALINGFACTORY: return 0;
406 case VREFRESH: return GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY ? 1 : 0;
407 case DESKTOPHORZRES:
408 if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY && pGetSystemMetrics)
410 DPI_AWARENESS_CONTEXT context;
411 UINT ret;
412 context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
413 ret = pGetSystemMetrics( SM_CXVIRTUALSCREEN );
414 pSetThreadDpiAwarenessContext( context );
415 return ret;
417 return GetDeviceCaps( dev->hdc, HORZRES );
418 case DESKTOPVERTRES:
419 if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY && pGetSystemMetrics)
421 DPI_AWARENESS_CONTEXT context;
422 UINT ret;
423 context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
424 ret = pGetSystemMetrics( SM_CYVIRTUALSCREEN );
425 pSetThreadDpiAwarenessContext( context );
426 return ret;
428 return GetDeviceCaps( dev->hdc, VERTRES );
429 case BLTALIGNMENT: return 0;
430 case SHADEBLENDCAPS: return 0;
431 case COLORMGMTCAPS: return 0;
432 case LOGPIXELSX:
433 case LOGPIXELSY: return get_system_dpi();
434 case NUMCOLORS:
435 bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
436 return (bpp > 8) ? -1 : (1 << bpp);
437 case COLORRES:
438 /* The observed correspondence between BITSPIXEL and COLORRES is:
439 * BITSPIXEL: 8 -> COLORRES: 18
440 * BITSPIXEL: 16 -> COLORRES: 16
441 * BITSPIXEL: 24 -> COLORRES: 24
442 * BITSPIXEL: 32 -> COLORRES: 24 */
443 bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
444 return (bpp <= 8) ? 18 : min( 24, bpp );
445 default:
446 FIXME("(%p): unsupported capability %d, will return 0\n", dev->hdc, cap );
447 return 0;
451 static BOOL CDECL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
453 SetLastError( ERROR_INVALID_PARAMETER );
454 return FALSE;
457 static DWORD CDECL nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
459 return FALSE;
462 static BOOL CDECL nulldrv_GetFontRealizationInfo( PHYSDEV dev, void *info )
464 return FALSE;
467 static DWORD CDECL nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
469 return 0;
472 static DWORD CDECL nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
474 return GDI_ERROR;
477 static DWORD CDECL nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
478 DWORD size, LPVOID buffer, const MAT2 *mat )
480 return GDI_ERROR;
483 static BOOL CDECL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
485 return FALSE;
488 static DWORD CDECL nulldrv_GetImage( PHYSDEV dev, BITMAPINFO *info, struct gdi_image_bits *bits,
489 struct bitblt_coords *src )
491 return ERROR_NOT_SUPPORTED;
494 static DWORD CDECL nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
496 return 0;
499 static UINT CDECL nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
501 return 0;
504 static UINT CDECL nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
506 return DEFAULT_CHARSET;
509 static BOOL CDECL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT *dx )
511 return FALSE;
514 static BOOL CDECL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT *dx )
516 return FALSE;
519 static INT CDECL nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
521 INT ret = 0;
522 LOGFONTW font;
523 DC *dc = get_nulldrv_dc( dev );
525 if (GetObjectW( dc->hFont, sizeof(font), &font ))
527 ret = strlenW( font.lfFaceName ) + 1;
528 if (name)
530 lstrcpynW( name, font.lfFaceName, size );
531 ret = min( size, ret );
534 return ret;
537 static BOOL CDECL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
539 return FALSE;
542 static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
544 return TRUE;
547 static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
549 return TRUE;
552 static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
554 return TRUE;
557 static BOOL CDECL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
559 return TRUE;
562 static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
563 INT xstart, INT ystart, INT xend, INT yend )
565 return TRUE;
568 static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
570 return TRUE;
573 static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
575 return TRUE;
578 static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
580 INT counts[1] = { count };
582 return PolyPolygon( dev->hdc, points, counts, 1 );
585 static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
587 DWORD counts[1] = { count };
589 if (count < 0) return FALSE;
590 return PolyPolyline( dev->hdc, points, counts, 1 );
593 static DWORD CDECL nulldrv_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
594 const struct gdi_image_bits *bits, struct bitblt_coords *src,
595 struct bitblt_coords *dst, DWORD rop )
597 return ERROR_SUCCESS;
600 static UINT CDECL nulldrv_RealizeDefaultPalette( PHYSDEV dev )
602 return 0;
605 static UINT CDECL nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
607 return 0;
610 static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
612 return TRUE;
615 static HDC CDECL nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
617 return 0;
620 static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
621 INT ell_width, INT ell_height )
623 return TRUE;
626 static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
628 return bitmap;
631 static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
633 return brush;
636 static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
638 return palette;
641 static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen, const struct brush_pattern *pattern )
643 return pen;
646 static INT CDECL nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
648 return dir;
651 static COLORREF CDECL nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
653 return color;
656 static INT CDECL nulldrv_SetBkMode( PHYSDEV dev, INT mode )
658 return mode;
661 static UINT CDECL nulldrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
663 return DCB_RESET;
666 static COLORREF CDECL nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
668 return color;
671 static COLORREF CDECL nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
673 return color;
676 static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
680 static DWORD CDECL nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
682 return layout;
685 static BOOL CDECL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
687 SetLastError( ERROR_INVALID_PARAMETER );
688 return FALSE;
691 static DWORD CDECL nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
693 return flags;
696 static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
698 return color;
701 static INT CDECL nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
703 return mode;
706 static INT CDECL nulldrv_SetROP2( PHYSDEV dev, INT rop )
708 return rop;
711 static INT CDECL nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
713 return mode;
716 static INT CDECL nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
718 return mode;
721 static UINT CDECL nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
723 return align;
726 static INT CDECL nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
728 return extra;
731 static COLORREF CDECL nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
733 return color;
736 static BOOL CDECL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
738 return TRUE;
741 static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
743 return 0;
746 static INT CDECL nulldrv_StartPage( PHYSDEV dev )
748 return 1;
751 static BOOL CDECL nulldrv_UnrealizePalette( HPALETTE palette )
753 return FALSE;
756 static NTSTATUS CDECL nulldrv_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc )
758 return STATUS_PROCEDURE_NOT_FOUND;
761 static NTSTATUS CDECL nulldrv_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc )
763 return STATUS_PROCEDURE_NOT_FOUND;
766 static struct opengl_funcs * CDECL nulldrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
768 return (void *)-1;
771 static const struct vulkan_funcs * CDECL nulldrv_wine_get_vulkan_driver( PHYSDEV dev, UINT version )
773 return NULL;
776 const struct gdi_dc_funcs null_driver =
778 nulldrv_AbortDoc, /* pAbortDoc */
779 nulldrv_AbortPath, /* pAbortPath */
780 nulldrv_AlphaBlend, /* pAlphaBlend */
781 nulldrv_AngleArc, /* pAngleArc */
782 nulldrv_Arc, /* pArc */
783 nulldrv_ArcTo, /* pArcTo */
784 nulldrv_BeginPath, /* pBeginPath */
785 nulldrv_BlendImage, /* pBlendImage */
786 nulldrv_Chord, /* pChord */
787 nulldrv_CloseFigure, /* pCloseFigure */
788 nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
789 nulldrv_CreateDC, /* pCreateDC */
790 nulldrv_DeleteDC, /* pDeleteDC */
791 nulldrv_DeleteObject, /* pDeleteObject */
792 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
793 nulldrv_Ellipse, /* pEllipse */
794 nulldrv_EndDoc, /* pEndDoc */
795 nulldrv_EndPage, /* pEndPage */
796 nulldrv_EndPath, /* pEndPath */
797 nulldrv_EnumFonts, /* pEnumFonts */
798 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
799 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
800 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
801 nulldrv_ExtEscape, /* pExtEscape */
802 nulldrv_ExtFloodFill, /* pExtFloodFill */
803 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
804 nulldrv_ExtTextOut, /* pExtTextOut */
805 nulldrv_FillPath, /* pFillPath */
806 nulldrv_FillRgn, /* pFillRgn */
807 nulldrv_FlattenPath, /* pFlattenPath */
808 nulldrv_FontIsLinked, /* pFontIsLinked */
809 nulldrv_FrameRgn, /* pFrameRgn */
810 nulldrv_GdiComment, /* pGdiComment */
811 nulldrv_GetBoundsRect, /* pGetBoundsRect */
812 nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
813 nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
814 nulldrv_GetCharWidth, /* pGetCharWidth */
815 nulldrv_GetCharWidthInfo, /* pGetCharWidthInfo */
816 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
817 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
818 nulldrv_GetFontData, /* pGetFontData */
819 nulldrv_GetFontRealizationInfo, /* pGetFontRealizationInfo */
820 nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
821 nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
822 nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
823 nulldrv_GetICMProfile, /* pGetICMProfile */
824 nulldrv_GetImage, /* pGetImage */
825 nulldrv_GetKerningPairs, /* pGetKerningPairs */
826 nulldrv_GetNearestColor, /* pGetNearestColor */
827 nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
828 nulldrv_GetPixel, /* pGetPixel */
829 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
830 nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
831 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
832 nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
833 nulldrv_GetTextFace, /* pGetTextFace */
834 nulldrv_GetTextMetrics, /* pGetTextMetrics */
835 nulldrv_GradientFill, /* pGradientFill */
836 nulldrv_IntersectClipRect, /* pIntersectClipRect */
837 nulldrv_InvertRgn, /* pInvertRgn */
838 nulldrv_LineTo, /* pLineTo */
839 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
840 nulldrv_MoveTo, /* pMoveTo */
841 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
842 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
843 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
844 nulldrv_PaintRgn, /* pPaintRgn */
845 nulldrv_PatBlt, /* pPatBlt */
846 nulldrv_Pie, /* pPie */
847 nulldrv_PolyBezier, /* pPolyBezier */
848 nulldrv_PolyBezierTo, /* pPolyBezierTo */
849 nulldrv_PolyDraw, /* pPolyDraw */
850 nulldrv_PolyPolygon, /* pPolyPolygon */
851 nulldrv_PolyPolyline, /* pPolyPolyline */
852 nulldrv_Polygon, /* pPolygon */
853 nulldrv_Polyline, /* pPolyline */
854 nulldrv_PolylineTo, /* pPolylineTo */
855 nulldrv_PutImage, /* pPutImage */
856 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
857 nulldrv_RealizePalette, /* pRealizePalette */
858 nulldrv_Rectangle, /* pRectangle */
859 nulldrv_ResetDC, /* pResetDC */
860 nulldrv_RestoreDC, /* pRestoreDC */
861 nulldrv_RoundRect, /* pRoundRect */
862 nulldrv_SaveDC, /* pSaveDC */
863 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
864 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
865 nulldrv_SelectBitmap, /* pSelectBitmap */
866 nulldrv_SelectBrush, /* pSelectBrush */
867 nulldrv_SelectClipPath, /* pSelectClipPath */
868 nulldrv_SelectFont, /* pSelectFont */
869 nulldrv_SelectPalette, /* pSelectPalette */
870 nulldrv_SelectPen, /* pSelectPen */
871 nulldrv_SetArcDirection, /* pSetArcDirection */
872 nulldrv_SetBkColor, /* pSetBkColor */
873 nulldrv_SetBkMode, /* pSetBkMode */
874 nulldrv_SetBoundsRect, /* pSetBoundsRect */
875 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
876 nulldrv_SetDCPenColor, /* pSetDCPenColor */
877 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
878 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
879 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
880 nulldrv_SetLayout, /* pSetLayout */
881 nulldrv_SetMapMode, /* pSetMapMode */
882 nulldrv_SetMapperFlags, /* pSetMapperFlags */
883 nulldrv_SetPixel, /* pSetPixel */
884 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
885 nulldrv_SetROP2, /* pSetROP2 */
886 nulldrv_SetRelAbs, /* pSetRelAbs */
887 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
888 nulldrv_SetTextAlign, /* pSetTextAlign */
889 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
890 nulldrv_SetTextColor, /* pSetTextColor */
891 nulldrv_SetTextJustification, /* pSetTextJustification */
892 nulldrv_SetViewportExtEx, /* pSetViewportExt */
893 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
894 nulldrv_SetWindowExtEx, /* pSetWindowExt */
895 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
896 nulldrv_SetWorldTransform, /* pSetWorldTransform */
897 nulldrv_StartDoc, /* pStartDoc */
898 nulldrv_StartPage, /* pStartPage */
899 nulldrv_StretchBlt, /* pStretchBlt */
900 nulldrv_StretchDIBits, /* pStretchDIBits */
901 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
902 nulldrv_StrokePath, /* pStrokePath */
903 nulldrv_UnrealizePalette, /* pUnrealizePalette */
904 nulldrv_WidenPath, /* pWidenPath */
905 nulldrv_D3DKMTCheckVidPnExclusiveOwnership, /* pD3DKMTCheckVidPnExclusiveOwnership */
906 nulldrv_D3DKMTSetVidPnSourceOwner, /* pD3DKMTSetVidPnSourceOwner */
907 nulldrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
908 nulldrv_wine_get_vulkan_driver, /* wine_get_vulkan_driver */
910 GDI_PRIORITY_NULL_DRV /* priority */
914 /*****************************************************************************
915 * DRIVER_GetDriverName
918 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
920 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
921 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
922 static const WCHAR empty_strW[] = { 0 };
923 WCHAR *p;
925 /* display is a special case */
926 if (!strcmpiW( device, displayW ) ||
927 is_display_device( device ))
929 lstrcpynW( driver, displayW, size );
930 return TRUE;
933 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
934 if(!size) {
935 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
936 return FALSE;
938 p = strchrW(driver, ',');
939 if(!p)
941 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
942 return FALSE;
944 *p = 0;
945 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
946 return TRUE;
950 /***********************************************************************
951 * GdiConvertToDevmodeW (GDI32.@)
953 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
955 DEVMODEW *dmW;
956 WORD dmW_size, dmA_size;
958 dmA_size = dmA->dmSize;
960 /* this is the minimal dmSize that XP accepts */
961 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
962 return NULL;
964 if (dmA_size > sizeof(DEVMODEA))
965 dmA_size = sizeof(DEVMODEA);
967 dmW_size = dmA_size + CCHDEVICENAME;
968 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
969 dmW_size += CCHFORMNAME;
971 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
972 if (!dmW) return NULL;
974 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
975 dmW->dmDeviceName, CCHDEVICENAME);
976 /* copy slightly more, to avoid long computations */
977 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
979 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
981 if (dmA->dmFields & DM_FORMNAME)
982 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
983 dmW->dmFormName, CCHFORMNAME);
984 else
985 dmW->dmFormName[0] = 0;
987 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
988 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
991 if (dmA->dmDriverExtra)
992 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
994 dmW->dmSize = dmW_size;
996 return dmW;
1000 /*****************************************************************************
1001 * @ [GDI32.100]
1003 * This should thunk to 16-bit and simply call the proc with the given args.
1005 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
1006 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
1008 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
1009 return -1;
1012 /*****************************************************************************
1013 * @ [GDI32.101]
1015 * This should load the correct driver for lpszDevice and calls this driver's
1016 * ExtDeviceModePropSheet proc.
1018 * Note: The driver calls a callback routine for each property sheet page; these
1019 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
1020 * The layout of this structure is:
1022 * struct
1024 * DWORD nPages;
1025 * DWORD unknown;
1026 * HPROPSHEETPAGE pages[10];
1027 * };
1029 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
1030 LPCSTR lpszPort, LPVOID lpPropSheet )
1032 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
1033 return -1;
1036 /*****************************************************************************
1037 * @ [GDI32.102]
1039 * This should load the correct driver for lpszDevice and call this driver's
1040 * ExtDeviceMode proc.
1042 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1044 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
1045 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
1046 LPSTR lpszPort, LPDEVMODEA lpdmInput,
1047 LPSTR lpszProfile, DWORD fwMode )
1049 WCHAR deviceW[300];
1050 WCHAR bufW[300];
1051 char buf[300];
1052 HDC hdc;
1053 DC *dc;
1054 INT ret = -1;
1056 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1057 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
1059 if (!lpszDevice) return -1;
1060 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1062 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1064 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1066 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1068 if ((dc = get_dc_ptr( hdc )))
1070 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
1071 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
1072 lpdmInput, lpszProfile, fwMode );
1073 release_dc_ptr( dc );
1075 DeleteDC( hdc );
1076 return ret;
1079 /****************************************************************************
1080 * @ [GDI32.103]
1082 * This should load the correct driver for lpszDevice and calls this driver's
1083 * AdvancedSetupDialog proc.
1085 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
1086 LPDEVMODEA devin, LPDEVMODEA devout )
1088 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
1089 return -1;
1092 /*****************************************************************************
1093 * @ [GDI32.104]
1095 * This should load the correct driver for lpszDevice and calls this driver's
1096 * DeviceCapabilities proc.
1098 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1100 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1101 WORD fwCapability, LPSTR lpszOutput,
1102 LPDEVMODEA lpdm )
1104 WCHAR deviceW[300];
1105 WCHAR bufW[300];
1106 char buf[300];
1107 HDC hdc;
1108 DC *dc;
1109 INT ret = -1;
1111 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1113 if (!lpszDevice) return -1;
1114 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1116 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1118 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1120 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1122 if ((dc = get_dc_ptr( hdc )))
1124 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1125 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1126 fwCapability, lpszOutput, lpdm );
1127 release_dc_ptr( dc );
1129 DeleteDC( hdc );
1130 return ret;
1134 /************************************************************************
1135 * Escape [GDI32.@]
1137 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1139 INT ret;
1140 POINT *pt;
1142 switch (escape)
1144 case ABORTDOC:
1145 return AbortDoc( hdc );
1147 case ENDDOC:
1148 return EndDoc( hdc );
1150 case GETPHYSPAGESIZE:
1151 pt = out_data;
1152 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1153 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1154 return 1;
1156 case GETPRINTINGOFFSET:
1157 pt = out_data;
1158 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1159 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1160 return 1;
1162 case GETSCALINGFACTOR:
1163 pt = out_data;
1164 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1165 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1166 return 1;
1168 case NEWFRAME:
1169 return EndPage( hdc );
1171 case SETABORTPROC:
1172 return SetAbortProc( hdc, (ABORTPROC)in_data );
1174 case STARTDOC:
1176 DOCINFOA doc;
1177 char *name = NULL;
1179 /* in_data may not be 0 terminated so we must copy it */
1180 if (in_data)
1182 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1183 memcpy( name, in_data, in_count );
1184 name[in_count] = 0;
1186 /* out_data is actually a pointer to the DocInfo structure and used as
1187 * a second input parameter */
1188 if (out_data) doc = *(DOCINFOA *)out_data;
1189 else
1191 doc.cbSize = sizeof(doc);
1192 doc.lpszOutput = NULL;
1193 doc.lpszDatatype = NULL;
1194 doc.fwType = 0;
1196 doc.lpszDocName = name;
1197 ret = StartDocA( hdc, &doc );
1198 HeapFree( GetProcessHeap(), 0, name );
1199 if (ret > 0) ret = StartPage( hdc );
1200 return ret;
1203 case QUERYESCSUPPORT:
1205 DWORD code;
1207 if (in_count < sizeof(SHORT)) return 0;
1208 code = (in_count < sizeof(DWORD)) ? *(const USHORT *)in_data : *(const DWORD *)in_data;
1209 switch (code)
1211 case ABORTDOC:
1212 case ENDDOC:
1213 case GETPHYSPAGESIZE:
1214 case GETPRINTINGOFFSET:
1215 case GETSCALINGFACTOR:
1216 case NEWFRAME:
1217 case QUERYESCSUPPORT:
1218 case SETABORTPROC:
1219 case STARTDOC:
1220 return TRUE;
1222 break;
1226 /* if not handled internally, pass it to the driver */
1227 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1231 /******************************************************************************
1232 * ExtEscape [GDI32.@]
1234 * Access capabilities of a particular device that are not available through GDI.
1236 * PARAMS
1237 * hdc [I] Handle to device context
1238 * nEscape [I] Escape function
1239 * cbInput [I] Number of bytes in input structure
1240 * lpszInData [I] Pointer to input structure
1241 * cbOutput [I] Number of bytes in output structure
1242 * lpszOutData [O] Pointer to output structure
1244 * RETURNS
1245 * Success: >0
1246 * Not implemented: 0
1247 * Failure: <0
1249 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1250 INT cbOutput, LPSTR lpszOutData )
1252 PHYSDEV physdev;
1253 INT ret;
1254 DC * dc = get_dc_ptr( hdc );
1256 if (!dc) return 0;
1257 update_dc( dc );
1258 physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1259 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1260 release_dc_ptr( dc );
1261 return ret;
1265 /*******************************************************************
1266 * DrawEscape [GDI32.@]
1270 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1272 FIXME("DrawEscape, stub\n");
1273 return 0;
1276 /*******************************************************************
1277 * NamedEscape [GDI32.@]
1279 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1280 INT cbOutput, LPSTR lpszOutData )
1282 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1283 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1284 lpszOutData);
1285 return 0;
1288 /*******************************************************************
1289 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1290 * GdiEntry13 [GDI32.@]
1292 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1294 static int warn_once;
1296 if (!warn_once++)
1297 FIXME("stub\n");
1298 return 0;
1301 /******************************************************************************
1302 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1304 NTSTATUS WINAPI D3DKMTOpenAdapterFromHdc( void *pData )
1306 FIXME("(%p): stub\n", pData);
1307 return STATUS_NO_MEMORY;
1310 /******************************************************************************
1311 * D3DKMTEscape [GDI32.@]
1313 NTSTATUS WINAPI D3DKMTEscape( const void *pData )
1315 FIXME("(%p): stub\n", pData);
1316 return STATUS_NO_MEMORY;
1319 /******************************************************************************
1320 * D3DKMTCloseAdapter [GDI32.@]
1322 NTSTATUS WINAPI D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER *desc )
1324 NTSTATUS status = STATUS_INVALID_PARAMETER;
1325 struct d3dkmt_adapter *adapter;
1327 TRACE("(%p)\n", desc);
1329 if (!desc || !desc->hAdapter)
1330 return STATUS_INVALID_PARAMETER;
1332 EnterCriticalSection( &driver_section );
1333 LIST_FOR_EACH_ENTRY( adapter, &d3dkmt_adapters, struct d3dkmt_adapter, entry )
1335 if (adapter->handle == desc->hAdapter)
1337 list_remove( &adapter->entry );
1338 heap_free( adapter );
1339 status = STATUS_SUCCESS;
1340 break;
1343 LeaveCriticalSection( &driver_section );
1345 return status;
1348 /******************************************************************************
1349 * D3DKMTOpenAdapterFromGdiDisplayName [GDI32.@]
1351 NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc )
1353 static const WCHAR displayW[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y'};
1354 static D3DKMT_HANDLE handle_start = 0;
1355 struct d3dkmt_adapter *adapter;
1356 WCHAR *end;
1357 int id;
1359 TRACE("(%p) semi-stub\n", desc);
1361 if (!desc || strncmpiW( desc->DeviceName, displayW, ARRAY_SIZE(displayW) ))
1362 return STATUS_UNSUCCESSFUL;
1364 id = strtolW( desc->DeviceName + ARRAY_SIZE(displayW), &end, 10 ) - 1;
1365 if (*end)
1366 return STATUS_UNSUCCESSFUL;
1368 adapter = heap_alloc( sizeof( *adapter ) );
1369 if (!adapter)
1370 return STATUS_NO_MEMORY;
1372 EnterCriticalSection( &driver_section );
1373 /* D3DKMT_HANDLE is UINT, so we can't use pointer as handle */
1374 adapter->handle = ++handle_start;
1375 list_add_tail( &d3dkmt_adapters, &adapter->entry );
1376 LeaveCriticalSection( &driver_section );
1378 desc->hAdapter = handle_start;
1379 /* FIXME: Support AdapterLuid */
1380 desc->AdapterLuid.LowPart = 0;
1381 desc->AdapterLuid.HighPart = 0;
1382 desc->VidPnSourceId = id;
1383 return STATUS_SUCCESS;
1386 /******************************************************************************
1387 * D3DKMTCreateDevice [GDI32.@]
1389 NTSTATUS WINAPI D3DKMTCreateDevice( D3DKMT_CREATEDEVICE *desc )
1391 static D3DKMT_HANDLE handle_start = 0;
1392 struct d3dkmt_adapter *adapter;
1393 struct d3dkmt_device *device;
1394 BOOL found = FALSE;
1396 TRACE("(%p)\n", desc);
1398 if (!desc)
1399 return STATUS_INVALID_PARAMETER;
1401 EnterCriticalSection( &driver_section );
1402 LIST_FOR_EACH_ENTRY( adapter, &d3dkmt_adapters, struct d3dkmt_adapter, entry )
1404 if (adapter->handle == desc->hAdapter)
1406 found = TRUE;
1407 break;
1410 LeaveCriticalSection( &driver_section );
1412 if (!found)
1413 return STATUS_INVALID_PARAMETER;
1415 if (desc->Flags.LegacyMode || desc->Flags.RequestVSync || desc->Flags.DisableGpuTimeout)
1416 FIXME("Flags unsupported.\n");
1418 device = heap_alloc_zero( sizeof( *device ) );
1419 if (!device)
1420 return STATUS_NO_MEMORY;
1422 EnterCriticalSection( &driver_section );
1423 device->handle = ++handle_start;
1424 list_add_tail( &d3dkmt_devices, &device->entry );
1425 LeaveCriticalSection( &driver_section );
1427 desc->hDevice = device->handle;
1428 return STATUS_SUCCESS;
1431 /******************************************************************************
1432 * D3DKMTDestroyDevice [GDI32.@]
1434 NTSTATUS WINAPI D3DKMTDestroyDevice( const D3DKMT_DESTROYDEVICE *desc )
1436 NTSTATUS status = STATUS_INVALID_PARAMETER;
1437 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc;
1438 struct d3dkmt_device *device;
1440 TRACE("(%p)\n", desc);
1442 if (!desc || !desc->hDevice)
1443 return STATUS_INVALID_PARAMETER;
1445 EnterCriticalSection( &driver_section );
1446 LIST_FOR_EACH_ENTRY( device, &d3dkmt_devices, struct d3dkmt_device, entry )
1448 if (device->handle == desc->hDevice)
1450 memset( &set_owner_desc, 0, sizeof(set_owner_desc) );
1451 set_owner_desc.hDevice = desc->hDevice;
1452 D3DKMTSetVidPnSourceOwner( &set_owner_desc );
1453 list_remove( &device->entry );
1454 heap_free( device );
1455 status = STATUS_SUCCESS;
1456 break;
1459 LeaveCriticalSection( &driver_section );
1461 return status;
1464 /******************************************************************************
1465 * D3DKMTQueryStatistics [GDI32.@]
1467 NTSTATUS WINAPI D3DKMTQueryStatistics(D3DKMT_QUERYSTATISTICS *stats)
1469 FIXME("(%p): stub\n", stats);
1470 return STATUS_SUCCESS;
1473 /******************************************************************************
1474 * D3DKMTSetQueuedLimit [GDI32.@]
1476 NTSTATUS WINAPI D3DKMTSetQueuedLimit( D3DKMT_SETQUEUEDLIMIT *desc )
1478 FIXME( "(%p): stub\n", desc );
1479 return STATUS_NOT_IMPLEMENTED;
1482 /******************************************************************************
1483 * D3DKMTSetVidPnSourceOwner [GDI32.@]
1485 NTSTATUS WINAPI D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc )
1487 TRACE("(%p)\n", desc);
1489 if (!get_display_driver()->pD3DKMTSetVidPnSourceOwner)
1490 return STATUS_PROCEDURE_NOT_FOUND;
1492 if (!desc || !desc->hDevice || (desc->VidPnSourceCount && (!desc->pType || !desc->pVidPnSourceId)))
1493 return STATUS_INVALID_PARAMETER;
1495 /* Store the VidPN source ownership info in the graphics driver because
1496 * the graphics driver needs to change ownership sometimes. For example,
1497 * when a new window is moved to a VidPN source with an exclusive owner,
1498 * such an exclusive owner will be released before showing the new window */
1499 return get_display_driver()->pD3DKMTSetVidPnSourceOwner( desc );
1502 /******************************************************************************
1503 * D3DKMTCheckVidPnExclusiveOwnership [GDI32.@]
1505 NTSTATUS WINAPI D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc )
1507 TRACE("(%p)\n", desc);
1509 if (!get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership)
1510 return STATUS_PROCEDURE_NOT_FOUND;
1512 if (!desc || !desc->hAdapter)
1513 return STATUS_INVALID_PARAMETER;
1515 return get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership( desc );