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"
33 #include "wine/winbase16.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
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 /**********************************************************************
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
;
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
;
90 /**********************************************************************
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 struct graphics_driver
*driver
;
98 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
102 if (display_driver
) return display_driver
->funcs
; /* already loaded */
104 strcpy( buffer
, "x11" ); /* default value */
105 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
106 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
108 DWORD type
, count
= sizeof(buffer
);
109 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
116 next
= strchr( name
, ',' );
117 if (next
) *next
++ = 0;
119 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
120 if ((module
= LoadLibraryA( libname
)) != 0) break;
124 if (!(driver
= create_driver( module
)))
126 MESSAGE( "Could not create graphics driver '%s'\n", buffer
);
127 FreeLibrary( module
);
130 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
132 /* somebody beat us to it */
133 FreeLibrary( driver
->module
);
134 HeapFree( GetProcessHeap(), 0, driver
);
136 return display_driver
->funcs
;
140 /**********************************************************************
143 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
146 struct graphics_driver
*driver
, *new_driver
;
147 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
148 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
150 /* display driver is a special case */
151 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
)) return get_display_driver();
153 if ((module
= GetModuleHandleW( name
)))
155 if (display_driver
&& display_driver
->module
== module
) return display_driver
->funcs
;
156 EnterCriticalSection( &driver_section
);
157 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
159 if (driver
->module
== module
) goto done
;
161 LeaveCriticalSection( &driver_section
);
164 if (!(module
= LoadLibraryW( name
))) return NULL
;
166 if (!(new_driver
= create_driver( module
)))
168 FreeLibrary( module
);
172 /* check if someone else added it in the meantime */
173 EnterCriticalSection( &driver_section
);
174 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
176 if (driver
->module
!= module
) continue;
177 FreeLibrary( module
);
178 HeapFree( GetProcessHeap(), 0, new_driver
);
182 list_add_head( &drivers
, &driver
->entry
);
183 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
185 LeaveCriticalSection( &driver_section
);
186 return driver
->funcs
;
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 INT
nulldrv_ChoosePixelFormat( PHYSDEV dev
, const PIXELFORMATDESCRIPTOR
*descr
)
206 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
207 INT xstart
, INT ystart
, INT xend
, INT yend
)
212 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
214 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
215 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
218 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
219 LPCWSTR output
, const DEVMODEW
*devmode
)
221 assert(0); /* should never be called */
225 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
227 assert(0); /* should never be called */
231 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
236 static INT
nulldrv_DescribePixelFormat( PHYSDEV dev
, INT format
, UINT size
, PIXELFORMATDESCRIPTOR
* descr
)
241 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
242 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
247 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
252 static INT
nulldrv_EndDoc( PHYSDEV dev
)
257 static INT
nulldrv_EndPage( PHYSDEV dev
)
262 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
267 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
272 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
273 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
278 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
279 INT out_size
, void *out_data
)
284 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
289 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
294 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
299 static BOOL
nulldrv_GdiRealizationInfo( PHYSDEV dev
, void *info
)
304 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
309 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
314 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
319 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
324 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
326 switch (cap
) /* return meaningful values for some entries */
328 case HORZRES
: return 640;
329 case VERTRES
: return 480;
330 case BITSPIXEL
: return 1;
331 case PLANES
: return 1;
332 case NUMCOLORS
: return 2;
333 case ASPECTX
: return 36;
334 case ASPECTY
: return 36;
335 case ASPECTXY
: return 51;
336 case LOGPIXELSX
: return 72;
337 case LOGPIXELSY
: return 72;
338 case SIZEPALETTE
: return 2;
339 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
340 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
341 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
346 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
348 SetLastError( ERROR_INVALID_PARAMETER
);
352 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
357 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
362 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
367 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
368 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
373 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
378 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
379 struct bitblt_coords
*src
)
381 return ERROR_NOT_SUPPORTED
;
384 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
389 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
394 static INT
nulldrv_GetPixelFormat( PHYSDEV dev
)
399 static UINT
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
, UINT count
, PALETTEENTRY
*entries
)
404 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
406 return DEFAULT_CHARSET
;
409 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT max_ext
,
410 INT
*fit
, INT
*dx
, SIZE
*size
)
415 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT max_ext
,
416 INT
*fit
, INT
*dx
, SIZE
*size
)
421 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
425 HFONT hfont
= GetCurrentObject( dev
->hdc
, OBJ_FONT
);
427 if (GetObjectW( hfont
, sizeof(font
), &font
))
429 ret
= strlenW( font
.lfFaceName
) + 1;
432 lstrcpynW( name
, font
.lfFaceName
, size
);
433 ret
= min( size
, ret
);
439 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
444 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
449 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
454 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
459 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
464 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
465 INT xstart
, INT ystart
, INT xend
, INT yend
)
470 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
475 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
480 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
482 INT counts
[1] = { count
};
484 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
487 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
489 DWORD counts
[1] = { count
};
491 if (count
< 0) return FALSE
;
492 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
495 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
496 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
497 struct bitblt_coords
*dst
, DWORD rop
)
499 return ERROR_SUCCESS
;
502 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
507 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
512 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
517 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
522 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
523 INT ell_width
, INT ell_height
)
528 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
533 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
538 static HFONT
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
)
543 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
548 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
553 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
558 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
563 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
568 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
573 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
578 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
583 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
587 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
592 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
594 SetLastError( ERROR_INVALID_PARAMETER
);
598 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
603 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
608 static BOOL
nulldrv_SetPixelFormat( PHYSDEV dev
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
613 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
618 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
623 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
628 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
633 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
638 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
643 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
648 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
653 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
658 static INT
nulldrv_StartPage( PHYSDEV dev
)
663 static BOOL
nulldrv_SwapBuffers( PHYSDEV dev
)
668 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
673 static HGLRC
nulldrv_wglCreateContext( PHYSDEV dev
)
678 static HGLRC
nulldrv_wglCreateContextAttribsARB( PHYSDEV dev
, HGLRC share_ctx
, const int *attribs
)
683 static PROC
nulldrv_wglGetProcAddress( LPCSTR name
)
688 static const struct wgl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
693 const struct gdi_dc_funcs null_driver
=
695 nulldrv_AbortDoc
, /* pAbortDoc */
696 nulldrv_AbortPath
, /* pAbortPath */
697 nulldrv_AlphaBlend
, /* pAlphaBlend */
698 nulldrv_AngleArc
, /* pAngleArc */
699 nulldrv_Arc
, /* pArc */
700 nulldrv_ArcTo
, /* pArcTo */
701 nulldrv_BeginPath
, /* pBeginPath */
702 nulldrv_BlendImage
, /* pBlendImage */
703 nulldrv_ChoosePixelFormat
, /* pChoosePixelFormat */
704 nulldrv_Chord
, /* pChord */
705 nulldrv_CloseFigure
, /* pCloseFigure */
706 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
707 nulldrv_CreateDC
, /* pCreateDC */
708 nulldrv_DeleteDC
, /* pDeleteDC */
709 nulldrv_DeleteObject
, /* pDeleteObject */
710 nulldrv_DescribePixelFormat
, /* pDescribePixelFormat */
711 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
712 nulldrv_Ellipse
, /* pEllipse */
713 nulldrv_EndDoc
, /* pEndDoc */
714 nulldrv_EndPage
, /* pEndPage */
715 nulldrv_EndPath
, /* pEndPath */
716 nulldrv_EnumFonts
, /* pEnumFonts */
717 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
718 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
719 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
720 nulldrv_ExtEscape
, /* pExtEscape */
721 nulldrv_ExtFloodFill
, /* pExtFloodFill */
722 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
723 nulldrv_ExtTextOut
, /* pExtTextOut */
724 nulldrv_FillPath
, /* pFillPath */
725 nulldrv_FillRgn
, /* pFillRgn */
726 nulldrv_FlattenPath
, /* pFlattenPath */
727 nulldrv_FontIsLinked
, /* pFontIsLinked */
728 nulldrv_FrameRgn
, /* pFrameRgn */
729 nulldrv_GdiComment
, /* pGdiComment */
730 nulldrv_GdiRealizationInfo
, /* pGdiRealizationInfo */
731 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
732 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
733 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
734 nulldrv_GetCharWidth
, /* pGetCharWidth */
735 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
736 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
737 nulldrv_GetFontData
, /* pGetFontData */
738 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
739 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
740 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
741 nulldrv_GetICMProfile
, /* pGetICMProfile */
742 nulldrv_GetImage
, /* pGetImage */
743 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
744 nulldrv_GetNearestColor
, /* pGetNearestColor */
745 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
746 nulldrv_GetPixel
, /* pGetPixel */
747 nulldrv_GetPixelFormat
, /* pGetPixelFormat */
748 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
749 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
750 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
751 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
752 nulldrv_GetTextFace
, /* pGetTextFace */
753 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
754 nulldrv_GradientFill
, /* pGradientFill */
755 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
756 nulldrv_InvertRgn
, /* pInvertRgn */
757 nulldrv_LineTo
, /* pLineTo */
758 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
759 nulldrv_MoveTo
, /* pMoveTo */
760 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
761 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
762 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
763 nulldrv_PaintRgn
, /* pPaintRgn */
764 nulldrv_PatBlt
, /* pPatBlt */
765 nulldrv_Pie
, /* pPie */
766 nulldrv_PolyBezier
, /* pPolyBezier */
767 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
768 nulldrv_PolyDraw
, /* pPolyDraw */
769 nulldrv_PolyPolygon
, /* pPolyPolygon */
770 nulldrv_PolyPolyline
, /* pPolyPolyline */
771 nulldrv_Polygon
, /* pPolygon */
772 nulldrv_Polyline
, /* pPolyline */
773 nulldrv_PolylineTo
, /* pPolylineTo */
774 nulldrv_PutImage
, /* pPutImage */
775 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
776 nulldrv_RealizePalette
, /* pRealizePalette */
777 nulldrv_Rectangle
, /* pRectangle */
778 nulldrv_ResetDC
, /* pResetDC */
779 nulldrv_RestoreDC
, /* pRestoreDC */
780 nulldrv_RoundRect
, /* pRoundRect */
781 nulldrv_SaveDC
, /* pSaveDC */
782 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
783 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
784 nulldrv_SelectBitmap
, /* pSelectBitmap */
785 nulldrv_SelectBrush
, /* pSelectBrush */
786 nulldrv_SelectClipPath
, /* pSelectClipPath */
787 nulldrv_SelectFont
, /* pSelectFont */
788 nulldrv_SelectPalette
, /* pSelectPalette */
789 nulldrv_SelectPen
, /* pSelectPen */
790 nulldrv_SetArcDirection
, /* pSetArcDirection */
791 nulldrv_SetBkColor
, /* pSetBkColor */
792 nulldrv_SetBkMode
, /* pSetBkMode */
793 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
794 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
795 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
796 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
797 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
798 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
799 nulldrv_SetLayout
, /* pSetLayout */
800 nulldrv_SetMapMode
, /* pSetMapMode */
801 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
802 nulldrv_SetPixel
, /* pSetPixel */
803 nulldrv_SetPixelFormat
, /* pSetPixelFormat */
804 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
805 nulldrv_SetROP2
, /* pSetROP2 */
806 nulldrv_SetRelAbs
, /* pSetRelAbs */
807 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
808 nulldrv_SetTextAlign
, /* pSetTextAlign */
809 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
810 nulldrv_SetTextColor
, /* pSetTextColor */
811 nulldrv_SetTextJustification
, /* pSetTextJustification */
812 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
813 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
814 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
815 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
816 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
817 nulldrv_StartDoc
, /* pStartDoc */
818 nulldrv_StartPage
, /* pStartPage */
819 nulldrv_StretchBlt
, /* pStretchBlt */
820 nulldrv_StretchDIBits
, /* pStretchDIBits */
821 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
822 nulldrv_StrokePath
, /* pStrokePath */
823 nulldrv_SwapBuffers
, /* pSwapBuffers */
824 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
825 nulldrv_WidenPath
, /* pWidenPath */
826 nulldrv_wglCreateContext
, /* pwglCreateContext */
827 nulldrv_wglCreateContextAttribsARB
, /* pwglCreateContextAttribsARB */
828 nulldrv_wglGetProcAddress
, /* pwglGetProcAddress */
829 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
831 GDI_PRIORITY_NULL_DRV
/* priority */
835 /*****************************************************************************
836 * DRIVER_GetDriverName
839 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
841 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
842 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
843 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
844 static const WCHAR empty_strW
[] = { 0 };
847 /* display is a special case */
848 if (!strcmpiW( device
, displayW
) ||
849 !strcmpiW( device
, display1W
))
851 lstrcpynW( driver
, displayW
, size
);
855 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
857 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
860 p
= strchrW(driver
, ',');
863 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
867 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
872 /***********************************************************************
873 * GdiConvertToDevmodeW (GDI32.@)
875 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
878 WORD dmW_size
, dmA_size
;
880 dmA_size
= dmA
->dmSize
;
882 /* this is the minimal dmSize that XP accepts */
883 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
886 if (dmA_size
> sizeof(DEVMODEA
))
887 dmA_size
= sizeof(DEVMODEA
);
889 dmW_size
= dmA_size
+ CCHDEVICENAME
;
890 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
891 dmW_size
+= CCHFORMNAME
;
893 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
894 if (!dmW
) return NULL
;
896 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
897 dmW
->dmDeviceName
, CCHDEVICENAME
);
898 /* copy slightly more, to avoid long computations */
899 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
901 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
903 if (dmA
->dmFields
& DM_FORMNAME
)
904 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
905 dmW
->dmFormName
, CCHFORMNAME
);
907 dmW
->dmFormName
[0] = 0;
909 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
910 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
913 if (dmA
->dmDriverExtra
)
914 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
916 dmW
->dmSize
= dmW_size
;
922 /*****************************************************************************
925 * This should thunk to 16-bit and simply call the proc with the given args.
927 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
928 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
930 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
934 /*****************************************************************************
937 * This should load the correct driver for lpszDevice and calls this driver's
938 * ExtDeviceModePropSheet proc.
940 * Note: The driver calls a callback routine for each property sheet page; these
941 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
942 * The layout of this structure is:
948 * HPROPSHEETPAGE pages[10];
951 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
952 LPCSTR lpszPort
, LPVOID lpPropSheet
)
954 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
958 /*****************************************************************************
961 * This should load the correct driver for lpszDevice and call this driver's
962 * ExtDeviceMode proc.
964 * FIXME: convert ExtDeviceMode to unicode in the driver interface
966 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
967 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
968 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
969 LPSTR lpszProfile
, DWORD fwMode
)
978 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
979 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
981 if (!lpszDevice
) return -1;
982 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
984 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
986 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
988 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
990 if ((dc
= get_dc_ptr( hdc
)))
992 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
993 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
994 lpdmInput
, lpszProfile
, fwMode
);
995 release_dc_ptr( dc
);
1001 /****************************************************************************
1004 * This should load the correct driver for lpszDevice and calls this driver's
1005 * AdvancedSetupDialog proc.
1007 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1008 LPDEVMODEA devin
, LPDEVMODEA devout
)
1010 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1014 /*****************************************************************************
1017 * This should load the correct driver for lpszDevice and calls this driver's
1018 * DeviceCapabilities proc.
1020 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1022 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1023 WORD fwCapability
, LPSTR lpszOutput
,
1033 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1035 if (!lpszDevice
) return -1;
1036 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1038 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1040 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1042 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1044 if ((dc
= get_dc_ptr( hdc
)))
1046 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1047 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1048 fwCapability
, lpszOutput
, lpdm
);
1049 release_dc_ptr( dc
);
1056 /************************************************************************
1059 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1067 return AbortDoc( hdc
);
1070 return EndDoc( hdc
);
1072 case GETPHYSPAGESIZE
:
1074 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1075 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1078 case GETPRINTINGOFFSET
:
1080 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1081 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1084 case GETSCALINGFACTOR
:
1086 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1087 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1091 return EndPage( hdc
);
1094 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1101 /* in_data may not be 0 terminated so we must copy it */
1104 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1105 memcpy( name
, in_data
, in_count
);
1108 /* out_data is actually a pointer to the DocInfo structure and used as
1109 * a second input parameter */
1110 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1113 doc
.cbSize
= sizeof(doc
);
1114 doc
.lpszOutput
= NULL
;
1115 doc
.lpszDatatype
= NULL
;
1118 doc
.lpszDocName
= name
;
1119 ret
= StartDocA( hdc
, &doc
);
1120 HeapFree( GetProcessHeap(), 0, name
);
1121 if (ret
> 0) ret
= StartPage( hdc
);
1125 case QUERYESCSUPPORT
:
1127 const INT
*ptr
= (const INT
*)in_data
;
1128 if (in_count
< sizeof(INT
)) return 0;
1133 case GETPHYSPAGESIZE
:
1134 case GETPRINTINGOFFSET
:
1135 case GETSCALINGFACTOR
:
1137 case QUERYESCSUPPORT
:
1146 /* if not handled internally, pass it to the driver */
1147 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1151 /******************************************************************************
1152 * ExtEscape [GDI32.@]
1154 * Access capabilities of a particular device that are not available through GDI.
1157 * hdc [I] Handle to device context
1158 * nEscape [I] Escape function
1159 * cbInput [I] Number of bytes in input structure
1160 * lpszInData [I] Pointer to input structure
1161 * cbOutput [I] Number of bytes in output structure
1162 * lpszOutData [O] Pointer to output structure
1166 * Not implemented: 0
1169 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1170 INT cbOutput
, LPSTR lpszOutData
)
1173 DC
* dc
= get_dc_ptr( hdc
);
1177 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1179 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1180 release_dc_ptr( dc
);
1186 /*******************************************************************
1187 * DrawEscape [GDI32.@]
1191 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1193 FIXME("DrawEscape, stub\n");
1197 /*******************************************************************
1198 * NamedEscape [GDI32.@]
1200 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1201 INT cbOutput
, LPSTR lpszOutData
)
1203 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1204 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1209 /*******************************************************************
1210 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1211 * GdiEntry13 [GDI32.@]
1213 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1215 static int warn_once
;