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"
34 #include "gdi_private.h"
35 #include "wine/unicode.h"
36 #include "wine/list.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(driver
);
41 struct graphics_driver
44 HMODULE module
; /* module handle */
45 const struct gdi_dc_funcs
*funcs
;
48 static struct list drivers
= LIST_INIT( drivers
);
49 static struct graphics_driver
*display_driver
;
51 const struct gdi_dc_funcs
*font_driver
= NULL
;
53 static CRITICAL_SECTION driver_section
;
54 static CRITICAL_SECTION_DEBUG critsect_debug
=
56 0, 0, &driver_section
,
57 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
58 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
60 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
62 /**********************************************************************
65 * Allocate and fill the driver structure for a given module.
67 static struct graphics_driver
*create_driver( HMODULE module
)
69 static const struct gdi_dc_funcs empty_funcs
;
70 const struct gdi_dc_funcs
*funcs
= NULL
;
71 struct graphics_driver
*driver
;
73 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
74 driver
->module
= module
;
78 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
80 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
81 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
83 if (!funcs
) funcs
= &empty_funcs
;
84 driver
->funcs
= funcs
;
89 /**********************************************************************
92 * Special case for loading the display driver: get the name from the config file
94 static const struct gdi_dc_funcs
*get_display_driver( HMODULE
*module_ret
)
98 HMODULE user32
= LoadLibraryA( "user32.dll" );
99 HWND (WINAPI
*pGetDesktopWindow
)(void) = (void *)GetProcAddress( user32
, "GetDesktopWindow" );
101 if (!pGetDesktopWindow() || !display_driver
)
103 WARN( "failed to load the display driver, falling back to null driver\n" );
104 __wine_set_display_driver( 0 );
108 *module_ret
= display_driver
->module
;
109 return display_driver
->funcs
;
113 /**********************************************************************
116 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
, HMODULE
*module_ret
)
119 struct graphics_driver
*driver
, *new_driver
;
120 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
121 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
123 /* display driver is a special case */
124 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
))
125 return get_display_driver( module_ret
);
127 if ((module
= GetModuleHandleW( name
)))
129 if (display_driver
&& display_driver
->module
== module
)
131 *module_ret
= module
;
132 return display_driver
->funcs
;
134 EnterCriticalSection( &driver_section
);
135 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
137 if (driver
->module
== module
) goto done
;
139 LeaveCriticalSection( &driver_section
);
142 if (!(module
= LoadLibraryW( name
))) return NULL
;
144 if (!(new_driver
= create_driver( module
)))
146 FreeLibrary( module
);
150 /* check if someone else added it in the meantime */
151 EnterCriticalSection( &driver_section
);
152 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
154 if (driver
->module
!= module
) continue;
155 FreeLibrary( module
);
156 HeapFree( GetProcessHeap(), 0, new_driver
);
160 list_add_head( &drivers
, &driver
->entry
);
161 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
163 *module_ret
= driver
->module
;
164 LeaveCriticalSection( &driver_section
);
165 return driver
->funcs
;
169 /***********************************************************************
170 * __wine_set_display_driver_module (GDI32.@)
172 void CDECL
__wine_set_display_driver( HMODULE module
)
174 struct graphics_driver
*driver
;
176 if (!(driver
= create_driver( module
)))
178 ERR( "Could not create graphics driver\n" );
181 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
182 HeapFree( GetProcessHeap(), 0, driver
);
186 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
191 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
192 INT xstart
, INT ystart
, INT xend
, INT yend
)
197 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
198 INT xstart
, INT ystart
, INT xend
, INT yend
)
203 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
205 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
206 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
209 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
210 LPCWSTR output
, const DEVMODEW
*devmode
)
212 assert(0); /* should never be called */
216 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
218 assert(0); /* should never be called */
222 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
227 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
228 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
233 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
238 static INT
nulldrv_EndDoc( PHYSDEV dev
)
243 static INT
nulldrv_EndPage( PHYSDEV dev
)
248 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
253 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
258 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
259 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
264 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
265 INT out_size
, void *out_data
)
270 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
275 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
280 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
285 static BOOL
nulldrv_GdiRealizationInfo( PHYSDEV dev
, void *info
)
290 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
295 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
300 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
305 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
310 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
312 switch (cap
) /* return meaningful values for some entries */
314 case HORZRES
: return 640;
315 case VERTRES
: return 480;
316 case BITSPIXEL
: return 1;
317 case PLANES
: return 1;
318 case NUMCOLORS
: return 2;
319 case ASPECTX
: return 36;
320 case ASPECTY
: return 36;
321 case ASPECTXY
: return 51;
322 case LOGPIXELSX
: return 72;
323 case LOGPIXELSY
: return 72;
324 case SIZEPALETTE
: return 2;
325 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
326 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
327 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
332 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
334 SetLastError( ERROR_INVALID_PARAMETER
);
338 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
343 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
348 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
353 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
354 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
359 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
364 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
365 struct bitblt_coords
*src
)
367 return ERROR_NOT_SUPPORTED
;
370 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
375 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
380 static UINT
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
, UINT count
, PALETTEENTRY
*entries
)
385 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
387 return DEFAULT_CHARSET
;
390 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
395 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
400 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
404 HFONT hfont
= GetCurrentObject( dev
->hdc
, OBJ_FONT
);
406 if (GetObjectW( hfont
, sizeof(font
), &font
))
408 ret
= strlenW( font
.lfFaceName
) + 1;
411 lstrcpynW( name
, font
.lfFaceName
, size
);
412 ret
= min( size
, ret
);
418 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
423 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
428 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
433 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
438 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
443 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
444 INT xstart
, INT ystart
, INT xend
, INT yend
)
449 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
454 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
459 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
461 INT counts
[1] = { count
};
463 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
466 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
468 DWORD counts
[1] = { count
};
470 if (count
< 0) return FALSE
;
471 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
474 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
475 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
476 struct bitblt_coords
*dst
, DWORD rop
)
478 return ERROR_SUCCESS
;
481 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
486 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
491 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
496 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
501 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
502 INT ell_width
, INT ell_height
)
507 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
512 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
517 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
522 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
527 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
532 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
537 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
542 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
547 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
552 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
557 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
561 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
566 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
568 SetLastError( ERROR_INVALID_PARAMETER
);
572 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
577 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
582 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
587 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
592 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
597 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
602 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
607 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
612 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
617 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
622 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
627 static INT
nulldrv_StartPage( PHYSDEV dev
)
632 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
637 static struct opengl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
642 const struct gdi_dc_funcs null_driver
=
644 nulldrv_AbortDoc
, /* pAbortDoc */
645 nulldrv_AbortPath
, /* pAbortPath */
646 nulldrv_AlphaBlend
, /* pAlphaBlend */
647 nulldrv_AngleArc
, /* pAngleArc */
648 nulldrv_Arc
, /* pArc */
649 nulldrv_ArcTo
, /* pArcTo */
650 nulldrv_BeginPath
, /* pBeginPath */
651 nulldrv_BlendImage
, /* pBlendImage */
652 nulldrv_Chord
, /* pChord */
653 nulldrv_CloseFigure
, /* pCloseFigure */
654 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
655 nulldrv_CreateDC
, /* pCreateDC */
656 nulldrv_DeleteDC
, /* pDeleteDC */
657 nulldrv_DeleteObject
, /* pDeleteObject */
658 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
659 nulldrv_Ellipse
, /* pEllipse */
660 nulldrv_EndDoc
, /* pEndDoc */
661 nulldrv_EndPage
, /* pEndPage */
662 nulldrv_EndPath
, /* pEndPath */
663 nulldrv_EnumFonts
, /* pEnumFonts */
664 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
665 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
666 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
667 nulldrv_ExtEscape
, /* pExtEscape */
668 nulldrv_ExtFloodFill
, /* pExtFloodFill */
669 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
670 nulldrv_ExtTextOut
, /* pExtTextOut */
671 nulldrv_FillPath
, /* pFillPath */
672 nulldrv_FillRgn
, /* pFillRgn */
673 nulldrv_FlattenPath
, /* pFlattenPath */
674 nulldrv_FontIsLinked
, /* pFontIsLinked */
675 nulldrv_FrameRgn
, /* pFrameRgn */
676 nulldrv_GdiComment
, /* pGdiComment */
677 nulldrv_GdiRealizationInfo
, /* pGdiRealizationInfo */
678 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
679 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
680 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
681 nulldrv_GetCharWidth
, /* pGetCharWidth */
682 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
683 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
684 nulldrv_GetFontData
, /* pGetFontData */
685 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
686 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
687 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
688 nulldrv_GetICMProfile
, /* pGetICMProfile */
689 nulldrv_GetImage
, /* pGetImage */
690 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
691 nulldrv_GetNearestColor
, /* pGetNearestColor */
692 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
693 nulldrv_GetPixel
, /* pGetPixel */
694 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
695 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
696 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
697 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
698 nulldrv_GetTextFace
, /* pGetTextFace */
699 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
700 nulldrv_GradientFill
, /* pGradientFill */
701 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
702 nulldrv_InvertRgn
, /* pInvertRgn */
703 nulldrv_LineTo
, /* pLineTo */
704 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
705 nulldrv_MoveTo
, /* pMoveTo */
706 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
707 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
708 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
709 nulldrv_PaintRgn
, /* pPaintRgn */
710 nulldrv_PatBlt
, /* pPatBlt */
711 nulldrv_Pie
, /* pPie */
712 nulldrv_PolyBezier
, /* pPolyBezier */
713 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
714 nulldrv_PolyDraw
, /* pPolyDraw */
715 nulldrv_PolyPolygon
, /* pPolyPolygon */
716 nulldrv_PolyPolyline
, /* pPolyPolyline */
717 nulldrv_Polygon
, /* pPolygon */
718 nulldrv_Polyline
, /* pPolyline */
719 nulldrv_PolylineTo
, /* pPolylineTo */
720 nulldrv_PutImage
, /* pPutImage */
721 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
722 nulldrv_RealizePalette
, /* pRealizePalette */
723 nulldrv_Rectangle
, /* pRectangle */
724 nulldrv_ResetDC
, /* pResetDC */
725 nulldrv_RestoreDC
, /* pRestoreDC */
726 nulldrv_RoundRect
, /* pRoundRect */
727 nulldrv_SaveDC
, /* pSaveDC */
728 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
729 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
730 nulldrv_SelectBitmap
, /* pSelectBitmap */
731 nulldrv_SelectBrush
, /* pSelectBrush */
732 nulldrv_SelectClipPath
, /* pSelectClipPath */
733 nulldrv_SelectFont
, /* pSelectFont */
734 nulldrv_SelectPalette
, /* pSelectPalette */
735 nulldrv_SelectPen
, /* pSelectPen */
736 nulldrv_SetArcDirection
, /* pSetArcDirection */
737 nulldrv_SetBkColor
, /* pSetBkColor */
738 nulldrv_SetBkMode
, /* pSetBkMode */
739 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
740 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
741 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
742 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
743 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
744 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
745 nulldrv_SetLayout
, /* pSetLayout */
746 nulldrv_SetMapMode
, /* pSetMapMode */
747 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
748 nulldrv_SetPixel
, /* pSetPixel */
749 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
750 nulldrv_SetROP2
, /* pSetROP2 */
751 nulldrv_SetRelAbs
, /* pSetRelAbs */
752 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
753 nulldrv_SetTextAlign
, /* pSetTextAlign */
754 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
755 nulldrv_SetTextColor
, /* pSetTextColor */
756 nulldrv_SetTextJustification
, /* pSetTextJustification */
757 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
758 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
759 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
760 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
761 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
762 nulldrv_StartDoc
, /* pStartDoc */
763 nulldrv_StartPage
, /* pStartPage */
764 nulldrv_StretchBlt
, /* pStretchBlt */
765 nulldrv_StretchDIBits
, /* pStretchDIBits */
766 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
767 nulldrv_StrokePath
, /* pStrokePath */
768 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
769 nulldrv_WidenPath
, /* pWidenPath */
770 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
772 GDI_PRIORITY_NULL_DRV
/* priority */
776 /*****************************************************************************
777 * DRIVER_GetDriverName
780 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
782 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
783 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
784 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
785 static const WCHAR empty_strW
[] = { 0 };
788 /* display is a special case */
789 if (!strcmpiW( device
, displayW
) ||
790 !strcmpiW( device
, display1W
))
792 lstrcpynW( driver
, displayW
, size
);
796 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
798 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
801 p
= strchrW(driver
, ',');
804 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
808 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
813 /***********************************************************************
814 * GdiConvertToDevmodeW (GDI32.@)
816 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
819 WORD dmW_size
, dmA_size
;
821 dmA_size
= dmA
->dmSize
;
823 /* this is the minimal dmSize that XP accepts */
824 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
827 if (dmA_size
> sizeof(DEVMODEA
))
828 dmA_size
= sizeof(DEVMODEA
);
830 dmW_size
= dmA_size
+ CCHDEVICENAME
;
831 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
832 dmW_size
+= CCHFORMNAME
;
834 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
835 if (!dmW
) return NULL
;
837 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
838 dmW
->dmDeviceName
, CCHDEVICENAME
);
839 /* copy slightly more, to avoid long computations */
840 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
842 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
844 if (dmA
->dmFields
& DM_FORMNAME
)
845 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
846 dmW
->dmFormName
, CCHFORMNAME
);
848 dmW
->dmFormName
[0] = 0;
850 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
851 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
854 if (dmA
->dmDriverExtra
)
855 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
857 dmW
->dmSize
= dmW_size
;
863 /*****************************************************************************
866 * This should thunk to 16-bit and simply call the proc with the given args.
868 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
869 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
871 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
875 /*****************************************************************************
878 * This should load the correct driver for lpszDevice and calls this driver's
879 * ExtDeviceModePropSheet proc.
881 * Note: The driver calls a callback routine for each property sheet page; these
882 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
883 * The layout of this structure is:
889 * HPROPSHEETPAGE pages[10];
892 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
893 LPCSTR lpszPort
, LPVOID lpPropSheet
)
895 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
899 /*****************************************************************************
902 * This should load the correct driver for lpszDevice and call this driver's
903 * ExtDeviceMode proc.
905 * FIXME: convert ExtDeviceMode to unicode in the driver interface
907 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
908 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
909 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
910 LPSTR lpszProfile
, DWORD fwMode
)
919 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
920 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
922 if (!lpszDevice
) return -1;
923 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
925 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
927 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
929 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
931 if ((dc
= get_dc_ptr( hdc
)))
933 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
934 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
935 lpdmInput
, lpszProfile
, fwMode
);
936 release_dc_ptr( dc
);
942 /****************************************************************************
945 * This should load the correct driver for lpszDevice and calls this driver's
946 * AdvancedSetupDialog proc.
948 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
949 LPDEVMODEA devin
, LPDEVMODEA devout
)
951 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
955 /*****************************************************************************
958 * This should load the correct driver for lpszDevice and calls this driver's
959 * DeviceCapabilities proc.
961 * FIXME: convert DeviceCapabilities to unicode in the driver interface
963 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
964 WORD fwCapability
, LPSTR lpszOutput
,
974 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
976 if (!lpszDevice
) return -1;
977 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
979 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
981 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
983 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
985 if ((dc
= get_dc_ptr( hdc
)))
987 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
988 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
989 fwCapability
, lpszOutput
, lpdm
);
990 release_dc_ptr( dc
);
997 /************************************************************************
1000 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1008 return AbortDoc( hdc
);
1011 return EndDoc( hdc
);
1013 case GETPHYSPAGESIZE
:
1015 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1016 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1019 case GETPRINTINGOFFSET
:
1021 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1022 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1025 case GETSCALINGFACTOR
:
1027 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1028 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1032 return EndPage( hdc
);
1035 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1042 /* in_data may not be 0 terminated so we must copy it */
1045 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1046 memcpy( name
, in_data
, in_count
);
1049 /* out_data is actually a pointer to the DocInfo structure and used as
1050 * a second input parameter */
1051 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1054 doc
.cbSize
= sizeof(doc
);
1055 doc
.lpszOutput
= NULL
;
1056 doc
.lpszDatatype
= NULL
;
1059 doc
.lpszDocName
= name
;
1060 ret
= StartDocA( hdc
, &doc
);
1061 HeapFree( GetProcessHeap(), 0, name
);
1062 if (ret
> 0) ret
= StartPage( hdc
);
1066 case QUERYESCSUPPORT
:
1070 if (in_count
< sizeof(SHORT
)) return 0;
1071 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1076 case GETPHYSPAGESIZE
:
1077 case GETPRINTINGOFFSET
:
1078 case GETSCALINGFACTOR
:
1080 case QUERYESCSUPPORT
:
1089 /* if not handled internally, pass it to the driver */
1090 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1094 /******************************************************************************
1095 * ExtEscape [GDI32.@]
1097 * Access capabilities of a particular device that are not available through GDI.
1100 * hdc [I] Handle to device context
1101 * nEscape [I] Escape function
1102 * cbInput [I] Number of bytes in input structure
1103 * lpszInData [I] Pointer to input structure
1104 * cbOutput [I] Number of bytes in output structure
1105 * lpszOutData [O] Pointer to output structure
1109 * Not implemented: 0
1112 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1113 INT cbOutput
, LPSTR lpszOutData
)
1117 DC
* dc
= get_dc_ptr( hdc
);
1121 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1122 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1123 release_dc_ptr( dc
);
1128 /*******************************************************************
1129 * DrawEscape [GDI32.@]
1133 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1135 FIXME("DrawEscape, stub\n");
1139 /*******************************************************************
1140 * NamedEscape [GDI32.@]
1142 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1143 INT cbOutput
, LPSTR lpszOutData
)
1145 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1146 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1151 /*******************************************************************
1152 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1153 * GdiEntry13 [GDI32.@]
1155 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1157 static int warn_once
;