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"
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)
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 /**********************************************************************
115 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
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
);
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
);
155 list_add_head( &drivers
, &driver
->entry
);
156 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
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" );
175 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
176 HeapFree( GetProcessHeap(), 0, driver
);
180 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
185 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
186 INT xstart
, INT ystart
, INT xend
, INT yend
)
191 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
192 INT xstart
, INT ystart
, INT xend
, INT yend
)
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 */
210 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
212 assert(0); /* should never be called */
216 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
221 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
222 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
227 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
232 static INT
nulldrv_EndDoc( PHYSDEV dev
)
237 static INT
nulldrv_EndPage( PHYSDEV dev
)
242 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
247 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
252 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
253 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
258 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
259 INT out_size
, void *out_data
)
264 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
269 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
274 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
279 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
284 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
289 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
294 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
299 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
301 switch (cap
) /* return meaningful values for some entries */
303 case HORZRES
: return 640;
304 case VERTRES
: return 480;
305 case BITSPIXEL
: return 1;
306 case PLANES
: return 1;
307 case NUMCOLORS
: return 2;
308 case ASPECTX
: return 36;
309 case ASPECTY
: return 36;
310 case ASPECTXY
: return 51;
311 case LOGPIXELSX
: return 72;
312 case LOGPIXELSY
: return 72;
313 case SIZEPALETTE
: return 2;
314 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
315 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
316 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
321 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
323 SetLastError( ERROR_INVALID_PARAMETER
);
327 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
332 static BOOL
nulldrv_GetFontRealizationInfo( PHYSDEV dev
, void *info
)
337 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
342 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
347 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
348 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
353 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
358 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
359 struct bitblt_coords
*src
)
361 return ERROR_NOT_SUPPORTED
;
364 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
369 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
374 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
376 return DEFAULT_CHARSET
;
379 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
384 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
389 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
393 HFONT hfont
= GetCurrentObject( dev
->hdc
, OBJ_FONT
);
395 if (GetObjectW( hfont
, sizeof(font
), &font
))
397 ret
= strlenW( font
.lfFaceName
) + 1;
400 lstrcpynW( name
, font
.lfFaceName
, size
);
401 ret
= min( size
, ret
);
407 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
412 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
417 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
422 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
427 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
432 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
433 INT xstart
, INT ystart
, INT xend
, INT yend
)
438 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
443 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
448 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
450 INT counts
[1] = { count
};
452 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
455 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
457 DWORD counts
[1] = { count
};
459 if (count
< 0) return FALSE
;
460 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
463 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
464 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
465 struct bitblt_coords
*dst
, DWORD rop
)
467 return ERROR_SUCCESS
;
470 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
475 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
480 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
485 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
490 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
491 INT ell_width
, INT ell_height
)
496 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
501 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
506 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
511 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
516 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
521 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
526 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
531 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
536 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
541 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
546 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
550 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
555 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
557 SetLastError( ERROR_INVALID_PARAMETER
);
561 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
566 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
571 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
576 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
581 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
586 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
591 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
596 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
601 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
606 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
611 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
616 static INT
nulldrv_StartPage( PHYSDEV dev
)
621 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
626 static struct opengl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
631 const struct gdi_dc_funcs null_driver
=
633 nulldrv_AbortDoc
, /* pAbortDoc */
634 nulldrv_AbortPath
, /* pAbortPath */
635 nulldrv_AlphaBlend
, /* pAlphaBlend */
636 nulldrv_AngleArc
, /* pAngleArc */
637 nulldrv_Arc
, /* pArc */
638 nulldrv_ArcTo
, /* pArcTo */
639 nulldrv_BeginPath
, /* pBeginPath */
640 nulldrv_BlendImage
, /* pBlendImage */
641 nulldrv_Chord
, /* pChord */
642 nulldrv_CloseFigure
, /* pCloseFigure */
643 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
644 nulldrv_CreateDC
, /* pCreateDC */
645 nulldrv_DeleteDC
, /* pDeleteDC */
646 nulldrv_DeleteObject
, /* pDeleteObject */
647 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
648 nulldrv_Ellipse
, /* pEllipse */
649 nulldrv_EndDoc
, /* pEndDoc */
650 nulldrv_EndPage
, /* pEndPage */
651 nulldrv_EndPath
, /* pEndPath */
652 nulldrv_EnumFonts
, /* pEnumFonts */
653 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
654 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
655 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
656 nulldrv_ExtEscape
, /* pExtEscape */
657 nulldrv_ExtFloodFill
, /* pExtFloodFill */
658 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
659 nulldrv_ExtTextOut
, /* pExtTextOut */
660 nulldrv_FillPath
, /* pFillPath */
661 nulldrv_FillRgn
, /* pFillRgn */
662 nulldrv_FlattenPath
, /* pFlattenPath */
663 nulldrv_FontIsLinked
, /* pFontIsLinked */
664 nulldrv_FrameRgn
, /* pFrameRgn */
665 nulldrv_GdiComment
, /* pGdiComment */
666 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
667 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
668 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
669 nulldrv_GetCharWidth
, /* pGetCharWidth */
670 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
671 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
672 nulldrv_GetFontData
, /* pGetFontData */
673 nulldrv_GetFontRealizationInfo
, /* pGetFontRealizationInfo */
674 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
675 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
676 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
677 nulldrv_GetICMProfile
, /* pGetICMProfile */
678 nulldrv_GetImage
, /* pGetImage */
679 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
680 nulldrv_GetNearestColor
, /* pGetNearestColor */
681 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
682 nulldrv_GetPixel
, /* pGetPixel */
683 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
684 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
685 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
686 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
687 nulldrv_GetTextFace
, /* pGetTextFace */
688 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
689 nulldrv_GradientFill
, /* pGradientFill */
690 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
691 nulldrv_InvertRgn
, /* pInvertRgn */
692 nulldrv_LineTo
, /* pLineTo */
693 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
694 nulldrv_MoveTo
, /* pMoveTo */
695 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
696 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
697 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
698 nulldrv_PaintRgn
, /* pPaintRgn */
699 nulldrv_PatBlt
, /* pPatBlt */
700 nulldrv_Pie
, /* pPie */
701 nulldrv_PolyBezier
, /* pPolyBezier */
702 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
703 nulldrv_PolyDraw
, /* pPolyDraw */
704 nulldrv_PolyPolygon
, /* pPolyPolygon */
705 nulldrv_PolyPolyline
, /* pPolyPolyline */
706 nulldrv_Polygon
, /* pPolygon */
707 nulldrv_Polyline
, /* pPolyline */
708 nulldrv_PolylineTo
, /* pPolylineTo */
709 nulldrv_PutImage
, /* pPutImage */
710 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
711 nulldrv_RealizePalette
, /* pRealizePalette */
712 nulldrv_Rectangle
, /* pRectangle */
713 nulldrv_ResetDC
, /* pResetDC */
714 nulldrv_RestoreDC
, /* pRestoreDC */
715 nulldrv_RoundRect
, /* pRoundRect */
716 nulldrv_SaveDC
, /* pSaveDC */
717 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
718 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
719 nulldrv_SelectBitmap
, /* pSelectBitmap */
720 nulldrv_SelectBrush
, /* pSelectBrush */
721 nulldrv_SelectClipPath
, /* pSelectClipPath */
722 nulldrv_SelectFont
, /* pSelectFont */
723 nulldrv_SelectPalette
, /* pSelectPalette */
724 nulldrv_SelectPen
, /* pSelectPen */
725 nulldrv_SetArcDirection
, /* pSetArcDirection */
726 nulldrv_SetBkColor
, /* pSetBkColor */
727 nulldrv_SetBkMode
, /* pSetBkMode */
728 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
729 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
730 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
731 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
732 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
733 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
734 nulldrv_SetLayout
, /* pSetLayout */
735 nulldrv_SetMapMode
, /* pSetMapMode */
736 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
737 nulldrv_SetPixel
, /* pSetPixel */
738 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
739 nulldrv_SetROP2
, /* pSetROP2 */
740 nulldrv_SetRelAbs
, /* pSetRelAbs */
741 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
742 nulldrv_SetTextAlign
, /* pSetTextAlign */
743 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
744 nulldrv_SetTextColor
, /* pSetTextColor */
745 nulldrv_SetTextJustification
, /* pSetTextJustification */
746 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
747 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
748 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
749 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
750 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
751 nulldrv_StartDoc
, /* pStartDoc */
752 nulldrv_StartPage
, /* pStartPage */
753 nulldrv_StretchBlt
, /* pStretchBlt */
754 nulldrv_StretchDIBits
, /* pStretchDIBits */
755 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
756 nulldrv_StrokePath
, /* pStrokePath */
757 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
758 nulldrv_WidenPath
, /* pWidenPath */
759 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
761 GDI_PRIORITY_NULL_DRV
/* priority */
765 /*****************************************************************************
766 * DRIVER_GetDriverName
769 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
771 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
772 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
773 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
774 static const WCHAR empty_strW
[] = { 0 };
777 /* display is a special case */
778 if (!strcmpiW( device
, displayW
) ||
779 !strcmpiW( device
, display1W
))
781 lstrcpynW( driver
, displayW
, size
);
785 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
787 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
790 p
= strchrW(driver
, ',');
793 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
797 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
802 /***********************************************************************
803 * GdiConvertToDevmodeW (GDI32.@)
805 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
808 WORD dmW_size
, dmA_size
;
810 dmA_size
= dmA
->dmSize
;
812 /* this is the minimal dmSize that XP accepts */
813 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
816 if (dmA_size
> sizeof(DEVMODEA
))
817 dmA_size
= sizeof(DEVMODEA
);
819 dmW_size
= dmA_size
+ CCHDEVICENAME
;
820 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
821 dmW_size
+= CCHFORMNAME
;
823 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
824 if (!dmW
) return NULL
;
826 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
827 dmW
->dmDeviceName
, CCHDEVICENAME
);
828 /* copy slightly more, to avoid long computations */
829 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
831 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
833 if (dmA
->dmFields
& DM_FORMNAME
)
834 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
835 dmW
->dmFormName
, CCHFORMNAME
);
837 dmW
->dmFormName
[0] = 0;
839 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
840 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
843 if (dmA
->dmDriverExtra
)
844 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
846 dmW
->dmSize
= dmW_size
;
852 /*****************************************************************************
855 * This should thunk to 16-bit and simply call the proc with the given args.
857 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
858 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
860 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
864 /*****************************************************************************
867 * This should load the correct driver for lpszDevice and calls this driver's
868 * ExtDeviceModePropSheet proc.
870 * Note: The driver calls a callback routine for each property sheet page; these
871 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
872 * The layout of this structure is:
878 * HPROPSHEETPAGE pages[10];
881 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
882 LPCSTR lpszPort
, LPVOID lpPropSheet
)
884 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
888 /*****************************************************************************
891 * This should load the correct driver for lpszDevice and call this driver's
892 * ExtDeviceMode proc.
894 * FIXME: convert ExtDeviceMode to unicode in the driver interface
896 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
897 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
898 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
899 LPSTR lpszProfile
, DWORD fwMode
)
908 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
909 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
911 if (!lpszDevice
) return -1;
912 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
914 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
916 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
918 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
920 if ((dc
= get_dc_ptr( hdc
)))
922 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
923 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
924 lpdmInput
, lpszProfile
, fwMode
);
925 release_dc_ptr( dc
);
931 /****************************************************************************
934 * This should load the correct driver for lpszDevice and calls this driver's
935 * AdvancedSetupDialog proc.
937 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
938 LPDEVMODEA devin
, LPDEVMODEA devout
)
940 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
944 /*****************************************************************************
947 * This should load the correct driver for lpszDevice and calls this driver's
948 * DeviceCapabilities proc.
950 * FIXME: convert DeviceCapabilities to unicode in the driver interface
952 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
953 WORD fwCapability
, LPSTR lpszOutput
,
963 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
965 if (!lpszDevice
) return -1;
966 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
968 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
970 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
972 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
974 if ((dc
= get_dc_ptr( hdc
)))
976 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
977 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
978 fwCapability
, lpszOutput
, lpdm
);
979 release_dc_ptr( dc
);
986 /************************************************************************
989 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
997 return AbortDoc( hdc
);
1000 return EndDoc( hdc
);
1002 case GETPHYSPAGESIZE
:
1004 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1005 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1008 case GETPRINTINGOFFSET
:
1010 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1011 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1014 case GETSCALINGFACTOR
:
1016 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1017 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1021 return EndPage( hdc
);
1024 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1031 /* in_data may not be 0 terminated so we must copy it */
1034 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1035 memcpy( name
, in_data
, in_count
);
1038 /* out_data is actually a pointer to the DocInfo structure and used as
1039 * a second input parameter */
1040 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1043 doc
.cbSize
= sizeof(doc
);
1044 doc
.lpszOutput
= NULL
;
1045 doc
.lpszDatatype
= NULL
;
1048 doc
.lpszDocName
= name
;
1049 ret
= StartDocA( hdc
, &doc
);
1050 HeapFree( GetProcessHeap(), 0, name
);
1051 if (ret
> 0) ret
= StartPage( hdc
);
1055 case QUERYESCSUPPORT
:
1059 if (in_count
< sizeof(SHORT
)) return 0;
1060 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1065 case GETPHYSPAGESIZE
:
1066 case GETPRINTINGOFFSET
:
1067 case GETSCALINGFACTOR
:
1069 case QUERYESCSUPPORT
:
1078 /* if not handled internally, pass it to the driver */
1079 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1083 /******************************************************************************
1084 * ExtEscape [GDI32.@]
1086 * Access capabilities of a particular device that are not available through GDI.
1089 * hdc [I] Handle to device context
1090 * nEscape [I] Escape function
1091 * cbInput [I] Number of bytes in input structure
1092 * lpszInData [I] Pointer to input structure
1093 * cbOutput [I] Number of bytes in output structure
1094 * lpszOutData [O] Pointer to output structure
1098 * Not implemented: 0
1101 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1102 INT cbOutput
, LPSTR lpszOutData
)
1106 DC
* dc
= get_dc_ptr( hdc
);
1110 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1111 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1112 release_dc_ptr( dc
);
1117 /*******************************************************************
1118 * DrawEscape [GDI32.@]
1122 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1124 FIXME("DrawEscape, stub\n");
1128 /*******************************************************************
1129 * NamedEscape [GDI32.@]
1131 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1132 INT cbOutput
, LPSTR lpszOutData
)
1134 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1135 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1140 /*******************************************************************
1141 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1142 * GdiEntry13 [GDI32.@]
1144 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1146 static int warn_once
;
1153 /******************************************************************************
1154 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1156 NTSTATUS WINAPI
D3DKMTOpenAdapterFromHdc( void *pData
)
1158 FIXME("(%p): stub\n", pData
);
1159 return STATUS_NO_MEMORY
;
1162 /******************************************************************************
1163 * D3DKMTEscape [GDI32.@]
1165 NTSTATUS WINAPI
D3DKMTEscape( const void *pData
)
1167 FIXME("(%p): stub\n", pData
);
1168 return STATUS_NO_MEMORY
;