2 * GDI Device Context functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
7 * Copyright 2021 Jacek Caban for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "gdi_private.h"
29 #include "wine/list.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(gdi
);
34 static struct list drivers
= LIST_INIT( drivers
);
36 static CRITICAL_SECTION driver_section
;
37 static CRITICAL_SECTION_DEBUG critsect_debug
=
39 0, 0, &driver_section
,
40 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
41 0, 0, { (DWORD_PTR
)(__FILE__
": driver_section") }
43 static CRITICAL_SECTION driver_section
= { &critsect_debug
, -1, 0, 0, 0, 0 };
45 typedef const void * (CDECL
*driver_entry_point
)( unsigned int version
);
47 struct graphics_driver
50 HMODULE module
; /* module handle */
51 driver_entry_point entry_point
;
55 DC_ATTR
*get_dc_attr( HDC hdc
)
57 DWORD type
= gdi_handle_type( hdc
);
59 if ((type
& 0x1f0000) != NTGDI_OBJ_DC
|| !(dc_attr
= get_gdi_client_ptr( hdc
, 0 )))
61 SetLastError( ERROR_INVALID_HANDLE
);
64 return dc_attr
->disabled
? NULL
: dc_attr
;
67 static BOOL
is_display_device( const WCHAR
*name
)
69 const WCHAR
*p
= name
;
74 if (wcsnicmp( name
, L
"\\\\.\\DISPLAY", lstrlenW(L
"\\\\.\\DISPLAY") )) return FALSE
;
76 p
+= lstrlenW(L
"\\\\.\\DISPLAY");
78 if (!iswdigit( *p
++ ))
90 static BOOL
get_driver_name( const WCHAR
*device
, WCHAR
*driver
, DWORD size
)
94 /* display is a special case */
95 if (!wcsicmp( device
, L
"display" ) || is_display_device( device
))
97 lstrcpynW( driver
, L
"display", size
);
101 size
= GetProfileStringW(L
"devices", device
, L
"", driver
, size
);
104 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device
));
107 p
= wcschr(driver
, ',');
110 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device
));
114 TRACE("Found %s for %s\n", debugstr_w(driver
), debugstr_w(device
));
118 static struct graphics_driver
*create_driver( HMODULE module
)
120 struct graphics_driver
*driver
;
122 if (!(driver
= HeapAlloc( GetProcessHeap(), 0, sizeof(*driver
)))) return NULL
;
123 driver
->module
= module
;
126 driver
->entry_point
= (void *)GetProcAddress( module
, "wine_get_gdi_driver" );
128 driver
->entry_point
= NULL
;
134 static const WCHAR printer_env
[] = L
"w32x86";
135 #elif defined __x86_64__
136 static const WCHAR printer_env
[] = L
"x64";
137 #elif defined __arm__
138 static const WCHAR printer_env
[] = L
"arm";
139 #elif defined __aarch64__
140 static const WCHAR printer_env
[] = L
"arm64";
142 #error not defined for this cpu
145 static driver_entry_point
load_driver( LPCWSTR name
)
148 struct graphics_driver
*driver
, *new_driver
;
150 if ((module
= GetModuleHandleW( name
)))
152 EnterCriticalSection( &driver_section
);
153 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
155 if (driver
->module
== module
) goto done
;
157 LeaveCriticalSection( &driver_section
);
160 if (!(module
= LoadLibraryW( name
)))
162 WCHAR path
[MAX_PATH
];
164 GetSystemDirectoryW( path
, MAX_PATH
);
165 swprintf( path
+ wcslen(path
), MAX_PATH
- wcslen(path
), L
"\\spool\\drivers\\%s\\3\\%s",
167 if (!(module
= LoadLibraryW( path
))) return NULL
;
170 if (!(new_driver
= create_driver( module
)))
172 FreeLibrary( module
);
176 /* check if someone else added it in the meantime */
177 EnterCriticalSection( &driver_section
);
178 LIST_FOR_EACH_ENTRY( driver
, &drivers
, struct graphics_driver
, entry
)
180 if (driver
->module
!= module
) continue;
181 FreeLibrary( module
);
182 HeapFree( GetProcessHeap(), 0, new_driver
);
186 list_add_head( &drivers
, &driver
->entry
);
187 TRACE( "loaded driver %p for %s\n", driver
, debugstr_w(name
) );
189 LeaveCriticalSection( &driver_section
);
190 return driver
->entry_point
;
193 /***********************************************************************
194 * CreateDCW (GDI32.@)
196 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
197 const DEVMODEW
*devmode
)
199 UNICODE_STRING device_str
, output_str
;
200 driver_entry_point entry_point
= NULL
;
201 const WCHAR
*display
= NULL
, *p
;
202 BOOL is_display
= FALSE
;
205 if (!device
|| !get_driver_name( device
, buf
, 300 ))
209 ERR( "no device found for %s\n", debugstr_w(device
) );
212 lstrcpyW(buf
, driver
);
215 if (is_display_device( driver
))
220 else if (is_display_device( device
))
225 else if (!wcsicmp( buf
, L
"display" ) || is_display_device( buf
))
229 else if (!(entry_point
= load_driver( buf
)))
231 ERR( "no driver found for %s\n", debugstr_w(buf
) );
237 /* Use only the display name. For example, \\.\DISPLAY1 in \\.\DISPLAY1\Monitor0 */
239 while (iswdigit( *p
)) p
++;
241 device_str
.Length
= device_str
.MaximumLength
= (p
- display
) * sizeof(WCHAR
);
242 device_str
.Buffer
= (WCHAR
*)display
;
246 device_str
.Length
= device_str
.MaximumLength
= lstrlenW( device
) * sizeof(WCHAR
);
247 device_str
.Buffer
= (WCHAR
*)device
;
252 output_str
.Length
= output_str
.MaximumLength
= lstrlenW(output
) * sizeof(WCHAR
);
253 output_str
.Buffer
= (WCHAR
*)output
;
256 return NtGdiOpenDCW( device
|| display
? &device_str
: NULL
, devmode
, output
? &output_str
: NULL
,
257 0, is_display
, entry_point
, NULL
, NULL
);
260 /***********************************************************************
261 * CreateDCA (GDI32.@)
263 HDC WINAPI
CreateDCA( const char *driver
, const char *device
, const char *output
,
264 const DEVMODEA
*init_data
)
266 UNICODE_STRING driverW
, deviceW
, outputW
;
267 DEVMODEW
*init_dataW
= NULL
;
270 if (driver
) RtlCreateUnicodeStringFromAsciiz( &driverW
, driver
);
271 else driverW
.Buffer
= NULL
;
273 if (device
) RtlCreateUnicodeStringFromAsciiz( &deviceW
, device
);
274 else deviceW
.Buffer
= NULL
;
276 if (output
) RtlCreateUnicodeStringFromAsciiz( &outputW
, output
);
277 else outputW
.Buffer
= NULL
;
281 /* don't convert init_data for DISPLAY driver, it's not used */
282 if (!driverW
.Buffer
|| wcsicmp( driverW
.Buffer
, L
"display" ))
283 init_dataW
= GdiConvertToDevmodeW( init_data
);
286 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, init_dataW
);
288 RtlFreeUnicodeString( &driverW
);
289 RtlFreeUnicodeString( &deviceW
);
290 RtlFreeUnicodeString( &outputW
);
291 HeapFree( GetProcessHeap(), 0, init_dataW
);
295 /***********************************************************************
296 * CreateICA (GDI32.@)
298 HDC WINAPI
CreateICA( const char *driver
, const char *device
, const char *output
,
299 const DEVMODEA
*init_data
)
301 /* Nothing special yet for ICs */
302 return CreateDCA( driver
, device
, output
, init_data
);
306 /***********************************************************************
307 * CreateICW (GDI32.@)
309 HDC WINAPI
CreateICW( const WCHAR
*driver
, const WCHAR
*device
, const WCHAR
*output
,
310 const DEVMODEW
*init_data
)
312 /* Nothing special yet for ICs */
313 return CreateDCW( driver
, device
, output
, init_data
);
316 /***********************************************************************
317 * GdiConvertToDevmodeW (GDI32.@)
319 DEVMODEW
*WINAPI
GdiConvertToDevmodeW( const DEVMODEA
*dmA
)
322 WORD dmW_size
, dmA_size
;
324 dmA_size
= dmA
->dmSize
;
326 /* this is the minimal dmSize that XP accepts */
327 if (dmA_size
< FIELD_OFFSET(DEVMODEA
, dmFields
))
330 if (dmA_size
> sizeof(DEVMODEA
))
331 dmA_size
= sizeof(DEVMODEA
);
333 dmW_size
= dmA_size
+ CCHDEVICENAME
;
334 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
335 dmW_size
+= CCHFORMNAME
;
337 dmW
= HeapAlloc( GetProcessHeap(), 0, dmW_size
+ dmA
->dmDriverExtra
);
338 if (!dmW
) return NULL
;
340 MultiByteToWideChar( CP_ACP
, 0, (const char*) dmA
->dmDeviceName
, -1,
341 dmW
->dmDeviceName
, CCHDEVICENAME
);
342 /* copy slightly more, to avoid long computations */
343 memcpy( &dmW
->dmSpecVersion
, &dmA
->dmSpecVersion
, dmA_size
- CCHDEVICENAME
);
345 if (dmA_size
>= FIELD_OFFSET(DEVMODEA
, dmFormName
) + CCHFORMNAME
)
347 if (dmA
->dmFields
& DM_FORMNAME
)
348 MultiByteToWideChar( CP_ACP
, 0, (const char*) dmA
->dmFormName
, -1,
349 dmW
->dmFormName
, CCHFORMNAME
);
351 dmW
->dmFormName
[0] = 0;
353 if (dmA_size
> FIELD_OFFSET(DEVMODEA
, dmLogPixels
))
354 memcpy( &dmW
->dmLogPixels
, &dmA
->dmLogPixels
, dmA_size
- FIELD_OFFSET(DEVMODEA
, dmLogPixels
) );
357 if (dmA
->dmDriverExtra
)
358 memcpy( (char *)dmW
+ dmW_size
, (const char *)dmA
+ dmA_size
, dmA
->dmDriverExtra
);
360 dmW
->dmSize
= dmW_size
;
365 /***********************************************************************
368 BOOL WINAPI
DeleteDC( HDC hdc
)
372 if (is_meta_dc( hdc
)) return METADC_DeleteDC( hdc
);
373 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
374 if (dc_attr
->emf
) EMFDC_DeleteDC( dc_attr
);
375 return NtGdiDeleteObjectApp( hdc
);
378 /***********************************************************************
381 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
386 if (devmode
) devmodeW
= GdiConvertToDevmodeW( devmode
);
387 else devmodeW
= NULL
;
389 ret
= ResetDCW( hdc
, devmodeW
);
391 HeapFree( GetProcessHeap(), 0, devmodeW
);
395 /***********************************************************************
398 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
400 return NtGdiResetDC( hdc
, devmode
, NULL
, NULL
, NULL
) ? hdc
: 0;
403 /***********************************************************************
406 INT WINAPI
SaveDC( HDC hdc
)
410 if (is_meta_dc( hdc
)) return METADC_SaveDC( hdc
);
411 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
412 if (dc_attr
->emf
&& !EMFDC_SaveDC( dc_attr
)) return FALSE
;
413 return NtGdiSaveDC( hdc
);
416 /***********************************************************************
417 * RestoreDC (GDI32.@)
419 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
423 if (is_meta_dc( hdc
)) return METADC_RestoreDC( hdc
, level
);
424 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
425 if (dc_attr
->emf
&& !EMFDC_RestoreDC( dc_attr
, level
)) return FALSE
;
426 return NtGdiRestoreDC( hdc
, level
);
429 /***********************************************************************
430 * GetDeviceCaps (GDI32.@)
432 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
434 if (is_meta_dc( hdc
)) return METADC_GetDeviceCaps( hdc
, cap
);
435 if (!get_dc_attr( hdc
)) return FALSE
;
436 return NtGdiGetDeviceCaps( hdc
, cap
);
439 /***********************************************************************
442 INT WINAPI
Escape( HDC hdc
, INT escape
, INT in_count
, const char *in_data
, void *out_data
)
450 return AbortDoc( hdc
);
453 return EndDoc( hdc
);
455 case GETPHYSPAGESIZE
:
457 pt
->x
= GetDeviceCaps( hdc
, PHYSICALWIDTH
);
458 pt
->y
= GetDeviceCaps( hdc
, PHYSICALHEIGHT
);
461 case GETPRINTINGOFFSET
:
463 pt
->x
= GetDeviceCaps( hdc
, PHYSICALOFFSETX
);
464 pt
->y
= GetDeviceCaps( hdc
, PHYSICALOFFSETY
);
467 case GETSCALINGFACTOR
:
469 pt
->x
= GetDeviceCaps( hdc
, SCALINGFACTORX
);
470 pt
->y
= GetDeviceCaps( hdc
, SCALINGFACTORY
);
474 return EndPage( hdc
);
477 return SetAbortProc( hdc
, (ABORTPROC
)in_data
);
484 /* in_data may not be 0 terminated so we must copy it */
487 name
= HeapAlloc( GetProcessHeap(), 0, in_count
+1 );
488 memcpy( name
, in_data
, in_count
);
491 /* out_data is actually a pointer to the DocInfo structure and used as
492 * a second input parameter */
493 if (out_data
) doc
= *(DOCINFOA
*)out_data
;
496 doc
.cbSize
= sizeof(doc
);
497 doc
.lpszOutput
= NULL
;
498 doc
.lpszDatatype
= NULL
;
501 doc
.lpszDocName
= name
;
502 ret
= StartDocA( hdc
, &doc
);
503 HeapFree( GetProcessHeap(), 0, name
);
504 if (ret
> 0) ret
= StartPage( hdc
);
508 case QUERYESCSUPPORT
:
512 if (in_count
< sizeof(SHORT
)) return 0;
513 code
= (in_count
< sizeof(DWORD
)) ? *(const USHORT
*)in_data
: *(const DWORD
*)in_data
;
518 case GETPHYSPAGESIZE
:
519 case GETPRINTINGOFFSET
:
520 case GETSCALINGFACTOR
:
522 case QUERYESCSUPPORT
:
531 /* if not handled internally, pass it to the driver */
532 return ExtEscape( hdc
, escape
, in_count
, in_data
, 0, out_data
);
535 /***********************************************************************
536 * ExtEscape [GDI32.@]
538 INT WINAPI
ExtEscape( HDC hdc
, INT escape
, INT input_size
, const char *input
,
539 INT output_size
, char *output
)
541 if (is_meta_dc( hdc
))
542 return METADC_ExtEscape( hdc
, escape
, input_size
, input
, output_size
, output
);
543 return NtGdiExtEscape( hdc
, NULL
, 0, escape
, input_size
, input
, output_size
, output
);
546 /***********************************************************************
547 * GetTextAlign (GDI32.@)
549 UINT WINAPI
GetTextAlign( HDC hdc
)
551 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
552 return dc_attr
? dc_attr
->text_align
: 0;
555 /***********************************************************************
556 * SetTextAlign (GDI32.@)
558 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
563 TRACE("hdc=%p align=%d\n", hdc
, align
);
565 if (is_meta_dc( hdc
)) return METADC_SetTextAlign( hdc
, align
);
566 if (!(dc_attr
= get_dc_attr( hdc
))) return GDI_ERROR
;
567 if (dc_attr
->emf
&& !EMFDC_SetTextAlign( dc_attr
, align
)) return GDI_ERROR
;
569 ret
= dc_attr
->text_align
;
570 dc_attr
->text_align
= align
;
574 /***********************************************************************
575 * GetBkColor (GDI32.@)
577 COLORREF WINAPI
GetBkColor( HDC hdc
)
579 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
580 return dc_attr
? dc_attr
->background_color
: CLR_INVALID
;
583 /***********************************************************************
584 * SetBkColor (GDI32.@)
586 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
591 if (is_meta_dc( hdc
)) return METADC_SetBkColor( hdc
, color
);
592 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
593 if (dc_attr
->emf
&& !EMFDC_SetBkColor( dc_attr
, color
)) return CLR_INVALID
;
594 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetBkColor
, color
, &ret
) ? ret
: CLR_INVALID
;
597 /***********************************************************************
598 * GetDCBrushColor (GDI32.@)
600 COLORREF WINAPI
GetDCBrushColor( HDC hdc
)
602 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
603 return dc_attr
? dc_attr
->brush_color
: CLR_INVALID
;
606 /***********************************************************************
607 * SetDCBrushColor (GDI32.@)
609 COLORREF WINAPI
SetDCBrushColor( HDC hdc
, COLORREF color
)
614 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
615 if (dc_attr
->emf
&& !EMFDC_SetDCBrushColor( dc_attr
, color
)) return CLR_INVALID
;
616 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetDCBrushColor
, color
, &ret
) ? ret
: CLR_INVALID
;
619 /***********************************************************************
620 * GetDCPenColor (GDI32.@)
622 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
624 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
625 return dc_attr
? dc_attr
->pen_color
: CLR_INVALID
;
628 /***********************************************************************
629 * SetDCPenColor (GDI32.@)
631 COLORREF WINAPI
SetDCPenColor( HDC hdc
, COLORREF color
)
636 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
637 if (dc_attr
->emf
&& !EMFDC_SetDCPenColor( dc_attr
, color
)) return CLR_INVALID
;
638 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetDCPenColor
, color
, &ret
) ? ret
: CLR_INVALID
;
641 /***********************************************************************
642 * GetTextColor (GDI32.@)
644 COLORREF WINAPI
GetTextColor( HDC hdc
)
646 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
647 return dc_attr
? dc_attr
->text_color
: 0;
650 /***********************************************************************
651 * SetTextColor (GDI32.@)
653 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
658 if (is_meta_dc( hdc
)) return METADC_SetTextColor( hdc
, color
);
659 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
660 if (dc_attr
->emf
&& !EMFDC_SetTextColor( dc_attr
, color
)) return CLR_INVALID
;
661 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetTextColor
, color
, &ret
) ? ret
: CLR_INVALID
;
664 /***********************************************************************
665 * GetBkMode (GDI32.@)
667 INT WINAPI
GetBkMode( HDC hdc
)
669 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
670 return dc_attr
? dc_attr
->background_mode
: 0;
673 /***********************************************************************
674 * SetBkMode (GDI32.@)
676 INT WINAPI
SetBkMode( HDC hdc
, INT mode
)
681 if (mode
<= 0 || mode
> BKMODE_LAST
)
683 SetLastError(ERROR_INVALID_PARAMETER
);
687 if (is_meta_dc( hdc
)) return METADC_SetBkMode( hdc
, mode
);
688 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
689 if (dc_attr
->emf
&& !EMFDC_SetBkMode( dc_attr
, mode
)) return 0;
691 ret
= dc_attr
->background_mode
;
692 dc_attr
->background_mode
= mode
;
696 /***********************************************************************
697 * GetGraphicsMode (GDI32.@)
699 INT WINAPI
GetGraphicsMode( HDC hdc
)
701 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
702 return dc_attr
? dc_attr
->graphics_mode
: 0;
705 /***********************************************************************
706 * SetGraphicsMode (GDI32.@)
708 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
711 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetGraphicsMode
, mode
, &ret
) ? ret
: 0;
714 /***********************************************************************
715 * GetArcDirection (GDI32.@)
717 INT WINAPI
GetArcDirection( HDC hdc
)
719 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
720 return dc_attr
? dc_attr
->arc_direction
: 0;
723 /***********************************************************************
724 * SetArcDirection (GDI32.@)
726 INT WINAPI
SetArcDirection( HDC hdc
, INT dir
)
731 if (dir
!= AD_COUNTERCLOCKWISE
&& dir
!= AD_CLOCKWISE
)
733 SetLastError(ERROR_INVALID_PARAMETER
);
737 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
738 if (dc_attr
->emf
&& !EMFDC_SetArcDirection( dc_attr
, dir
)) return 0;
740 ret
= dc_attr
->arc_direction
;
741 dc_attr
->arc_direction
= dir
;
745 /***********************************************************************
746 * GetLayout (GDI32.@)
748 DWORD WINAPI
GetLayout( HDC hdc
)
750 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
751 return dc_attr
? dc_attr
->layout
: GDI_ERROR
;
754 /***********************************************************************
755 * SetLayout (GDI32.@)
757 DWORD WINAPI
SetLayout( HDC hdc
, DWORD layout
)
761 if (is_meta_dc( hdc
)) return METADC_SetLayout( hdc
, layout
);
762 if (!(dc_attr
= get_dc_attr( hdc
))) return GDI_ERROR
;
763 if (dc_attr
->emf
&& !EMFDC_SetLayout( dc_attr
, layout
)) return GDI_ERROR
;
764 return NtGdiSetLayout( hdc
, -1, layout
);
767 /***********************************************************************
768 * GetMapMode (GDI32.@)
770 INT WINAPI
GetMapMode( HDC hdc
)
772 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
773 return dc_attr
? dc_attr
->map_mode
: 0;
776 /***********************************************************************
777 * SetMapMode (GDI32.@)
779 INT WINAPI
SetMapMode( HDC hdc
, INT mode
)
784 TRACE("%p %d\n", hdc
, mode
);
786 if (is_meta_dc( hdc
)) return METADC_SetMapMode( hdc
, mode
);
787 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
788 if (dc_attr
->emf
&& !EMFDC_SetMapMode( dc_attr
, mode
)) return 0;
789 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetMapMode
, mode
, &ret
) ? ret
: 0;
792 /***********************************************************************
793 * GetTextCharacterExtra (GDI32.@)
795 INT WINAPI
GetTextCharacterExtra( HDC hdc
)
797 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
798 return dc_attr
? dc_attr
->char_extra
: 0x80000000;
801 /***********************************************************************
802 * SetTextCharacterExtra (GDI32.@)
804 INT WINAPI
SetTextCharacterExtra( HDC hdc
, INT extra
)
809 if (is_meta_dc( hdc
)) return METADC_SetTextCharacterExtra( hdc
, extra
);
810 if (!(dc_attr
= get_dc_attr( hdc
))) return 0x8000000;
811 ret
= dc_attr
->char_extra
;
812 dc_attr
->char_extra
= extra
;
816 /***********************************************************************
817 * SetMapperFlags (GDI32.@)
819 DWORD WINAPI
SetMapperFlags( HDC hdc
, DWORD flags
)
824 if (is_meta_dc( hdc
)) return METADC_SetMapperFlags( hdc
, flags
);
825 if (!(dc_attr
= get_dc_attr( hdc
))) return GDI_ERROR
;
826 if (dc_attr
->emf
&& !EMFDC_SetMapperFlags( dc_attr
, flags
)) return GDI_ERROR
;
827 ret
= dc_attr
->mapper_flags
;
828 dc_attr
->mapper_flags
= flags
;
832 /***********************************************************************
833 * GetPolyFillMode (GDI32.@)
835 INT WINAPI
GetPolyFillMode( HDC hdc
)
837 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
838 return dc_attr
? dc_attr
->poly_fill_mode
: 0;
841 /***********************************************************************
842 * SetPolyFillMode (GDI32.@)
844 INT WINAPI
SetPolyFillMode( HDC hdc
, INT mode
)
849 if (mode
<= 0 || mode
> POLYFILL_LAST
)
851 SetLastError(ERROR_INVALID_PARAMETER
);
855 if (is_meta_dc( hdc
)) return METADC_SetPolyFillMode( hdc
, mode
);
856 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
857 if (dc_attr
->emf
&& !EMFDC_SetPolyFillMode( dc_attr
, mode
)) return 0;
859 ret
= dc_attr
->poly_fill_mode
;
860 dc_attr
->poly_fill_mode
= mode
;
864 /***********************************************************************
865 * GetStretchBltMode (GDI32.@)
867 INT WINAPI
GetStretchBltMode( HDC hdc
)
869 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
870 return dc_attr
? dc_attr
->stretch_blt_mode
: 0;
873 /***********************************************************************
874 * GetBrushOrgEx (GDI32.@)
876 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, POINT
*point
)
879 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
880 *point
= dc_attr
->brush_org
;
884 /***********************************************************************
885 * SetBrushOrgEx (GDI32.@)
887 BOOL WINAPI
SetBrushOrgEx( HDC hdc
, INT x
, INT y
, POINT
*oldorg
)
890 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
891 if (oldorg
) *oldorg
= dc_attr
->brush_org
;
892 dc_attr
->brush_org
.x
= x
;
893 dc_attr
->brush_org
.y
= y
;
897 /***********************************************************************
898 * FixBrushOrgEx (GDI32.@)
900 BOOL WINAPI
FixBrushOrgEx( HDC hdc
, INT x
, INT y
, POINT
*oldorg
)
902 return SetBrushOrgEx( hdc
, x
, y
, oldorg
);
905 /***********************************************************************
906 * GetDCOrgEx (GDI32.@)
908 BOOL WINAPI
GetDCOrgEx( HDC hdc
, POINT
*point
)
911 if (!point
|| !(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
912 point
->x
= dc_attr
->vis_rect
.left
;
913 point
->y
= dc_attr
->vis_rect
.top
;
917 /***********************************************************************
918 * GetWindowExtEx (GDI32.@)
920 BOOL WINAPI
GetWindowExtEx( HDC hdc
, SIZE
*size
)
923 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
924 *size
= dc_attr
->wnd_ext
;
928 /***********************************************************************
929 * SetWindowExtEx (GDI32.@)
931 BOOL WINAPI
SetWindowExtEx( HDC hdc
, INT x
, INT y
, SIZE
*size
)
935 if (is_meta_dc( hdc
)) return METADC_SetWindowExtEx( hdc
, x
, y
);
936 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
937 if (dc_attr
->emf
&& !EMFDC_SetWindowExtEx( dc_attr
, x
, y
)) return FALSE
;
939 if (size
) *size
= dc_attr
->wnd_ext
;
940 if (dc_attr
->map_mode
!= MM_ISOTROPIC
&& dc_attr
->map_mode
!= MM_ANISOTROPIC
) return TRUE
;
941 if (!x
|| !y
) return FALSE
;
942 dc_attr
->wnd_ext
.cx
= x
;
943 dc_attr
->wnd_ext
.cy
= y
;
944 return NtGdiComputeXformCoefficients( hdc
);
947 /***********************************************************************
948 * GetWindowOrgEx (GDI32.@)
950 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, POINT
*point
)
953 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
954 *point
= dc_attr
->wnd_org
;
958 /***********************************************************************
959 * SetWindowOrgEx (GDI32.@)
961 BOOL WINAPI
SetWindowOrgEx( HDC hdc
, INT x
, INT y
, POINT
*point
)
965 if (is_meta_dc( hdc
)) return METADC_SetWindowOrgEx( hdc
, x
, y
);
966 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
967 if (dc_attr
->emf
&& !EMFDC_SetWindowOrgEx( dc_attr
, x
, y
)) return FALSE
;
969 if (point
) *point
= dc_attr
->wnd_org
;
970 dc_attr
->wnd_org
.x
= x
;
971 dc_attr
->wnd_org
.y
= y
;
972 return NtGdiComputeXformCoefficients( hdc
);
975 /***********************************************************************
976 * OffsetWindowOrgEx (GDI32.@)
978 BOOL WINAPI
OffsetWindowOrgEx( HDC hdc
, INT x
, INT y
, POINT
*point
)
982 if (is_meta_dc( hdc
)) return METADC_OffsetWindowOrgEx( hdc
, x
, y
);
983 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
984 if (point
) *point
= dc_attr
->wnd_org
;
985 dc_attr
->wnd_org
.x
+= x
;
986 dc_attr
->wnd_org
.y
+= y
;
987 if (dc_attr
->emf
&& !EMFDC_SetWindowOrgEx( dc_attr
, dc_attr
->wnd_org
.x
,
988 dc_attr
->wnd_org
.y
)) return FALSE
;
989 return NtGdiComputeXformCoefficients( hdc
);
992 /***********************************************************************
993 * GetViewportExtEx (GDI32.@)
995 BOOL WINAPI
GetViewportExtEx( HDC hdc
, SIZE
*size
)
998 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
999 *size
= dc_attr
->vport_ext
;
1003 /***********************************************************************
1004 * SetViewportExtEx (GDI32.@)
1006 BOOL WINAPI
SetViewportExtEx( HDC hdc
, INT x
, INT y
, LPSIZE size
)
1010 if (is_meta_dc( hdc
)) return METADC_SetViewportExtEx( hdc
, x
, y
);
1011 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1012 if (dc_attr
->emf
&& !EMFDC_SetViewportExtEx( dc_attr
, x
, y
)) return FALSE
;
1014 if (size
) *size
= dc_attr
->vport_ext
;
1015 if (dc_attr
->map_mode
!= MM_ISOTROPIC
&& dc_attr
->map_mode
!= MM_ANISOTROPIC
) return TRUE
;
1016 if (!x
|| !y
) return FALSE
;
1017 dc_attr
->vport_ext
.cx
= x
;
1018 dc_attr
->vport_ext
.cy
= y
;
1019 return NtGdiComputeXformCoefficients( hdc
);
1022 /***********************************************************************
1023 * GetViewportOrgEx (GDI32.@)
1025 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, POINT
*point
)
1028 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1029 *point
= dc_attr
->vport_org
;
1033 /***********************************************************************
1034 * SetViewportOrgEx (GDI32.@)
1036 BOOL WINAPI
SetViewportOrgEx( HDC hdc
, INT x
, INT y
, POINT
*point
)
1040 if (is_meta_dc( hdc
)) return METADC_SetViewportOrgEx( hdc
, x
, y
);
1041 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1042 if (dc_attr
->emf
&& !EMFDC_SetViewportOrgEx( dc_attr
, x
, y
)) return FALSE
;
1044 if (point
) *point
= dc_attr
->vport_org
;
1045 dc_attr
->vport_org
.x
= x
;
1046 dc_attr
->vport_org
.y
= y
;
1047 return NtGdiComputeXformCoefficients( hdc
);
1050 /***********************************************************************
1051 * OffsetViewportOrgEx (GDI32.@)
1053 BOOL WINAPI
OffsetViewportOrgEx( HDC hdc
, INT x
, INT y
, POINT
*point
)
1057 if (is_meta_dc( hdc
)) return METADC_OffsetViewportOrgEx( hdc
, x
, y
);
1058 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1059 if (point
) *point
= dc_attr
->vport_org
;
1060 dc_attr
->vport_org
.x
+= x
;
1061 dc_attr
->vport_org
.y
+= y
;
1062 if (dc_attr
->emf
&& !EMFDC_SetViewportOrgEx( dc_attr
, dc_attr
->vport_org
.x
,
1063 dc_attr
->vport_org
.y
)) return FALSE
;
1064 return NtGdiComputeXformCoefficients( hdc
);
1067 /***********************************************************************
1068 * GetWorldTransform (GDI32.@)
1070 BOOL WINAPI
GetWorldTransform( HDC hdc
, XFORM
*xform
)
1072 return NtGdiGetTransform( hdc
, 0x203, xform
);
1075 /****************************************************************************
1076 * ModifyWorldTransform (GDI32.@)
1078 BOOL WINAPI
ModifyWorldTransform( HDC hdc
, const XFORM
*xform
, DWORD mode
)
1082 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1083 if (dc_attr
->emf
&& !EMFDC_ModifyWorldTransform( dc_attr
, xform
, mode
)) return FALSE
;
1084 return NtGdiModifyWorldTransform( hdc
, xform
, mode
);
1087 /***********************************************************************
1088 * SetWorldTransform (GDI32.@)
1090 BOOL WINAPI
SetWorldTransform( HDC hdc
, const XFORM
*xform
)
1094 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1095 if (dc_attr
->emf
&& !EMFDC_SetWorldTransform( dc_attr
, xform
)) return FALSE
;
1096 return NtGdiModifyWorldTransform( hdc
, xform
, MWT_SET
);
1099 /***********************************************************************
1100 * SetStretchBltMode (GDI32.@)
1102 INT WINAPI
SetStretchBltMode( HDC hdc
, INT mode
)
1107 if (mode
<= 0 || mode
> MAXSTRETCHBLTMODE
)
1109 SetLastError(ERROR_INVALID_PARAMETER
);
1113 if (is_meta_dc( hdc
)) return METADC_SetStretchBltMode( hdc
, mode
);
1114 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
1115 if (dc_attr
->emf
&& !EMFDC_SetStretchBltMode( dc_attr
, mode
)) return 0;
1117 ret
= dc_attr
->stretch_blt_mode
;
1118 dc_attr
->stretch_blt_mode
= mode
;
1122 /***********************************************************************
1123 * GetCurrentPositionEx (GDI32.@)
1125 BOOL WINAPI
GetCurrentPositionEx( HDC hdc
, POINT
*point
)
1128 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1129 *point
= dc_attr
->cur_pos
;
1133 /***********************************************************************
1136 INT WINAPI
GetROP2( HDC hdc
)
1138 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
1139 return dc_attr
? dc_attr
->rop_mode
: 0;
1142 /***********************************************************************
1143 * GetRelAbs (GDI32.@)
1145 INT WINAPI
GetRelAbs( HDC hdc
, DWORD ignore
)
1147 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
1148 return dc_attr
? dc_attr
->rel_abs_mode
: 0;
1151 /***********************************************************************
1152 * SetRelAbs (GDI32.@)
1154 INT WINAPI
SetRelAbs( HDC hdc
, INT mode
)
1159 if (mode
!= ABSOLUTE
&& mode
!= RELATIVE
)
1161 SetLastError(ERROR_INVALID_PARAMETER
);
1165 if (is_meta_dc( hdc
)) return METADC_SetRelAbs( hdc
, mode
);
1166 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
1167 ret
= dc_attr
->rel_abs_mode
;
1168 dc_attr
->rel_abs_mode
= mode
;
1172 /***********************************************************************
1175 INT WINAPI
SetROP2( HDC hdc
, INT mode
)
1180 if ((mode
< R2_BLACK
) || (mode
> R2_WHITE
))
1182 SetLastError(ERROR_INVALID_PARAMETER
);
1186 if (is_meta_dc( hdc
)) return METADC_SetROP2( hdc
, mode
);
1187 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
1188 if (dc_attr
->emf
&& !EMFDC_SetROP2( dc_attr
, mode
)) return 0;
1190 ret
= dc_attr
->rop_mode
;
1191 dc_attr
->rop_mode
= mode
;
1195 /***********************************************************************
1196 * GetMiterLimit (GDI32.@)
1198 BOOL WINAPI
GetMiterLimit( HDC hdc
, FLOAT
*limit
)
1201 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1202 if (limit
) *limit
= dc_attr
->miter_limit
;
1206 /*******************************************************************
1207 * SetMiterLimit (GDI32.@)
1209 BOOL WINAPI
SetMiterLimit( HDC hdc
, FLOAT limit
, FLOAT
*old_limit
)
1212 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1213 /* FIXME: record EMFs */
1214 if (old_limit
) *old_limit
= dc_attr
->miter_limit
;
1215 dc_attr
->miter_limit
= limit
;
1219 /***********************************************************************
1220 * SetPixel (GDI32.@)
1222 COLORREF WINAPI
SetPixel( HDC hdc
, INT x
, INT y
, COLORREF color
)
1226 if (is_meta_dc( hdc
)) return METADC_SetPixel( hdc
, x
, y
, color
);
1227 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
1228 if (dc_attr
->emf
&& !EMFDC_SetPixel( dc_attr
, x
, y
, color
)) return CLR_INVALID
;
1229 return NtGdiSetPixel( hdc
, x
, y
, color
);
1232 /***********************************************************************
1233 * SetPixelV (GDI32.@)
1235 BOOL WINAPI
SetPixelV( HDC hdc
, INT x
, INT y
, COLORREF color
)
1237 return SetPixel( hdc
, x
, y
, color
) != CLR_INVALID
;
1240 /***********************************************************************
1243 BOOL WINAPI
LineTo( HDC hdc
, INT x
, INT y
)
1247 TRACE( "%p, (%d, %d)\n", hdc
, x
, y
);
1249 if (is_meta_dc( hdc
)) return METADC_LineTo( hdc
, x
, y
);
1250 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1251 if (dc_attr
->emf
&& !EMFDC_LineTo( dc_attr
, x
, y
)) return FALSE
;
1252 return NtGdiLineTo( hdc
, x
, y
);
1255 /***********************************************************************
1256 * MoveToEx (GDI32.@)
1258 BOOL WINAPI
MoveToEx( HDC hdc
, INT x
, INT y
, POINT
*pt
)
1262 TRACE( "%p, (%d, %d), %p\n", hdc
, x
, y
, pt
);
1264 if (is_meta_dc( hdc
)) return METADC_MoveTo( hdc
, x
, y
);
1265 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1266 if (dc_attr
->emf
&& !EMFDC_MoveTo( dc_attr
, x
, y
)) return FALSE
;
1267 return NtGdiMoveTo( hdc
, x
, y
, pt
);
1270 /***********************************************************************
1273 BOOL WINAPI
Arc( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
1274 INT xstart
, INT ystart
, INT xend
, INT yend
)
1278 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
1279 right
, bottom
, xstart
, ystart
, xend
, yend
);
1281 if (is_meta_dc( hdc
))
1282 return METADC_Arc( hdc
, left
, top
, right
, bottom
,
1283 xstart
, ystart
, xend
, yend
);
1285 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1286 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
1287 xstart
, ystart
, xend
, yend
, EMR_ARC
))
1290 return NtGdiArcInternal( NtGdiArc
, hdc
, left
, top
, right
, bottom
,
1291 xstart
, ystart
, xend
, yend
);
1294 /***********************************************************************
1297 BOOL WINAPI
ArcTo( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
1298 INT xstart
, INT ystart
, INT xend
, INT yend
)
1302 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
1303 right
, bottom
, xstart
, ystart
, xend
, yend
);
1305 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1306 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
1307 xstart
, ystart
, xend
, yend
, EMR_ARCTO
))
1310 return NtGdiArcInternal( NtGdiArcTo
, hdc
, left
, top
, right
, bottom
,
1311 xstart
, ystart
, xend
, yend
);
1314 /***********************************************************************
1317 BOOL WINAPI
Chord( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
1318 INT xstart
, INT ystart
, INT xend
, INT yend
)
1322 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
1323 right
, bottom
, xstart
, ystart
, xend
, yend
);
1325 if (is_meta_dc( hdc
))
1326 return METADC_Chord( hdc
, left
, top
, right
, bottom
,
1327 xstart
, ystart
, xend
, yend
);
1329 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1330 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
1331 xstart
, ystart
, xend
, yend
, EMR_CHORD
))
1334 return NtGdiArcInternal( NtGdiChord
, hdc
, left
, top
, right
, bottom
,
1335 xstart
, ystart
, xend
, yend
);
1338 /***********************************************************************
1341 BOOL WINAPI
Pie( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
1342 INT xstart
, INT ystart
, INT xend
, INT yend
)
1346 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
1347 right
, bottom
, xstart
, ystart
, xend
, yend
);
1349 if (is_meta_dc( hdc
))
1350 return METADC_Pie( hdc
, left
, top
, right
, bottom
,
1351 xstart
, ystart
, xend
, yend
);
1353 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1354 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
1355 xstart
, ystart
, xend
, yend
, EMR_PIE
))
1358 return NtGdiArcInternal( NtGdiPie
, hdc
, left
, top
, right
, bottom
,
1359 xstart
, ystart
, xend
, yend
);
1362 /***********************************************************************
1363 * AngleArc (GDI32.@)
1365 BOOL WINAPI
AngleArc( HDC hdc
, INT x
, INT y
, DWORD radius
, FLOAT start_angle
, FLOAT sweep_angle
)
1369 TRACE( "%p, (%d, %d), %lu, %f, %f\n", hdc
, x
, y
, radius
, start_angle
, sweep_angle
);
1371 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1372 if (dc_attr
->emf
&& !EMFDC_AngleArc( dc_attr
, x
, y
, radius
, start_angle
, sweep_angle
))
1374 return NtGdiAngleArc( hdc
, x
, y
, radius
, start_angle
, sweep_angle
);
1377 /***********************************************************************
1380 BOOL WINAPI
Ellipse( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
1384 TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc
, left
, top
, right
, bottom
);
1386 if (is_meta_dc( hdc
)) return METADC_Ellipse( hdc
, left
, top
, right
, bottom
);
1387 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1388 if (dc_attr
->emf
&& !EMFDC_Ellipse( dc_attr
, left
, top
, right
, bottom
)) return FALSE
;
1389 return NtGdiEllipse( hdc
, left
, top
, right
, bottom
);
1392 /***********************************************************************
1393 * Rectangle (GDI32.@)
1395 BOOL WINAPI
Rectangle( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
1399 TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc
, left
, top
, right
, bottom
);
1401 if (is_meta_dc( hdc
)) return METADC_Rectangle( hdc
, left
, top
, right
, bottom
);
1402 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1403 if (dc_attr
->emf
&& !EMFDC_Rectangle( dc_attr
, left
, top
, right
, bottom
)) return FALSE
;
1404 return NtGdiRectangle( hdc
, left
, top
, right
, bottom
);
1407 /***********************************************************************
1408 * RoundRect (GDI32.@)
1410 BOOL WINAPI
RoundRect( HDC hdc
, INT left
, INT top
, INT right
,
1411 INT bottom
, INT ell_width
, INT ell_height
)
1415 TRACE( "%p, (%d, %d)-(%d, %d), %dx%d\n", hdc
, left
, top
, right
, bottom
,
1416 ell_width
, ell_height
);
1418 if (is_meta_dc( hdc
))
1419 return METADC_RoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
1421 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1422 if (dc_attr
->emf
&& !EMFDC_RoundRect( dc_attr
, left
, top
, right
, bottom
,
1423 ell_width
, ell_height
))
1426 return NtGdiRoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
1429 /**********************************************************************
1432 BOOL WINAPI
Polygon( HDC hdc
, const POINT
*points
, INT count
)
1436 TRACE( "%p, %p, %d\n", hdc
, points
, count
);
1438 if (is_meta_dc( hdc
)) return METADC_Polygon( hdc
, points
, count
);
1439 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1440 if (dc_attr
->emf
&& !EMFDC_Polygon( dc_attr
, points
, count
)) return FALSE
;
1441 return NtGdiPolyPolyDraw( hdc
, points
, (const ULONG
*)&count
, 1, NtGdiPolyPolygon
);
1444 /**********************************************************************
1445 * PolyPolygon (GDI32.@)
1447 BOOL WINAPI
PolyPolygon( HDC hdc
, const POINT
*points
, const INT
*counts
, UINT polygons
)
1451 TRACE( "%p, %p, %p, %u\n", hdc
, points
, counts
, polygons
);
1453 if (is_meta_dc( hdc
)) return METADC_PolyPolygon( hdc
, points
, counts
, polygons
);
1454 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1455 if (dc_attr
->emf
&& !EMFDC_PolyPolygon( dc_attr
, points
, counts
, polygons
)) return FALSE
;
1456 return NtGdiPolyPolyDraw( hdc
, points
, (const ULONG
*)counts
, polygons
, NtGdiPolyPolygon
);
1459 /**********************************************************************
1460 * Polyline (GDI32.@)
1462 BOOL WINAPI
Polyline( HDC hdc
, const POINT
*points
, INT count
)
1466 TRACE( "%p, %p, %d\n", hdc
, points
, count
);
1468 if (is_meta_dc( hdc
)) return METADC_Polyline( hdc
, points
, count
);
1469 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1470 if (dc_attr
->emf
&& !EMFDC_Polyline( dc_attr
, points
, count
)) return FALSE
;
1471 return NtGdiPolyPolyDraw( hdc
, points
, (const ULONG
*)&count
, 1, NtGdiPolyPolyline
);
1474 /**********************************************************************
1475 * PolyPolyline (GDI32.@)
1477 BOOL WINAPI
PolyPolyline( HDC hdc
, const POINT
*points
, const DWORD
*counts
, DWORD polylines
)
1481 TRACE( "%p, %p, %p, %lu\n", hdc
, points
, counts
, polylines
);
1483 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1484 if (dc_attr
->emf
&& !EMFDC_PolyPolyline( dc_attr
, points
, counts
, polylines
)) return FALSE
;
1485 return NtGdiPolyPolyDraw( hdc
, points
, counts
, polylines
, NtGdiPolyPolyline
);
1488 /******************************************************************************
1489 * PolyBezier (GDI32.@)
1491 BOOL WINAPI
PolyBezier( HDC hdc
, const POINT
*points
, DWORD count
)
1495 TRACE( "%p, %p, %lu\n", hdc
, points
, count
);
1497 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1498 if (dc_attr
->emf
&& !EMFDC_PolyBezier( dc_attr
, points
, count
)) return FALSE
;
1499 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolyBezier
);
1502 /******************************************************************************
1503 * PolyBezierTo (GDI32.@)
1505 BOOL WINAPI
PolyBezierTo( HDC hdc
, const POINT
*points
, DWORD count
)
1509 TRACE( "%p, %p, %lu\n", hdc
, points
, count
);
1511 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1512 if (dc_attr
->emf
&& !EMFDC_PolyBezierTo( dc_attr
, points
, count
)) return FALSE
;
1513 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolyBezierTo
);
1516 /**********************************************************************
1517 * PolylineTo (GDI32.@)
1519 BOOL WINAPI
PolylineTo( HDC hdc
, const POINT
*points
, DWORD count
)
1523 TRACE( "%p, %p, %lu\n", hdc
, points
, count
);
1525 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1526 if (dc_attr
->emf
&& !EMFDC_PolylineTo( dc_attr
, points
, count
)) return FALSE
;
1527 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolylineTo
);
1530 /***********************************************************************
1531 * PolyDraw (GDI32.@)
1533 BOOL WINAPI
PolyDraw( HDC hdc
, const POINT
*points
, const BYTE
*types
, DWORD count
)
1537 TRACE( "%p, %p, %p, %lu\n", hdc
, points
, types
, count
);
1539 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1540 if (dc_attr
->emf
&& !EMFDC_PolyDraw( dc_attr
, points
, types
, count
)) return FALSE
;
1541 return NtGdiPolyDraw( hdc
, points
, types
, count
);
1544 /***********************************************************************
1547 BOOL WINAPI
FillRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
)
1551 TRACE( "%p, %p, %p\n", hdc
, hrgn
, hbrush
);
1553 if (is_meta_dc( hdc
)) return METADC_FillRgn( hdc
, hrgn
, hbrush
);
1554 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1555 if (dc_attr
->emf
&& !EMFDC_FillRgn( dc_attr
, hrgn
, hbrush
)) return FALSE
;
1556 return NtGdiFillRgn( hdc
, hrgn
, hbrush
);
1559 /***********************************************************************
1560 * PaintRgn (GDI32.@)
1562 BOOL WINAPI
PaintRgn( HDC hdc
, HRGN hrgn
)
1566 TRACE( "%p, %p\n", hdc
, hrgn
);
1568 if (is_meta_dc( hdc
)) return METADC_PaintRgn( hdc
, hrgn
);
1569 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1570 if (dc_attr
->emf
&& !EMFDC_PaintRgn( dc_attr
, hrgn
)) return FALSE
;
1571 return NtGdiFillRgn( hdc
, hrgn
, GetCurrentObject( hdc
, OBJ_BRUSH
));
1574 /***********************************************************************
1575 * FrameRgn (GDI32.@)
1577 BOOL WINAPI
FrameRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
, INT width
, INT height
)
1581 TRACE( "%p, %p, %p, %dx%d\n", hdc
, hrgn
, hbrush
, width
, height
);
1583 if (is_meta_dc( hdc
)) return METADC_FrameRgn( hdc
, hrgn
, hbrush
, width
, height
);
1584 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1585 if (dc_attr
->emf
&& !EMFDC_FrameRgn( dc_attr
, hrgn
, hbrush
, width
, height
))
1587 return NtGdiFrameRgn( hdc
, hrgn
, hbrush
, width
, height
);
1590 /***********************************************************************
1591 * InvertRgn (GDI32.@)
1593 BOOL WINAPI
InvertRgn( HDC hdc
, HRGN hrgn
)
1597 TRACE( "%p, %p\n", hdc
, hrgn
);
1599 if (is_meta_dc( hdc
)) return METADC_InvertRgn( hdc
, hrgn
);
1600 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1601 if (dc_attr
->emf
&& !EMFDC_InvertRgn( dc_attr
, hrgn
)) return FALSE
;
1602 return NtGdiInvertRgn( hdc
, hrgn
);
1605 /***********************************************************************
1606 * ExtFloodFill (GDI32.@)
1608 BOOL WINAPI
ExtFloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
, UINT fill_type
)
1612 TRACE( "%p, (%d, %d), %08lx, %x\n", hdc
, x
, y
, color
, fill_type
);
1614 if (is_meta_dc( hdc
)) return METADC_ExtFloodFill( hdc
, x
, y
, color
, fill_type
);
1615 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1616 if (dc_attr
->emf
&& !EMFDC_ExtFloodFill( dc_attr
, x
, y
, color
, fill_type
)) return FALSE
;
1617 return NtGdiExtFloodFill( hdc
, x
, y
, color
, fill_type
);
1620 /***********************************************************************
1621 * FloodFill (GDI32.@)
1623 BOOL WINAPI
FloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
)
1625 return ExtFloodFill( hdc
, x
, y
, color
, FLOODFILLBORDER
);
1628 /******************************************************************************
1629 * GdiGradientFill (GDI32.@)
1631 BOOL WINAPI
GdiGradientFill( HDC hdc
, TRIVERTEX
*vert_array
, ULONG nvert
,
1632 void *grad_array
, ULONG ngrad
, ULONG mode
)
1636 TRACE( "%p vert_array:%p nvert:%ld grad_array:%p ngrad:%ld\n", hdc
, vert_array
,
1637 nvert
, grad_array
, ngrad
);
1639 if (!(dc_attr
= get_dc_attr( hdc
)))
1641 SetLastError( ERROR_INVALID_PARAMETER
);
1645 !EMFDC_GradientFill( dc_attr
, vert_array
, nvert
, grad_array
, ngrad
, mode
))
1647 return NtGdiGradientFill( hdc
, vert_array
, nvert
, grad_array
, ngrad
, mode
);
1650 /***********************************************************************
1651 * SetTextJustification (GDI32.@)
1653 BOOL WINAPI
SetTextJustification( HDC hdc
, INT extra
, INT breaks
)
1657 if (is_meta_dc( hdc
)) return METADC_SetTextJustification( hdc
, extra
, breaks
);
1658 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1659 if (dc_attr
->emf
&& !EMFDC_SetTextJustification( dc_attr
, extra
, breaks
))
1661 return NtGdiSetTextJustification( hdc
, extra
, breaks
);
1664 /***********************************************************************
1667 BOOL WINAPI
PatBlt( HDC hdc
, INT left
, INT top
, INT width
, INT height
, DWORD rop
)
1671 if (is_meta_dc( hdc
)) return METADC_PatBlt( hdc
, left
, top
, width
, height
, rop
);
1672 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1673 if (dc_attr
->emf
&& !EMFDC_PatBlt( dc_attr
, left
, top
, width
, height
, rop
))
1675 return NtGdiPatBlt( hdc
, left
, top
, width
, height
, rop
);
1678 /***********************************************************************
1681 BOOL WINAPI DECLSPEC_HOTPATCH
BitBlt( HDC hdc_dst
, INT x_dst
, INT y_dst
, INT width
, INT height
,
1682 HDC hdc_src
, INT x_src
, INT y_src
, DWORD rop
)
1686 if (is_meta_dc( hdc_dst
)) return METADC_BitBlt( hdc_dst
, x_dst
, y_dst
, width
, height
,
1687 hdc_src
, x_src
, y_src
, rop
);
1688 if (!(dc_attr
= get_dc_attr( hdc_dst
))) return FALSE
;
1689 if (dc_attr
->emf
&& !EMFDC_BitBlt( dc_attr
, x_dst
, y_dst
, width
, height
,
1690 hdc_src
, x_src
, y_src
, rop
))
1692 return NtGdiBitBlt( hdc_dst
, x_dst
, y_dst
, width
, height
,
1693 hdc_src
, x_src
, y_src
, rop
, 0 /* FIXME */, 0 /* FIXME */ );
1696 /***********************************************************************
1697 * StretchBlt (GDI32.@)
1699 BOOL WINAPI
StretchBlt( HDC hdc
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
1700 HDC hdc_src
, INT x_src
, INT y_src
, INT width_src
, INT height_src
,
1705 if (is_meta_dc( hdc
)) return METADC_StretchBlt( hdc
, x_dst
, y_dst
, width_dst
, height_dst
,
1706 hdc_src
, x_src
, y_src
, width_src
,
1708 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1709 if (dc_attr
->emf
&& !EMFDC_StretchBlt( dc_attr
, x_dst
, y_dst
, width_dst
, height_dst
,
1710 hdc_src
, x_src
, y_src
, width_src
,
1713 return NtGdiStretchBlt( hdc
, x_dst
, y_dst
, width_dst
, height_dst
,
1714 hdc_src
, x_src
, y_src
, width_src
,
1715 height_src
, rop
, 0 /* FIXME */ );
1718 /***********************************************************************
1721 BOOL WINAPI
MaskBlt( HDC hdc
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
1722 HDC hdc_src
, INT x_src
, INT y_src
, HBITMAP mask
,
1723 INT x_mask
, INT y_mask
, DWORD rop
)
1727 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1728 if (dc_attr
->emf
&& !EMFDC_MaskBlt( dc_attr
, x_dst
, y_dst
, width_dst
, height_dst
,
1729 hdc_src
, x_src
, y_src
, mask
, x_mask
, y_mask
, rop
))
1731 return NtGdiMaskBlt( hdc
, x_dst
, y_dst
, width_dst
, height_dst
, hdc_src
, x_src
, y_src
,
1732 mask
, x_mask
, y_mask
, rop
, 0 /* FIXME */ );
1735 /***********************************************************************
1738 BOOL WINAPI
PlgBlt( HDC hdc
, const POINT
*points
, HDC hdc_src
, INT x_src
, INT y_src
,
1739 INT width
, INT height
, HBITMAP mask
, INT x_mask
, INT y_mask
)
1743 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1744 if (dc_attr
->emf
&& !EMFDC_PlgBlt( dc_attr
, points
, hdc_src
, x_src
, y_src
,
1745 width
, height
, mask
, x_mask
, y_mask
))
1747 return NtGdiPlgBlt( hdc
, points
, hdc_src
, x_src
, y_src
, width
, height
,
1748 mask
, x_mask
, y_mask
, 0 /* FIXME */ );
1751 /******************************************************************************
1752 * GdiTransparentBlt (GDI32.@)
1754 BOOL WINAPI
GdiTransparentBlt( HDC hdc
, int x_dst
, int y_dst
, int width_dst
, int height_dst
,
1755 HDC hdc_src
, int x_src
, int y_src
, int width_src
, int height_src
,
1760 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1761 if (dc_attr
->emf
&& !EMFDC_TransparentBlt( dc_attr
, x_dst
, y_dst
, width_dst
, height_dst
, hdc_src
,
1762 x_src
, y_src
, width_src
, height_src
, color
))
1764 return NtGdiTransparentBlt( hdc
, x_dst
, y_dst
, width_dst
, height_dst
, hdc_src
, x_src
, y_src
,
1765 width_src
, height_src
, color
);
1768 /******************************************************************************
1769 * GdiAlphaBlend (GDI32.@)
1771 BOOL WINAPI
GdiAlphaBlend( HDC hdc_dst
, int x_dst
, int y_dst
, int width_dst
, int height_dst
,
1772 HDC hdc_src
, int x_src
, int y_src
, int width_src
, int height_src
,
1773 BLENDFUNCTION blend_function
)
1777 if (!(dc_attr
= get_dc_attr( hdc_dst
))) return FALSE
;
1778 if (dc_attr
->emf
&& !EMFDC_AlphaBlend( dc_attr
, x_dst
, y_dst
, width_dst
, height_dst
,
1779 hdc_src
, x_src
, y_src
, width_src
,
1780 height_src
, blend_function
))
1782 return NtGdiAlphaBlend( hdc_dst
, x_dst
, y_dst
, width_dst
, height_dst
,
1783 hdc_src
, x_src
, y_src
, width_src
, height_src
,
1784 blend_function
, 0 /* FIXME */ );
1787 /***********************************************************************
1788 * SetDIBitsToDevice (GDI32.@)
1790 INT WINAPI
SetDIBitsToDevice( HDC hdc
, INT x_dst
, INT y_dst
, DWORD cx
,
1791 DWORD cy
, INT x_src
, INT y_src
, UINT startscan
,
1792 UINT lines
, const void *bits
, const BITMAPINFO
*bmi
,
1797 if (is_meta_dc( hdc
))
1798 return METADC_SetDIBitsToDevice( hdc
, x_dst
, y_dst
, cx
, cy
, x_src
, y_src
, startscan
,
1799 lines
, bits
, bmi
, coloruse
);
1800 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1801 if (dc_attr
->emf
&& !EMFDC_SetDIBitsToDevice( dc_attr
, x_dst
, y_dst
, cx
, cy
, x_src
, y_src
,
1802 startscan
, lines
, bits
, bmi
, coloruse
))
1804 return NtGdiSetDIBitsToDeviceInternal( hdc
, x_dst
, y_dst
, cx
, cy
, x_src
, y_src
,
1805 startscan
, lines
, bits
, bmi
, coloruse
,
1806 0, 0, FALSE
, NULL
);
1809 /***********************************************************************
1810 * StretchDIBits (GDI32.@)
1812 INT WINAPI DECLSPEC_HOTPATCH
StretchDIBits( HDC hdc
, INT x_dst
, INT y_dst
, INT width_dst
,
1813 INT height_dst
, INT x_src
, INT y_src
, INT width_src
,
1814 INT height_src
, const void *bits
, const BITMAPINFO
*bmi
,
1815 UINT coloruse
, DWORD rop
)
1819 if (is_meta_dc( hdc
))
1820 return METADC_StretchDIBits( hdc
, x_dst
, y_dst
, width_dst
, height_dst
, x_src
, y_src
,
1821 width_src
, height_src
, bits
, bmi
, coloruse
, rop
);
1822 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1823 if (dc_attr
->emf
&& !EMFDC_StretchDIBits( dc_attr
, x_dst
, y_dst
, width_dst
, height_dst
,
1824 x_src
, y_src
, width_src
, height_src
, bits
,
1825 bmi
, coloruse
, rop
))
1827 return NtGdiStretchDIBitsInternal( hdc
, x_dst
, y_dst
, width_dst
, height_dst
, x_src
, y_src
,
1828 width_src
, height_src
, bits
, bmi
, coloruse
, rop
,
1832 /***********************************************************************
1833 * BeginPath (GDI32.@)
1835 BOOL WINAPI
BeginPath(HDC hdc
)
1839 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1840 if (dc_attr
->emf
&& !EMFDC_BeginPath( dc_attr
)) return FALSE
;
1841 return NtGdiBeginPath( hdc
);
1844 /***********************************************************************
1847 BOOL WINAPI
EndPath(HDC hdc
)
1851 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1852 if (dc_attr
->emf
&& !EMFDC_EndPath( dc_attr
)) return FALSE
;
1853 return NtGdiEndPath( hdc
);
1856 /***********************************************************************
1857 * AbortPath (GDI32.@)
1859 BOOL WINAPI
AbortPath( HDC hdc
)
1863 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1864 if (dc_attr
->emf
&& !EMFDC_AbortPath( dc_attr
)) return FALSE
;
1865 return NtGdiAbortPath( hdc
);
1868 /***********************************************************************
1869 * CloseFigure (GDI32.@)
1871 BOOL WINAPI
CloseFigure( HDC hdc
)
1875 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1876 if (dc_attr
->emf
&& !EMFDC_CloseFigure( dc_attr
)) return FALSE
;
1877 return NtGdiCloseFigure( hdc
);
1880 /***********************************************************************
1881 * FillPath (GDI32.@)
1883 BOOL WINAPI
FillPath( HDC hdc
)
1887 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1888 if (dc_attr
->emf
&& !EMFDC_FillPath( dc_attr
)) return FALSE
;
1889 return NtGdiFillPath( hdc
);
1892 /*******************************************************************
1893 * StrokeAndFillPath (GDI32.@)
1895 BOOL WINAPI
StrokeAndFillPath( HDC hdc
)
1899 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1900 if (dc_attr
->emf
&& !EMFDC_StrokeAndFillPath( dc_attr
)) return FALSE
;
1901 return NtGdiStrokeAndFillPath( hdc
);
1904 /*******************************************************************
1905 * StrokePath (GDI32.@)
1907 BOOL WINAPI
StrokePath( HDC hdc
)
1911 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1912 if (dc_attr
->emf
&& !EMFDC_StrokePath( dc_attr
)) return FALSE
;
1913 return NtGdiStrokePath( hdc
);
1916 /***********************************************************************
1917 * FlattenPath (GDI32.@)
1919 BOOL WINAPI
FlattenPath( HDC hdc
)
1923 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1924 if (dc_attr
->emf
&& !EMFDC_FlattenPath( dc_attr
)) return FALSE
;
1925 return NtGdiFlattenPath( hdc
);
1928 /***********************************************************************
1929 * WidenPath (GDI32.@)
1931 BOOL WINAPI
WidenPath( HDC hdc
)
1935 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1936 if (dc_attr
->emf
&& !EMFDC_WidenPath( dc_attr
)) return FALSE
;
1937 return NtGdiWidenPath( hdc
);
1940 /***********************************************************************
1941 * SelectClipPath (GDI32.@)
1943 BOOL WINAPI
SelectClipPath( HDC hdc
, INT mode
)
1947 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1948 if (dc_attr
->emf
&& !EMFDC_SelectClipPath( dc_attr
, mode
)) return FALSE
;
1949 return NtGdiSelectClipPath( hdc
, mode
);
1952 /***********************************************************************
1953 * GetClipRgn (GDI32.@)
1955 INT WINAPI
GetClipRgn( HDC hdc
, HRGN rgn
)
1957 return NtGdiGetRandomRgn( hdc
, rgn
, NTGDI_RGN_MIRROR_RTL
| 1 );
1960 /***********************************************************************
1961 * GetMetaRgn (GDI32.@)
1963 INT WINAPI
GetMetaRgn( HDC hdc
, HRGN rgn
)
1965 return NtGdiGetRandomRgn( hdc
, rgn
, NTGDI_RGN_MIRROR_RTL
| 2 );
1968 /***********************************************************************
1969 * IntersectClipRect (GDI32.@)
1971 INT WINAPI
IntersectClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
1975 TRACE("%p %d,%d - %d,%d\n", hdc
, left
, top
, right
, bottom
);
1977 if (is_meta_dc( hdc
)) return METADC_IntersectClipRect( hdc
, left
, top
, right
, bottom
);
1978 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1979 if (dc_attr
->emf
&& !EMFDC_IntersectClipRect( dc_attr
, left
, top
, right
, bottom
))
1981 return NtGdiIntersectClipRect( hdc
, left
, top
, right
, bottom
);
1984 /***********************************************************************
1985 * OffsetClipRgn (GDI32.@)
1987 INT WINAPI
OffsetClipRgn( HDC hdc
, INT x
, INT y
)
1991 if (is_meta_dc( hdc
)) return METADC_OffsetClipRgn( hdc
, x
, y
);
1992 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1993 if (dc_attr
->emf
&& !EMFDC_OffsetClipRgn( dc_attr
, x
, y
)) return FALSE
;
1994 return NtGdiOffsetClipRgn( hdc
, x
, y
);
1997 /***********************************************************************
1998 * ExcludeClipRect (GDI32.@)
2000 INT WINAPI
ExcludeClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
2004 if (is_meta_dc( hdc
)) return METADC_ExcludeClipRect( hdc
, left
, top
, right
, bottom
);
2005 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2006 if (dc_attr
->emf
&& !EMFDC_ExcludeClipRect( dc_attr
, left
, top
, right
, bottom
))
2008 return NtGdiExcludeClipRect( hdc
, left
, top
, right
, bottom
);
2011 /******************************************************************************
2012 * ExtSelectClipRgn (GDI32.@)
2014 INT WINAPI
ExtSelectClipRgn( HDC hdc
, HRGN hrgn
, INT mode
)
2018 TRACE("%p %p %d\n", hdc
, hrgn
, mode
);
2020 if (is_meta_dc( hdc
)) return METADC_ExtSelectClipRgn( hdc
, hrgn
, mode
);
2021 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2022 if (dc_attr
->emf
&& !EMFDC_ExtSelectClipRgn( dc_attr
, hrgn
, mode
))
2024 return NtGdiExtSelectClipRgn( hdc
, hrgn
, mode
);
2027 /***********************************************************************
2028 * SelectClipRgn (GDI32.@)
2030 INT WINAPI
SelectClipRgn( HDC hdc
, HRGN hrgn
)
2032 return ExtSelectClipRgn( hdc
, hrgn
, RGN_COPY
);
2035 /***********************************************************************
2036 * SetMetaRgn (GDI32.@)
2038 INT WINAPI
SetMetaRgn( HDC hdc
)
2042 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2043 if (dc_attr
->emf
) FIXME( "EMFs are not yet supported\n" );
2044 return NtGdiSetMetaRgn( hdc
);
2047 /***********************************************************************
2050 BOOL WINAPI
DPtoLP( HDC hdc
, POINT
*points
, INT count
)
2052 return NtGdiTransformPoints( hdc
, points
, points
, count
, NtGdiDPtoLP
);
2055 /***********************************************************************
2058 BOOL WINAPI
LPtoDP( HDC hdc
, POINT
*points
, INT count
)
2060 return NtGdiTransformPoints( hdc
, points
, points
, count
, NtGdiLPtoDP
);
2063 /***********************************************************************
2064 * ScaleViewportExtEx (GDI32.@)
2066 BOOL WINAPI
ScaleViewportExtEx( HDC hdc
, INT x_num
, INT x_denom
,
2067 INT y_num
, INT y_denom
, SIZE
*size
)
2071 if (is_meta_dc( hdc
)) return METADC_ScaleViewportExtEx( hdc
, x_num
, x_denom
, y_num
, y_denom
);
2072 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2073 if (dc_attr
->emf
&& !EMFDC_ScaleViewportExtEx( dc_attr
, x_num
, x_denom
, y_num
, y_denom
))
2075 return NtGdiScaleViewportExtEx( hdc
, x_num
, x_denom
, y_num
, y_denom
, size
);
2078 /***********************************************************************
2079 * ScaleWindowExtEx (GDI32.@)
2081 BOOL WINAPI
ScaleWindowExtEx( HDC hdc
, INT x_num
, INT x_denom
,
2082 INT y_num
, INT y_denom
, SIZE
*size
)
2086 if (is_meta_dc( hdc
)) return METADC_ScaleWindowExtEx( hdc
, x_num
, x_denom
, y_num
, y_denom
);
2087 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2088 if (dc_attr
->emf
&& !EMFDC_ScaleWindowExtEx( dc_attr
, x_num
, x_denom
, y_num
, y_denom
))
2090 return NtGdiScaleWindowExtEx( hdc
, x_num
, x_denom
, y_num
, y_denom
, size
);
2093 static UINT WINAPI
realize_palette( HDC hdc
)
2095 return NtUserRealizePalette( hdc
);
2098 /* Pointers to USER implementation of SelectPalette/RealizePalette */
2099 /* they will be patched by USER on startup */
2100 HPALETTE (WINAPI
*pfnSelectPalette
)( HDC hdc
, HPALETTE hpal
, WORD bkgnd
) = NtUserSelectPalette
;
2101 UINT (WINAPI
*pfnRealizePalette
)( HDC hdc
) = realize_palette
;
2103 /***********************************************************************
2104 * SelectPalette (GDI32.@)
2106 HPALETTE WINAPI
SelectPalette( HDC hdc
, HPALETTE palette
, BOOL force_background
)
2110 palette
= get_full_gdi_handle( palette
);
2111 if (is_meta_dc( hdc
)) return ULongToHandle( METADC_SelectPalette( hdc
, palette
) );
2112 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2113 if (dc_attr
->emf
&& !EMFDC_SelectPalette( dc_attr
, palette
)) return 0;
2114 return pfnSelectPalette( hdc
, palette
, force_background
);
2117 /***********************************************************************
2118 * RealizePalette (GDI32.@)
2120 UINT WINAPI
RealizePalette( HDC hdc
)
2122 if (is_meta_dc( hdc
)) return METADC_RealizePalette( hdc
);
2123 return pfnRealizePalette( hdc
);
2126 /***********************************************************************
2127 * GdiSetPixelFormat (GDI32.@)
2129 BOOL WINAPI
GdiSetPixelFormat( HDC hdc
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
2131 TRACE( "(%p,%d,%p)\n", hdc
, format
, descr
);
2132 return NtGdiSetPixelFormat( hdc
, format
);
2135 /***********************************************************************
2136 * CancelDC (GDI32.@)
2138 BOOL WINAPI
CancelDC(HDC hdc
)
2144 /***********************************************************************
2145 * StartDocW [GDI32.@]
2147 * StartDoc calls the STARTDOC Escape with the input data pointing to DocName
2148 * and the output data (which is used as a second input parameter).pointing at
2149 * the whole docinfo structure. This seems to be an undocumented feature of
2150 * the STARTDOC Escape.
2152 * Note: we now do it the other way, with the STARTDOC Escape calling StartDoc.
2154 INT WINAPI
StartDocW( HDC hdc
, const DOCINFOW
*doc
)
2159 TRACE("DocName %s, Output %s, Datatype %s, fwType %#lx\n",
2160 debugstr_w(doc
->lpszDocName
), debugstr_w(doc
->lpszOutput
),
2161 debugstr_w(doc
->lpszDatatype
), doc
->fwType
);
2163 if (!(dc_attr
= get_dc_attr( hdc
))) return SP_ERROR
;
2165 proc
= (ABORTPROC
)(UINT_PTR
)dc_attr
->abort_proc
;
2166 if (proc
&& !proc( hdc
, 0 )) return 0;
2167 return NtGdiStartDoc( hdc
, doc
, NULL
, 0 );
2170 /***********************************************************************
2171 * StartDocA [GDI32.@]
2173 INT WINAPI
StartDocA( HDC hdc
, const DOCINFOA
*doc
)
2175 WCHAR
*doc_name
= NULL
, *output
= NULL
, *data_type
= NULL
;
2179 docW
.cbSize
= doc
->cbSize
;
2180 if (doc
->lpszDocName
)
2182 len
= MultiByteToWideChar( CP_ACP
, 0, doc
->lpszDocName
, -1, NULL
, 0 );
2183 doc_name
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
2184 MultiByteToWideChar( CP_ACP
, 0, doc
->lpszDocName
, -1, doc_name
, len
);
2186 if (doc
->lpszOutput
)
2188 len
= MultiByteToWideChar( CP_ACP
, 0, doc
->lpszOutput
, -1, NULL
, 0 );
2189 output
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
2190 MultiByteToWideChar( CP_ACP
, 0, doc
->lpszOutput
, -1, output
, len
);
2192 if (doc
->lpszDatatype
)
2194 len
= MultiByteToWideChar( CP_ACP
, 0, doc
->lpszDatatype
, -1, NULL
, 0);
2195 data_type
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
2196 MultiByteToWideChar( CP_ACP
, 0, doc
->lpszDatatype
, -1, data_type
, len
);
2199 docW
.lpszDocName
= doc_name
;
2200 docW
.lpszOutput
= output
;
2201 docW
.lpszDatatype
= data_type
;
2202 docW
.fwType
= doc
->fwType
;
2204 ret
= StartDocW(hdc
, &docW
);
2206 HeapFree( GetProcessHeap(), 0, doc_name
);
2207 HeapFree( GetProcessHeap(), 0, output
);
2208 HeapFree( GetProcessHeap(), 0, data_type
);
2212 /***********************************************************************
2213 * StartPage (GDI32.@)
2215 INT WINAPI
StartPage( HDC hdc
)
2217 return NtGdiStartPage( hdc
);
2220 /***********************************************************************
2223 INT WINAPI
EndPage( HDC hdc
)
2225 return NtGdiEndPage( hdc
);
2228 /***********************************************************************
2231 INT WINAPI
EndDoc( HDC hdc
)
2233 return NtGdiEndDoc( hdc
);
2236 /***********************************************************************
2237 * AbortDoc (GDI32.@)
2239 INT WINAPI
AbortDoc( HDC hdc
)
2241 return NtGdiAbortDoc( hdc
);
2244 /**********************************************************************
2245 * SetAbortProc (GDI32.@)
2247 INT WINAPI
SetAbortProc( HDC hdc
, ABORTPROC abrtprc
)
2251 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
2252 dc_attr
->abort_proc
= (UINT_PTR
)abrtprc
;
2256 /***********************************************************************
2257 * SetICMMode (GDI32.@)
2259 INT WINAPI
SetICMMode( HDC hdc
, INT mode
)
2261 /* FIXME: Assume that ICM is always off, and cannot be turned on */
2264 case ICM_OFF
: return ICM_OFF
;
2265 case ICM_ON
: return 0;
2266 case ICM_QUERY
: return ICM_OFF
;
2271 /***********************************************************************
2272 * GdiIsMetaPrintDC (GDI32.@)
2274 BOOL WINAPI
GdiIsMetaPrintDC( HDC hdc
)
2276 FIXME( "%p\n", hdc
);
2280 /***********************************************************************
2281 * GdiIsMetaFileDC (GDI32.@)
2283 BOOL WINAPI
GdiIsMetaFileDC( HDC hdc
)
2285 TRACE( "%p\n", hdc
);
2287 switch (GetObjectType( hdc
))
2296 /***********************************************************************
2297 * GdiIsPlayMetafileDC (GDI32.@)
2299 BOOL WINAPI
GdiIsPlayMetafileDC( HDC hdc
)
2301 FIXME( "%p\n", hdc
);
2305 /*******************************************************************
2306 * DrawEscape (GDI32.@)
2308 INT WINAPI
DrawEscape( HDC hdc
, INT escape
, INT input_size
, const char *input
)
2314 /*******************************************************************
2315 * NamedEscape (GDI32.@)
2317 INT WINAPI
NamedEscape( HDC hdc
, const WCHAR
*driver
, INT escape
, INT input_size
,
2318 const char *input
, INT output_size
, char *output
)
2320 FIXME( "(%p %s %d, %d %p %d %p)\n", hdc
, wine_dbgstr_w(driver
), escape
, input_size
,
2321 input
, output_size
, output
);
2325 /*******************************************************************
2326 * DdQueryDisplaySettingsUniqueness (GDI32.@)
2329 ULONG WINAPI
DdQueryDisplaySettingsUniqueness(void)
2331 static int warn_once
;
2332 if (!warn_once
++) FIXME( "stub\n" );