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 */
48 static struct list drivers
= LIST_INIT( drivers
);
49 static struct graphics_driver
*display_driver
;
51 static CRITICAL_SECTION driver_section
;
52 static CRITICAL_SECTION_DEBUG critsect_debug
=
54 0, 0, &driver_section
,
55 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
56 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
58 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
60 /**********************************************************************
63 * Allocate and fill the driver structure for a given module.
65 static struct graphics_driver
*create_driver( HMODULE module
)
67 struct graphics_driver
*driver
;
69 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
70 driver
->module
= module
;
72 /* fill the function table */
75 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
84 GET_FUNC(ChoosePixelFormat
);
86 GET_FUNC(CloseFigure
);
87 GET_FUNC(CreateBitmap
);
89 GET_FUNC(CreateDIBSection
);
90 GET_FUNC(DeleteBitmap
);
92 GET_FUNC(DescribePixelFormat
);
93 GET_FUNC(DeviceCapabilities
);
98 GET_FUNC(EnumDeviceFonts
);
99 GET_FUNC(EnumICMProfiles
);
100 GET_FUNC(ExcludeClipRect
);
101 GET_FUNC(ExtDeviceMode
);
103 GET_FUNC(ExtFloodFill
);
104 GET_FUNC(ExtSelectClipRgn
);
105 GET_FUNC(ExtTextOut
);
108 GET_FUNC(FlattenPath
);
110 GET_FUNC(GdiComment
);
111 GET_FUNC(GetBitmapBits
);
112 GET_FUNC(GetCharWidth
);
114 GET_FUNC(GetDeviceCaps
);
115 GET_FUNC(GetDeviceGammaRamp
);
116 GET_FUNC(GetICMProfile
);
117 GET_FUNC(GetNearestColor
);
119 GET_FUNC(GetPixelFormat
);
120 GET_FUNC(GetSystemPaletteEntries
);
121 GET_FUNC(GetTextExtentExPoint
);
122 GET_FUNC(GetTextMetrics
);
123 GET_FUNC(IntersectClipRect
);
127 GET_FUNC(ModifyWorldTransform
);
128 GET_FUNC(OffsetClipRgn
);
129 GET_FUNC(OffsetViewportOrgEx
);
130 GET_FUNC(OffsetWindowOrgEx
);
134 GET_FUNC(PolyBezier
);
135 GET_FUNC(PolyBezierTo
);
137 GET_FUNC(PolyPolygon
);
138 GET_FUNC(PolyPolyline
);
141 GET_FUNC(PolylineTo
);
142 GET_FUNC(RealizeDefaultPalette
);
143 GET_FUNC(RealizePalette
);
149 GET_FUNC(ScaleViewportExtEx
);
150 GET_FUNC(ScaleWindowExtEx
);
151 GET_FUNC(SelectBitmap
);
152 GET_FUNC(SelectBrush
);
153 GET_FUNC(SelectClipPath
);
154 GET_FUNC(SelectFont
);
155 GET_FUNC(SelectPalette
);
157 GET_FUNC(SetArcDirection
);
158 GET_FUNC(SetBitmapBits
);
159 GET_FUNC(SetBkColor
);
161 GET_FUNC(SetDCBrushColor
);
162 GET_FUNC(SetDCPenColor
);
163 GET_FUNC(SetDIBColorTable
);
165 GET_FUNC(SetDIBitsToDevice
);
166 GET_FUNC(SetDeviceClipping
);
167 GET_FUNC(SetDeviceGammaRamp
);
168 GET_FUNC(SetMapMode
);
169 GET_FUNC(SetMapperFlags
);
171 GET_FUNC(SetPixelFormat
);
172 GET_FUNC(SetPolyFillMode
);
175 GET_FUNC(SetStretchBltMode
);
176 GET_FUNC(SetTextAlign
);
177 GET_FUNC(SetTextCharacterExtra
);
178 GET_FUNC(SetTextColor
);
179 GET_FUNC(SetTextJustification
);
180 GET_FUNC(SetViewportExtEx
);
181 GET_FUNC(SetViewportOrgEx
);
182 GET_FUNC(SetWindowExtEx
);
183 GET_FUNC(SetWindowOrgEx
);
184 GET_FUNC(SetWorldTransform
);
187 GET_FUNC(StretchBlt
);
188 GET_FUNC(StretchDIBits
);
189 GET_FUNC(StrokeAndFillPath
);
190 GET_FUNC(StrokePath
);
191 GET_FUNC(SwapBuffers
);
192 GET_FUNC(UnrealizePalette
);
196 GET_FUNC(wglCreateContext
);
197 GET_FUNC(wglCreateContextAttribsARB
);
198 GET_FUNC(wglDeleteContext
);
199 GET_FUNC(wglGetProcAddress
);
200 GET_FUNC(wglGetPbufferDCARB
);
201 GET_FUNC(wglMakeContextCurrentARB
);
202 GET_FUNC(wglMakeCurrent
);
203 GET_FUNC(wglSetPixelFormatWINE
);
204 GET_FUNC(wglShareLists
);
205 GET_FUNC(wglUseFontBitmapsA
);
206 GET_FUNC(wglUseFontBitmapsW
);
209 else memset( &driver
->funcs
, 0, sizeof(driver
->funcs
) );
215 /**********************************************************************
216 * DRIVER_get_display_driver
218 * Special case for loading the display driver: get the name from the config file
220 const DC_FUNCTIONS
*DRIVER_get_display_driver(void)
222 struct graphics_driver
*driver
;
223 char buffer
[MAX_PATH
], libname
[32], *name
, *next
;
227 if (display_driver
) return &display_driver
->funcs
; /* already loaded */
229 strcpy( buffer
, "x11" ); /* default value */
230 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
231 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Drivers", &hkey
))
233 DWORD type
, count
= sizeof(buffer
);
234 RegQueryValueExA( hkey
, "Graphics", 0, &type
, (LPBYTE
) buffer
, &count
);
241 next
= strchr( name
, ',' );
242 if (next
) *next
++ = 0;
244 snprintf( libname
, sizeof(libname
), "wine%s.drv", name
);
245 if ((module
= LoadLibraryA( libname
)) != 0) break;
249 if (!(driver
= create_driver( module
)))
251 MESSAGE( "Could not create graphics driver '%s'\n", buffer
);
252 FreeLibrary( module
);
255 if (InterlockedCompareExchangePointer( (void **)&display_driver
, driver
, NULL
))
257 /* somebody beat us to it */
258 FreeLibrary( driver
->module
);
259 HeapFree( GetProcessHeap(), 0, driver
);
261 return &display_driver
->funcs
;
265 /**********************************************************************
268 const DC_FUNCTIONS
*DRIVER_load_driver( LPCWSTR name
)
271 struct graphics_driver
*driver
, *new_driver
;
272 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
273 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
275 /* display driver is a special case */
276 if (!strcmpiW( name
, displayW
) || !strcmpiW( name
, display1W
)) return DRIVER_get_display_driver();
278 if ((module
= GetModuleHandleW( name
)))
280 if (display_driver
&& display_driver
->module
== module
) return &display_driver
->funcs
;
281 EnterCriticalSection( &driver_section
);
282 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
284 if (driver
->module
== module
) goto done
;
286 LeaveCriticalSection( &driver_section
);
289 if (!(module
= LoadLibraryW( name
))) return NULL
;
291 if (!(new_driver
= create_driver( module
)))
293 FreeLibrary( module
);
297 /* check if someone else added it in the meantime */
298 EnterCriticalSection( &driver_section
);
299 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
301 if (driver
->module
!= module
) continue;
302 FreeLibrary( module
);
303 HeapFree( GetProcessHeap(), 0, new_driver
);
307 list_add_head( &drivers
, &driver
->entry
);
308 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
310 LeaveCriticalSection( &driver_section
);
311 return &driver
->funcs
;
315 static INT CDECL
nulldrv_AbortDoc( PHYSDEV dev
)
320 static BOOL CDECL
nulldrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
321 INT xstart
, INT ystart
, INT xend
, INT yend
)
326 static BOOL CDECL
nulldrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
327 INT xstart
, INT ystart
, INT xend
, INT yend
)
332 static BOOL CDECL
nulldrv_DeleteObject( PHYSDEV dev
, HGDIOBJ obj
)
337 static BOOL CDECL
nulldrv_Ellipse( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
342 static INT CDECL
nulldrv_EndDoc( PHYSDEV dev
)
347 static INT CDECL
nulldrv_EndPage( PHYSDEV dev
)
352 static BOOL CDECL
nulldrv_ExtFloodFill( PHYSDEV dev
, INT x
, INT y
, COLORREF color
, UINT type
)
357 static COLORREF CDECL
nulldrv_GetPixel( PHYSDEV dev
, INT x
, INT y
)
362 static BOOL CDECL
nulldrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
367 static BOOL CDECL
nulldrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
372 static BOOL CDECL
nulldrv_PaintRgn( PHYSDEV dev
, HRGN rgn
)
377 static BOOL CDECL
nulldrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
378 INT xstart
, INT ystart
, INT xend
, INT yend
)
383 static BOOL CDECL
nulldrv_PolyPolygon( PHYSDEV dev
, const POINT
*points
, const INT
*counts
, UINT polygons
)
385 /* FIXME: could be implemented with Polygon */
389 static BOOL CDECL
nulldrv_PolyPolyline( PHYSDEV dev
, const POINT
*points
, const DWORD
*counts
, DWORD lines
)
391 /* FIXME: could be implemented with Polyline */
395 static BOOL CDECL
nulldrv_Polygon( PHYSDEV dev
, const POINT
*points
, INT count
)
400 static BOOL CDECL
nulldrv_Polyline( PHYSDEV dev
, const POINT
*points
, INT count
)
405 static BOOL CDECL
nulldrv_Rectangle( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
410 static BOOL CDECL
nulldrv_RoundRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
411 INT ell_width
, INT ell_height
)
416 static HBITMAP CDECL
nulldrv_SelectBitmap( PHYSDEV dev
, HBITMAP bitmap
)
421 static HBRUSH CDECL
nulldrv_SelectBrush( PHYSDEV dev
, HBRUSH brush
)
426 static HFONT CDECL
nulldrv_SelectFont( PHYSDEV dev
, HFONT font
, HANDLE gdi_font
)
431 static HPALETTE CDECL
nulldrv_SelectPalette( PHYSDEV dev
, HPALETTE palette
, BOOL bkgnd
)
436 static HPEN CDECL
nulldrv_SelectPen( PHYSDEV dev
, HPEN pen
)
441 static INT CDECL
nulldrv_SetArcDirection( PHYSDEV dev
, INT dir
)
446 static COLORREF CDECL
nulldrv_SetBkColor( PHYSDEV dev
, COLORREF color
)
451 static INT CDECL
nulldrv_SetBkMode( PHYSDEV dev
, INT mode
)
456 static COLORREF CDECL
nulldrv_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
461 static COLORREF CDECL
nulldrv_SetDCPenColor( PHYSDEV dev
, COLORREF color
)
466 static void CDECL
nulldrv_SetDeviceClipping( PHYSDEV dev
, HRGN vis_rgn
, HRGN clip_rgn
)
470 static DWORD CDECL
nulldrv_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
475 static COLORREF CDECL
nulldrv_SetPixel( PHYSDEV dev
, INT x
, INT y
, COLORREF color
)
480 static INT CDECL
nulldrv_SetPolyFillMode( PHYSDEV dev
, INT mode
)
485 static INT CDECL
nulldrv_SetROP2( PHYSDEV dev
, INT rop
)
490 static INT CDECL
nulldrv_SetRelAbs( PHYSDEV dev
, INT mode
)
495 static INT CDECL
nulldrv_SetStretchBltMode( PHYSDEV dev
, INT mode
)
500 static UINT CDECL
nulldrv_SetTextAlign( PHYSDEV dev
, UINT align
)
505 static INT CDECL
nulldrv_SetTextCharacterExtra( PHYSDEV dev
, INT extra
)
510 static COLORREF CDECL
nulldrv_SetTextColor( PHYSDEV dev
, COLORREF color
)
515 static BOOL CDECL
nulldrv_SetTextJustification( PHYSDEV dev
, INT extra
, INT breaks
)
520 static INT CDECL
nulldrv_StartDoc( PHYSDEV dev
, const DOCINFOW
*info
)
525 static INT CDECL
nulldrv_StartPage( PHYSDEV dev
)
530 static BOOL CDECL
nulldrv_wglCopyContext( HGLRC ctx_src
, HGLRC ctx_dst
, UINT mask
)
535 static HGLRC CDECL
nulldrv_wglCreateContext( PHYSDEV dev
)
540 static HGLRC CDECL
nulldrv_wglCreateContextAttribsARB( PHYSDEV dev
, HGLRC share_ctx
, const int *attribs
)
545 static BOOL CDECL
nulldrv_wglDeleteContext( HGLRC ctx
)
550 static PROC CDECL
nulldrv_wglGetProcAddress( LPCSTR name
)
555 static HDC CDECL
nulldrv_wglGetPbufferDCARB( PHYSDEV dev
, void *pbuffer
)
560 static BOOL CDECL
nulldrv_wglMakeCurrent( PHYSDEV dev
, HGLRC ctx
)
565 static BOOL CDECL
nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw
, PHYSDEV dev_read
, HGLRC ctx
)
570 static BOOL CDECL
nulldrv_wglSetPixelFormatWINE( PHYSDEV dev
, INT format
,
571 const PIXELFORMATDESCRIPTOR
*descr
)
576 static BOOL CDECL
nulldrv_wglShareLists( HGLRC ctx1
, HGLRC ctx2
)
581 static BOOL CDECL
nulldrv_wglUseFontBitmapsA( PHYSDEV dev
, DWORD start
, DWORD count
, DWORD base
)
586 static BOOL CDECL
nulldrv_wglUseFontBitmapsW( PHYSDEV dev
, DWORD start
, DWORD count
, DWORD base
)
591 const DC_FUNCTIONS null_driver
=
593 nulldrv_AbortDoc
, /* pAbortDoc */
594 NULL
, /* pAbortPath */
595 NULL
, /* pAlphaBlend */
596 nulldrv_AngleArc
, /* pAngleArc */
597 nulldrv_Arc
, /* pArc */
598 nulldrv_ArcTo
, /* pArcTo */
599 NULL
, /* pBeginPath */
601 NULL
, /* pChoosePixelFormat */
602 nulldrv_Chord
, /* pChord */
603 NULL
, /* pCloseFigure */
604 NULL
, /* pCreateBitmap */
605 NULL
, /* pCreateDC */
606 NULL
, /* pCreateDIBSection */
607 NULL
, /* pDeleteBitmap */
608 NULL
, /* pDeleteDC */
609 nulldrv_DeleteObject
, /* pDeleteObject */
610 NULL
, /* pDescribePixelFormat */
611 NULL
, /* pDeviceCapabilities */
612 nulldrv_Ellipse
, /* pEllipse */
613 nulldrv_EndDoc
, /* pEndDoc */
614 nulldrv_EndPage
, /* pEndPage */
616 NULL
, /* pEnumICMProfiles */
617 NULL
, /* pEnumDeviceFonts */
618 nulldrv_ExcludeClipRect
, /* pExcludeClipRect */
619 NULL
, /* pExtDeviceMode */
620 NULL
, /* pExtEscape */
621 nulldrv_ExtFloodFill
, /* pExtFloodFill */
622 nulldrv_ExtSelectClipRgn
, /* pExtSelectClipRgn */
623 NULL
, /* pExtTextOut */
624 NULL
, /* pFillPath */
625 nulldrv_FillRgn
, /* pFillRgn */
626 NULL
, /* pFlattenPath */
627 nulldrv_FrameRgn
, /* pFrameRgn */
628 NULL
, /* pGdiComment */
629 NULL
, /* pGetBitmapBits */
630 NULL
, /* pGetCharWidth */
631 NULL
, /* pGetDIBits */
632 NULL
, /* pGetDeviceCaps */
633 NULL
, /* pGetDeviceGammaRamp */
634 NULL
, /* pGetICMProfile */
635 NULL
, /* pGetNearestColor */
636 nulldrv_GetPixel
, /* pGetPixel */
637 NULL
, /* pGetPixelFormat */
638 NULL
, /* pGetSystemPaletteEntries */
639 NULL
, /* pGetTextExtentExPoint */
640 NULL
, /* pGetTextMetrics */
641 nulldrv_IntersectClipRect
, /* pIntersectClipRect */
642 nulldrv_InvertRgn
, /* pInvertRgn */
643 nulldrv_LineTo
, /* pLineTo */
644 NULL
, /* pModifyWorldTransform */
645 nulldrv_MoveTo
, /* pMoveTo */
646 nulldrv_OffsetClipRgn
, /* pOffsetClipRgn */
647 nulldrv_OffsetViewportOrgEx
, /* pOffsetViewportOrg */
648 nulldrv_OffsetWindowOrgEx
, /* pOffsetWindowOrg */
649 nulldrv_PaintRgn
, /* pPaintRgn */
651 nulldrv_Pie
, /* pPie */
652 nulldrv_PolyBezier
, /* pPolyBezier */
653 nulldrv_PolyBezierTo
, /* pPolyBezierTo */
654 nulldrv_PolyDraw
, /* pPolyDraw */
655 nulldrv_PolyPolygon
, /* pPolyPolygon */
656 nulldrv_PolyPolyline
, /* pPolyPolyline */
657 nulldrv_Polygon
, /* pPolygon */
658 nulldrv_Polyline
, /* pPolyline */
659 nulldrv_PolylineTo
, /* pPolylineTo */
660 NULL
, /* pRealizeDefaultPalette */
661 NULL
, /* pRealizePalette */
662 nulldrv_Rectangle
, /* pRectangle */
664 NULL
, /* pRestoreDC */
665 nulldrv_RoundRect
, /* pRoundRect */
667 nulldrv_ScaleViewportExtEx
, /* pScaleViewportExt */
668 nulldrv_ScaleWindowExtEx
, /* pScaleWindowExt */
669 nulldrv_SelectBitmap
, /* pSelectBitmap */
670 nulldrv_SelectBrush
, /* pSelectBrush */
671 NULL
, /* pSelectClipPath */
672 nulldrv_SelectFont
, /* pSelectFont */
673 nulldrv_SelectPalette
, /* pSelectPalette */
674 nulldrv_SelectPen
, /* pSelectPen */
675 nulldrv_SetArcDirection
, /* pSetArcDirection */
676 NULL
, /* pSetBitmapBits */
677 nulldrv_SetBkColor
, /* pSetBkColor */
678 nulldrv_SetBkMode
, /* pSetBkMode */
679 nulldrv_SetDCBrushColor
, /* pSetDCBrushColor */
680 nulldrv_SetDCPenColor
, /* pSetDCPenColor */
681 NULL
, /* pSetDIBColorTable */
682 NULL
, /* pSetDIBits */
683 NULL
, /* pSetDIBitsToDevice */
684 nulldrv_SetDeviceClipping
, /* pSetDeviceClipping */
685 NULL
, /* pSetDeviceGammaRamp */
686 nulldrv_SetMapMode
, /* pSetMapMode */
687 nulldrv_SetMapperFlags
, /* pSetMapperFlags */
688 nulldrv_SetPixel
, /* pSetPixel */
689 NULL
, /* pSetPixelFormat */
690 nulldrv_SetPolyFillMode
, /* pSetPolyFillMode */
691 nulldrv_SetROP2
, /* pSetROP2 */
692 nulldrv_SetRelAbs
, /* pSetRelAbs */
693 nulldrv_SetStretchBltMode
, /* pSetStretchBltMode */
694 nulldrv_SetTextAlign
, /* pSetTextAlign */
695 nulldrv_SetTextCharacterExtra
, /* pSetTextCharacterExtra */
696 nulldrv_SetTextColor
, /* pSetTextColor */
697 nulldrv_SetTextJustification
, /* pSetTextJustification */
698 nulldrv_SetViewportExtEx
, /* pSetViewportExt */
699 nulldrv_SetViewportOrgEx
, /* pSetViewportOrg */
700 nulldrv_SetWindowExtEx
, /* pSetWindowExt */
701 nulldrv_SetWindowOrgEx
, /* pSetWindowOrg */
702 NULL
, /* pSetWorldTransform */
703 nulldrv_StartDoc
, /* pStartDoc */
704 nulldrv_StartPage
, /* pStartPage */
705 NULL
, /* pStretchBlt */
706 NULL
, /* pStretchDIBits */
707 NULL
, /* pStrokeAndFillPath */
708 NULL
, /* pStrokePath */
709 NULL
, /* pSwapBuffers */
710 NULL
, /* pUnrealizePalette */
711 NULL
, /* pWidenPath */
712 nulldrv_wglCopyContext
, /* pwglCopyContext */
713 nulldrv_wglCreateContext
, /* pwglCreateContext */
714 nulldrv_wglCreateContextAttribsARB
, /* pwglCreateContextAttribsARB */
715 nulldrv_wglDeleteContext
, /* pwglDeleteContext */
716 nulldrv_wglGetProcAddress
, /* pwglGetProcAddress */
717 nulldrv_wglGetPbufferDCARB
, /* pwglGetPbufferDCARB */
718 nulldrv_wglMakeCurrent
, /* pwglMakeCurrent */
719 nulldrv_wglMakeContextCurrentARB
, /* pwglMakeContextCurrentARB */
720 nulldrv_wglSetPixelFormatWINE
, /* pwglSetPixelFormatWINE */
721 nulldrv_wglShareLists
, /* pwglShareLists */
722 nulldrv_wglUseFontBitmapsA
, /* pwglUseFontBitmapsA */
723 nulldrv_wglUseFontBitmapsW
, /* pwglUseFontBitmapsW */
727 /*****************************************************************************
728 * DRIVER_GetDriverName
731 BOOL
DRIVER_GetDriverName( LPCWSTR device
, LPWSTR driver
, DWORD size
)
733 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
734 static const WCHAR devicesW
[] = { 'd','e','v','i','c','e','s',0 };
735 static const WCHAR display1W
[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
736 static const WCHAR empty_strW
[] = { 0 };
739 /* display is a special case */
740 if (!strcmpiW( device
, displayW
) ||
741 !strcmpiW( device
, display1W
))
743 lstrcpynW( driver
, displayW
, size
);
747 size
= GetProfileStringW(devicesW
, device
, empty_strW
, driver
, size
);
749 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
752 p
= strchrW(driver
, ',');
755 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
759 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
764 /***********************************************************************
765 * GdiConvertToDevmodeW (GDI32.@)
767 DEVMODEW
* WINAPI
GdiConvertToDevmodeW(const DEVMODEA
*dmA
)
770 WORD dmW_size
, dmA_size
;
772 dmA_size
= dmA
->dmSize
;
774 /* this is the minimal dmSize that XP accepts */
775 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
778 if (dmA_size
> sizeof(DEVMODEA
))
779 dmA_size
= sizeof(DEVMODEA
);
781 dmW_size
= dmA_size
+ CCHDEVICENAME
;
782 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
783 dmW_size
+= CCHFORMNAME
;
785 dmW
= HeapAlloc(GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
786 if (!dmW
) return NULL
;
788 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
789 dmW
->dmDeviceName
, CCHDEVICENAME
);
790 /* copy slightly more, to avoid long computations */
791 memcpy(&dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
793 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
795 if (dmA
->dmFields
& DM_FORMNAME
)
796 MultiByteToWideChar(CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
797 dmW
->dmFormName
, CCHFORMNAME
);
799 dmW
->dmFormName
[0] = 0;
801 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
802 memcpy(&dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
));
805 if (dmA
->dmDriverExtra
)
806 memcpy((char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
808 dmW
->dmSize
= dmW_size
;
814 /*****************************************************************************
817 * This should thunk to 16-bit and simply call the proc with the given args.
819 INT WINAPI
GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc
, HWND hWnd
,
820 LPSTR lpModelName
, LPSTR OldPort
, LPSTR NewPort
)
822 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc
, hWnd
, lpModelName
, OldPort
, NewPort
);
826 /*****************************************************************************
829 * This should load the correct driver for lpszDevice and calls this driver's
830 * ExtDeviceModePropSheet proc.
832 * Note: The driver calls a callback routine for each property sheet page; these
833 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
834 * The layout of this structure is:
840 * HPROPSHEETPAGE pages[10];
843 INT WINAPI
GDI_CallExtDeviceModePropSheet16( HWND hWnd
, LPCSTR lpszDevice
,
844 LPCSTR lpszPort
, LPVOID lpPropSheet
)
846 FIXME("(%p, %s, %s, %p)\n", hWnd
, lpszDevice
, lpszPort
, lpPropSheet
);
850 /*****************************************************************************
853 * This should load the correct driver for lpszDevice and call this driver's
854 * ExtDeviceMode proc.
856 * FIXME: convert ExtDeviceMode to unicode in the driver interface
858 INT WINAPI
GDI_CallExtDeviceMode16( HWND hwnd
,
859 LPDEVMODEA lpdmOutput
, LPSTR lpszDevice
,
860 LPSTR lpszPort
, LPDEVMODEA lpdmInput
,
861 LPSTR lpszProfile
, DWORD fwMode
)
870 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
871 hwnd
, lpdmOutput
, lpszDevice
, lpszPort
, lpdmInput
, lpszProfile
, fwMode
);
873 if (!lpszDevice
) return -1;
874 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
876 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
878 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
880 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
882 if ((dc
= get_dc_ptr( hdc
)))
884 if (dc
->funcs
->pExtDeviceMode
)
885 ret
= dc
->funcs
->pExtDeviceMode( buf
, hwnd
, lpdmOutput
, lpszDevice
, lpszPort
,
886 lpdmInput
, lpszProfile
, fwMode
);
887 release_dc_ptr( dc
);
893 /****************************************************************************
896 * This should load the correct driver for lpszDevice and calls this driver's
897 * AdvancedSetupDialog proc.
899 INT WINAPI
GDI_CallAdvancedSetupDialog16( HWND hwnd
, LPSTR lpszDevice
,
900 LPDEVMODEA devin
, LPDEVMODEA devout
)
902 TRACE("(%p, %s, %p, %p)\n", hwnd
, lpszDevice
, devin
, devout
);
906 /*****************************************************************************
909 * This should load the correct driver for lpszDevice and calls this driver's
910 * DeviceCapabilities proc.
912 * FIXME: convert DeviceCapabilities to unicode in the driver interface
914 DWORD WINAPI
GDI_CallDeviceCapabilities16( LPCSTR lpszDevice
, LPCSTR lpszPort
,
915 WORD fwCapability
, LPSTR lpszOutput
,
925 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice
, lpszPort
, fwCapability
, lpszOutput
, lpdm
);
927 if (!lpszDevice
) return -1;
928 if (!MultiByteToWideChar(CP_ACP
, 0, lpszDevice
, -1, deviceW
, 300)) return -1;
930 if(!DRIVER_GetDriverName( deviceW
, bufW
, 300 )) return -1;
932 if (!WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, 300, NULL
, NULL
)) return -1;
934 if (!(hdc
= CreateICA( buf
, lpszDevice
, lpszPort
, NULL
))) return -1;
936 if ((dc
= get_dc_ptr( hdc
)))
938 if (dc
->funcs
->pDeviceCapabilities
)
939 ret
= dc
->funcs
->pDeviceCapabilities( buf
, lpszDevice
, lpszPort
,
940 fwCapability
, lpszOutput
, lpdm
);
941 release_dc_ptr( dc
);
948 /************************************************************************
951 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, LPCSTR in_data
, LPVOID out_data
)
959 return AbortDoc( hdc
);
962 return EndDoc( hdc
);
964 case GETPHYSPAGESIZE
:
966 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
967 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
970 case GETPRINTINGOFFSET
:
972 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
973 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
976 case GETSCALINGFACTOR
:
978 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
979 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
983 return EndPage( hdc
);
986 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
993 /* in_data may not be 0 terminated so we must copy it */
996 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
997 memcpy( name
, in_data
, in_count
);
1000 /* out_data is actually a pointer to the DocInfo structure and used as
1001 * a second input parameter */
1002 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
1005 doc
.cbSize
= sizeof(doc
);
1006 doc
.lpszOutput
= NULL
;
1007 doc
.lpszDatatype
= NULL
;
1010 doc
.lpszDocName
= name
;
1011 ret
= StartDocA( hdc
, &doc
);
1012 HeapFree( GetProcessHeap(), 0, name
);
1013 if (ret
> 0) ret
= StartPage( hdc
);
1017 case QUERYESCSUPPORT
:
1019 const INT
*ptr
= (const INT
*)in_data
;
1020 if (in_count
< sizeof(INT
)) return 0;
1025 case GETPHYSPAGESIZE
:
1026 case GETPRINTINGOFFSET
:
1027 case GETSCALINGFACTOR
:
1029 case QUERYESCSUPPORT
:
1038 /* if not handled internally, pass it to the driver */
1039 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
1043 /******************************************************************************
1044 * ExtEscape [GDI32.@]
1046 * Access capabilities of a particular device that are not available through GDI.
1049 * hdc [I] Handle to device context
1050 * nEscape [I] Escape function
1051 * cbInput [I] Number of bytes in input structure
1052 * lpszInData [I] Pointer to input structure
1053 * cbOutput [I] Number of bytes in output structure
1054 * lpszOutData [O] Pointer to output structure
1058 * Not implemented: 0
1061 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1062 INT cbOutput
, LPSTR lpszOutData
)
1065 DC
* dc
= get_dc_ptr( hdc
);
1068 if (dc
->funcs
->pExtEscape
)
1069 ret
= dc
->funcs
->pExtEscape( dc
->physDev
, nEscape
, cbInput
, lpszInData
, cbOutput
, lpszOutData
);
1070 release_dc_ptr( dc
);
1076 /*******************************************************************
1077 * DrawEscape [GDI32.@]
1081 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
1083 FIXME("DrawEscape, stub\n");
1087 /*******************************************************************
1088 * NamedEscape [GDI32.@]
1090 INT WINAPI
NamedEscape( HDC hdc
, LPCWSTR pDriver
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
,
1091 INT cbOutput
, LPSTR lpszOutData
)
1093 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1094 hdc
, wine_dbgstr_w(pDriver
), nEscape
, cbInput
, lpszInData
, cbOutput
,
1099 /*******************************************************************
1100 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1101 * GdiEntry13 [GDI32.@]
1103 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(VOID
)
1105 static int warn_once
;