2 * Graphics driver management functions
4 * Copyright 1994 Bob Amstadt
5 * Copyright 1996, 2001 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
33 #include "wine/winbase16.h"
35 #include "gdi_private.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(driver
);
42 struct graphics_driver
45 HMODULE module
; /* module handle */
46 const struct gdi_dc_funcs
*funcs
;
49 static struct list drivers
= LIST_INIT( drivers
);
50 static struct graphics_driver
*display_driver
;
52 const struct gdi_dc_funcs
*font_driver
= NULL
;
53 static const struct wgl_funcs null_wgl_driver
;
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(void)
98 struct graphics_driver
*driver
;
99 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
103 if (display_driver
) return display_driver
->funcs
; /* already loaded */
105 strcpy( buffer
, "x11" ); /* default value */
106 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
107 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
109 DWORD type
, count
= sizeof(buffer
);
110 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
117 next
= strchr( name
, ',' );
118 if (next
) *next
++ = 0;
120 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
121 if ((module
= LoadLibraryA( libname
)) != 0) break;
125 if (!(driver
= create_driver( module
)))
127 MESSAGE( "Could not create graphics driver '%s'\n", buffer
);
128 FreeLibrary( module
);
131 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
133 /* somebody beat us to it */
134 FreeLibrary( driver
->module
);
135 HeapFree( GetProcessHeap(), 0, driver
);
137 return display_driver
->funcs
;
141 /**********************************************************************
144 const struct gdi_dc_funcs
*DRIVER_load_driver( LPCWSTR name
)
147 struct graphics_driver
*driver
, *new_driver
;
148 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
149 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
151 /* display driver is a special case */
152 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
)) return get_display_driver();
154 if ((module
= GetModuleHandleW( name
)))
156 if (display_driver
&& display_driver
->module
== module
) return display_driver
->funcs
;
157 EnterCriticalSection( &driver_section
);
158 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
160 if (driver
->module
== module
) goto done
;
162 LeaveCriticalSection( &driver_section
);
165 if (!(module
= LoadLibraryW( name
))) return NULL
;
167 if (!(new_driver
= create_driver( module
)))
169 FreeLibrary( module
);
173 /* check if someone else added it in the meantime */
174 EnterCriticalSection( &driver_section
);
175 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
177 if (driver
->module
!= module
) continue;
178 FreeLibrary( module
);
179 HeapFree( GetProcessHeap(), 0, new_driver
);
183 list_add_head( &drivers
, &driver
->entry
);
184 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
186 LeaveCriticalSection( &driver_section
);
187 return driver
->funcs
;
191 static INT
nulldrv_AbortDoc( PHYSDEV dev
)
196 static BOOL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
197 INT xstart
, INT ystart
, INT xend
, INT yend
)
202 static BOOL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
203 INT xstart
, INT ystart
, INT xend
, INT yend
)
208 static BOOL
nulldrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
210 if (!display_driver
|| !display_driver
->funcs
->pCreateCompatibleDC
) return TRUE
;
211 return display_driver
->funcs
->pCreateCompatibleDC( NULL
, pdev
);
214 static BOOL
nulldrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
215 LPCWSTR output
, const DEVMODEW
*devmode
)
217 assert(0); /* should never be called */
221 static BOOL
nulldrv_DeleteDC( PHYSDEV dev
)
223 assert(0); /* should never be called */
227 static BOOL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
232 static INT
nulldrv_DescribePixelFormat( PHYSDEV dev
, INT format
, UINT size
, PIXELFORMATDESCRIPTOR
* descr
)
237 static DWORD
nulldrv_DeviceCapabilities( LPSTR buffer
, LPCSTR device
, LPCSTR port
,
238 WORD cap
, LPSTR output
, DEVMODEA
*devmode
)
243 static BOOL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
248 static INT
nulldrv_EndDoc( PHYSDEV dev
)
253 static INT
nulldrv_EndPage( PHYSDEV dev
)
258 static BOOL
nulldrv_EnumFonts( PHYSDEV dev
, LOGFONTW
*logfont
, FONTENUMPROCW proc
, LPARAM lParam
)
263 static INT
nulldrv_EnumICMProfiles( PHYSDEV dev
, ICMENUMPROCW func
, LPARAM lparam
)
268 static INT
nulldrv_ExtDeviceMode( LPSTR buffer
, HWND hwnd
, DEVMODEA
*output
, LPSTR device
,
269 LPSTR port
, DEVMODEA
*input
, LPSTR profile
, DWORD mode
)
274 static INT
nulldrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_size
, const void *in_data
,
275 INT out_size
, void *out_data
)
280 static BOOL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
285 static BOOL
nulldrv_FontIsLinked( PHYSDEV dev
)
290 static BOOL
nulldrv_GdiComment( PHYSDEV dev
, UINT size
, const BYTE
*data
)
295 static BOOL
nulldrv_GdiRealizationInfo( PHYSDEV dev
, void *info
)
300 static UINT
nulldrv_GetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
305 static BOOL
nulldrv_GetCharABCWidths( PHYSDEV dev
, UINT first
, UINT last
, LPABC abc
)
310 static BOOL
nulldrv_GetCharABCWidthsI( PHYSDEV dev
, UINT first
, UINT count
, WORD
*indices
, LPABC abc
)
315 static BOOL
nulldrv_GetCharWidth( PHYSDEV dev
, UINT first
, UINT last
, INT
*buffer
)
320 static INT
nulldrv_GetDeviceCaps( PHYSDEV dev
, INT cap
)
322 switch (cap
) /* return meaningful values for some entries */
324 case HORZRES
: return 640;
325 case VERTRES
: return 480;
326 case BITSPIXEL
: return 1;
327 case PLANES
: return 1;
328 case NUMCOLORS
: return 2;
329 case ASPECTX
: return 36;
330 case ASPECTY
: return 36;
331 case ASPECTXY
: return 51;
332 case LOGPIXELSX
: return 72;
333 case LOGPIXELSY
: return 72;
334 case SIZEPALETTE
: return 2;
335 case TEXTCAPS
: return (TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
336 TC_CR_ANY
| TC_SF_X_YINDEP
| TC_SA_DOUBLE
| TC_SA_INTEGER
|
337 TC_SA_CONTIN
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
| TC_VA_ABLE
);
342 static BOOL
nulldrv_GetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
344 SetLastError( ERROR_INVALID_PARAMETER
);
348 static DWORD
nulldrv_GetFontData( PHYSDEV dev
, DWORD table
, DWORD offset
, LPVOID buffer
, DWORD length
)
353 static DWORD
nulldrv_GetFontUnicodeRanges( PHYSDEV dev
, LPGLYPHSET glyphs
)
358 static DWORD
nulldrv_GetGlyphIndices( PHYSDEV dev
, LPCWSTR str
, INT count
, LPWORD indices
, DWORD flags
)
363 static DWORD
nulldrv_GetGlyphOutline( PHYSDEV dev
, UINT ch
, UINT format
, LPGLYPHMETRICS metrics
,
364 DWORD size
, LPVOID buffer
, const MAT2
*mat
)
369 static BOOL
nulldrv_GetICMProfile( PHYSDEV dev
, LPDWORD size
, LPWSTR filename
)
374 static DWORD
nulldrv_GetImage( PHYSDEV dev
, BITMAPINFO
*info
, struct gdi_image_bits
*bits
,
375 struct bitblt_coords
*src
)
377 return ERROR_NOT_SUPPORTED
;
380 static DWORD
nulldrv_GetKerningPairs( PHYSDEV dev
, DWORD count
, LPKERNINGPAIR pairs
)
385 static UINT
nulldrv_GetOutlineTextMetrics( PHYSDEV dev
, UINT size
, LPOUTLINETEXTMETRICW otm
)
390 static INT
nulldrv_GetPixelFormat( HDC hdc
)
395 static UINT
nulldrv_GetSystemPaletteEntries( PHYSDEV dev
, UINT start
, UINT count
, PALETTEENTRY
*entries
)
400 static UINT
nulldrv_GetTextCharsetInfo( PHYSDEV dev
, LPFONTSIGNATURE fs
, DWORD flags
)
402 return DEFAULT_CHARSET
;
405 static BOOL
nulldrv_GetTextExtentExPoint( PHYSDEV dev
, LPCWSTR str
, INT count
, INT max_ext
,
406 INT
*fit
, INT
*dx
, SIZE
*size
)
411 static BOOL
nulldrv_GetTextExtentExPointI( PHYSDEV dev
, const WORD
*indices
, INT count
, INT max_ext
,
412 INT
*fit
, INT
*dx
, SIZE
*size
)
417 static INT
nulldrv_GetTextFace( PHYSDEV dev
, INT size
, LPWSTR name
)
421 HFONT hfont
= GetCurrentObject( dev
->hdc
, OBJ_FONT
);
423 if (GetObjectW( hfont
, sizeof(font
), &font
))
425 ret
= strlenW( font
.lfFaceName
) + 1;
428 lstrcpynW( name
, font
.lfFaceName
, size
);
429 ret
= min( size
, ret
);
435 static BOOL
nulldrv_GetTextMetrics( PHYSDEV dev
, TEXTMETRICW
*metrics
)
440 static BOOL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
445 static BOOL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
450 static BOOL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
455 static BOOL
nulldrv_PatBlt( PHYSDEV dev
, struct bitblt_coords
*dst
, DWORD rop
)
460 static BOOL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
461 INT xstart
, INT ystart
, INT xend
, INT yend
)
466 static BOOL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
471 static BOOL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
476 static BOOL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
478 INT counts
[1] = { count
};
480 return PolyPolygon( dev
->hdc
, points
, counts
, 1 );
483 static BOOL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
485 DWORD counts
[1] = { count
};
487 if (count
< 0) return FALSE
;
488 return PolyPolyline( dev
->hdc
, points
, counts
, 1 );
491 static DWORD
nulldrv_PutImage( PHYSDEV dev
, HRGN clip
, BITMAPINFO
*info
,
492 const struct gdi_image_bits
*bits
, struct bitblt_coords
*src
,
493 struct bitblt_coords
*dst
, DWORD rop
)
495 return ERROR_SUCCESS
;
498 static UINT
nulldrv_RealizeDefaultPalette( PHYSDEV dev
)
503 static UINT
nulldrv_RealizePalette( PHYSDEV dev
, HPALETTE palette
, BOOL primary
)
508 static BOOL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
513 static HDC
nulldrv_ResetDC( PHYSDEV dev
, const DEVMODEW
*devmode
)
518 static BOOL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
519 INT ell_width
, INT ell_height
)
524 static HBITMAP
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
529 static HBRUSH
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
, const struct brush_pattern
*pattern
)
534 static HFONT
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
)
539 static HPALETTE
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
544 static HPEN
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
, const struct brush_pattern
*pattern
)
549 static INT
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
554 static COLORREF
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
559 static INT
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
564 static UINT
nulldrv_SetBoundsRect( PHYSDEV dev
, RECT
*rect
, UINT flags
)
569 static COLORREF
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
574 static COLORREF
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
579 static void nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN rgn
)
583 static DWORD
nulldrv_SetLayout( PHYSDEV dev
, DWORD layout
)
588 static BOOL
nulldrv_SetDeviceGammaRamp( PHYSDEV dev
, void *ramp
)
590 SetLastError( ERROR_INVALID_PARAMETER
);
594 static DWORD
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
599 static COLORREF
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
604 static BOOL
nulldrv_SetPixelFormat( PHYSDEV dev
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
609 static INT
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
614 static INT
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
619 static INT
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
624 static INT
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
629 static UINT
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
634 static INT
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
639 static COLORREF
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
644 static BOOL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
649 static INT
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
654 static INT
nulldrv_StartPage( PHYSDEV dev
)
659 static BOOL
nulldrv_SwapBuffers( PHYSDEV dev
)
664 static BOOL
nulldrv_UnrealizePalette( HPALETTE palette
)
669 static BOOL
nulldrv_wglCopyContext( struct wgl_context
*src
, struct wgl_context
*dst
, UINT mask
)
674 static struct wgl_context
*nulldrv_wglCreateContext( HDC hdc
)
679 static struct wgl_context
*nulldrv_wglCreateContextAttribsARB( HDC hdc
, struct wgl_context
*share_ctx
,
685 static void nulldrv_wglDeleteContext( struct wgl_context
*context
)
689 static HDC
nulldrv_wglGetCurrentDC( struct wgl_context
*context
)
694 static PROC
nulldrv_wglGetProcAddress( LPCSTR name
)
699 static BOOL
nulldrv_wglMakeContextCurrentARB( HDC draw_hdc
, HDC read_hdc
, struct wgl_context
*context
)
704 static BOOL
nulldrv_wglMakeCurrent( HDC hdc
, struct wgl_context
*context
)
709 static BOOL
nulldrv_wglShareLists( struct wgl_context
*org
, struct wgl_context
*dst
)
714 static const struct wgl_funcs
*nulldrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
716 if (version
!= WINE_GDI_DRIVER_VERSION
)
718 ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version
, WINE_GDI_DRIVER_VERSION
);
721 return &null_wgl_driver
;
724 const struct gdi_dc_funcs null_driver
=
726 nulldrv_AbortDoc
, /* pAbortDoc */
727 nulldrv_AbortPath
, /* pAbortPath */
728 nulldrv_AlphaBlend
, /* pAlphaBlend */
729 nulldrv_AngleArc
, /* pAngleArc */
730 nulldrv_Arc
, /* pArc */
731 nulldrv_ArcTo
, /* pArcTo */
732 nulldrv_BeginPath
, /* pBeginPath */
733 nulldrv_BlendImage
, /* pBlendImage */
734 nulldrv_Chord
, /* pChord */
735 nulldrv_CloseFigure
, /* pCloseFigure */
736 nulldrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
737 nulldrv_CreateDC
, /* pCreateDC */
738 nulldrv_DeleteDC
, /* pDeleteDC */
739 nulldrv_DeleteObject
, /* pDeleteObject */
740 nulldrv_DescribePixelFormat
, /* pDescribePixelFormat */
741 nulldrv_DeviceCapabilities
, /* pDeviceCapabilities */
742 nulldrv_Ellipse
, /* pEllipse */
743 nulldrv_EndDoc
, /* pEndDoc */
744 nulldrv_EndPage
, /* pEndPage */
745 nulldrv_EndPath
, /* pEndPath */
746 nulldrv_EnumFonts
, /* pEnumFonts */
747 nulldrv_EnumICMProfiles
, /* pEnumICMProfiles */
748 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
749 nulldrv_ExtDeviceMode
, /* pExtDeviceMode */
750 nulldrv_ExtEscape
, /* pExtEscape */
751 nulldrv_ExtFloodFill
, /* pExtFloodFill */
752 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
753 nulldrv_ExtTextOut
, /* pExtTextOut */
754 nulldrv_FillPath
, /* pFillPath */
755 nulldrv_FillRgn
, /* pFillRgn */
756 nulldrv_FlattenPath
, /* pFlattenPath */
757 nulldrv_FontIsLinked
, /* pFontIsLinked */
758 nulldrv_FrameRgn
, /* pFrameRgn */
759 nulldrv_GdiComment
, /* pGdiComment */
760 nulldrv_GdiRealizationInfo
, /* pGdiRealizationInfo */
761 nulldrv_GetBoundsRect
, /* pGetBoundsRect */
762 nulldrv_GetCharABCWidths
, /* pGetCharABCWidths */
763 nulldrv_GetCharABCWidthsI
, /* pGetCharABCWidthsI */
764 nulldrv_GetCharWidth
, /* pGetCharWidth */
765 nulldrv_GetDeviceCaps
, /* pGetDeviceCaps */
766 nulldrv_GetDeviceGammaRamp
, /* pGetDeviceGammaRamp */
767 nulldrv_GetFontData
, /* pGetFontData */
768 nulldrv_GetFontUnicodeRanges
, /* pGetFontUnicodeRanges */
769 nulldrv_GetGlyphIndices
, /* pGetGlyphIndices */
770 nulldrv_GetGlyphOutline
, /* pGetGlyphOutline */
771 nulldrv_GetICMProfile
, /* pGetICMProfile */
772 nulldrv_GetImage
, /* pGetImage */
773 nulldrv_GetKerningPairs
, /* pGetKerningPairs */
774 nulldrv_GetNearestColor
, /* pGetNearestColor */
775 nulldrv_GetOutlineTextMetrics
, /* pGetOutlineTextMetrics */
776 nulldrv_GetPixel
, /* pGetPixel */
777 nulldrv_GetSystemPaletteEntries
, /* pGetSystemPaletteEntries */
778 nulldrv_GetTextCharsetInfo
, /* pGetTextCharsetInfo */
779 nulldrv_GetTextExtentExPoint
, /* pGetTextExtentExPoint */
780 nulldrv_GetTextExtentExPointI
, /* pGetTextExtentExPointI */
781 nulldrv_GetTextFace
, /* pGetTextFace */
782 nulldrv_GetTextMetrics
, /* pGetTextMetrics */
783 nulldrv_GradientFill
, /* pGradientFill */
784 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
785 nulldrv_InvertRgn
, /* pInvertRgn */
786 nulldrv_LineTo
, /* pLineTo */
787 nulldrv_ModifyWorldTransform
, /* pModifyWorldTransform */
788 nulldrv_MoveTo
, /* pMoveTo */
789 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
790 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
791 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
792 nulldrv_PaintRgn
, /* pPaintRgn */
793 nulldrv_PatBlt
, /* pPatBlt */
794 nulldrv_Pie
, /* pPie */
795 nulldrv_PolyBezier
, /* pPolyBezier */
796 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
797 nulldrv_PolyDraw
, /* pPolyDraw */
798 nulldrv_PolyPolygon
, /* pPolyPolygon */
799 nulldrv_PolyPolyline
, /* pPolyPolyline */
800 nulldrv_Polygon
, /* pPolygon */
801 nulldrv_Polyline
, /* pPolyline */
802 nulldrv_PolylineTo
, /* pPolylineTo */
803 nulldrv_PutImage
, /* pPutImage */
804 nulldrv_RealizeDefaultPalette
, /* pRealizeDefaultPalette */
805 nulldrv_RealizePalette
, /* pRealizePalette */
806 nulldrv_Rectangle
, /* pRectangle */
807 nulldrv_ResetDC
, /* pResetDC */
808 nulldrv_RestoreDC
, /* pRestoreDC */
809 nulldrv_RoundRect
, /* pRoundRect */
810 nulldrv_SaveDC
, /* pSaveDC */
811 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
812 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
813 nulldrv_SelectBitmap
, /* pSelectBitmap */
814 nulldrv_SelectBrush
, /* pSelectBrush */
815 nulldrv_SelectClipPath
, /* pSelectClipPath */
816 nulldrv_SelectFont
, /* pSelectFont */
817 nulldrv_SelectPalette
, /* pSelectPalette */
818 nulldrv_SelectPen
, /* pSelectPen */
819 nulldrv_SetArcDirection
, /* pSetArcDirection */
820 nulldrv_SetBkColor
, /* pSetBkColor */
821 nulldrv_SetBkMode
, /* pSetBkMode */
822 nulldrv_SetBoundsRect
, /* pSetBoundsRect */
823 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
824 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
825 nulldrv_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
826 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
827 nulldrv_SetDeviceGammaRamp
, /* pSetDeviceGammaRamp */
828 nulldrv_SetLayout
, /* pSetLayout */
829 nulldrv_SetMapMode
, /* pSetMapMode */
830 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
831 nulldrv_SetPixel
, /* pSetPixel */
832 nulldrv_SetPixelFormat
, /* pSetPixelFormat */
833 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
834 nulldrv_SetROP2
, /* pSetROP2 */
835 nulldrv_SetRelAbs
, /* pSetRelAbs */
836 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
837 nulldrv_SetTextAlign
, /* pSetTextAlign */
838 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
839 nulldrv_SetTextColor
, /* pSetTextColor */
840 nulldrv_SetTextJustification
, /* pSetTextJustification */
841 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
842 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
843 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
844 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
845 nulldrv_SetWorldTransform
, /* pSetWorldTransform */
846 nulldrv_StartDoc
, /* pStartDoc */
847 nulldrv_StartPage
, /* pStartPage */
848 nulldrv_StretchBlt
, /* pStretchBlt */
849 nulldrv_StretchDIBits
, /* pStretchDIBits */
850 nulldrv_StrokeAndFillPath
, /* pStrokeAndFillPath */
851 nulldrv_StrokePath
, /* pStrokePath */
852 nulldrv_SwapBuffers
, /* pSwapBuffers */
853 nulldrv_UnrealizePalette
, /* pUnrealizePalette */
854 nulldrv_WidenPath
, /* pWidenPath */
855 nulldrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
857 GDI_PRIORITY_NULL_DRV
/* priority */
860 static const struct wgl_funcs null_wgl_driver
=
862 nulldrv_GetPixelFormat
, /* p_GetPixelFormat */
863 nulldrv_wglCopyContext
, /* p_wglCopyContext */
864 nulldrv_wglCreateContext
, /* p_wglCreateContext */
865 nulldrv_wglCreateContextAttribsARB
, /* p_wglCreateContextAttribsARB */
866 nulldrv_wglDeleteContext
, /* p_wglDeleteContext */
867 nulldrv_wglGetCurrentDC
, /* p_wglGetCurrentDC */
868 nulldrv_wglGetProcAddress
, /* p_wglGetProcAddress */
869 nulldrv_wglMakeContextCurrentARB
, /* p_wglMakeContextCurrentARB */
870 nulldrv_wglMakeCurrent
, /* p_wglMakeCurrent */
871 nulldrv_wglShareLists
, /* p_wglShareLists */
874 /*****************************************************************************
875 * DRIVER_GetDriverName
878 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
880 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
881 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
882 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
883 static const WCHAR empty_strW
[] = { 0 };
886 /* display is a special case */
887 if (!strcmpiW( device
, displayW
) ||
888 !strcmpiW( device
, display1W
))
890 lstrcpynW( driver
, displayW
, size
);
894 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
896 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
899 p
= strchrW(driver
, ',');
902 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
906 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
911 /***********************************************************************
912 * GdiConvertToDevmodeW (GDI32.@)
914 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
917 WORD dmW_size
, dmA_size
;
919 dmA_size
= dmA
->dmSize
;
921 /* this is the minimal dmSize that XP accepts */
922 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
925 if (dmA_size
> sizeof(DEVMODEA
))
926 dmA_size
= sizeof(DEVMODEA
);
928 dmW_size
= dmA_size
+ CCHDEVICENAME
;
929 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
930 dmW_size
+= CCHFORMNAME
;
932 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
933 if (!dmW
) return NULL
;
935 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
936 dmW
->dmDeviceName
, CCHDEVICENAME
);
937 /* copy slightly more, to avoid long computations */
938 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
940 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
942 if (dmA
->dmFields
& DM_FORMNAME
)
943 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
944 dmW
->dmFormName
, CCHFORMNAME
);
946 dmW
->dmFormName
[0] = 0;
948 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
949 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
952 if (dmA
->dmDriverExtra
)
953 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
955 dmW
->dmSize
= dmW_size
;
961 /*****************************************************************************
964 * This should thunk to 16-bit and simply call the proc with the given args.
966 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
967 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
969 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
973 /*****************************************************************************
976 * This should load the correct driver for lpszDevice and calls this driver's
977 * ExtDeviceModePropSheet proc.
979 * Note: The driver calls a callback routine for each property sheet page; these
980 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
981 * The layout of this structure is:
987 * HPROPSHEETPAGE pages[10];
990 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
991 LPCSTR lpszPort
, LPVOID lpPropSheet
)
993 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
997 /*****************************************************************************
1000 * This should load the correct driver for lpszDevice and call this driver's
1001 * ExtDeviceMode proc.
1003 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1005 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
1006 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
1007 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
1008 LPSTR lpszProfile
, DWORD fwMode
)
1017 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1018 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
1020 if (!lpszDevice
) return -1;
1021 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1023 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1025 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1027 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1029 if ((dc
= get_dc_ptr( hdc
)))
1031 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtDeviceMode
);
1032 ret
= physdev
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
1033 lpdmInput
, lpszProfile
, fwMode
);
1034 release_dc_ptr( dc
);
1040 /****************************************************************************
1043 * This should load the correct driver for lpszDevice and calls this driver's
1044 * AdvancedSetupDialog proc.
1046 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
1047 LPDEVMODEA devin
, LPDEVMODEA devout
)
1049 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
1053 /*****************************************************************************
1056 * This should load the correct driver for lpszDevice and calls this driver's
1057 * DeviceCapabilities proc.
1059 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1061 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
1062 WORD fwCapability
, LPSTR lpszOutput
,
1072 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
1074 if (!lpszDevice
) return -1;
1075 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
1077 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
1079 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
1081 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
1083 if ((dc
= get_dc_ptr( hdc
)))
1085 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pDeviceCapabilities
);
1086 ret
= physdev
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
1087 fwCapability
, lpszOutput
, lpdm
);
1088 release_dc_ptr( dc
);
1095 /************************************************************************
1098 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
1106 return AbortDoc( hdc
);
1109 return EndDoc( hdc
);
1111 case GETPHYSPAGESIZE
:
1113 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
1114 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
1117 case GETPRINTINGOFFSET
:
1119 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
1120 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
1123 case GETSCALINGFACTOR
:
1125 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
1126 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
1130 return EndPage( hdc
);
1133 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
1140 /* in_data may not be 0 terminated so we must copy it */
1143 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
1144 memcpy( name
, in_data
, in_count
);
1147 /* out_data is actually a pointer to the DocInfo structure and used as
1148 * a second input parameter */
1149 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1152 doc
.cbSize
= sizeof(doc
);
1153 doc
.lpszOutput
= NULL
;
1154 doc
.lpszDatatype
= NULL
;
1157 doc
.lpszDocName
= name
;
1158 ret
= StartDocA( hdc
, &doc
);
1159 HeapFree( GetProcessHeap(), 0, name
);
1160 if (ret
> 0) ret
= StartPage( hdc
);
1164 case QUERYESCSUPPORT
:
1166 const INT
*ptr
= (const INT
*)in_data
;
1167 if (in_count
< sizeof(INT
)) return 0;
1172 case GETPHYSPAGESIZE
:
1173 case GETPRINTINGOFFSET
:
1174 case GETSCALINGFACTOR
:
1176 case QUERYESCSUPPORT
:
1185 /* if not handled internally, pass it to the driver */
1186 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1190 /******************************************************************************
1191 * ExtEscape [GDI32.@]
1193 * Access capabilities of a particular device that are not available through GDI.
1196 * hdc [I] Handle to device context
1197 * nEscape [I] Escape function
1198 * cbInput [I] Number of bytes in input structure
1199 * lpszInData [I] Pointer to input structure
1200 * cbOutput [I] Number of bytes in output structure
1201 * lpszOutData [O] Pointer to output structure
1205 * Not implemented: 0
1208 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1209 INT cbOutput
, LPSTR lpszOutData
)
1212 DC
* dc
= get_dc_ptr( hdc
);
1216 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pExtEscape
);
1218 ret
= physdev
->funcs
->pExtEscape( physdev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1219 release_dc_ptr( dc
);
1225 /*******************************************************************
1226 * DrawEscape [GDI32.@]
1230 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1232 FIXME("DrawEscape, stub\n");
1236 /*******************************************************************
1237 * NamedEscape [GDI32.@]
1239 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1240 INT cbOutput
, LPSTR lpszOutData
)
1242 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1243 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1248 /*******************************************************************
1249 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1250 * GdiEntry13 [GDI32.@]
1252 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1254 static int warn_once
;