gdi32: Take DPI awareness into account for the LOGPIXELSX/Y device caps.
[wine.git] / dlls / gdi32 / driver.c
blobc81a2e103d4e99811ca37e37d0df24b59bd2ebb4
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 "windef.h"
30 #include "winbase.h"
31 #include "ddrawgdi.h"
32 #include "wine/winbase16.h"
33 #include "winternl.h"
35 #include "gdi_private.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(driver);
42 struct graphics_driver
44 struct list entry;
45 HMODULE module; /* module handle */
46 const struct gdi_dc_funcs *funcs;
49 static struct list drivers = LIST_INIT( drivers );
50 static struct graphics_driver *display_driver;
52 const struct gdi_dc_funcs *font_driver = NULL;
54 static CRITICAL_SECTION driver_section;
55 static CRITICAL_SECTION_DEBUG critsect_debug =
57 0, 0, &driver_section,
58 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
59 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
61 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
63 /**********************************************************************
64 * create_driver
66 * Allocate and fill the driver structure for a given module.
68 static struct graphics_driver *create_driver( HMODULE module )
70 static const struct gdi_dc_funcs empty_funcs;
71 const struct gdi_dc_funcs *funcs = NULL;
72 struct graphics_driver *driver;
74 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
75 driver->module = module;
77 if (module)
79 const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int version );
81 if ((wine_get_gdi_driver = (void *)GetProcAddress( module, "wine_get_gdi_driver" )))
82 funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
84 if (!funcs) funcs = &empty_funcs;
85 driver->funcs = funcs;
86 return driver;
90 /**********************************************************************
91 * get_display_driver
93 * Special case for loading the display driver: get the name from the config file
95 static const struct gdi_dc_funcs *get_display_driver(void)
97 if (!display_driver)
99 HMODULE user32 = LoadLibraryA( "user32.dll" );
100 HWND (WINAPI *pGetDesktopWindow)(void) = (void *)GetProcAddress( user32, "GetDesktopWindow" );
102 if (!pGetDesktopWindow() || !display_driver)
104 WARN( "failed to load the display driver, falling back to null driver\n" );
105 __wine_set_display_driver( 0 );
108 return display_driver->funcs;
112 /**********************************************************************
113 * DRIVER_load_driver
115 const struct gdi_dc_funcs *DRIVER_load_driver( LPCWSTR name )
117 HMODULE module;
118 struct graphics_driver *driver, *new_driver;
119 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
120 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
122 /* display driver is a special case */
123 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return get_display_driver();
125 if ((module = GetModuleHandleW( name )))
127 if (display_driver && display_driver->module == module) return display_driver->funcs;
129 EnterCriticalSection( &driver_section );
130 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
132 if (driver->module == module) goto done;
134 LeaveCriticalSection( &driver_section );
137 if (!(module = LoadLibraryW( name ))) return NULL;
139 if (!(new_driver = create_driver( module )))
141 FreeLibrary( module );
142 return NULL;
145 /* check if someone else added it in the meantime */
146 EnterCriticalSection( &driver_section );
147 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
149 if (driver->module != module) continue;
150 FreeLibrary( module );
151 HeapFree( GetProcessHeap(), 0, new_driver );
152 goto done;
154 driver = new_driver;
155 list_add_head( &drivers, &driver->entry );
156 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
157 done:
158 LeaveCriticalSection( &driver_section );
159 return driver->funcs;
163 /***********************************************************************
164 * __wine_set_display_driver (GDI32.@)
166 void CDECL __wine_set_display_driver( HMODULE module )
168 struct graphics_driver *driver;
170 if (!(driver = create_driver( module )))
172 ERR( "Could not create graphics driver\n" );
173 ExitProcess(1);
175 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
176 HeapFree( GetProcessHeap(), 0, driver );
180 static INT nulldrv_AbortDoc( PHYSDEV dev )
182 return 0;
185 static BOOL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
186 INT xstart, INT ystart, INT xend, INT yend )
188 return TRUE;
191 static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
192 INT xstart, INT ystart, INT xend, INT yend )
194 return TRUE;
197 static BOOL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
199 if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
200 return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
203 static BOOL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
204 LPCWSTR output, const DEVMODEW *devmode )
206 assert(0); /* should never be called */
207 return FALSE;
210 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
212 assert(0); /* should never be called */
213 return TRUE;
216 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
218 return TRUE;
221 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
222 WORD cap, LPSTR output, DEVMODEA *devmode )
224 return -1;
227 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
229 return TRUE;
232 static INT nulldrv_EndDoc( PHYSDEV dev )
234 return 0;
237 static INT nulldrv_EndPage( PHYSDEV dev )
239 return 0;
242 static BOOL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
244 return TRUE;
247 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
249 return -1;
252 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
253 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
255 return -1;
258 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
259 INT out_size, void *out_data )
261 return 0;
264 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
266 return TRUE;
269 static BOOL nulldrv_FontIsLinked( PHYSDEV dev )
271 return FALSE;
274 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
276 return FALSE;
279 static UINT nulldrv_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
281 return DCB_RESET;
284 static BOOL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
286 return FALSE;
289 static BOOL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
291 return FALSE;
294 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
296 return FALSE;
299 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
301 int bpp;
303 switch (cap)
305 case DRIVERVERSION: return 0x4000;
306 case TECHNOLOGY: return DT_RASDISPLAY;
307 case HORZSIZE: return MulDiv( GetDeviceCaps( dev->hdc, HORZRES ), 254,
308 GetDeviceCaps( dev->hdc, LOGPIXELSX ) * 10 );
309 case VERTSIZE: return MulDiv( GetDeviceCaps( dev->hdc, VERTRES ), 254,
310 GetDeviceCaps( dev->hdc, LOGPIXELSY ) * 10 );
311 case HORZRES: return 640;
312 case VERTRES: return 480;
313 case BITSPIXEL: return 32;
314 case PLANES: return 1;
315 case NUMBRUSHES: return -1;
316 case NUMPENS: return -1;
317 case NUMMARKERS: return 0;
318 case NUMFONTS: return 0;
319 case PDEVICESIZE: return 0;
320 case CURVECAPS: return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
321 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
322 case LINECAPS: return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
323 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
324 case POLYGONALCAPS: return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
325 PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
326 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
327 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
328 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
329 case CLIPCAPS: return CP_RECTANGLE;
330 case RASTERCAPS: return (RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT | RC_DI_BITMAP | RC_DIBTODEV |
331 RC_BIGFONT | RC_STRETCHBLT | RC_FLOODFILL | RC_STRETCHDIB | RC_DEVBITS |
332 (GetDeviceCaps( dev->hdc, SIZEPALETTE ) ? RC_PALETTE : 0));
333 case ASPECTX: return 36;
334 case ASPECTY: return 36;
335 case ASPECTXY: return (int)(hypot( GetDeviceCaps( dev->hdc, ASPECTX ),
336 GetDeviceCaps( dev->hdc, ASPECTY )) + 0.5);
337 case CAPS1: return 0;
338 case SIZEPALETTE: return 0;
339 case NUMRESERVED: return 20;
340 case PHYSICALWIDTH: return 0;
341 case PHYSICALHEIGHT: return 0;
342 case PHYSICALOFFSETX: return 0;
343 case PHYSICALOFFSETY: return 0;
344 case SCALINGFACTORX: return 0;
345 case SCALINGFACTORY: return 0;
346 case VREFRESH: return GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY ? 1 : 0;
347 case DESKTOPVERTRES: return GetDeviceCaps( dev->hdc, VERTRES );
348 case DESKTOPHORZRES: return GetDeviceCaps( dev->hdc, HORZRES );
349 case BLTALIGNMENT: return 0;
350 case SHADEBLENDCAPS: return 0;
351 case COLORMGMTCAPS: return 0;
352 case LOGPIXELSX:
353 case LOGPIXELSY: return get_system_dpi();
354 case NUMCOLORS:
355 bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
356 return (bpp > 8) ? -1 : (1 << bpp);
357 case COLORRES:
358 /* The observed correspondence between BITSPIXEL and COLORRES is:
359 * BITSPIXEL: 8 -> COLORRES: 18
360 * BITSPIXEL: 16 -> COLORRES: 16
361 * BITSPIXEL: 24 -> COLORRES: 24
362 * BITSPIXEL: 32 -> COLORRES: 24 */
363 bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
364 return (bpp <= 8) ? 18 : min( 24, bpp );
365 default:
366 FIXME("(%p): unsupported capability %d, will return 0\n", dev->hdc, cap );
367 return 0;
371 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
373 SetLastError( ERROR_INVALID_PARAMETER );
374 return FALSE;
377 static DWORD nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
379 return FALSE;
382 static BOOL nulldrv_GetFontRealizationInfo( PHYSDEV dev, void *info )
384 return FALSE;
387 static DWORD nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
389 return 0;
392 static DWORD nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
394 return GDI_ERROR;
397 static DWORD nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
398 DWORD size, LPVOID buffer, const MAT2 *mat )
400 return GDI_ERROR;
403 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
405 return FALSE;
408 static DWORD nulldrv_GetImage( PHYSDEV dev, BITMAPINFO *info, struct gdi_image_bits *bits,
409 struct bitblt_coords *src )
411 return ERROR_NOT_SUPPORTED;
414 static DWORD nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
416 return 0;
419 static UINT nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
421 return 0;
424 static UINT nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
426 return DEFAULT_CHARSET;
429 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT *dx )
431 return FALSE;
434 static BOOL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT *dx )
436 return FALSE;
439 static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
441 INT ret = 0;
442 LOGFONTW font;
443 DC *dc = get_nulldrv_dc( dev );
445 if (GetObjectW( dc->hFont, sizeof(font), &font ))
447 ret = strlenW( font.lfFaceName ) + 1;
448 if (name)
450 lstrcpynW( name, font.lfFaceName, size );
451 ret = min( size, ret );
454 return ret;
457 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
459 return FALSE;
462 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
464 return TRUE;
467 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
469 return TRUE;
472 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
474 return TRUE;
477 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
479 return TRUE;
482 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
483 INT xstart, INT ystart, INT xend, INT yend )
485 return TRUE;
488 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
490 return TRUE;
493 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
495 return TRUE;
498 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
500 INT counts[1] = { count };
502 return PolyPolygon( dev->hdc, points, counts, 1 );
505 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
507 DWORD counts[1] = { count };
509 if (count < 0) return FALSE;
510 return PolyPolyline( dev->hdc, points, counts, 1 );
513 static DWORD nulldrv_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
514 const struct gdi_image_bits *bits, struct bitblt_coords *src,
515 struct bitblt_coords *dst, DWORD rop )
517 return ERROR_SUCCESS;
520 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
522 return 0;
525 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
527 return 0;
530 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
532 return TRUE;
535 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
537 return 0;
540 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
541 INT ell_width, INT ell_height )
543 return TRUE;
546 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
548 return bitmap;
551 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
553 return brush;
556 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
558 return palette;
561 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen, const struct brush_pattern *pattern )
563 return pen;
566 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
568 return dir;
571 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
573 return color;
576 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
578 return mode;
581 static UINT nulldrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
583 return DCB_RESET;
586 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
588 return color;
591 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
593 return color;
596 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
600 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
602 return layout;
605 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
607 SetLastError( ERROR_INVALID_PARAMETER );
608 return FALSE;
611 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
613 return flags;
616 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
618 return color;
621 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
623 return mode;
626 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
628 return rop;
631 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
633 return mode;
636 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
638 return mode;
641 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
643 return align;
646 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
648 return extra;
651 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
653 return color;
656 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
658 return TRUE;
661 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
663 return 0;
666 static INT nulldrv_StartPage( PHYSDEV dev )
668 return 1;
671 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
673 return FALSE;
676 static struct opengl_funcs *nulldrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
678 return (void *)-1;
681 static const struct vulkan_funcs *nulldrv_wine_get_vulkan_driver( PHYSDEV dev, UINT version )
683 return NULL;
686 const struct gdi_dc_funcs null_driver =
688 nulldrv_AbortDoc, /* pAbortDoc */
689 nulldrv_AbortPath, /* pAbortPath */
690 nulldrv_AlphaBlend, /* pAlphaBlend */
691 nulldrv_AngleArc, /* pAngleArc */
692 nulldrv_Arc, /* pArc */
693 nulldrv_ArcTo, /* pArcTo */
694 nulldrv_BeginPath, /* pBeginPath */
695 nulldrv_BlendImage, /* pBlendImage */
696 nulldrv_Chord, /* pChord */
697 nulldrv_CloseFigure, /* pCloseFigure */
698 nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
699 nulldrv_CreateDC, /* pCreateDC */
700 nulldrv_DeleteDC, /* pDeleteDC */
701 nulldrv_DeleteObject, /* pDeleteObject */
702 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
703 nulldrv_Ellipse, /* pEllipse */
704 nulldrv_EndDoc, /* pEndDoc */
705 nulldrv_EndPage, /* pEndPage */
706 nulldrv_EndPath, /* pEndPath */
707 nulldrv_EnumFonts, /* pEnumFonts */
708 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
709 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
710 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
711 nulldrv_ExtEscape, /* pExtEscape */
712 nulldrv_ExtFloodFill, /* pExtFloodFill */
713 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
714 nulldrv_ExtTextOut, /* pExtTextOut */
715 nulldrv_FillPath, /* pFillPath */
716 nulldrv_FillRgn, /* pFillRgn */
717 nulldrv_FlattenPath, /* pFlattenPath */
718 nulldrv_FontIsLinked, /* pFontIsLinked */
719 nulldrv_FrameRgn, /* pFrameRgn */
720 nulldrv_GdiComment, /* pGdiComment */
721 nulldrv_GetBoundsRect, /* pGetBoundsRect */
722 nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
723 nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
724 nulldrv_GetCharWidth, /* pGetCharWidth */
725 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
726 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
727 nulldrv_GetFontData, /* pGetFontData */
728 nulldrv_GetFontRealizationInfo, /* pGetFontRealizationInfo */
729 nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
730 nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
731 nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
732 nulldrv_GetICMProfile, /* pGetICMProfile */
733 nulldrv_GetImage, /* pGetImage */
734 nulldrv_GetKerningPairs, /* pGetKerningPairs */
735 nulldrv_GetNearestColor, /* pGetNearestColor */
736 nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
737 nulldrv_GetPixel, /* pGetPixel */
738 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
739 nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
740 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
741 nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
742 nulldrv_GetTextFace, /* pGetTextFace */
743 nulldrv_GetTextMetrics, /* pGetTextMetrics */
744 nulldrv_GradientFill, /* pGradientFill */
745 nulldrv_IntersectClipRect, /* pIntersectClipRect */
746 nulldrv_InvertRgn, /* pInvertRgn */
747 nulldrv_LineTo, /* pLineTo */
748 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
749 nulldrv_MoveTo, /* pMoveTo */
750 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
751 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
752 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
753 nulldrv_PaintRgn, /* pPaintRgn */
754 nulldrv_PatBlt, /* pPatBlt */
755 nulldrv_Pie, /* pPie */
756 nulldrv_PolyBezier, /* pPolyBezier */
757 nulldrv_PolyBezierTo, /* pPolyBezierTo */
758 nulldrv_PolyDraw, /* pPolyDraw */
759 nulldrv_PolyPolygon, /* pPolyPolygon */
760 nulldrv_PolyPolyline, /* pPolyPolyline */
761 nulldrv_Polygon, /* pPolygon */
762 nulldrv_Polyline, /* pPolyline */
763 nulldrv_PolylineTo, /* pPolylineTo */
764 nulldrv_PutImage, /* pPutImage */
765 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
766 nulldrv_RealizePalette, /* pRealizePalette */
767 nulldrv_Rectangle, /* pRectangle */
768 nulldrv_ResetDC, /* pResetDC */
769 nulldrv_RestoreDC, /* pRestoreDC */
770 nulldrv_RoundRect, /* pRoundRect */
771 nulldrv_SaveDC, /* pSaveDC */
772 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
773 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
774 nulldrv_SelectBitmap, /* pSelectBitmap */
775 nulldrv_SelectBrush, /* pSelectBrush */
776 nulldrv_SelectClipPath, /* pSelectClipPath */
777 nulldrv_SelectFont, /* pSelectFont */
778 nulldrv_SelectPalette, /* pSelectPalette */
779 nulldrv_SelectPen, /* pSelectPen */
780 nulldrv_SetArcDirection, /* pSetArcDirection */
781 nulldrv_SetBkColor, /* pSetBkColor */
782 nulldrv_SetBkMode, /* pSetBkMode */
783 nulldrv_SetBoundsRect, /* pSetBoundsRect */
784 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
785 nulldrv_SetDCPenColor, /* pSetDCPenColor */
786 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
787 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
788 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
789 nulldrv_SetLayout, /* pSetLayout */
790 nulldrv_SetMapMode, /* pSetMapMode */
791 nulldrv_SetMapperFlags, /* pSetMapperFlags */
792 nulldrv_SetPixel, /* pSetPixel */
793 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
794 nulldrv_SetROP2, /* pSetROP2 */
795 nulldrv_SetRelAbs, /* pSetRelAbs */
796 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
797 nulldrv_SetTextAlign, /* pSetTextAlign */
798 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
799 nulldrv_SetTextColor, /* pSetTextColor */
800 nulldrv_SetTextJustification, /* pSetTextJustification */
801 nulldrv_SetViewportExtEx, /* pSetViewportExt */
802 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
803 nulldrv_SetWindowExtEx, /* pSetWindowExt */
804 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
805 nulldrv_SetWorldTransform, /* pSetWorldTransform */
806 nulldrv_StartDoc, /* pStartDoc */
807 nulldrv_StartPage, /* pStartPage */
808 nulldrv_StretchBlt, /* pStretchBlt */
809 nulldrv_StretchDIBits, /* pStretchDIBits */
810 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
811 nulldrv_StrokePath, /* pStrokePath */
812 nulldrv_UnrealizePalette, /* pUnrealizePalette */
813 nulldrv_WidenPath, /* pWidenPath */
814 nulldrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
815 nulldrv_wine_get_vulkan_driver, /* wine_get_vulkan_driver */
817 GDI_PRIORITY_NULL_DRV /* priority */
821 /*****************************************************************************
822 * DRIVER_GetDriverName
825 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
827 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
828 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
829 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
830 static const WCHAR empty_strW[] = { 0 };
831 WCHAR *p;
833 /* display is a special case */
834 if (!strcmpiW( device, displayW ) ||
835 !strcmpiW( device, display1W ))
837 lstrcpynW( driver, displayW, size );
838 return TRUE;
841 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
842 if(!size) {
843 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
844 return FALSE;
846 p = strchrW(driver, ',');
847 if(!p)
849 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
850 return FALSE;
852 *p = 0;
853 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
854 return TRUE;
858 /***********************************************************************
859 * GdiConvertToDevmodeW (GDI32.@)
861 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
863 DEVMODEW *dmW;
864 WORD dmW_size, dmA_size;
866 dmA_size = dmA->dmSize;
868 /* this is the minimal dmSize that XP accepts */
869 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
870 return NULL;
872 if (dmA_size > sizeof(DEVMODEA))
873 dmA_size = sizeof(DEVMODEA);
875 dmW_size = dmA_size + CCHDEVICENAME;
876 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
877 dmW_size += CCHFORMNAME;
879 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
880 if (!dmW) return NULL;
882 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
883 dmW->dmDeviceName, CCHDEVICENAME);
884 /* copy slightly more, to avoid long computations */
885 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
887 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
889 if (dmA->dmFields & DM_FORMNAME)
890 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
891 dmW->dmFormName, CCHFORMNAME);
892 else
893 dmW->dmFormName[0] = 0;
895 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
896 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
899 if (dmA->dmDriverExtra)
900 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
902 dmW->dmSize = dmW_size;
904 return dmW;
908 /*****************************************************************************
909 * @ [GDI32.100]
911 * This should thunk to 16-bit and simply call the proc with the given args.
913 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
914 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
916 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
917 return -1;
920 /*****************************************************************************
921 * @ [GDI32.101]
923 * This should load the correct driver for lpszDevice and calls this driver's
924 * ExtDeviceModePropSheet proc.
926 * Note: The driver calls a callback routine for each property sheet page; these
927 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
928 * The layout of this structure is:
930 * struct
932 * DWORD nPages;
933 * DWORD unknown;
934 * HPROPSHEETPAGE pages[10];
935 * };
937 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
938 LPCSTR lpszPort, LPVOID lpPropSheet )
940 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
941 return -1;
944 /*****************************************************************************
945 * @ [GDI32.102]
947 * This should load the correct driver for lpszDevice and call this driver's
948 * ExtDeviceMode proc.
950 * FIXME: convert ExtDeviceMode to unicode in the driver interface
952 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
953 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
954 LPSTR lpszPort, LPDEVMODEA lpdmInput,
955 LPSTR lpszProfile, DWORD fwMode )
957 WCHAR deviceW[300];
958 WCHAR bufW[300];
959 char buf[300];
960 HDC hdc;
961 DC *dc;
962 INT ret = -1;
964 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
965 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
967 if (!lpszDevice) return -1;
968 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
970 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
972 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
974 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
976 if ((dc = get_dc_ptr( hdc )))
978 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
979 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
980 lpdmInput, lpszProfile, fwMode );
981 release_dc_ptr( dc );
983 DeleteDC( hdc );
984 return ret;
987 /****************************************************************************
988 * @ [GDI32.103]
990 * This should load the correct driver for lpszDevice and calls this driver's
991 * AdvancedSetupDialog proc.
993 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
994 LPDEVMODEA devin, LPDEVMODEA devout )
996 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
997 return -1;
1000 /*****************************************************************************
1001 * @ [GDI32.104]
1003 * This should load the correct driver for lpszDevice and calls this driver's
1004 * DeviceCapabilities proc.
1006 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1008 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1009 WORD fwCapability, LPSTR lpszOutput,
1010 LPDEVMODEA lpdm )
1012 WCHAR deviceW[300];
1013 WCHAR bufW[300];
1014 char buf[300];
1015 HDC hdc;
1016 DC *dc;
1017 INT ret = -1;
1019 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1021 if (!lpszDevice) return -1;
1022 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1024 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1026 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1028 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1030 if ((dc = get_dc_ptr( hdc )))
1032 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1033 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1034 fwCapability, lpszOutput, lpdm );
1035 release_dc_ptr( dc );
1037 DeleteDC( hdc );
1038 return ret;
1042 /************************************************************************
1043 * Escape [GDI32.@]
1045 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1047 INT ret;
1048 POINT *pt;
1050 switch (escape)
1052 case ABORTDOC:
1053 return AbortDoc( hdc );
1055 case ENDDOC:
1056 return EndDoc( hdc );
1058 case GETPHYSPAGESIZE:
1059 pt = out_data;
1060 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1061 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1062 return 1;
1064 case GETPRINTINGOFFSET:
1065 pt = out_data;
1066 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1067 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1068 return 1;
1070 case GETSCALINGFACTOR:
1071 pt = out_data;
1072 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1073 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1074 return 1;
1076 case NEWFRAME:
1077 return EndPage( hdc );
1079 case SETABORTPROC:
1080 return SetAbortProc( hdc, (ABORTPROC)in_data );
1082 case STARTDOC:
1084 DOCINFOA doc;
1085 char *name = NULL;
1087 /* in_data may not be 0 terminated so we must copy it */
1088 if (in_data)
1090 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1091 memcpy( name, in_data, in_count );
1092 name[in_count] = 0;
1094 /* out_data is actually a pointer to the DocInfo structure and used as
1095 * a second input parameter */
1096 if (out_data) doc = *(DOCINFOA *)out_data;
1097 else
1099 doc.cbSize = sizeof(doc);
1100 doc.lpszOutput = NULL;
1101 doc.lpszDatatype = NULL;
1102 doc.fwType = 0;
1104 doc.lpszDocName = name;
1105 ret = StartDocA( hdc, &doc );
1106 HeapFree( GetProcessHeap(), 0, name );
1107 if (ret > 0) ret = StartPage( hdc );
1108 return ret;
1111 case QUERYESCSUPPORT:
1113 DWORD code;
1115 if (in_count < sizeof(SHORT)) return 0;
1116 code = (in_count < sizeof(DWORD)) ? *(const USHORT *)in_data : *(const DWORD *)in_data;
1117 switch (code)
1119 case ABORTDOC:
1120 case ENDDOC:
1121 case GETPHYSPAGESIZE:
1122 case GETPRINTINGOFFSET:
1123 case GETSCALINGFACTOR:
1124 case NEWFRAME:
1125 case QUERYESCSUPPORT:
1126 case SETABORTPROC:
1127 case STARTDOC:
1128 return TRUE;
1130 break;
1134 /* if not handled internally, pass it to the driver */
1135 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1139 /******************************************************************************
1140 * ExtEscape [GDI32.@]
1142 * Access capabilities of a particular device that are not available through GDI.
1144 * PARAMS
1145 * hdc [I] Handle to device context
1146 * nEscape [I] Escape function
1147 * cbInput [I] Number of bytes in input structure
1148 * lpszInData [I] Pointer to input structure
1149 * cbOutput [I] Number of bytes in output structure
1150 * lpszOutData [O] Pointer to output structure
1152 * RETURNS
1153 * Success: >0
1154 * Not implemented: 0
1155 * Failure: <0
1157 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1158 INT cbOutput, LPSTR lpszOutData )
1160 PHYSDEV physdev;
1161 INT ret;
1162 DC * dc = get_dc_ptr( hdc );
1164 if (!dc) return 0;
1165 update_dc( dc );
1166 physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1167 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1168 release_dc_ptr( dc );
1169 return ret;
1173 /*******************************************************************
1174 * DrawEscape [GDI32.@]
1178 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1180 FIXME("DrawEscape, stub\n");
1181 return 0;
1184 /*******************************************************************
1185 * NamedEscape [GDI32.@]
1187 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1188 INT cbOutput, LPSTR lpszOutData )
1190 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1191 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1192 lpszOutData);
1193 return 0;
1196 /*******************************************************************
1197 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1198 * GdiEntry13 [GDI32.@]
1200 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1202 static int warn_once;
1204 if (!warn_once++)
1205 FIXME("stub\n");
1206 return 0;
1209 /******************************************************************************
1210 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1212 NTSTATUS WINAPI D3DKMTOpenAdapterFromHdc( void *pData )
1214 FIXME("(%p): stub\n", pData);
1215 return STATUS_NO_MEMORY;
1218 /******************************************************************************
1219 * D3DKMTEscape [GDI32.@]
1221 NTSTATUS WINAPI D3DKMTEscape( const void *pData )
1223 FIXME("(%p): stub\n", pData);
1224 return STATUS_NO_MEMORY;