2 * Graphics driver management functions
4 * Copyright 1994 Bob Amstadt
5 * Copyright 1996, 2001 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
32 #include "wine/winbase16.h"
36 #include "gdi_private.h"
37 #include "wine/unicode.h"
38 #include "wine/list.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(driver
);
43 struct graphics_driver
46 HMODULE module
; /* module handle */
47 const struct gdi_dc_funcs
*funcs
;
50 static struct list drivers
= LIST_INIT( drivers
);
51 static struct graphics_driver
*display_driver
;
53 const struct gdi_dc_funcs
*font_driver
= NULL
;
55 static CRITICAL_SECTION driver_section
;
56 static CRITICAL_SECTION_DEBUG critsect_debug
=
58 0, 0, &driver_section
,
59 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
60 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
62 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
64 static typeof(GetDesktopWindow
) *pGetDesktopWindow
;
65 static typeof(GetSystemMetrics
) *pGetSystemMetrics
;
66 static typeof(SetThreadDpiAwarenessContext
) *pSetThreadDpiAwarenessContext
;
68 /**********************************************************************
71 * Allocate and fill the driver structure for a given module.
73 static struct graphics_driver
*create_driver( HMODULE module
)
75 static const struct gdi_dc_funcs empty_funcs
;
76 const struct gdi_dc_funcs
*funcs
= NULL
;
77 struct graphics_driver
*driver
;
79 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
80 driver
->module
= module
;
84 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
86 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
87 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
89 if (!funcs
) funcs
= &empty_funcs
;
90 driver
->funcs
= funcs
;
95 /**********************************************************************
98 * Special case for loading the display driver: get the name from the config file
100 static const struct gdi_dc_funcs
*get_display_driver(void)
104 HMODULE user32
= LoadLibraryA( "user32.dll" );
105 pGetDesktopWindow
= (void *)GetProcAddress( user32
, "GetDesktopWindow" );
107 if (!pGetDesktopWindow() || !display_driver
)
109 WARN( "failed to load the display driver, falling back to null driver\n" );
110 __wine_set_display_driver( 0 );
113 return display_driver
->funcs
;
117 /**********************************************************************
120 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
123 struct graphics_driver
*driver
, *new_driver
;
124 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
125 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
127 /* display driver is a special case */
128 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
)) return get_display_driver();
130 if ((module
= GetModuleHandleW( name
)))
132 if (display_driver
&& display_driver
->module
== module
) return display_driver
->funcs
;
134 EnterCriticalSection( &driver_section
);
135 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
137 if (driver
->module
== module
) goto done
;
139 LeaveCriticalSection( &driver_section
);
142 if (!(module
= LoadLibraryW( name
))) return NULL
;
144 if (!(new_driver
= create_driver( module
)))
146 FreeLibrary( module
);
150 /* check if someone else added it in the meantime */
151 EnterCriticalSection( &driver_section
);
152 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
154 if (driver
->module
!= module
) continue;
155 FreeLibrary( module
);
156 HeapFree( GetProcessHeap(), 0, new_driver
);
160 list_add_head( &drivers
, &driver
->entry
);
161 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
163 LeaveCriticalSection( &driver_section
);
164 return driver
->funcs
;
168 /***********************************************************************
169 * __wine_set_display_driver (GDI32.@)
171 void CDECL
__wine_set_display_driver( HMODULE module
)
173 struct graphics_driver
*driver
;
176 if (!(driver
= create_driver( module
)))
178 ERR( "Could not create graphics driver\n" );
181 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
182 HeapFree( GetProcessHeap(), 0, driver
);
184 user32
= LoadLibraryA( "user32.dll" );
185 pGetSystemMetrics
= (void *)GetProcAddress( user32
, "GetSystemMetrics" );
186 pSetThreadDpiAwarenessContext
= (void *)GetProcAddress( user32
, "SetThreadDpiAwarenessContext" );
190 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
195 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
196 INT xstart
, INT ystart
, INT xend
, INT yend
)
201 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
202 INT xstart
, INT ystart
, INT xend
, INT yend
)
207 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
209 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
210 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
213 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
214 LPCWSTR output
, const DEVMODEW
*devmode
)
216 assert(0); /* should never be called */
220 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
222 assert(0); /* should never be called */
226 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
231 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
232 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
237 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
242 static INT
nulldrv_EndDoc( PHYSDEV dev
)
247 static INT
nulldrv_EndPage( PHYSDEV dev
)
252 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
257 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
262 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
263 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
268 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
269 INT out_size
, void *out_data
)
274 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
279 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
284 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
289 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
294 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
299 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
304 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
309 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
315 case DRIVERVERSION
: return 0x4000;
316 case TECHNOLOGY
: return DT_RASDISPLAY
;
317 case HORZSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, HORZRES
), 254,
318 GetDeviceCaps( dev
->hdc
, LOGPIXELSX
) * 10 );
319 case VERTSIZE
: return MulDiv( GetDeviceCaps( dev
->hdc
, VERTRES
), 254,
320 GetDeviceCaps( dev
->hdc
, LOGPIXELSY
) * 10 );
321 case HORZRES
: return pGetSystemMetrics
? pGetSystemMetrics( SM_CXSCREEN
) : 640;
322 case VERTRES
: return pGetSystemMetrics
? pGetSystemMetrics( SM_CYSCREEN
) : 480;
323 case BITSPIXEL
: return 32;
324 case PLANES
: return 1;
325 case NUMBRUSHES
: return -1;
326 case NUMPENS
: return -1;
327 case NUMMARKERS
: return 0;
328 case NUMFONTS
: return 0;
329 case PDEVICESIZE
: return 0;
330 case CURVECAPS
: return (CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
| CC_WIDE
|
331 CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
);
332 case LINECAPS
: return (LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
333 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
);
334 case POLYGONALCAPS
: return (PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
| PC_SCANLINE
|
335 PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
);
336 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
337 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
338 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
339 case CLIPCAPS
: return CP_RECTANGLE
;
340 case RASTERCAPS
: return (RC_BITBLT
| RC_BITMAP64
| RC_GDI20_OUTPUT
| RC_DI_BITMAP
| RC_DIBTODEV
|
341 RC_BIGFONT
| RC_STRETCHBLT
| RC_FLOODFILL
| RC_STRETCHDIB
| RC_DEVBITS
|
342 (GetDeviceCaps( dev
->hdc
, SIZEPALETTE
) ? RC_PALETTE
: 0));
343 case ASPECTX
: return 36;
344 case ASPECTY
: return 36;
345 case ASPECTXY
: return (int)(hypot( GetDeviceCaps( dev
->hdc
, ASPECTX
),
346 GetDeviceCaps( dev
->hdc
, ASPECTY
)) + 0.5);
347 case CAPS1
: return 0;
348 case SIZEPALETTE
: return 0;
349 case NUMRESERVED
: return 20;
350 case PHYSICALWIDTH
: return 0;
351 case PHYSICALHEIGHT
: return 0;
352 case PHYSICALOFFSETX
: return 0;
353 case PHYSICALOFFSETY
: return 0;
354 case SCALINGFACTORX
: return 0;
355 case SCALINGFACTORY
: return 0;
356 case VREFRESH
: return GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
? 1 : 0;
358 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
360 DPI_AWARENESS_CONTEXT context
;
362 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
363 ret
= pGetSystemMetrics( SM_CXVIRTUALSCREEN
);
364 pSetThreadDpiAwarenessContext( context
);
367 return GetDeviceCaps( dev
->hdc
, HORZRES
);
369 if (GetDeviceCaps( dev
->hdc
, TECHNOLOGY
) == DT_RASDISPLAY
&& pGetSystemMetrics
)
371 DPI_AWARENESS_CONTEXT context
;
373 context
= pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
374 ret
= pGetSystemMetrics( SM_CYVIRTUALSCREEN
);
375 pSetThreadDpiAwarenessContext( context
);
378 return GetDeviceCaps( dev
->hdc
, VERTRES
);
379 case BLTALIGNMENT
: return 0;
380 case SHADEBLENDCAPS
: return 0;
381 case COLORMGMTCAPS
: return 0;
383 case LOGPIXELSY
: return get_system_dpi();
385 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
386 return (bpp
> 8) ? -1 : (1 << bpp
);
388 /* The observed correspondence between BITSPIXEL and COLORRES is:
389 * BITSPIXEL: 8 -> COLORRES: 18
390 * BITSPIXEL: 16 -> COLORRES: 16
391 * BITSPIXEL: 24 -> COLORRES: 24
392 * BITSPIXEL: 32 -> COLORRES: 24 */
393 bpp
= GetDeviceCaps( dev
->hdc
, BITSPIXEL
);
394 return (bpp
<= 8) ? 18 : min( 24, bpp
);
396 FIXME("(%p): unsupported capability %d, will return 0\n", dev
->hdc
, cap
);
401 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
403 SetLastError( ERROR_INVALID_PARAMETER
);
407 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
412 static BOOL
nulldrv_GetFontRealizationInfo( PHYSDEV dev
, void *info
)
417 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
422 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
427 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
428 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
433 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
438 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
439 struct bitblt_coords
*src
)
441 return ERROR_NOT_SUPPORTED
;
444 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
449 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
454 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
456 return DEFAULT_CHARSET
;
459 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
464 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
469 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
473 DC
*dc
= get_nulldrv_dc( dev
);
475 if (GetObjectW( dc
->hFont
, sizeof(font
), &font
))
477 ret
= strlenW( font
.lfFaceName
) + 1;
480 lstrcpynW( name
, font
.lfFaceName
, size
);
481 ret
= min( size
, ret
);
487 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
492 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
497 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
502 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
507 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
512 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
513 INT xstart
, INT ystart
, INT xend
, INT yend
)
518 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
523 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
528 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
530 INT counts
[1] = { count
};
532 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
535 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
537 DWORD counts
[1] = { count
};
539 if (count
< 0) return FALSE
;
540 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
543 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
544 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
545 struct bitblt_coords
*dst
, DWORD rop
)
547 return ERROR_SUCCESS
;
550 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
555 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
560 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
565 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
570 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
571 INT ell_width
, INT ell_height
)
576 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
581 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
586 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
591 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
596 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
601 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
606 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
611 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
616 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
621 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
626 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
630 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
635 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
637 SetLastError( ERROR_INVALID_PARAMETER
);
641 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
646 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
651 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
656 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
661 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
666 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
671 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
676 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
681 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
686 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
691 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
696 static INT
nulldrv_StartPage( PHYSDEV dev
)
701 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
706 static struct opengl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
711 static const struct vulkan_funcs
*nulldrv_wine_get_vulkan_driver( PHYSDEV dev
, UINT version
)
716 const struct gdi_dc_funcs null_driver
=
718 nulldrv_AbortDoc
, /* pAbortDoc */
719 nulldrv_AbortPath
, /* pAbortPath */
720 nulldrv_AlphaBlend
, /* pAlphaBlend */
721 nulldrv_AngleArc
, /* pAngleArc */
722 nulldrv_Arc
, /* pArc */
723 nulldrv_ArcTo
, /* pArcTo */
724 nulldrv_BeginPath
, /* pBeginPath */
725 nulldrv_BlendImage
, /* pBlendImage */
726 nulldrv_Chord
, /* pChord */
727 nulldrv_CloseFigure
, /* pCloseFigure */
728 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
729 nulldrv_CreateDC
, /* pCreateDC */
730 nulldrv_DeleteDC
, /* pDeleteDC */
731 nulldrv_DeleteObject
, /* pDeleteObject */
732 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
733 nulldrv_Ellipse
, /* pEllipse */
734 nulldrv_EndDoc
, /* pEndDoc */
735 nulldrv_EndPage
, /* pEndPage */
736 nulldrv_EndPath
, /* pEndPath */
737 nulldrv_EnumFonts
, /* pEnumFonts */
738 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
739 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
740 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
741 nulldrv_ExtEscape
, /* pExtEscape */
742 nulldrv_ExtFloodFill
, /* pExtFloodFill */
743 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
744 nulldrv_ExtTextOut
, /* pExtTextOut */
745 nulldrv_FillPath
, /* pFillPath */
746 nulldrv_FillRgn
, /* pFillRgn */
747 nulldrv_FlattenPath
, /* pFlattenPath */
748 nulldrv_FontIsLinked
, /* pFontIsLinked */
749 nulldrv_FrameRgn
, /* pFrameRgn */
750 nulldrv_GdiComment
, /* pGdiComment */
751 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
752 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
753 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
754 nulldrv_GetCharWidth
, /* pGetCharWidth */
755 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
756 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
757 nulldrv_GetFontData
, /* pGetFontData */
758 nulldrv_GetFontRealizationInfo
, /* pGetFontRealizationInfo */
759 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
760 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
761 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
762 nulldrv_GetICMProfile
, /* pGetICMProfile */
763 nulldrv_GetImage
, /* pGetImage */
764 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
765 nulldrv_GetNearestColor
, /* pGetNearestColor */
766 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
767 nulldrv_GetPixel
, /* pGetPixel */
768 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
769 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
770 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
771 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
772 nulldrv_GetTextFace
, /* pGetTextFace */
773 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
774 nulldrv_GradientFill
, /* pGradientFill */
775 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
776 nulldrv_InvertRgn
, /* pInvertRgn */
777 nulldrv_LineTo
, /* pLineTo */
778 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
779 nulldrv_MoveTo
, /* pMoveTo */
780 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
781 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
782 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
783 nulldrv_PaintRgn
, /* pPaintRgn */
784 nulldrv_PatBlt
, /* pPatBlt */
785 nulldrv_Pie
, /* pPie */
786 nulldrv_PolyBezier
, /* pPolyBezier */
787 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
788 nulldrv_PolyDraw
, /* pPolyDraw */
789 nulldrv_PolyPolygon
, /* pPolyPolygon */
790 nulldrv_PolyPolyline
, /* pPolyPolyline */
791 nulldrv_Polygon
, /* pPolygon */
792 nulldrv_Polyline
, /* pPolyline */
793 nulldrv_PolylineTo
, /* pPolylineTo */
794 nulldrv_PutImage
, /* pPutImage */
795 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
796 nulldrv_RealizePalette
, /* pRealizePalette */
797 nulldrv_Rectangle
, /* pRectangle */
798 nulldrv_ResetDC
, /* pResetDC */
799 nulldrv_RestoreDC
, /* pRestoreDC */
800 nulldrv_RoundRect
, /* pRoundRect */
801 nulldrv_SaveDC
, /* pSaveDC */
802 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
803 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
804 nulldrv_SelectBitmap
, /* pSelectBitmap */
805 nulldrv_SelectBrush
, /* pSelectBrush */
806 nulldrv_SelectClipPath
, /* pSelectClipPath */
807 nulldrv_SelectFont
, /* pSelectFont */
808 nulldrv_SelectPalette
, /* pSelectPalette */
809 nulldrv_SelectPen
, /* pSelectPen */
810 nulldrv_SetArcDirection
, /* pSetArcDirection */
811 nulldrv_SetBkColor
, /* pSetBkColor */
812 nulldrv_SetBkMode
, /* pSetBkMode */
813 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
814 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
815 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
816 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
817 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
818 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
819 nulldrv_SetLayout
, /* pSetLayout */
820 nulldrv_SetMapMode
, /* pSetMapMode */
821 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
822 nulldrv_SetPixel
, /* pSetPixel */
823 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
824 nulldrv_SetROP2
, /* pSetROP2 */
825 nulldrv_SetRelAbs
, /* pSetRelAbs */
826 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
827 nulldrv_SetTextAlign
, /* pSetTextAlign */
828 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
829 nulldrv_SetTextColor
, /* pSetTextColor */
830 nulldrv_SetTextJustification
, /* pSetTextJustification */
831 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
832 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
833 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
834 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
835 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
836 nulldrv_StartDoc
, /* pStartDoc */
837 nulldrv_StartPage
, /* pStartPage */
838 nulldrv_StretchBlt
, /* pStretchBlt */
839 nulldrv_StretchDIBits
, /* pStretchDIBits */
840 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
841 nulldrv_StrokePath
, /* pStrokePath */
842 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
843 nulldrv_WidenPath
, /* pWidenPath */
844 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
845 nulldrv_wine_get_vulkan_driver
, /* wine_get_vulkan_driver */
847 GDI_PRIORITY_NULL_DRV
/* priority */
851 /*****************************************************************************
852 * DRIVER_GetDriverName
855 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
857 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
858 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
859 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
860 static const WCHAR empty_strW
[] = { 0 };
863 /* display is a special case */
864 if (!strcmpiW( device
, displayW
) ||
865 !strcmpiW( device
, display1W
))
867 lstrcpynW( driver
, displayW
, size
);
871 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
873 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
876 p
= strchrW(driver
, ',');
879 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
883 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
888 /***********************************************************************
889 * GdiConvertToDevmodeW (GDI32.@)
891 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
894 WORD dmW_size
, dmA_size
;
896 dmA_size
= dmA
->dmSize
;
898 /* this is the minimal dmSize that XP accepts */
899 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
902 if (dmA_size
> sizeof(DEVMODEA
))
903 dmA_size
= sizeof(DEVMODEA
);
905 dmW_size
= dmA_size
+ CCHDEVICENAME
;
906 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
907 dmW_size
+= CCHFORMNAME
;
909 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
910 if (!dmW
) return NULL
;
912 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
913 dmW
->dmDeviceName
, CCHDEVICENAME
);
914 /* copy slightly more, to avoid long computations */
915 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
917 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
919 if (dmA
->dmFields
& DM_FORMNAME
)
920 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
921 dmW
->dmFormName
, CCHFORMNAME
);
923 dmW
->dmFormName
[0] = 0;
925 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
926 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
929 if (dmA
->dmDriverExtra
)
930 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
932 dmW
->dmSize
= dmW_size
;
938 /*****************************************************************************
941 * This should thunk to 16-bit and simply call the proc with the given args.
943 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
944 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
946 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
950 /*****************************************************************************
953 * This should load the correct driver for lpszDevice and calls this driver's
954 * ExtDeviceModePropSheet proc.
956 * Note: The driver calls a callback routine for each property sheet page; these
957 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
958 * The layout of this structure is:
964 * HPROPSHEETPAGE pages[10];
967 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
968 LPCSTR lpszPort
, LPVOID lpPropSheet
)
970 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
974 /*****************************************************************************
977 * This should load the correct driver for lpszDevice and call this driver's
978 * ExtDeviceMode proc.
980 * FIXME: convert ExtDeviceMode to unicode in the driver interface
982 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
983 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
984 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
985 LPSTR lpszProfile
, DWORD fwMode
)
994 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
995 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
997 if (!lpszDevice
) return -1;
998 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1000 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1002 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1004 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1006 if ((dc
= get_dc_ptr( hdc
)))
1008 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
1009 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1010 lpdmInput
, lpszProfile
, fwMode
);
1011 release_dc_ptr( dc
);
1017 /****************************************************************************
1020 * This should load the correct driver for lpszDevice and calls this driver's
1021 * AdvancedSetupDialog proc.
1023 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1024 LPDEVMODEA devin
, LPDEVMODEA devout
)
1026 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1030 /*****************************************************************************
1033 * This should load the correct driver for lpszDevice and calls this driver's
1034 * DeviceCapabilities proc.
1036 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1038 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1039 WORD fwCapability
, LPSTR lpszOutput
,
1049 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1051 if (!lpszDevice
) return -1;
1052 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1054 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1056 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1058 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1060 if ((dc
= get_dc_ptr( hdc
)))
1062 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1063 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1064 fwCapability
, lpszOutput
, lpdm
);
1065 release_dc_ptr( dc
);
1072 /************************************************************************
1075 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1083 return AbortDoc( hdc
);
1086 return EndDoc( hdc
);
1088 case GETPHYSPAGESIZE
:
1090 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1091 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1094 case GETPRINTINGOFFSET
:
1096 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1097 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1100 case GETSCALINGFACTOR
:
1102 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1103 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1107 return EndPage( hdc
);
1110 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1117 /* in_data may not be 0 terminated so we must copy it */
1120 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1121 memcpy( name
, in_data
, in_count
);
1124 /* out_data is actually a pointer to the DocInfo structure and used as
1125 * a second input parameter */
1126 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1129 doc
.cbSize
= sizeof(doc
);
1130 doc
.lpszOutput
= NULL
;
1131 doc
.lpszDatatype
= NULL
;
1134 doc
.lpszDocName
= name
;
1135 ret
= StartDocA( hdc
, &doc
);
1136 HeapFree( GetProcessHeap(), 0, name
);
1137 if (ret
> 0) ret
= StartPage( hdc
);
1141 case QUERYESCSUPPORT
:
1145 if (in_count
< sizeof(SHORT
)) return 0;
1146 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1151 case GETPHYSPAGESIZE
:
1152 case GETPRINTINGOFFSET
:
1153 case GETSCALINGFACTOR
:
1155 case QUERYESCSUPPORT
:
1164 /* if not handled internally, pass it to the driver */
1165 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1169 /******************************************************************************
1170 * ExtEscape [GDI32.@]
1172 * Access capabilities of a particular device that are not available through GDI.
1175 * hdc [I] Handle to device context
1176 * nEscape [I] Escape function
1177 * cbInput [I] Number of bytes in input structure
1178 * lpszInData [I] Pointer to input structure
1179 * cbOutput [I] Number of bytes in output structure
1180 * lpszOutData [O] Pointer to output structure
1184 * Not implemented: 0
1187 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1188 INT cbOutput
, LPSTR lpszOutData
)
1192 DC
* dc
= get_dc_ptr( hdc
);
1196 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1197 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1198 release_dc_ptr( dc
);
1203 /*******************************************************************
1204 * DrawEscape [GDI32.@]
1208 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1210 FIXME("DrawEscape, stub\n");
1214 /*******************************************************************
1215 * NamedEscape [GDI32.@]
1217 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1218 INT cbOutput
, LPSTR lpszOutData
)
1220 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1221 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1226 /*******************************************************************
1227 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1228 * GdiEntry13 [GDI32.@]
1230 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1232 static int warn_once
;
1239 /******************************************************************************
1240 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1242 NTSTATUS WINAPI
D3DKMTOpenAdapterFromHdc( void *pData
)
1244 FIXME("(%p): stub\n", pData
);
1245 return STATUS_NO_MEMORY
;
1248 /******************************************************************************
1249 * D3DKMTEscape [GDI32.@]
1251 NTSTATUS WINAPI
D3DKMTEscape( const void *pData
)
1253 FIXME("(%p): stub\n", pData
);
1254 return STATUS_NO_MEMORY
;