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 };
64 /**********************************************************************
67 * Allocate and fill the driver structure for a given module.
69 static struct graphics_driver
*create_driver( HMODULE module
)
71 static const struct gdi_dc_funcs empty_funcs
;
72 const struct gdi_dc_funcs
*funcs
= NULL
;
73 struct graphics_driver
*driver
;
75 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
76 driver
->module
= module
;
80 const struct gdi_dc_funcs
* (CDECL
*wine_get_gdi_driver
)( unsigned int version
);
82 if ((wine_get_gdi_driver
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" )))
83 funcs
= wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION
);
85 if (!funcs
) funcs
= &empty_funcs
;
86 driver
->funcs
= funcs
;
91 /**********************************************************************
94 * Special case for loading the display driver: get the name from the config file
96 static const struct gdi_dc_funcs
*get_display_driver( HMODULE
*module_ret
)
98 struct graphics_driver
*driver
;
99 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
105 *module_ret
= display_driver
->module
;
106 return display_driver
->funcs
; /* already loaded */
109 strcpy( buffer
, "x11" ); /* default value */
110 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
111 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
113 DWORD type
, count
= sizeof(buffer
);
114 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
121 next
= strchr( name
, ',' );
122 if (next
) *next
++ = 0;
124 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
125 if ((module
= LoadLibraryA( libname
)) != 0) break;
129 if (!module
) display_driver_load_error
= GetLastError();
131 if (!(driver
= create_driver( module
)))
133 MESSAGE( "Could not create graphics driver '%s'\n", buffer
);
134 FreeLibrary( module
);
137 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
139 /* somebody beat us to it */
140 FreeLibrary( driver
->module
);
141 HeapFree( GetProcessHeap(), 0, driver
);
143 return display_driver
->funcs
;
147 /**********************************************************************
150 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
, HMODULE
*module_ret
)
153 struct graphics_driver
*driver
, *new_driver
;
154 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
155 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
157 /* display driver is a special case */
158 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
))
159 return get_display_driver( module_ret
);
161 if ((module
= GetModuleHandleW( name
)))
163 if (display_driver
&& display_driver
->module
== module
)
165 *module_ret
= module
;
166 return display_driver
->funcs
;
168 EnterCriticalSection( &driver_section
);
169 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
171 if (driver
->module
== module
) goto done
;
173 LeaveCriticalSection( &driver_section
);
176 if (!(module
= LoadLibraryW( name
))) return NULL
;
178 if (!(new_driver
= create_driver( module
)))
180 FreeLibrary( module
);
184 /* check if someone else added it in the meantime */
185 EnterCriticalSection( &driver_section
);
186 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
188 if (driver
->module
!= module
) continue;
189 FreeLibrary( module
);
190 HeapFree( GetProcessHeap(), 0, new_driver
);
194 list_add_head( &drivers
, &driver
->entry
);
195 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
197 *module_ret
= driver
->module
;
198 LeaveCriticalSection( &driver_section
);
199 return driver
->funcs
;
203 /***********************************************************************
204 * __wine_get_driver_module (GDI32.@)
206 HMODULE CDECL
__wine_get_driver_module( HDC hdc
)
211 if ((dc
= get_dc_ptr( hdc
)))
214 release_dc_ptr( dc
);
215 if (!ret
) SetLastError( display_driver_load_error
);
217 else SetLastError( ERROR_INVALID_HANDLE
);
222 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
227 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
228 INT xstart
, INT ystart
, INT xend
, INT yend
)
233 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
234 INT xstart
, INT ystart
, INT xend
, INT yend
)
239 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
241 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
242 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
245 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
246 LPCWSTR output
, const DEVMODEW
*devmode
)
248 assert(0); /* should never be called */
252 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
254 assert(0); /* should never be called */
258 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
263 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
264 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
269 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
274 static INT
nulldrv_EndDoc( PHYSDEV dev
)
279 static INT
nulldrv_EndPage( PHYSDEV dev
)
284 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
289 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
294 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
295 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
300 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
301 INT out_size
, void *out_data
)
306 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
311 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
316 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
321 static BOOL
nulldrv_GdiRealizationInfo( PHYSDEV dev
, void *info
)
326 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
331 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
336 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
341 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
346 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
348 switch (cap
) /* return meaningful values for some entries */
350 case HORZRES
: return 640;
351 case VERTRES
: return 480;
352 case BITSPIXEL
: return 1;
353 case PLANES
: return 1;
354 case NUMCOLORS
: return 2;
355 case ASPECTX
: return 36;
356 case ASPECTY
: return 36;
357 case ASPECTXY
: return 51;
358 case LOGPIXELSX
: return 72;
359 case LOGPIXELSY
: return 72;
360 case SIZEPALETTE
: return 2;
361 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
362 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
363 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
368 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
370 SetLastError( ERROR_INVALID_PARAMETER
);
374 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
379 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
384 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
389 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
390 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
395 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
400 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
401 struct bitblt_coords
*src
)
403 return ERROR_NOT_SUPPORTED
;
406 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
411 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
416 static UINT
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
, UINT count
, PALETTEENTRY
*entries
)
421 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
423 return DEFAULT_CHARSET
;
426 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT max_ext
,
427 INT
*fit
, INT
*dx
, SIZE
*size
)
432 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT max_ext
,
433 INT
*fit
, INT
*dx
, SIZE
*size
)
438 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
442 HFONT hfont
= GetCurrentObject( dev
->hdc
, OBJ_FONT
);
444 if (GetObjectW( hfont
, sizeof(font
), &font
))
446 ret
= strlenW( font
.lfFaceName
) + 1;
449 lstrcpynW( name
, font
.lfFaceName
, size
);
450 ret
= min( size
, ret
);
456 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
461 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
466 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
471 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
476 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
481 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
482 INT xstart
, INT ystart
, INT xend
, INT yend
)
487 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
492 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
497 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
499 INT counts
[1] = { count
};
501 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
504 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
506 DWORD counts
[1] = { count
};
508 if (count
< 0) return FALSE
;
509 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
512 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
513 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
514 struct bitblt_coords
*dst
, DWORD rop
)
516 return ERROR_SUCCESS
;
519 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
524 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
529 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
534 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
539 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
540 INT ell_width
, INT ell_height
)
545 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
550 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
555 static HFONT
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
)
560 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
565 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
570 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
575 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
580 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
585 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
590 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
595 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
600 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
604 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
609 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
611 SetLastError( ERROR_INVALID_PARAMETER
);
615 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
620 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
625 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
630 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
635 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
640 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
645 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
650 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
655 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
660 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
665 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
670 static INT
nulldrv_StartPage( PHYSDEV dev
)
675 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
680 static struct opengl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
685 const struct gdi_dc_funcs null_driver
=
687 nulldrv_AbortDoc
, /* pAbortDoc */
688 nulldrv_AbortPath
, /* pAbortPath */
689 nulldrv_AlphaBlend
, /* pAlphaBlend */
690 nulldrv_AngleArc
, /* pAngleArc */
691 nulldrv_Arc
, /* pArc */
692 nulldrv_ArcTo
, /* pArcTo */
693 nulldrv_BeginPath
, /* pBeginPath */
694 nulldrv_BlendImage
, /* pBlendImage */
695 nulldrv_Chord
, /* pChord */
696 nulldrv_CloseFigure
, /* pCloseFigure */
697 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
698 nulldrv_CreateDC
, /* pCreateDC */
699 nulldrv_DeleteDC
, /* pDeleteDC */
700 nulldrv_DeleteObject
, /* pDeleteObject */
701 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
702 nulldrv_Ellipse
, /* pEllipse */
703 nulldrv_EndDoc
, /* pEndDoc */
704 nulldrv_EndPage
, /* pEndPage */
705 nulldrv_EndPath
, /* pEndPath */
706 nulldrv_EnumFonts
, /* pEnumFonts */
707 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
708 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
709 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
710 nulldrv_ExtEscape
, /* pExtEscape */
711 nulldrv_ExtFloodFill
, /* pExtFloodFill */
712 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
713 nulldrv_ExtTextOut
, /* pExtTextOut */
714 nulldrv_FillPath
, /* pFillPath */
715 nulldrv_FillRgn
, /* pFillRgn */
716 nulldrv_FlattenPath
, /* pFlattenPath */
717 nulldrv_FontIsLinked
, /* pFontIsLinked */
718 nulldrv_FrameRgn
, /* pFrameRgn */
719 nulldrv_GdiComment
, /* pGdiComment */
720 nulldrv_GdiRealizationInfo
, /* pGdiRealizationInfo */
721 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
722 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
723 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
724 nulldrv_GetCharWidth
, /* pGetCharWidth */
725 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
726 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
727 nulldrv_GetFontData
, /* pGetFontData */
728 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
729 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
730 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
731 nulldrv_GetICMProfile
, /* pGetICMProfile */
732 nulldrv_GetImage
, /* pGetImage */
733 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
734 nulldrv_GetNearestColor
, /* pGetNearestColor */
735 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
736 nulldrv_GetPixel
, /* pGetPixel */
737 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
738 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
739 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
740 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
741 nulldrv_GetTextFace
, /* pGetTextFace */
742 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
743 nulldrv_GradientFill
, /* pGradientFill */
744 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
745 nulldrv_InvertRgn
, /* pInvertRgn */
746 nulldrv_LineTo
, /* pLineTo */
747 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
748 nulldrv_MoveTo
, /* pMoveTo */
749 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
750 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
751 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
752 nulldrv_PaintRgn
, /* pPaintRgn */
753 nulldrv_PatBlt
, /* pPatBlt */
754 nulldrv_Pie
, /* pPie */
755 nulldrv_PolyBezier
, /* pPolyBezier */
756 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
757 nulldrv_PolyDraw
, /* pPolyDraw */
758 nulldrv_PolyPolygon
, /* pPolyPolygon */
759 nulldrv_PolyPolyline
, /* pPolyPolyline */
760 nulldrv_Polygon
, /* pPolygon */
761 nulldrv_Polyline
, /* pPolyline */
762 nulldrv_PolylineTo
, /* pPolylineTo */
763 nulldrv_PutImage
, /* pPutImage */
764 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
765 nulldrv_RealizePalette
, /* pRealizePalette */
766 nulldrv_Rectangle
, /* pRectangle */
767 nulldrv_ResetDC
, /* pResetDC */
768 nulldrv_RestoreDC
, /* pRestoreDC */
769 nulldrv_RoundRect
, /* pRoundRect */
770 nulldrv_SaveDC
, /* pSaveDC */
771 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
772 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
773 nulldrv_SelectBitmap
, /* pSelectBitmap */
774 nulldrv_SelectBrush
, /* pSelectBrush */
775 nulldrv_SelectClipPath
, /* pSelectClipPath */
776 nulldrv_SelectFont
, /* pSelectFont */
777 nulldrv_SelectPalette
, /* pSelectPalette */
778 nulldrv_SelectPen
, /* pSelectPen */
779 nulldrv_SetArcDirection
, /* pSetArcDirection */
780 nulldrv_SetBkColor
, /* pSetBkColor */
781 nulldrv_SetBkMode
, /* pSetBkMode */
782 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
783 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
784 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
785 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
786 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
787 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
788 nulldrv_SetLayout
, /* pSetLayout */
789 nulldrv_SetMapMode
, /* pSetMapMode */
790 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
791 nulldrv_SetPixel
, /* pSetPixel */
792 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
793 nulldrv_SetROP2
, /* pSetROP2 */
794 nulldrv_SetRelAbs
, /* pSetRelAbs */
795 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
796 nulldrv_SetTextAlign
, /* pSetTextAlign */
797 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
798 nulldrv_SetTextColor
, /* pSetTextColor */
799 nulldrv_SetTextJustification
, /* pSetTextJustification */
800 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
801 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
802 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
803 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
804 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
805 nulldrv_StartDoc
, /* pStartDoc */
806 nulldrv_StartPage
, /* pStartPage */
807 nulldrv_StretchBlt
, /* pStretchBlt */
808 nulldrv_StretchDIBits
, /* pStretchDIBits */
809 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
810 nulldrv_StrokePath
, /* pStrokePath */
811 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
812 nulldrv_WidenPath
, /* pWidenPath */
813 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
815 GDI_PRIORITY_NULL_DRV
/* priority */
819 /*****************************************************************************
820 * DRIVER_GetDriverName
823 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
825 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
826 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
827 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
828 static const WCHAR empty_strW
[] = { 0 };
831 /* display is a special case */
832 if (!strcmpiW( device
, displayW
) ||
833 !strcmpiW( device
, display1W
))
835 lstrcpynW( driver
, displayW
, size
);
839 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
841 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
844 p
= strchrW(driver
, ',');
847 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
851 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
856 /***********************************************************************
857 * GdiConvertToDevmodeW (GDI32.@)
859 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
862 WORD dmW_size
, dmA_size
;
864 dmA_size
= dmA
->dmSize
;
866 /* this is the minimal dmSize that XP accepts */
867 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
870 if (dmA_size
> sizeof(DEVMODEA
))
871 dmA_size
= sizeof(DEVMODEA
);
873 dmW_size
= dmA_size
+ CCHDEVICENAME
;
874 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
875 dmW_size
+= CCHFORMNAME
;
877 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
878 if (!dmW
) return NULL
;
880 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
881 dmW
->dmDeviceName
, CCHDEVICENAME
);
882 /* copy slightly more, to avoid long computations */
883 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
885 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
887 if (dmA
->dmFields
& DM_FORMNAME
)
888 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
889 dmW
->dmFormName
, CCHFORMNAME
);
891 dmW
->dmFormName
[0] = 0;
893 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
894 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
897 if (dmA
->dmDriverExtra
)
898 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
900 dmW
->dmSize
= dmW_size
;
906 /*****************************************************************************
909 * This should thunk to 16-bit and simply call the proc with the given args.
911 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
912 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
914 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
918 /*****************************************************************************
921 * This should load the correct driver for lpszDevice and calls this driver's
922 * ExtDeviceModePropSheet proc.
924 * Note: The driver calls a callback routine for each property sheet page; these
925 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
926 * The layout of this structure is:
932 * HPROPSHEETPAGE pages[10];
935 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
936 LPCSTR lpszPort
, LPVOID lpPropSheet
)
938 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
942 /*****************************************************************************
945 * This should load the correct driver for lpszDevice and call this driver's
946 * ExtDeviceMode proc.
948 * FIXME: convert ExtDeviceMode to unicode in the driver interface
950 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
951 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
952 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
953 LPSTR lpszProfile
, DWORD fwMode
)
962 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
963 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
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
, pExtDeviceMode
);
977 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
978 lpdmInput
, lpszProfile
, fwMode
);
979 release_dc_ptr( dc
);
985 /****************************************************************************
988 * This should load the correct driver for lpszDevice and calls this driver's
989 * AdvancedSetupDialog proc.
991 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
992 LPDEVMODEA devin
, LPDEVMODEA devout
)
994 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
998 /*****************************************************************************
1001 * This should load the correct driver for lpszDevice and calls this driver's
1002 * DeviceCapabilities proc.
1004 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1006 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1007 WORD fwCapability
, LPSTR lpszOutput
,
1017 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1019 if (!lpszDevice
) return -1;
1020 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1022 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1024 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1026 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1028 if ((dc
= get_dc_ptr( hdc
)))
1030 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1031 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1032 fwCapability
, lpszOutput
, lpdm
);
1033 release_dc_ptr( dc
);
1040 /************************************************************************
1043 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1051 return AbortDoc( hdc
);
1054 return EndDoc( hdc
);
1056 case GETPHYSPAGESIZE
:
1058 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1059 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1062 case GETPRINTINGOFFSET
:
1064 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1065 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1068 case GETSCALINGFACTOR
:
1070 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1071 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1075 return EndPage( hdc
);
1078 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1085 /* in_data may not be 0 terminated so we must copy it */
1088 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1089 memcpy( name
, in_data
, in_count
);
1092 /* out_data is actually a pointer to the DocInfo structure and used as
1093 * a second input parameter */
1094 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1097 doc
.cbSize
= sizeof(doc
);
1098 doc
.lpszOutput
= NULL
;
1099 doc
.lpszDatatype
= NULL
;
1102 doc
.lpszDocName
= name
;
1103 ret
= StartDocA( hdc
, &doc
);
1104 HeapFree( GetProcessHeap(), 0, name
);
1105 if (ret
> 0) ret
= StartPage( hdc
);
1109 case QUERYESCSUPPORT
:
1111 const INT
*ptr
= (const INT
*)in_data
;
1112 if (in_count
< sizeof(INT
)) return 0;
1117 case GETPHYSPAGESIZE
:
1118 case GETPRINTINGOFFSET
:
1119 case GETSCALINGFACTOR
:
1121 case QUERYESCSUPPORT
:
1130 /* if not handled internally, pass it to the driver */
1131 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1135 /******************************************************************************
1136 * ExtEscape [GDI32.@]
1138 * Access capabilities of a particular device that are not available through GDI.
1141 * hdc [I] Handle to device context
1142 * nEscape [I] Escape function
1143 * cbInput [I] Number of bytes in input structure
1144 * lpszInData [I] Pointer to input structure
1145 * cbOutput [I] Number of bytes in output structure
1146 * lpszOutData [O] Pointer to output structure
1150 * Not implemented: 0
1153 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1154 INT cbOutput
, LPSTR lpszOutData
)
1158 DC
* dc
= get_dc_ptr( hdc
);
1162 physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1163 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1164 release_dc_ptr( dc
);
1169 /*******************************************************************
1170 * DrawEscape [GDI32.@]
1174 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1176 FIXME("DrawEscape, stub\n");
1180 /*******************************************************************
1181 * NamedEscape [GDI32.@]
1183 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1184 INT cbOutput
, LPSTR lpszOutData
)
1186 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1187 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1192 /*******************************************************************
1193 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1194 * GdiEntry13 [GDI32.@]
1196 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1198 static int warn_once
;