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(OffsetViewportOrg);
130 GET_FUNC(OffsetWindowOrg);
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(ScaleViewportExt);
150 GET_FUNC(ScaleWindowExt);
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(SetViewportExt);
181 GET_FUNC(SetViewportOrg);
182 GET_FUNC(SetWindowExt);
183 GET_FUNC(SetWindowOrg);
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_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
337 static INT CDECL nulldrv_EndDoc( PHYSDEV dev )
342 static INT CDECL nulldrv_EndPage( PHYSDEV dev )
347 static BOOL CDECL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
352 static COLORREF CDECL nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
357 static BOOL CDECL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
362 static BOOL CDECL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
367 static BOOL CDECL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
372 static BOOL CDECL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
373 INT xstart, INT ystart, INT xend, INT yend )
378 static BOOL CDECL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
380 /* FIXME: could be implemented with Polygon */
384 static BOOL CDECL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
386 /* FIXME: could be implemented with Polyline */
390 static BOOL CDECL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
395 static BOOL CDECL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
400 static BOOL CDECL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
405 static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
406 INT ell_width, INT ell_height )
411 static COLORREF CDECL nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
416 static INT CDECL nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
421 static INT CDECL nulldrv_StartPage( PHYSDEV dev )
426 const DC_FUNCTIONS null_driver =
428 nulldrv_AbortDoc, /* pAbortDoc */
429 NULL, /* pAbortPath */
430 NULL, /* pAlphaBlend */
431 nulldrv_AngleArc, /* pAngleArc */
432 nulldrv_Arc, /* pArc */
433 nulldrv_ArcTo, /* pArcTo */
434 NULL, /* pBeginPath */
436 NULL, /* pChoosePixelFormat */
437 nulldrv_Chord, /* pChord */
438 NULL, /* pCloseFigure */
439 NULL, /* pCreateBitmap */
440 NULL, /* pCreateDC */
441 NULL, /* pCreateDIBSection */
442 NULL, /* pDeleteBitmap */
443 NULL, /* pDeleteDC */
444 NULL, /* pDeleteObject */
445 NULL, /* pDescribePixelFormat */
446 NULL, /* pDeviceCapabilities */
447 nulldrv_Ellipse, /* pEllipse */
448 nulldrv_EndDoc, /* pEndDoc */
449 nulldrv_EndPage, /* pEndPage */
451 NULL, /* pEnumICMProfiles */
452 NULL, /* pEnumDeviceFonts */
453 NULL, /* pExcludeClipRect */
454 NULL, /* pExtDeviceMode */
455 NULL, /* pExtEscape */
456 nulldrv_ExtFloodFill, /* pExtFloodFill */
457 NULL, /* pExtSelectClipRgn */
458 NULL, /* pExtTextOut */
459 NULL, /* pFillPath */
460 nulldrv_FillRgn, /* pFillRgn */
461 NULL, /* pFlattenPath */
462 nulldrv_FrameRgn, /* pFrameRgn */
463 NULL, /* pGdiComment */
464 NULL, /* pGetBitmapBits */
465 NULL, /* pGetCharWidth */
466 NULL, /* pGetDIBits */
467 NULL, /* pGetDeviceCaps */
468 NULL, /* pGetDeviceGammaRamp */
469 NULL, /* pGetICMProfile */
470 NULL, /* pGetNearestColor */
471 nulldrv_GetPixel, /* pGetPixel */
472 NULL, /* pGetPixelFormat */
473 NULL, /* pGetSystemPaletteEntries */
474 NULL, /* pGetTextExtentExPoint */
475 NULL, /* pGetTextMetrics */
476 NULL, /* pIntersectClipRect */
477 nulldrv_InvertRgn, /* pInvertRgn */
478 nulldrv_LineTo, /* pLineTo */
479 NULL, /* pModifyWorldTransform */
480 nulldrv_MoveTo, /* pMoveTo */
481 NULL, /* pOffsetClipRgn */
482 NULL, /* pOffsetViewportOrg */
483 NULL, /* pOffsetWindowOrg */
484 nulldrv_PaintRgn, /* pPaintRgn */
486 nulldrv_Pie, /* pPie */
487 nulldrv_PolyBezier, /* pPolyBezier */
488 nulldrv_PolyBezierTo, /* pPolyBezierTo */
489 nulldrv_PolyDraw, /* pPolyDraw */
490 nulldrv_PolyPolygon, /* pPolyPolygon */
491 nulldrv_PolyPolyline, /* pPolyPolyline */
492 nulldrv_Polygon, /* pPolygon */
493 nulldrv_Polyline, /* pPolyline */
494 nulldrv_PolylineTo, /* pPolylineTo */
495 NULL, /* pRealizeDefaultPalette */
496 NULL, /* pRealizePalette */
497 nulldrv_Rectangle, /* pRectangle */
499 NULL, /* pRestoreDC */
500 nulldrv_RoundRect, /* pRoundRect */
502 NULL, /* pScaleViewportExt */
503 NULL, /* pScaleWindowExt */
504 NULL, /* pSelectBitmap */
505 NULL, /* pSelectBrush */
506 NULL, /* pSelectClipPath */
507 NULL, /* pSelectFont */
508 NULL, /* pSelectPalette */
509 NULL, /* pSelectPen */
510 NULL, /* pSetArcDirection */
511 NULL, /* pSetBitmapBits */
512 NULL, /* pSetBkColor */
513 NULL, /* pSetBkMode */
514 NULL, /* pSetDCBrushColor */
515 NULL, /* pSetDCPenColor */
516 NULL, /* pSetDIBColorTable */
517 NULL, /* pSetDIBits */
518 NULL, /* pSetDIBitsToDevice */
519 NULL, /* pSetDeviceClipping */
520 NULL, /* pSetDeviceGammaRamp */
521 NULL, /* pSetMapMode */
522 NULL, /* pSetMapperFlags */
523 nulldrv_SetPixel, /* pSetPixel */
524 NULL, /* pSetPixelFormat */
525 NULL, /* pSetPolyFillMode */
527 NULL, /* pSetRelAbs */
528 NULL, /* pSetStretchBltMode */
529 NULL, /* pSetTextAlign */
530 NULL, /* pSetTextCharacterExtra */
531 NULL, /* pSetTextColor */
532 NULL, /* pSetTextJustification */
533 NULL, /* pSetViewportExt */
534 NULL, /* pSetViewportOrg */
535 NULL, /* pSetWindowExt */
536 NULL, /* pSetWindowOrg */
537 NULL, /* pSetWorldTransform */
538 nulldrv_StartDoc, /* pStartDoc */
539 nulldrv_StartPage, /* pStartPage */
540 NULL, /* pStretchBlt */
541 NULL, /* pStretchDIBits */
542 NULL, /* pStrokeAndFillPath */
543 NULL, /* pStrokePath */
544 NULL, /* pSwapBuffers */
545 NULL, /* pUnrealizePalette */
546 NULL, /* pWidenPath */
547 NULL, /* pwglCopyContext */
548 NULL, /* pwglCreateContext */
549 NULL, /* pwglCreateContextAttribsARB */
550 NULL, /* pwglDeleteContext */
551 NULL, /* pwglGetProcAddress */
552 NULL, /* pwglGetPbufferDCARB */
553 NULL, /* pwglMakeCurrent */
554 NULL, /* pwglMakeContextCurrentARB */
555 NULL, /* pwglSetPixelFormatWINE */
556 NULL, /* pwglShareLists */
557 NULL, /* pwglUseFontBitmapsA */
558 NULL, /* pwglUseFontBitmapsW */
562 /*****************************************************************************
563 * DRIVER_GetDriverName
566 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
568 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
569 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
570 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
571 static const WCHAR empty_strW[] = { 0 };
574 /* display is a special case */
575 if (!strcmpiW( device, displayW ) ||
576 !strcmpiW( device, display1W ))
578 lstrcpynW( driver, displayW, size );
582 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
584 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
587 p = strchrW(driver, ',');
590 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
594 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
599 /***********************************************************************
600 * GdiConvertToDevmodeW (GDI32.@)
602 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
605 WORD dmW_size, dmA_size;
607 dmA_size = dmA->dmSize;
609 /* this is the minimal dmSize that XP accepts */
610 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
613 if (dmA_size > sizeof(DEVMODEA))
614 dmA_size = sizeof(DEVMODEA);
616 dmW_size = dmA_size + CCHDEVICENAME;
617 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
618 dmW_size += CCHFORMNAME;
620 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
621 if (!dmW) return NULL;
623 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
624 dmW->dmDeviceName, CCHDEVICENAME);
625 /* copy slightly more, to avoid long computations */
626 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
628 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
630 if (dmA->dmFields & DM_FORMNAME)
631 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
632 dmW->dmFormName, CCHFORMNAME);
634 dmW->dmFormName[0] = 0;
636 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
637 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
640 if (dmA->dmDriverExtra)
641 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
643 dmW->dmSize = dmW_size;
649 /*****************************************************************************
652 * This should thunk to 16-bit and simply call the proc with the given args.
654 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
655 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
657 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
661 /*****************************************************************************
664 * This should load the correct driver for lpszDevice and calls this driver's
665 * ExtDeviceModePropSheet proc.
667 * Note: The driver calls a callback routine for each property sheet page; these
668 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
669 * The layout of this structure is:
675 * HPROPSHEETPAGE pages[10];
678 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
679 LPCSTR lpszPort, LPVOID lpPropSheet )
681 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
685 /*****************************************************************************
688 * This should load the correct driver for lpszDevice and call this driver's
689 * ExtDeviceMode proc.
691 * FIXME: convert ExtDeviceMode to unicode in the driver interface
693 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
694 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
695 LPSTR lpszPort, LPDEVMODEA lpdmInput,
696 LPSTR lpszProfile, DWORD fwMode )
705 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
706 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
708 if (!lpszDevice) return -1;
709 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
711 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
713 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
715 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
717 if ((dc = get_dc_ptr( hdc )))
719 if (dc->funcs->pExtDeviceMode)
720 ret = dc->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
721 lpdmInput, lpszProfile, fwMode );
722 release_dc_ptr( dc );
728 /****************************************************************************
731 * This should load the correct driver for lpszDevice and calls this driver's
732 * AdvancedSetupDialog proc.
734 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
735 LPDEVMODEA devin, LPDEVMODEA devout )
737 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
741 /*****************************************************************************
744 * This should load the correct driver for lpszDevice and calls this driver's
745 * DeviceCapabilities proc.
747 * FIXME: convert DeviceCapabilities to unicode in the driver interface
749 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
750 WORD fwCapability, LPSTR lpszOutput,
760 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
762 if (!lpszDevice) return -1;
763 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
765 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
767 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
769 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
771 if ((dc = get_dc_ptr( hdc )))
773 if (dc->funcs->pDeviceCapabilities)
774 ret = dc->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
775 fwCapability, lpszOutput, lpdm );
776 release_dc_ptr( dc );
783 /************************************************************************
786 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
794 return AbortDoc( hdc );
797 return EndDoc( hdc );
799 case GETPHYSPAGESIZE:
801 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
802 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
805 case GETPRINTINGOFFSET:
807 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
808 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
811 case GETSCALINGFACTOR:
813 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
814 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
818 return EndPage( hdc );
821 return SetAbortProc( hdc, (ABORTPROC)in_data );
828 /* in_data may not be 0 terminated so we must copy it */
831 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
832 memcpy( name, in_data, in_count );
835 /* out_data is actually a pointer to the DocInfo structure and used as
836 * a second input parameter */
837 if (out_data) doc = *(DOCINFOA *)out_data;
840 doc.cbSize = sizeof(doc);
841 doc.lpszOutput = NULL;
842 doc.lpszDatatype = NULL;
845 doc.lpszDocName = name;
846 ret = StartDocA( hdc, &doc );
847 HeapFree( GetProcessHeap(), 0, name );
848 if (ret > 0) ret = StartPage( hdc );
852 case QUERYESCSUPPORT:
854 const INT *ptr = (const INT *)in_data;
855 if (in_count < sizeof(INT)) return 0;
860 case GETPHYSPAGESIZE:
861 case GETPRINTINGOFFSET:
862 case GETSCALINGFACTOR:
864 case QUERYESCSUPPORT:
873 /* if not handled internally, pass it to the driver */
874 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
878 /******************************************************************************
879 * ExtEscape [GDI32.@]
881 * Access capabilities of a particular device that are not available through GDI.
884 * hdc [I] Handle to device context
885 * nEscape [I] Escape function
886 * cbInput [I] Number of bytes in input structure
887 * lpszInData [I] Pointer to input structure
888 * cbOutput [I] Number of bytes in output structure
889 * lpszOutData [O] Pointer to output structure
896 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
897 INT cbOutput, LPSTR lpszOutData )
900 DC * dc = get_dc_ptr( hdc );
903 if (dc->funcs->pExtEscape)
904 ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
905 release_dc_ptr( dc );
911 /*******************************************************************
912 * DrawEscape [GDI32.@]
916 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
918 FIXME("DrawEscape, stub\n");
922 /*******************************************************************
923 * NamedEscape [GDI32.@]
925 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
926 INT cbOutput, LPSTR lpszOutData )
928 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
929 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
934 /*******************************************************************
935 * DdQueryDisplaySettingsUniqueness [GDI32.@]
936 * GdiEntry13 [GDI32.@]
938 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
940 static int warn_once;