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
;
51 static DWORD display_driver_load_error
;
53 const struct gdi_dc_funcs
*font_driver
= NULL
;
55 static CRITICAL_SECTION driver_section
;
56 static CRITICAL_SECTION_DEBUG critsect_debug
=
58 0, 0, &driver_section
,
59 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
60 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
62 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
65 static const char default_driver
[] = "mac,x11";
67 static const char default_driver
[] = "x11";
70 /**********************************************************************
73 * Allocate and fill the driver structure for a given module.
75 static struct graphics_driver
*create_driver( HMODULE module
)
77 static const struct gdi_dc_funcs empty_funcs
;
78 const struct gdi_dc_funcs
*funcs
= NULL
;
79 struct graphics_driver
*driver
;
81 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
82 driver
->module
= module
;
86 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
88 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
89 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
91 if (!funcs
) funcs
= &empty_funcs
;
92 driver
->funcs
= funcs
;
97 /**********************************************************************
100 * Special case for loading the display driver: get the name from the config file
102 static const struct gdi_dc_funcs
*get_display_driver( HMODULE
*module_ret
)
104 struct graphics_driver
*driver
;
105 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
109 if (display_driver
) goto done
;
111 strcpy( buffer
, default_driver
);
112 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
113 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
115 DWORD type
, count
= sizeof(buffer
);
116 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
123 next
= strchr( name
, ',' );
124 if (next
) *next
++ = 0;
126 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
127 if ((module
= LoadLibraryA( libname
)) != 0) break;
131 if (!module
) display_driver_load_error
= GetLastError();
133 if (!(driver
= create_driver( module
)))
135 MESSAGE( "Could not create graphics driver '%s'\n", buffer
);
136 FreeLibrary( module
);
139 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
141 /* somebody beat us to it */
142 FreeLibrary( driver
->module
);
143 HeapFree( GetProcessHeap(), 0, driver
);
146 *module_ret
= display_driver
->module
;
147 return display_driver
->funcs
;
151 /**********************************************************************
154 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
, HMODULE
*module_ret
)
157 struct graphics_driver
*driver
, *new_driver
;
158 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
159 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
161 /* display driver is a special case */
162 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
))
163 return get_display_driver( module_ret
);
165 if ((module
= GetModuleHandleW( name
)))
167 if (display_driver
&& display_driver
->module
== module
)
169 *module_ret
= module
;
170 return display_driver
->funcs
;
172 EnterCriticalSection( &driver_section
);
173 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
175 if (driver
->module
== module
) goto done
;
177 LeaveCriticalSection( &driver_section
);
180 if (!(module
= LoadLibraryW( name
))) return NULL
;
182 if (!(new_driver
= create_driver( module
)))
184 FreeLibrary( module
);
188 /* check if someone else added it in the meantime */
189 EnterCriticalSection( &driver_section
);
190 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
192 if (driver
->module
!= module
) continue;
193 FreeLibrary( module
);
194 HeapFree( GetProcessHeap(), 0, new_driver
);
198 list_add_head( &drivers
, &driver
->entry
);
199 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
201 *module_ret
= driver
->module
;
202 LeaveCriticalSection( &driver_section
);
203 return driver
->funcs
;
207 /***********************************************************************
208 * __wine_get_driver_module (GDI32.@)
210 HMODULE CDECL
__wine_get_driver_module( HDC hdc
)
215 if ((dc
= get_dc_ptr( hdc
)))
218 release_dc_ptr( dc
);
219 if (!ret
) SetLastError( display_driver_load_error
);
221 else SetLastError( ERROR_INVALID_HANDLE
);
226 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
231 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
232 INT xstart
, INT ystart
, INT xend
, INT yend
)
237 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
238 INT xstart
, INT ystart
, INT xend
, INT yend
)
243 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
245 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
246 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
249 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
250 LPCWSTR output
, const DEVMODEW
*devmode
)
252 assert(0); /* should never be called */
256 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
258 assert(0); /* should never be called */
262 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
267 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
268 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
273 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
278 static INT
nulldrv_EndDoc( PHYSDEV dev
)
283 static INT
nulldrv_EndPage( PHYSDEV dev
)
288 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
293 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
298 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
299 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
304 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
305 INT out_size
, void *out_data
)
310 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
315 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
320 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
325 static BOOL
nulldrv_GdiRealizationInfo( PHYSDEV dev
, void *info
)
330 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
335 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
340 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
345 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
350 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
352 switch (cap
) /* return meaningful values for some entries */
354 case HORZRES
: return 640;
355 case VERTRES
: return 480;
356 case BITSPIXEL
: return 1;
357 case PLANES
: return 1;
358 case NUMCOLORS
: return 2;
359 case ASPECTX
: return 36;
360 case ASPECTY
: return 36;
361 case ASPECTXY
: return 51;
362 case LOGPIXELSX
: return 72;
363 case LOGPIXELSY
: return 72;
364 case SIZEPALETTE
: return 2;
365 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
366 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
367 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
372 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
374 SetLastError( ERROR_INVALID_PARAMETER
);
378 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
383 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
388 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
393 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
394 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
399 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
404 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
405 struct bitblt_coords
*src
)
407 return ERROR_NOT_SUPPORTED
;
410 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
415 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
420 static UINT
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
, UINT count
, PALETTEENTRY
*entries
)
425 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
427 return DEFAULT_CHARSET
;
430 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT
*dx
)
435 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT
*dx
)
440 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
444 HFONT hfont
= GetCurrentObject( dev
->hdc
, OBJ_FONT
);
446 if (GetObjectW( hfont
, sizeof(font
), &font
))
448 ret
= strlenW( font
.lfFaceName
) + 1;
451 lstrcpynW( name
, font
.lfFaceName
, size
);
452 ret
= min( size
, ret
);
458 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
463 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
468 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
473 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
478 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
483 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
484 INT xstart
, INT ystart
, INT xend
, INT yend
)
489 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
494 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
499 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
501 INT counts
[1] = { count
};
503 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
506 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
508 DWORD counts
[1] = { count
};
510 if (count
< 0) return FALSE
;
511 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
514 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
515 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
516 struct bitblt_coords
*dst
, DWORD rop
)
518 return ERROR_SUCCESS
;
521 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
526 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
531 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
536 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
541 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
542 INT ell_width
, INT ell_height
)
547 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
552 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
557 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
562 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
567 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
572 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
577 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
582 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
587 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
592 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
597 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
601 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
606 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
608 SetLastError( ERROR_INVALID_PARAMETER
);
612 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
617 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
622 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
627 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
632 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
637 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
642 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
647 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
652 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
657 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
662 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
667 static INT
nulldrv_StartPage( PHYSDEV dev
)
672 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
677 static struct opengl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
682 const struct gdi_dc_funcs null_driver
=
684 nulldrv_AbortDoc
, /* pAbortDoc */
685 nulldrv_AbortPath
, /* pAbortPath */
686 nulldrv_AlphaBlend
, /* pAlphaBlend */
687 nulldrv_AngleArc
, /* pAngleArc */
688 nulldrv_Arc
, /* pArc */
689 nulldrv_ArcTo
, /* pArcTo */
690 nulldrv_BeginPath
, /* pBeginPath */
691 nulldrv_BlendImage
, /* pBlendImage */
692 nulldrv_Chord
, /* pChord */
693 nulldrv_CloseFigure
, /* pCloseFigure */
694 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
695 nulldrv_CreateDC
, /* pCreateDC */
696 nulldrv_DeleteDC
, /* pDeleteDC */
697 nulldrv_DeleteObject
, /* pDeleteObject */
698 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
699 nulldrv_Ellipse
, /* pEllipse */
700 nulldrv_EndDoc
, /* pEndDoc */
701 nulldrv_EndPage
, /* pEndPage */
702 nulldrv_EndPath
, /* pEndPath */
703 nulldrv_EnumFonts
, /* pEnumFonts */
704 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
705 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
706 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
707 nulldrv_ExtEscape
, /* pExtEscape */
708 nulldrv_ExtFloodFill
, /* pExtFloodFill */
709 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
710 nulldrv_ExtTextOut
, /* pExtTextOut */
711 nulldrv_FillPath
, /* pFillPath */
712 nulldrv_FillRgn
, /* pFillRgn */
713 nulldrv_FlattenPath
, /* pFlattenPath */
714 nulldrv_FontIsLinked
, /* pFontIsLinked */
715 nulldrv_FrameRgn
, /* pFrameRgn */
716 nulldrv_GdiComment
, /* pGdiComment */
717 nulldrv_GdiRealizationInfo
, /* pGdiRealizationInfo */
718 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
719 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
720 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
721 nulldrv_GetCharWidth
, /* pGetCharWidth */
722 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
723 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
724 nulldrv_GetFontData
, /* pGetFontData */
725 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
726 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
727 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
728 nulldrv_GetICMProfile
, /* pGetICMProfile */
729 nulldrv_GetImage
, /* pGetImage */
730 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
731 nulldrv_GetNearestColor
, /* pGetNearestColor */
732 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
733 nulldrv_GetPixel
, /* pGetPixel */
734 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
735 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
736 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
737 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
738 nulldrv_GetTextFace
, /* pGetTextFace */
739 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
740 nulldrv_GradientFill
, /* pGradientFill */
741 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
742 nulldrv_InvertRgn
, /* pInvertRgn */
743 nulldrv_LineTo
, /* pLineTo */
744 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
745 nulldrv_MoveTo
, /* pMoveTo */
746 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
747 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
748 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
749 nulldrv_PaintRgn
, /* pPaintRgn */
750 nulldrv_PatBlt
, /* pPatBlt */
751 nulldrv_Pie
, /* pPie */
752 nulldrv_PolyBezier
, /* pPolyBezier */
753 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
754 nulldrv_PolyDraw
, /* pPolyDraw */
755 nulldrv_PolyPolygon
, /* pPolyPolygon */
756 nulldrv_PolyPolyline
, /* pPolyPolyline */
757 nulldrv_Polygon
, /* pPolygon */
758 nulldrv_Polyline
, /* pPolyline */
759 nulldrv_PolylineTo
, /* pPolylineTo */
760 nulldrv_PutImage
, /* pPutImage */
761 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
762 nulldrv_RealizePalette
, /* pRealizePalette */
763 nulldrv_Rectangle
, /* pRectangle */
764 nulldrv_ResetDC
, /* pResetDC */
765 nulldrv_RestoreDC
, /* pRestoreDC */
766 nulldrv_RoundRect
, /* pRoundRect */
767 nulldrv_SaveDC
, /* pSaveDC */
768 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
769 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
770 nulldrv_SelectBitmap
, /* pSelectBitmap */
771 nulldrv_SelectBrush
, /* pSelectBrush */
772 nulldrv_SelectClipPath
, /* pSelectClipPath */
773 nulldrv_SelectFont
, /* pSelectFont */
774 nulldrv_SelectPalette
, /* pSelectPalette */
775 nulldrv_SelectPen
, /* pSelectPen */
776 nulldrv_SetArcDirection
, /* pSetArcDirection */
777 nulldrv_SetBkColor
, /* pSetBkColor */
778 nulldrv_SetBkMode
, /* pSetBkMode */
779 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
780 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
781 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
782 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
783 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
784 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
785 nulldrv_SetLayout
, /* pSetLayout */
786 nulldrv_SetMapMode
, /* pSetMapMode */
787 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
788 nulldrv_SetPixel
, /* pSetPixel */
789 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
790 nulldrv_SetROP2
, /* pSetROP2 */
791 nulldrv_SetRelAbs
, /* pSetRelAbs */
792 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
793 nulldrv_SetTextAlign
, /* pSetTextAlign */
794 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
795 nulldrv_SetTextColor
, /* pSetTextColor */
796 nulldrv_SetTextJustification
, /* pSetTextJustification */
797 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
798 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
799 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
800 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
801 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
802 nulldrv_StartDoc
, /* pStartDoc */
803 nulldrv_StartPage
, /* pStartPage */
804 nulldrv_StretchBlt
, /* pStretchBlt */
805 nulldrv_StretchDIBits
, /* pStretchDIBits */
806 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
807 nulldrv_StrokePath
, /* pStrokePath */
808 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
809 nulldrv_WidenPath
, /* pWidenPath */
810 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
812 GDI_PRIORITY_NULL_DRV
/* priority */
816 /*****************************************************************************
817 * DRIVER_GetDriverName
820 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
822 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
823 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
824 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
825 static const WCHAR empty_strW
[] = { 0 };
828 /* display is a special case */
829 if (!strcmpiW( device
, displayW
) ||
830 !strcmpiW( device
, display1W
))
832 lstrcpynW( driver
, displayW
, size
);
836 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
838 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
841 p
= strchrW(driver
, ',');
844 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
848 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
853 /***********************************************************************
854 * GdiConvertToDevmodeW (GDI32.@)
856 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
859 WORD dmW_size
, dmA_size
;
861 dmA_size
= dmA
->dmSize
;
863 /* this is the minimal dmSize that XP accepts */
864 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
867 if (dmA_size
> sizeof(DEVMODEA
))
868 dmA_size
= sizeof(DEVMODEA
);
870 dmW_size
= dmA_size
+ CCHDEVICENAME
;
871 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
872 dmW_size
+= CCHFORMNAME
;
874 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
875 if (!dmW
) return NULL
;
877 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
878 dmW
->dmDeviceName
, CCHDEVICENAME
);
879 /* copy slightly more, to avoid long computations */
880 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
882 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
884 if (dmA
->dmFields
& DM_FORMNAME
)
885 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
886 dmW
->dmFormName
, CCHFORMNAME
);
888 dmW
->dmFormName
[0] = 0;
890 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
891 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
894 if (dmA
->dmDriverExtra
)
895 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
897 dmW
->dmSize
= dmW_size
;
903 /*****************************************************************************
906 * This should thunk to 16-bit and simply call the proc with the given args.
908 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
909 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
911 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
915 /*****************************************************************************
918 * This should load the correct driver for lpszDevice and calls this driver's
919 * ExtDeviceModePropSheet proc.
921 * Note: The driver calls a callback routine for each property sheet page; these
922 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
923 * The layout of this structure is:
929 * HPROPSHEETPAGE pages[10];
932 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
933 LPCSTR lpszPort
, LPVOID lpPropSheet
)
935 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
939 /*****************************************************************************
942 * This should load the correct driver for lpszDevice and call this driver's
943 * ExtDeviceMode proc.
945 * FIXME: convert ExtDeviceMode to unicode in the driver interface
947 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
948 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
949 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
950 LPSTR lpszProfile
, DWORD fwMode
)
959 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
960 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
962 if (!lpszDevice
) return -1;
963 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
965 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
967 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
969 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
971 if ((dc
= get_dc_ptr( hdc
)))
973 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
974 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
975 lpdmInput
, lpszProfile
, fwMode
);
976 release_dc_ptr( dc
);
982 /****************************************************************************
985 * This should load the correct driver for lpszDevice and calls this driver's
986 * AdvancedSetupDialog proc.
988 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
989 LPDEVMODEA devin
, LPDEVMODEA devout
)
991 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
995 /*****************************************************************************
998 * This should load the correct driver for lpszDevice and calls this driver's
999 * DeviceCapabilities proc.
1001 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1003 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1004 WORD fwCapability
, LPSTR lpszOutput
,
1014 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1016 if (!lpszDevice
) return -1;
1017 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1019 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1021 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1023 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1025 if ((dc
= get_dc_ptr( hdc
)))
1027 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1028 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1029 fwCapability
, lpszOutput
, lpdm
);
1030 release_dc_ptr( dc
);
1037 /************************************************************************
1040 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1048 return AbortDoc( hdc
);
1051 return EndDoc( hdc
);
1053 case GETPHYSPAGESIZE
:
1055 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1056 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1059 case GETPRINTINGOFFSET
:
1061 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1062 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1065 case GETSCALINGFACTOR
:
1067 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1068 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1072 return EndPage( hdc
);
1075 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1082 /* in_data may not be 0 terminated so we must copy it */
1085 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1086 memcpy( name
, in_data
, in_count
);
1089 /* out_data is actually a pointer to the DocInfo structure and used as
1090 * a second input parameter */
1091 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1094 doc
.cbSize
= sizeof(doc
);
1095 doc
.lpszOutput
= NULL
;
1096 doc
.lpszDatatype
= NULL
;
1099 doc
.lpszDocName
= name
;
1100 ret
= StartDocA( hdc
, &doc
);
1101 HeapFree( GetProcessHeap(), 0, name
);
1102 if (ret
> 0) ret
= StartPage( hdc
);
1106 case QUERYESCSUPPORT
:
1110 if (in_count
< sizeof(SHORT
)) return 0;
1111 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
1116 case GETPHYSPAGESIZE
:
1117 case GETPRINTINGOFFSET
:
1118 case GETSCALINGFACTOR
:
1120 case QUERYESCSUPPORT
:
1129 /* if not handled internally, pass it to the driver */
1130 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1134 /******************************************************************************
1135 * ExtEscape [GDI32.@]
1137 * Access capabilities of a particular device that are not available through GDI.
1140 * hdc [I] Handle to device context
1141 * nEscape [I] Escape function
1142 * cbInput [I] Number of bytes in input structure
1143 * lpszInData [I] Pointer to input structure
1144 * cbOutput [I] Number of bytes in output structure
1145 * lpszOutData [O] Pointer to output structure
1149 * Not implemented: 0
1152 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1153 INT cbOutput
, LPSTR lpszOutData
)
1157 DC
* dc
= get_dc_ptr( hdc
);
1161 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1162 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1163 release_dc_ptr( dc
);
1168 /*******************************************************************
1169 * DrawEscape [GDI32.@]
1173 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1175 FIXME("DrawEscape, stub\n");
1179 /*******************************************************************
1180 * NamedEscape [GDI32.@]
1182 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1183 INT cbOutput
, LPSTR lpszOutData
)
1185 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1186 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1191 /*******************************************************************
1192 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1193 * GdiEntry13 [GDI32.@]
1195 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1197 static int warn_once
;