1 /*
2 * Graphics driver management functions
3 *
4 * Copyright 1994 Bob Amstadt
5 * Copyright 1996, 2001 Alexandre Julliard
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #include "config.h"
23 #include "wine/port.h"
24
25 #include <stdarg.h>
26 #include <string.h>
27 #include <stdio.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "ddrawgdi.h"
32
33 #include "gdi_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(driver);
38
39 struct graphics_driver
40 {
41 struct graphics_driver *next;
42 struct graphics_driver *prev;
43 HMODULE module; /* module handle */
44 unsigned int count; /* reference count */
45 DC_FUNCTIONS funcs;
46 };
47
48 static struct graphics_driver *first_driver;
49 static struct graphics_driver *display_driver;
50
51 static CRITICAL_SECTION driver_section;
52 static CRITICAL_SECTION_DEBUG critsect_debug =
53 {
54 0, 0, &driver_section,
55 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
56 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
57 };
58 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
59
60 /**********************************************************************
61 * create_driver
62 *
63 * Allocate and fill the driver structure for a given module.
64 */
65 static struct graphics_driver *create_driver( HMODULE module )
66 {
67 struct graphics_driver *driver;
68
69 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
70 driver->next = NULL;
71 driver->prev = NULL;
72 driver->module = module;
73 driver->count = 1;
74
75 /* fill the function table */
76 if (module)
77 {
78 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
79 GET_FUNC(AbortDoc);
80 GET_FUNC(AbortPath);
81 GET_FUNC(AlphaBlend);
82 GET_FUNC(AngleArc);
83 GET_FUNC(Arc);
84 GET_FUNC(ArcTo);
85 GET_FUNC(BeginPath);
86 GET_FUNC(BitBlt);
87 GET_FUNC(ChoosePixelFormat);
88 GET_FUNC(Chord);
89 GET_FUNC(CloseFigure);
90 GET_FUNC(CreateBitmap);
91 GET_FUNC(CreateDC);
92 GET_FUNC(CreateDIBSection);
93 GET_FUNC(DeleteBitmap);
94 GET_FUNC(DeleteDC);
95 GET_FUNC(DescribePixelFormat);
96 GET_FUNC(DeviceCapabilities);
97 GET_FUNC(Ellipse);
98 GET_FUNC(EndDoc);
99 GET_FUNC(EndPage);
100 GET_FUNC(EndPath);
101 GET_FUNC(EnumDeviceFonts);
102 GET_FUNC(ExcludeClipRect);
103 GET_FUNC(ExtDeviceMode);
104 GET_FUNC(ExtEscape);
105 GET_FUNC(ExtFloodFill);
106 GET_FUNC(ExtSelectClipRgn);
107 GET_FUNC(ExtTextOut);
108 GET_FUNC(FillPath);
109 GET_FUNC(FillRgn);
110 GET_FUNC(FlattenPath);
111 GET_FUNC(FrameRgn);
112 GET_FUNC(GdiComment);
113 GET_FUNC(GetBitmapBits);
114 GET_FUNC(GetCharWidth);
115 GET_FUNC(GetDCOrgEx);
116 GET_FUNC(GetDIBColorTable);
117 GET_FUNC(GetDIBits);
118 GET_FUNC(GetDeviceCaps);
119 GET_FUNC(GetDeviceGammaRamp);
120 GET_FUNC(GetICMProfile);
121 GET_FUNC(GetNearestColor);
122 GET_FUNC(GetPixel);
123 GET_FUNC(GetPixelFormat);
124 GET_FUNC(GetSystemPaletteEntries);
125 GET_FUNC(GetTextExtentExPoint);
126 GET_FUNC(GetTextMetrics);
127 GET_FUNC(IntersectClipRect);
128 GET_FUNC(InvertRgn);
129 GET_FUNC(LineTo);
130 GET_FUNC(MoveTo);
131 GET_FUNC(ModifyWorldTransform);
132 GET_FUNC(OffsetClipRgn);
133 GET_FUNC(OffsetViewportOrg);
134 GET_FUNC(OffsetWindowOrg);
135 GET_FUNC(PaintRgn);
136 GET_FUNC(PatBlt);
137 GET_FUNC(Pie);
138 GET_FUNC(PolyBezier);
139 GET_FUNC(PolyBezierTo);
140 GET_FUNC(PolyDraw);
141 GET_FUNC(PolyPolygon);
142 GET_FUNC(PolyPolyline);
143 GET_FUNC(Polygon);
144 GET_FUNC(Polyline);
145 GET_FUNC(PolylineTo);
146 GET_FUNC(RealizeDefaultPalette);
147 GET_FUNC(RealizePalette);
148 GET_FUNC(Rectangle);
149 GET_FUNC(ResetDC);
150 GET_FUNC(RestoreDC);
151 GET_FUNC(RoundRect);
152 GET_FUNC(SaveDC);
153 GET_FUNC(ScaleViewportExt);
154 GET_FUNC(ScaleWindowExt);
155 GET_FUNC(SelectBitmap);
156 GET_FUNC(SelectBrush);
157 GET_FUNC(SelectClipPath);
158 GET_FUNC(SelectFont);
159 GET_FUNC(SelectPalette);
160 GET_FUNC(SelectPen);
161 GET_FUNC(SetArcDirection);
162 GET_FUNC(SetBitmapBits);
163 GET_FUNC(SetBkColor);
164 GET_FUNC(SetBkMode);
165 GET_FUNC(SetDCBrushColor);
166 GET_FUNC(SetDCOrg);
167 GET_FUNC(SetDCPenColor);
168 GET_FUNC(SetDIBColorTable);
169 GET_FUNC(SetDIBits);
170 GET_FUNC(SetDIBitsToDevice);
171 GET_FUNC(SetDeviceClipping);
172 GET_FUNC(SetDeviceGammaRamp);
173 GET_FUNC(SetMapMode);
174 GET_FUNC(SetMapperFlags);
175 GET_FUNC(SetPixel);
176 GET_FUNC(SetPixelFormat);
177 GET_FUNC(SetPolyFillMode);
178 GET_FUNC(SetROP2);
179 GET_FUNC(SetRelAbs);
180 GET_FUNC(SetStretchBltMode);
181 GET_FUNC(SetTextAlign);
182 GET_FUNC(SetTextCharacterExtra);
183 GET_FUNC(SetTextColor);
184 GET_FUNC(SetTextJustification);
185 GET_FUNC(SetViewportExt);
186 GET_FUNC(SetViewportOrg);
187 GET_FUNC(SetWindowExt);
188 GET_FUNC(SetWindowOrg);
189 GET_FUNC(SetWorldTransform);
190 GET_FUNC(StartDoc);
191 GET_FUNC(StartPage);
192 GET_FUNC(StretchBlt);
193 GET_FUNC(StretchDIBits);
194 GET_FUNC(StrokeAndFillPath);
195 GET_FUNC(StrokePath);
196 GET_FUNC(SwapBuffers);
197 GET_FUNC(UnrealizePalette);
198 GET_FUNC(WidenPath);
199
200 /* OpenGL32 */
201 GET_FUNC(wglCreateContext);
202 GET_FUNC(wglDeleteContext);
203 GET_FUNC(wglGetProcAddress);
204 GET_FUNC(wglGetPbufferDCARB);
205 GET_FUNC(wglMakeContextCurrentARB);
206 GET_FUNC(wglMakeCurrent);
207 GET_FUNC(wglSetPixelFormatWINE);
208 GET_FUNC(wglShareLists);
209 GET_FUNC(wglUseFontBitmapsA);
210 GET_FUNC(wglUseFontBitmapsW);
211 #undef GET_FUNC
212 }
213 else memset( &driver->funcs, 0, sizeof(driver->funcs) );
214
215 /* add it to the list */
216 driver->prev = NULL;
217 if ((driver->next = first_driver)) driver->next->prev = driver;
218 first_driver = driver;
219 return driver;
220 }
221
222
223 /**********************************************************************
224 * load_display_driver
225 *
226 * Special case for loading the display driver: get the name from the config file
227 */
228 static struct graphics_driver *load_display_driver(void)
229 {
230 char buffer[MAX_PATH], libname[32], *name, *next;
231 HMODULE module = 0;
232 HKEY hkey;
233
234 if (display_driver) /* already loaded */
235 {
236 display_driver->count++;
237 return display_driver;
238 }
239
240 strcpy( buffer, "x11" ); /* default value */
241 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
242 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
243 {
244 DWORD type, count = sizeof(buffer);
245 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
246 RegCloseKey( hkey );
247 }
248
249 name = buffer;
250 while (name)
251 {
252 next = strchr( name, ',' );
253 if (next) *next++ = 0;
254
255 snprintf( libname, sizeof(libname), "wine%s.drv", name );
256 if ((module = LoadLibraryA( libname )) != 0) break;
257 name = next;
258 }
259
260 if (!(display_driver = create_driver( module )))
261 {
262 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
263 FreeLibrary( module );
264 ExitProcess(1);
265 }
266
267 display_driver->count++; /* we don't want to free it */
268 return display_driver;
269 }
270
271
272 /**********************************************************************
273 * DRIVER_load_driver
274 */
275 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
276 {
277 HMODULE module;
278 struct graphics_driver *driver;
279 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
280 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
281
282 EnterCriticalSection( &driver_section );
283
284 /* display driver is a special case */
285 if (!strcmpiW( name, displayW ) ||
286 !strcmpiW( name, display1W ))
287 {
288 driver = load_display_driver();
289 LeaveCriticalSection( &driver_section );
290 return &driver->funcs;
291 }
292
293 if ((module = GetModuleHandleW( name )))
294 {
295 for (driver = first_driver; driver; driver = driver->next)
296 {
297 if (driver->module == module)
298 {
299 driver->count++;
300 LeaveCriticalSection( &driver_section );
301 return &driver->funcs;
302 }
303 }
304 }
305
306 if (!(module = LoadLibraryW( name )))
307 {
308 LeaveCriticalSection( &driver_section );
309 return NULL;
310 }
311
312 if (!(driver = create_driver( module )))
313 {
314 FreeLibrary( module );
315 LeaveCriticalSection( &driver_section );
316 return NULL;
317 }
318
319 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
320 LeaveCriticalSection( &driver_section );
321 return &driver->funcs;
322 }
323
324
325 /**********************************************************************
326 * DRIVER_get_driver
327 *
328 * Get a new copy of an existing driver.
329 */
330 const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs )
331 {
332 struct graphics_driver *driver;
333
334 EnterCriticalSection( &driver_section );
335 for (driver = first_driver; driver; driver = driver->next)
336 if (&driver->funcs == funcs) break;
337 if (!driver) ERR( "driver not found, trouble ahead\n" );
338 driver->count++;
339 LeaveCriticalSection( &driver_section );
340 return funcs;
341 }
342
343
344 /**********************************************************************
345 * DRIVER_release_driver
346 *
347 * Release a driver by decrementing ref count and freeing it if needed.
348 */
349 void DRIVER_release_driver( const DC_FUNCTIONS *funcs )
350 {
351 struct graphics_driver *driver;
352
353 EnterCriticalSection( &driver_section );
354
355 for (driver = first_driver; driver; driver = driver->next)
356 if (&driver->funcs == funcs) break;
357
358 if (!driver) goto done;
359 if (--driver->count) goto done;
360
361 /* removed last reference, free it */
362 if (driver->next) driver->next->prev = driver->prev;
363 if (driver->prev) driver->prev->next = driver->next;
364 else first_driver = driver->next;
365 if (driver == display_driver) display_driver = NULL;
366
367 FreeLibrary( driver->module );
368 HeapFree( GetProcessHeap(), 0, driver );
369 done:
370 LeaveCriticalSection( &driver_section );
371 }
372
373
374 /*****************************************************************************
375 * DRIVER_GetDriverName
376 *
377 */
378 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
379 {
380 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
381 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
382 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
383 static const WCHAR empty_strW[] = { 0 };
384 WCHAR *p;
385
386 /* display is a special case */
387 if (!strcmpiW( device, displayW ) ||
388 !strcmpiW( device, display1W ))
389 {
390 lstrcpynW( driver, displayW, size );
391 return TRUE;
392 }
393
394 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
395 if(!size) {
396 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
397 return FALSE;
398 }
399 p = strchrW(driver, ',');
400 if(!p)
401 {
402 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
403 return FALSE;
404 }
405 *p = 0;
406 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
407 return TRUE;
408 }
409
410
411 /***********************************************************************
412 * GdiConvertToDevmodeW (GDI32.@)
413 */
414 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
415 {
416 DEVMODEW *dmW;
417 WORD dmW_size, dmA_size;
418
419 dmA_size = dmA->dmSize;
420
421 /* this is the minimal dmSize that XP accepts */
422 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
423 return NULL;
424
425 if (dmA_size > sizeof(DEVMODEA))
426 dmA_size = sizeof(DEVMODEA);
427
428 dmW_size = dmA_size + CCHDEVICENAME;
429 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
430 dmW_size += CCHFORMNAME;
431
432 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
433 if (!dmW) return NULL;
434
435 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
436 dmW->dmDeviceName, CCHDEVICENAME);
437 /* copy slightly more, to avoid long computations */
438 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
439
440 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
441 {
442 if (dmA->dmFields & DM_FORMNAME)
443 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
444 dmW->dmFormName, CCHFORMNAME);
445 else
446 dmW->dmFormName[0] = 0;
447
448 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
449 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
450 }
451
452 if (dmA->dmDriverExtra)
453 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
454
455 dmW->dmSize = dmW_size;
456
457 return dmW;
458 }
459
460
461 /*****************************************************************************
462 * @ [GDI32.100]
463 *
464 * This should thunk to 16-bit and simply call the proc with the given args.
465 */
466 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
467 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
468 {
469 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
470 return -1;
471 }
472
473 /*****************************************************************************
474 * @ [GDI32.101]
475 *
476 * This should load the correct driver for lpszDevice and calls this driver's
477 * ExtDeviceModePropSheet proc.
478 *
479 * Note: The driver calls a callback routine for each property sheet page; these
480 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
481 * The layout of this structure is:
482 *
483 * struct
484 * {
485 * DWORD nPages;
486 * DWORD unknown;
487 * HPROPSHEETPAGE pages[10];
488 * };
489 */
490 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
491 LPCSTR lpszPort, LPVOID lpPropSheet )
492 {
493 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
494 return -1;
495 }
496
497 /*****************************************************************************
498 * @ [GDI32.102]
499 *
500 * This should load the correct driver for lpszDevice and call this driver's
501 * ExtDeviceMode proc.
502 *
503 * FIXME: convert ExtDeviceMode to unicode in the driver interface
504 */
505 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
506 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
507 LPSTR lpszPort, LPDEVMODEA lpdmInput,
508 LPSTR lpszProfile, DWORD fwMode )
509 {
510 WCHAR deviceW[300];
511 WCHAR bufW[300];
512 char buf[300];
513 HDC hdc;
514 DC *dc;
515 INT ret = -1;
516
517 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
518 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
519
520 if (!lpszDevice) return -1;
521 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
522
523 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
524
525 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
526
527 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
528
529 if ((dc = get_dc_ptr( hdc )))
530 {
531 if (dc->funcs->pExtDeviceMode)
532 ret = dc->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
533 lpdmInput, lpszProfile, fwMode );
534 release_dc_ptr( dc );
535 }
536 DeleteDC( hdc );
537 return ret;
538 }
539
540 /****************************************************************************
541 * @ [GDI32.103]
542 *
543 * This should load the correct driver for lpszDevice and calls this driver's
544 * AdvancedSetupDialog proc.
545 */
546 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
547 LPDEVMODEA devin, LPDEVMODEA devout )
548 {
549 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
550 return -1;
551 }
552
553 /*****************************************************************************
554 * @ [GDI32.104]
555 *
556 * This should load the correct driver for lpszDevice and calls this driver's
557 * DeviceCapabilities proc.
558 *
559 * FIXME: convert DeviceCapabilities to unicode in the driver interface
560 */
561 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
562 WORD fwCapability, LPSTR lpszOutput,
563 LPDEVMODEA lpdm )
564 {
565 WCHAR deviceW[300];
566 WCHAR bufW[300];
567 char buf[300];
568 HDC hdc;
569 DC *dc;
570 INT ret = -1;
571
572 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
573
574 if (!lpszDevice) return -1;
575 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
576
577 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
578
579 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
580
581 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
582
583 if ((dc = get_dc_ptr( hdc )))
584 {
585 if (dc->funcs->pDeviceCapabilities)
586 ret = dc->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
587 fwCapability, lpszOutput, lpdm );
588 release_dc_ptr( dc );
589 }
590 DeleteDC( hdc );
591 return ret;
592 }
593
594
595 /************************************************************************
596 * Escape [GDI32.@]
597 */
598 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
599 {
600 INT ret;
601 POINT *pt;
602
603 switch (escape)
604 {
605 case ABORTDOC:
606 return AbortDoc( hdc );
607
608 case ENDDOC:
609 return EndDoc( hdc );
610
611 case GETPHYSPAGESIZE:
612 pt = out_data;
613 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
614 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
615 return 1;
616
617 case GETPRINTINGOFFSET:
618 pt = out_data;
619 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
620 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
621 return 1;
622
623 case GETSCALINGFACTOR:
624 pt = out_data;
625 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
626 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
627 return 1;
628
629 case NEWFRAME:
630 return EndPage( hdc );
631
632 case SETABORTPROC:
633 return SetAbortProc( hdc, (ABORTPROC)in_data );
634
635 case STARTDOC:
636 {
637 DOCINFOA doc;
638 char *name = NULL;
639
640 /* in_data may not be 0 terminated so we must copy it */
641 if (in_data)
642 {
643 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
644 memcpy( name, in_data, in_count );
645 name[in_count] = 0;
646 }
647 /* out_data is actually a pointer to the DocInfo structure and used as
648 * a second input parameter */
649 if (out_data) doc = *(DOCINFOA *)out_data;
650 else
651 {
652 doc.cbSize = sizeof(doc);
653 doc.lpszOutput = NULL;
654 doc.lpszDatatype = NULL;
655 doc.fwType = 0;
656 }
657 doc.lpszDocName = name;
658 ret = StartDocA( hdc, &doc );
659 HeapFree( GetProcessHeap(), 0, name );
660 if (ret > 0) ret = StartPage( hdc );
661 return ret;
662 }
663
664 case QUERYESCSUPPORT:
665 {
666 const INT *ptr = (const INT *)in_data;
667 if (in_count < sizeof(INT)) return 0;
668 switch(*ptr)
669 {
670 case ABORTDOC:
671 case ENDDOC:
672 case GETPHYSPAGESIZE:
673 case GETPRINTINGOFFSET:
674 case GETSCALINGFACTOR:
675 case NEWFRAME:
676 case QUERYESCSUPPORT:
677 case SETABORTPROC:
678 case STARTDOC:
679 return TRUE;
680 }
681 break;
682 }
683 }
684
685 /* if not handled internally, pass it to the driver */
686 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
687 }
688
689
690 /******************************************************************************
691 * ExtEscape [GDI32.@]
692 *
693 * Access capabilities of a particular device that are not available through GDI.
694 *
695 * PARAMS
696 * hdc [I] Handle to device context
697 * nEscape [I] Escape function
698 * cbInput [I] Number of bytes in input structure
699 * lpszInData [I] Pointer to input structure
700 * cbOutput [I] Number of bytes in output structure
701 * lpszOutData [O] Pointer to output structure
702 *
703 * RETURNS
704 * Success: >0
705 * Not implemented: 0
706 * Failure: <0
707 */
708 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
709 INT cbOutput, LPSTR lpszOutData )
710 {
711 INT ret = 0;
712 DC * dc = get_dc_ptr( hdc );
713 if (dc)
714 {
715 if (dc->funcs->pExtEscape)
716 ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
717 release_dc_ptr( dc );
718 }
719 return ret;
720 }
721
722
723 /*******************************************************************
724 * DrawEscape [GDI32.@]
725 *
726 *
727 */
728 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
729 {
730 FIXME("DrawEscape, stub\n");
731 return 0;
732 }
733
734 /*******************************************************************
735 * NamedEscape [GDI32.@]
736 */
737 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
738 INT cbOutput, LPSTR lpszOutData )
739 {
740 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
741 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
742 lpszOutData);
743 return 0;
744 }
745
746 /*******************************************************************
747 * DdQueryDisplaySettingsUniqueness [GDI32.@]
748 * GdiEntry13 [GDI32.@]
749 */
750 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
751 {
752 FIXME("stub\n");
753 return 0;
754 }
755
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.