mirrored from git://source.winehq.org/git/wine.git
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
driver.c
1700 lines (1449 loc) · 53 KB
/
driver.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Graphics driver management functions
*
* Copyright 1994 Bob Amstadt
* Copyright 1996, 2001 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winreg.h"
#include "ddrawgdi.h"
#include "wine/winbase16.h"
#include "winuser.h"
#include "winternl.h"
#include "initguid.h"
#include "devguid.h"
#include "setupapi.h"
#include "ddk/d3dkmthk.h"
#include "gdi_private.h"
#include "wine/list.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(driver);
DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
struct graphics_driver
{
struct list entry;
HMODULE module; /* module handle */
const struct gdi_dc_funcs *funcs;
};
struct d3dkmt_adapter
{
D3DKMT_HANDLE handle; /* Kernel mode graphics adapter handle */
struct list entry; /* List entry */
};
struct d3dkmt_device
{
D3DKMT_HANDLE handle; /* Kernel mode graphics device handle*/
struct list entry; /* List entry */
};
static struct list drivers = LIST_INIT( drivers );
static struct graphics_driver *display_driver;
static struct list d3dkmt_adapters = LIST_INIT( d3dkmt_adapters );
static struct list d3dkmt_devices = LIST_INIT( d3dkmt_devices );
static CRITICAL_SECTION driver_section;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &driver_section,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
};
static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static BOOL (WINAPI *pEnumDisplayMonitors)(HDC, LPRECT, MONITORENUMPROC, LPARAM);
static BOOL (WINAPI *pEnumDisplaySettingsW)(LPCWSTR, DWORD, LPDEVMODEW);
static HWND (WINAPI *pGetDesktopWindow)(void);
static BOOL (WINAPI *pGetMonitorInfoW)(HMONITOR, LPMONITORINFO);
static INT (WINAPI *pGetSystemMetrics)(INT);
static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
/**********************************************************************
* create_driver
*
* Allocate and fill the driver structure for a given module.
*/
static struct graphics_driver *create_driver( HMODULE module )
{
static const struct gdi_dc_funcs empty_funcs;
const struct gdi_dc_funcs *funcs = NULL;
struct graphics_driver *driver;
if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
driver->module = module;
if (module)
{
const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int version );
if ((wine_get_gdi_driver = (void *)GetProcAddress( module, "wine_get_gdi_driver" )))
funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
}
if (!funcs) funcs = &empty_funcs;
driver->funcs = funcs;
return driver;
}
/**********************************************************************
* get_display_driver
*
* Special case for loading the display driver: get the name from the config file
*/
static const struct gdi_dc_funcs *get_display_driver(void)
{
if (!display_driver)
{
HMODULE user32 = LoadLibraryA( "user32.dll" );
pGetDesktopWindow = (void *)GetProcAddress( user32, "GetDesktopWindow" );
if (!pGetDesktopWindow() || !display_driver)
{
WARN( "failed to load the display driver, falling back to null driver\n" );
__wine_set_display_driver( 0 );
}
}
return display_driver->funcs;
}
/**********************************************************************
* is_display_device
*/
BOOL is_display_device( LPCWSTR name )
{
const WCHAR *p = name;
if (!name)
return FALSE;
if (wcsnicmp( name, L"\\\\.\\DISPLAY", lstrlenW(L"\\\\.\\DISPLAY") )) return FALSE;
p += lstrlenW(L"\\\\.\\DISPLAY");
if (!iswdigit( *p++ ))
return FALSE;
for (; *p; p++)
{
if (!iswdigit( *p ))
return FALSE;
}
return TRUE;
}
static HANDLE get_display_device_init_mutex( void )
{
HANDLE mutex = CreateMutexW( NULL, FALSE, L"display_device_init" );
WaitForSingleObject( mutex, INFINITE );
return mutex;
}
static void release_display_device_init_mutex( HANDLE mutex )
{
ReleaseMutex( mutex );
CloseHandle( mutex );
}
#ifdef __i386__
static const WCHAR printer_env[] = L"w32x86";
#elif defined __x86_64__
static const WCHAR printer_env[] = L"x64";
#elif defined __arm__
static const WCHAR printer_env[] = L"arm";
#elif defined __aarch64__
static const WCHAR printer_env[] = L"arm64";
#else
#error not defined for this cpu
#endif
/**********************************************************************
* DRIVER_load_driver
*/
const struct gdi_dc_funcs *DRIVER_load_driver( LPCWSTR name )
{
HMODULE module;
struct graphics_driver *driver, *new_driver;
/* display driver is a special case */
if (!wcsicmp( name, L"display" ) || is_display_device( name )) return get_display_driver();
if ((module = GetModuleHandleW( name )))
{
if (display_driver && display_driver->module == module) return display_driver->funcs;
EnterCriticalSection( &driver_section );
LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
{
if (driver->module == module) goto done;
}
LeaveCriticalSection( &driver_section );
}
if (!(module = LoadLibraryW( name )))
{
WCHAR path[MAX_PATH];
GetSystemDirectoryW( path, MAX_PATH );
swprintf( path + wcslen(path), MAX_PATH - wcslen(path), L"\\spool\\drivers\\%s\\3\\%s",
printer_env, name );
if (!(module = LoadLibraryW( path ))) return NULL;
}
if (!(new_driver = create_driver( module )))
{
FreeLibrary( module );
return NULL;
}
/* check if someone else added it in the meantime */
EnterCriticalSection( &driver_section );
LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
{
if (driver->module != module) continue;
FreeLibrary( module );
HeapFree( GetProcessHeap(), 0, new_driver );
goto done;
}
driver = new_driver;
list_add_head( &drivers, &driver->entry );
TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
done:
LeaveCriticalSection( &driver_section );
return driver->funcs;
}
/***********************************************************************
* __wine_set_display_driver (GDI32.@)
*/
void CDECL __wine_set_display_driver( HMODULE module )
{
struct graphics_driver *driver;
HMODULE user32;
if (!(driver = create_driver( module )))
{
ERR( "Could not create graphics driver\n" );
ExitProcess(1);
}
if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
HeapFree( GetProcessHeap(), 0, driver );
user32 = LoadLibraryA( "user32.dll" );
pGetMonitorInfoW = (void *)GetProcAddress( user32, "GetMonitorInfoW" );
pGetSystemMetrics = (void *)GetProcAddress( user32, "GetSystemMetrics" );
pEnumDisplayMonitors = (void *)GetProcAddress( user32, "EnumDisplayMonitors" );
pEnumDisplaySettingsW = (void *)GetProcAddress( user32, "EnumDisplaySettingsW" );
pSetThreadDpiAwarenessContext = (void *)GetProcAddress( user32, "SetThreadDpiAwarenessContext" );
}
struct monitor_info
{
const WCHAR *name;
RECT rect;
};
static BOOL CALLBACK monitor_enum_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lparam )
{
struct monitor_info *info = (struct monitor_info *)lparam;
MONITORINFOEXW mi;
mi.cbSize = sizeof(mi);
pGetMonitorInfoW( monitor, (MONITORINFO *)&mi );
if (!lstrcmpiW( info->name, mi.szDevice ))
{
info->rect = mi.rcMonitor;
return FALSE;
}
return TRUE;
}
static INT CDECL nulldrv_AbortDoc( PHYSDEV dev )
{
return 0;
}
static BOOL CDECL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return TRUE;
}
static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return TRUE;
}
static BOOL CDECL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
{
if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
}
static BOOL CDECL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
LPCWSTR output, const DEVMODEW *devmode )
{
assert(0); /* should never be called */
return FALSE;
}
static BOOL CDECL nulldrv_DeleteDC( PHYSDEV dev )
{
assert(0); /* should never be called */
return TRUE;
}
static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
{
return TRUE;
}
static DWORD CDECL nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
WORD cap, LPSTR output, DEVMODEA *devmode )
{
return -1;
}
static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
{
return TRUE;
}
static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
{
return 0;
}
static INT CDECL nulldrv_EndPage( PHYSDEV dev )
{
return 0;
}
static BOOL CDECL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
{
return TRUE;
}
static INT CDECL nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
{
return -1;
}
static INT CDECL nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
{
return -1;
}
static INT CDECL nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
INT out_size, void *out_data )
{
return 0;
}
static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
{
return TRUE;
}
static BOOL CDECL nulldrv_FontIsLinked( PHYSDEV dev )
{
return FALSE;
}
static BOOL CDECL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
{
return FALSE;
}
static UINT CDECL nulldrv_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
{
return DCB_RESET;
}
static BOOL CDECL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
{
return FALSE;
}
static BOOL CDECL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
{
return FALSE;
}
static BOOL CDECL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
{
return FALSE;
}
static BOOL CDECL nulldrv_GetCharWidthInfo( PHYSDEV dev, void *info )
{
return FALSE;
}
static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
{
int bpp;
switch (cap)
{
case DRIVERVERSION: return 0x4000;
case TECHNOLOGY: return DT_RASDISPLAY;
case HORZSIZE: return MulDiv( GetDeviceCaps( dev->hdc, HORZRES ), 254,
GetDeviceCaps( dev->hdc, LOGPIXELSX ) * 10 );
case VERTSIZE: return MulDiv( GetDeviceCaps( dev->hdc, VERTRES ), 254,
GetDeviceCaps( dev->hdc, LOGPIXELSY ) * 10 );
case HORZRES:
{
DC *dc = get_nulldrv_dc( dev );
struct monitor_info info;
if (dc->display[0] && pEnumDisplayMonitors && pGetMonitorInfoW)
{
info.name = dc->display;
SetRectEmpty( &info.rect );
pEnumDisplayMonitors( NULL, NULL, monitor_enum_proc, (LPARAM)&info );
if (!IsRectEmpty( &info.rect ))
return info.rect.right - info.rect.left;
}
return pGetSystemMetrics ? pGetSystemMetrics( SM_CXSCREEN ) : 640;
}
case VERTRES:
{
DC *dc = get_nulldrv_dc( dev );
struct monitor_info info;
if (dc->display[0] && pEnumDisplayMonitors && pGetMonitorInfoW)
{
info.name = dc->display;
SetRectEmpty( &info.rect );
pEnumDisplayMonitors( NULL, NULL, monitor_enum_proc, (LPARAM)&info );
if (!IsRectEmpty( &info.rect ))
return info.rect.bottom - info.rect.top;
}
return pGetSystemMetrics ? pGetSystemMetrics( SM_CYSCREEN ) : 480;
}
case BITSPIXEL:
{
DEVMODEW devmode;
WCHAR *display;
DC *dc;
if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY && pEnumDisplaySettingsW)
{
dc = get_nulldrv_dc( dev );
display = dc->display[0] ? dc->display : NULL;
memset( &devmode, 0, sizeof(devmode) );
devmode.dmSize = sizeof(devmode);
if (pEnumDisplaySettingsW( display, ENUM_CURRENT_SETTINGS, &devmode )
&& devmode.dmFields & DM_BITSPERPEL && devmode.dmBitsPerPel)
return devmode.dmBitsPerPel;
}
return 32;
}
case PLANES: return 1;
case NUMBRUSHES: return -1;
case NUMPENS: return -1;
case NUMMARKERS: return 0;
case NUMFONTS: return 0;
case PDEVICESIZE: return 0;
case CURVECAPS: return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
case LINECAPS: return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
case POLYGONALCAPS: return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
case CLIPCAPS: return CP_RECTANGLE;
case RASTERCAPS: return (RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT | RC_DI_BITMAP | RC_DIBTODEV |
RC_BIGFONT | RC_STRETCHBLT | RC_FLOODFILL | RC_STRETCHDIB | RC_DEVBITS |
(GetDeviceCaps( dev->hdc, SIZEPALETTE ) ? RC_PALETTE : 0));
case ASPECTX: return 36;
case ASPECTY: return 36;
case ASPECTXY: return (int)(hypot( GetDeviceCaps( dev->hdc, ASPECTX ),
GetDeviceCaps( dev->hdc, ASPECTY )) + 0.5);
case CAPS1: return 0;
case SIZEPALETTE: return 0;
case NUMRESERVED: return 20;
case PHYSICALWIDTH: return 0;
case PHYSICALHEIGHT: return 0;
case PHYSICALOFFSETX: return 0;
case PHYSICALOFFSETY: return 0;
case SCALINGFACTORX: return 0;
case SCALINGFACTORY: return 0;
case VREFRESH:
{
DEVMODEW devmode;
WCHAR *display;
DC *dc;
if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) != DT_RASDISPLAY)
return 0;
if (pEnumDisplaySettingsW)
{
dc = get_nulldrv_dc( dev );
memset( &devmode, 0, sizeof(devmode) );
devmode.dmSize = sizeof(devmode);
display = dc->display[0] ? dc->display : NULL;
if (pEnumDisplaySettingsW( display, ENUM_CURRENT_SETTINGS, &devmode ))
return devmode.dmDisplayFrequency ? devmode.dmDisplayFrequency : 1;
}
return 1;
}
case DESKTOPHORZRES:
if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY && pGetSystemMetrics)
{
DPI_AWARENESS_CONTEXT context;
UINT ret;
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
ret = pGetSystemMetrics( SM_CXVIRTUALSCREEN );
pSetThreadDpiAwarenessContext( context );
return ret;
}
return GetDeviceCaps( dev->hdc, HORZRES );
case DESKTOPVERTRES:
if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY && pGetSystemMetrics)
{
DPI_AWARENESS_CONTEXT context;
UINT ret;
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
ret = pGetSystemMetrics( SM_CYVIRTUALSCREEN );
pSetThreadDpiAwarenessContext( context );
return ret;
}
return GetDeviceCaps( dev->hdc, VERTRES );
case BLTALIGNMENT: return 0;
case SHADEBLENDCAPS: return 0;
case COLORMGMTCAPS: return 0;
case LOGPIXELSX:
case LOGPIXELSY: return get_system_dpi();
case NUMCOLORS:
bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
return (bpp > 8) ? -1 : (1 << bpp);
case COLORRES:
/* The observed correspondence between BITSPIXEL and COLORRES is:
* BITSPIXEL: 8 -> COLORRES: 18
* BITSPIXEL: 16 -> COLORRES: 16
* BITSPIXEL: 24 -> COLORRES: 24
* BITSPIXEL: 32 -> COLORRES: 24 */
bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
return (bpp <= 8) ? 18 : min( 24, bpp );
default:
FIXME("(%p): unsupported capability %d, will return 0\n", dev->hdc, cap );
return 0;
}
}
static BOOL CDECL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
static DWORD CDECL nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
{
return FALSE;
}
static BOOL CDECL nulldrv_GetFontRealizationInfo( PHYSDEV dev, void *info )
{
return FALSE;
}
static DWORD CDECL nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
{
return 0;
}
static DWORD CDECL nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
{
return GDI_ERROR;
}
static DWORD CDECL nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
DWORD size, LPVOID buffer, const MAT2 *mat )
{
return GDI_ERROR;
}
static BOOL CDECL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
{
return FALSE;
}
static DWORD CDECL nulldrv_GetImage( PHYSDEV dev, BITMAPINFO *info, struct gdi_image_bits *bits,
struct bitblt_coords *src )
{
return ERROR_NOT_SUPPORTED;
}
static DWORD CDECL nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
{
return 0;
}
static UINT CDECL nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
{
return 0;
}
static UINT CDECL nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
{
return DEFAULT_CHARSET;
}
static BOOL CDECL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT *dx )
{
return FALSE;
}
static BOOL CDECL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT *dx )
{
return FALSE;
}
static INT CDECL nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
{
INT ret = 0;
LOGFONTW font;
DC *dc = get_nulldrv_dc( dev );
if (GetObjectW( dc->hFont, sizeof(font), &font ))
{
ret = lstrlenW( font.lfFaceName ) + 1;
if (name)
{
lstrcpynW( name, font.lfFaceName, size );
ret = min( size, ret );
}
}
return ret;
}
static BOOL CDECL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
{
return FALSE;
}
static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
{
return TRUE;
}
static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
{
return TRUE;
}
static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
{
return TRUE;
}
static BOOL CDECL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
{
return TRUE;
}
static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return TRUE;
}
static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
{
return TRUE;
}
static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
{
return TRUE;
}
static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
{
INT counts[1] = { count };
return PolyPolygon( dev->hdc, points, counts, 1 );
}
static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
{
DWORD counts[1] = { count };
if (count < 0) return FALSE;
return PolyPolyline( dev->hdc, points, counts, 1 );
}
static DWORD CDECL nulldrv_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
const struct gdi_image_bits *bits, struct bitblt_coords *src,
struct bitblt_coords *dst, DWORD rop )
{
return ERROR_SUCCESS;
}
static UINT CDECL nulldrv_RealizeDefaultPalette( PHYSDEV dev )
{
return 0;
}
static UINT CDECL nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
{
return 0;
}
static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
{
return TRUE;
}
static HDC CDECL nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
{
return 0;
}
static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height )
{
return TRUE;
}
static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
{
return bitmap;
}
static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
{
return brush;
}
static HFONT CDECL nulldrv_SelectFont( PHYSDEV dev, HFONT font, UINT *aa_flags )
{
return font;
}
static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
{
return palette;
}
static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen, const struct brush_pattern *pattern )
{
return pen;
}
static INT CDECL nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
{
return dir;
}
static COLORREF CDECL nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
{
return color;
}
static INT CDECL nulldrv_SetBkMode( PHYSDEV dev, INT mode )
{
return mode;
}
static UINT CDECL nulldrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
{
return DCB_RESET;
}
static COLORREF CDECL nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
{
return color;
}
static COLORREF CDECL nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
{
return color;
}
static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
{
}
static DWORD CDECL nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
{
DC *dc = get_nulldrv_dc( dev );
DWORD old_layout;
old_layout = dc->layout;
dc->layout = layout;
if (layout != old_layout)
{
if (layout & LAYOUT_RTL) dc->MapMode = MM_ANISOTROPIC;
DC_UpdateXforms( dc );
}
return old_layout;
}
static BOOL CDECL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
static DWORD CDECL nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
{
return flags;
}
static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
{
return color;
}
static INT CDECL nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
{
return mode;
}
static INT CDECL nulldrv_SetROP2( PHYSDEV dev, INT rop )
{
return rop;
}
static INT CDECL nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
{
return mode;
}
static INT CDECL nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
{
return mode;
}
static UINT CDECL nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
{
return align;
}
static INT CDECL nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
{
return extra;
}
static COLORREF CDECL nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
{
return color;
}
static BOOL CDECL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
{
return TRUE;
}
static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
{
return 0;
}
static INT CDECL nulldrv_StartPage( PHYSDEV dev )
{
return 1;
}
static BOOL CDECL nulldrv_UnrealizePalette( HPALETTE palette )
{
return FALSE;
}
static NTSTATUS CDECL nulldrv_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc )
{
return STATUS_PROCEDURE_NOT_FOUND;
}
static NTSTATUS CDECL nulldrv_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc )
{
return STATUS_PROCEDURE_NOT_FOUND;
}
static struct opengl_funcs * CDECL nulldrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
{
return (void *)-1;
}
static const struct vulkan_funcs * CDECL nulldrv_wine_get_vulkan_driver( PHYSDEV dev, UINT version )
{
return NULL;
}
const struct gdi_dc_funcs null_driver =
{
nulldrv_AbortDoc, /* pAbortDoc */
nulldrv_AbortPath, /* pAbortPath */
nulldrv_AlphaBlend, /* pAlphaBlend */
nulldrv_AngleArc, /* pAngleArc */
nulldrv_Arc, /* pArc */
nulldrv_ArcTo, /* pArcTo */
nulldrv_BeginPath, /* pBeginPath */
nulldrv_BlendImage, /* pBlendImage */
nulldrv_Chord, /* pChord */
nulldrv_CloseFigure, /* pCloseFigure */
nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
nulldrv_CreateDC, /* pCreateDC */
nulldrv_DeleteDC, /* pDeleteDC */
nulldrv_DeleteObject, /* pDeleteObject */
nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
nulldrv_Ellipse, /* pEllipse */
nulldrv_EndDoc, /* pEndDoc */
nulldrv_EndPage, /* pEndPage */
nulldrv_EndPath, /* pEndPath */
nulldrv_EnumFonts, /* pEnumFonts */
nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
nulldrv_ExcludeClipRect, /* pExcludeClipRect */
nulldrv_ExtDeviceMode, /* pExtDeviceMode */
nulldrv_ExtEscape, /* pExtEscape */
nulldrv_ExtFloodFill, /* pExtFloodFill */
nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
nulldrv_ExtTextOut, /* pExtTextOut */
nulldrv_FillPath, /* pFillPath */
nulldrv_FillRgn, /* pFillRgn */
nulldrv_FlattenPath, /* pFlattenPath */
nulldrv_FontIsLinked, /* pFontIsLinked */
nulldrv_FrameRgn, /* pFrameRgn */
nulldrv_GdiComment, /* pGdiComment */
nulldrv_GetBoundsRect, /* pGetBoundsRect */
nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
nulldrv_GetCharWidth, /* pGetCharWidth */
nulldrv_GetCharWidthInfo, /* pGetCharWidthInfo */
nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
nulldrv_GetFontData, /* pGetFontData */
nulldrv_GetFontRealizationInfo, /* pGetFontRealizationInfo */
nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
nulldrv_GetICMProfile, /* pGetICMProfile */
nulldrv_GetImage, /* pGetImage */
nulldrv_GetKerningPairs, /* pGetKerningPairs */
nulldrv_GetNearestColor, /* pGetNearestColor */
nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
nulldrv_GetPixel, /* pGetPixel */
nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
nulldrv_GetTextFace, /* pGetTextFace */
nulldrv_GetTextMetrics, /* pGetTextMetrics */
nulldrv_GradientFill, /* pGradientFill */
nulldrv_IntersectClipRect, /* pIntersectClipRect */
nulldrv_InvertRgn, /* pInvertRgn */
nulldrv_LineTo, /* pLineTo */
nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
nulldrv_MoveTo, /* pMoveTo */
nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
nulldrv_PaintRgn, /* pPaintRgn */
nulldrv_PatBlt, /* pPatBlt */
nulldrv_Pie, /* pPie */
nulldrv_PolyBezier, /* pPolyBezier */
nulldrv_PolyBezierTo, /* pPolyBezierTo */
nulldrv_PolyDraw, /* pPolyDraw */
nulldrv_PolyPolygon, /* pPolyPolygon */
nulldrv_PolyPolyline, /* pPolyPolyline */
nulldrv_Polygon, /* pPolygon */
nulldrv_Polyline, /* pPolyline */
nulldrv_PolylineTo, /* pPolylineTo */
nulldrv_PutImage, /* pPutImage */
nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */