2 * GDI Device Context functions
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "gdi_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dc
);
39 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
41 static BOOL
DC_DeleteObject( HGDIOBJ handle
);
43 static const struct gdi_obj_funcs dc_funcs
=
45 NULL
, /* pSelectObject */
46 NULL
, /* pGetObjectA */
47 NULL
, /* pGetObjectW */
48 NULL
, /* pUnrealizeObject */
49 DC_DeleteObject
/* pDeleteObject */
53 static inline DC
*get_dc_obj( HDC hdc
)
55 DC
*dc
= GDI_GetObjPtr( hdc
, 0 );
58 if ((dc
->header
.type
!= OBJ_DC
) &&
59 (dc
->header
.type
!= OBJ_MEMDC
) &&
60 (dc
->header
.type
!= OBJ_METADC
) &&
61 (dc
->header
.type
!= OBJ_ENHMETADC
))
63 GDI_ReleaseObj( hdc
);
64 SetLastError( ERROR_INVALID_HANDLE
);
71 /***********************************************************************
74 DC
*alloc_dc_ptr( WORD magic
)
78 if (!(dc
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*dc
) ))) return NULL
;
80 dc
->nulldrv
.funcs
= &null_driver
;
81 dc
->physDev
= &dc
->nulldrv
;
82 dc
->thread
= GetCurrentThreadId();
88 dc
->miterLimit
= 10.0f
; /* 10.0 is the default, from MSDN */
89 dc
->hPen
= GDI_inc_ref_count( GetStockObject( BLACK_PEN
));
90 dc
->hBrush
= GDI_inc_ref_count( GetStockObject( WHITE_BRUSH
));
91 dc
->hFont
= GDI_inc_ref_count( GetStockObject( SYSTEM_FONT
));
92 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
93 dc
->font_code_page
= CP_ACP
;
94 dc
->ROPmode
= R2_COPYPEN
;
95 dc
->polyFillMode
= ALTERNATE
;
96 dc
->stretchBltMode
= BLACKONWHITE
;
97 dc
->relAbsMode
= ABSOLUTE
;
98 dc
->backgroundMode
= OPAQUE
;
99 dc
->backgroundColor
= RGB( 255, 255, 255 );
100 dc
->dcBrushColor
= RGB( 255, 255, 255 );
101 dc
->dcPenColor
= RGB( 0, 0, 0 );
102 dc
->textColor
= RGB( 0, 0, 0 );
103 dc
->textAlign
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
104 dc
->MapMode
= MM_TEXT
;
105 dc
->GraphicsMode
= GM_COMPATIBLE
;
106 dc
->ArcDirection
= AD_COUNTERCLOCKWISE
;
107 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
108 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
109 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
110 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
111 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
112 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
113 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
114 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
115 dc
->vport2WorldValid
= TRUE
;
117 if (!(dc
->hSelf
= alloc_gdi_handle( &dc
->header
, magic
, &dc_funcs
)))
119 HeapFree( GetProcessHeap(), 0, dc
);
122 dc
->nulldrv
.hdc
= dc
->hSelf
;
124 if (font_driver
&& !font_driver
->pCreateDC( &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
134 /***********************************************************************
137 static void free_dc_state( DC
*dc
)
139 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
140 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
141 if (dc
->hMetaClipRgn
) DeleteObject( dc
->hMetaClipRgn
);
142 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
143 if (dc
->region
) DeleteObject( dc
->region
);
144 if (dc
->path
) free_gdi_path( dc
->path
);
145 HeapFree( GetProcessHeap(), 0, dc
);
149 /***********************************************************************
152 void free_dc_ptr( DC
*dc
)
154 assert( dc
->refcount
== 1 );
156 while (dc
->physDev
!= &dc
->nulldrv
)
158 PHYSDEV physdev
= pop_dc_driver( &dc
->physDev
);
159 physdev
->funcs
->pDeleteDC( physdev
);
160 if (physdev
== dc
->dibdrv
) dc
->dibdrv
= NULL
;
162 if (dc
->dibdrv
) dc
->dibdrv
->funcs
->pDeleteDC( dc
->dibdrv
);
163 free_gdi_handle( dc
->hSelf
);
168 /***********************************************************************
171 * Retrieve a DC pointer but release the GDI lock.
173 DC
*get_dc_ptr( HDC hdc
)
175 DC
*dc
= get_dc_obj( hdc
);
176 if (!dc
) return NULL
;
178 if (!InterlockedCompareExchange( &dc
->refcount
, 1, 0 ))
180 dc
->thread
= GetCurrentThreadId();
182 else if (dc
->thread
!= GetCurrentThreadId())
184 WARN( "dc %p belongs to thread %04x\n", hdc
, dc
->thread
);
185 GDI_ReleaseObj( hdc
);
188 else InterlockedIncrement( &dc
->refcount
);
190 GDI_ReleaseObj( hdc
);
195 /***********************************************************************
198 void release_dc_ptr( DC
*dc
)
203 ref
= InterlockedDecrement( &dc
->refcount
);
205 if (ref
) dc
->thread
= GetCurrentThreadId(); /* we still own it */
209 /***********************************************************************
212 * Make sure the DC vis region is up to date.
213 * This function may call up to USER so the GDI lock should _not_
214 * be held when calling it.
216 void update_dc( DC
*dc
)
218 if (InterlockedExchange( &dc
->dirty
, 0 ) && dc
->hookProc
)
219 dc
->hookProc( dc
->hSelf
, DCHC_INVALIDVISRGN
, dc
->dwHookData
, 0 );
223 /***********************************************************************
226 static BOOL
DC_DeleteObject( HGDIOBJ handle
)
228 return DeleteDC( handle
);
232 /***********************************************************************
235 * Setup device-specific DC values for a newly created DC.
237 void DC_InitDC( DC
* dc
)
239 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRealizeDefaultPalette
);
240 physdev
->funcs
->pRealizeDefaultPalette( physdev
);
241 SetTextColor( dc
->hSelf
, dc
->textColor
);
242 SetBkColor( dc
->hSelf
, dc
->backgroundColor
);
243 SelectObject( dc
->hSelf
, dc
->hPen
);
244 SelectObject( dc
->hSelf
, dc
->hBrush
);
245 SelectObject( dc
->hSelf
, dc
->hFont
);
246 CLIPPING_UpdateGCRegion( dc
);
247 SetVirtualResolution( dc
->hSelf
, 0, 0, 0, 0 );
251 /***********************************************************************
254 * Computes the inverse of the transformation xformSrc and stores it to
255 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
258 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
262 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
263 xformSrc
->eM12
*xformSrc
->eM21
;
264 if (determinant
> -1e-12 && determinant
< 1e-12)
267 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
268 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
269 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
270 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
271 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
272 xformSrc
->eDy
* xformDest
->eM21
;
273 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
274 xformSrc
->eDy
* xformDest
->eM22
;
279 /* Construct a transformation to do the window-to-viewport conversion */
280 static void construct_window_to_viewport(DC
*dc
, XFORM
*xform
)
282 double scaleX
, scaleY
;
283 scaleX
= (double)dc
->vportExtX
/ (double)dc
->wndExtX
;
284 scaleY
= (double)dc
->vportExtY
/ (double)dc
->wndExtY
;
286 if (dc
->layout
& LAYOUT_RTL
) scaleX
= -scaleX
;
287 xform
->eM11
= scaleX
;
290 xform
->eM22
= scaleY
;
291 xform
->eDx
= (double)dc
->vportOrgX
- scaleX
* (double)dc
->wndOrgX
;
292 xform
->eDy
= (double)dc
->vportOrgY
- scaleY
* (double)dc
->wndOrgY
;
293 if (dc
->layout
& LAYOUT_RTL
) xform
->eDx
= dc
->vis_rect
.right
- dc
->vis_rect
.left
- 1 - xform
->eDx
;
296 /***********************************************************************
299 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
300 * fields of the specified DC by creating a transformation that
301 * represents the current mapping mode and combining it with the DC's
302 * world transform. This function should be called whenever the
303 * parameters associated with the mapping mode (window and viewport
304 * extents and origins) or the world transform change.
306 void DC_UpdateXforms( DC
*dc
)
308 XFORM xformWnd2Vport
, oldworld2vport
;
310 construct_window_to_viewport(dc
, &xformWnd2Vport
);
312 oldworld2vport
= dc
->xformWorld2Vport
;
313 /* Combine with the world transformation */
314 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
317 /* Create inverse of world-to-viewport transformation */
318 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
319 &dc
->xformVport2World
);
321 /* Reselect the font and pen back into the dc so that the size
323 if (memcmp(&oldworld2vport
, &dc
->xformWorld2Vport
, sizeof(oldworld2vport
)) &&
324 !GdiIsMetaFileDC(dc
->hSelf
))
326 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_FONT
));
327 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_PEN
));
332 /***********************************************************************
335 INT
nulldrv_SaveDC( PHYSDEV dev
)
337 DC
*newdc
, *dc
= get_nulldrv_dc( dev
);
339 if (!(newdc
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*newdc
)))) return 0;
340 newdc
->flags
= dc
->flags
;
341 newdc
->layout
= dc
->layout
;
342 newdc
->hPen
= dc
->hPen
;
343 newdc
->hBrush
= dc
->hBrush
;
344 newdc
->hFont
= dc
->hFont
;
345 newdc
->hBitmap
= dc
->hBitmap
;
346 newdc
->hDevice
= dc
->hDevice
;
347 newdc
->hPalette
= dc
->hPalette
;
348 newdc
->ROPmode
= dc
->ROPmode
;
349 newdc
->polyFillMode
= dc
->polyFillMode
;
350 newdc
->stretchBltMode
= dc
->stretchBltMode
;
351 newdc
->relAbsMode
= dc
->relAbsMode
;
352 newdc
->backgroundMode
= dc
->backgroundMode
;
353 newdc
->backgroundColor
= dc
->backgroundColor
;
354 newdc
->textColor
= dc
->textColor
;
355 newdc
->dcBrushColor
= dc
->dcBrushColor
;
356 newdc
->dcPenColor
= dc
->dcPenColor
;
357 newdc
->brushOrgX
= dc
->brushOrgX
;
358 newdc
->brushOrgY
= dc
->brushOrgY
;
359 newdc
->mapperFlags
= dc
->mapperFlags
;
360 newdc
->textAlign
= dc
->textAlign
;
361 newdc
->charExtra
= dc
->charExtra
;
362 newdc
->breakExtra
= dc
->breakExtra
;
363 newdc
->breakRem
= dc
->breakRem
;
364 newdc
->MapMode
= dc
->MapMode
;
365 newdc
->GraphicsMode
= dc
->GraphicsMode
;
366 newdc
->CursPosX
= dc
->CursPosX
;
367 newdc
->CursPosY
= dc
->CursPosY
;
368 newdc
->ArcDirection
= dc
->ArcDirection
;
369 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
370 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
371 newdc
->xformVport2World
= dc
->xformVport2World
;
372 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
373 newdc
->wndOrgX
= dc
->wndOrgX
;
374 newdc
->wndOrgY
= dc
->wndOrgY
;
375 newdc
->wndExtX
= dc
->wndExtX
;
376 newdc
->wndExtY
= dc
->wndExtY
;
377 newdc
->vportOrgX
= dc
->vportOrgX
;
378 newdc
->vportOrgY
= dc
->vportOrgY
;
379 newdc
->vportExtX
= dc
->vportExtX
;
380 newdc
->vportExtY
= dc
->vportExtY
;
381 newdc
->virtual_res
= dc
->virtual_res
;
382 newdc
->virtual_size
= dc
->virtual_size
;
383 newdc
->BoundsRect
= dc
->BoundsRect
;
384 newdc
->gdiFont
= dc
->gdiFont
;
386 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
390 newdc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
391 CombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
395 newdc
->hMetaRgn
= CreateRectRgn( 0, 0, 0, 0 );
396 CombineRgn( newdc
->hMetaRgn
, dc
->hMetaRgn
, 0, RGN_COPY
);
399 /* don't bother recomputing hMetaClipRgn, we'll do that in SetDCState */
401 if (!PATH_SavePath( newdc
, dc
))
403 release_dc_ptr( dc
);
404 free_dc_state( newdc
);
408 newdc
->saved_dc
= dc
->saved_dc
;
409 dc
->saved_dc
= newdc
;
410 return ++dc
->saveLevel
;
414 /***********************************************************************
417 BOOL
nulldrv_RestoreDC( PHYSDEV dev
, INT level
)
419 DC
*dcs
, *first_dcs
, *dc
= get_nulldrv_dc( dev
);
422 /* find the state level to restore */
424 if (abs(level
) > dc
->saveLevel
|| level
== 0) return FALSE
;
425 if (level
< 0) level
= dc
->saveLevel
+ level
+ 1;
426 first_dcs
= dc
->saved_dc
;
427 for (dcs
= first_dcs
, save_level
= dc
->saveLevel
; save_level
> level
; save_level
--)
430 /* restore the state */
432 if (!PATH_RestorePath( dc
, dcs
)) return FALSE
;
434 dc
->flags
= dcs
->flags
;
435 dc
->layout
= dcs
->layout
;
436 dc
->hDevice
= dcs
->hDevice
;
437 dc
->ROPmode
= dcs
->ROPmode
;
438 dc
->polyFillMode
= dcs
->polyFillMode
;
439 dc
->stretchBltMode
= dcs
->stretchBltMode
;
440 dc
->relAbsMode
= dcs
->relAbsMode
;
441 dc
->backgroundMode
= dcs
->backgroundMode
;
442 dc
->backgroundColor
= dcs
->backgroundColor
;
443 dc
->textColor
= dcs
->textColor
;
444 dc
->dcBrushColor
= dcs
->dcBrushColor
;
445 dc
->dcPenColor
= dcs
->dcPenColor
;
446 dc
->brushOrgX
= dcs
->brushOrgX
;
447 dc
->brushOrgY
= dcs
->brushOrgY
;
448 dc
->mapperFlags
= dcs
->mapperFlags
;
449 dc
->textAlign
= dcs
->textAlign
;
450 dc
->charExtra
= dcs
->charExtra
;
451 dc
->breakExtra
= dcs
->breakExtra
;
452 dc
->breakRem
= dcs
->breakRem
;
453 dc
->MapMode
= dcs
->MapMode
;
454 dc
->GraphicsMode
= dcs
->GraphicsMode
;
455 dc
->CursPosX
= dcs
->CursPosX
;
456 dc
->CursPosY
= dcs
->CursPosY
;
457 dc
->ArcDirection
= dcs
->ArcDirection
;
458 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
459 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
460 dc
->xformVport2World
= dcs
->xformVport2World
;
461 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
462 dc
->BoundsRect
= dcs
->BoundsRect
;
464 dc
->wndOrgX
= dcs
->wndOrgX
;
465 dc
->wndOrgY
= dcs
->wndOrgY
;
466 dc
->wndExtX
= dcs
->wndExtX
;
467 dc
->wndExtY
= dcs
->wndExtY
;
468 dc
->vportOrgX
= dcs
->vportOrgX
;
469 dc
->vportOrgY
= dcs
->vportOrgY
;
470 dc
->vportExtX
= dcs
->vportExtX
;
471 dc
->vportExtY
= dcs
->vportExtY
;
472 dc
->virtual_res
= dcs
->virtual_res
;
473 dc
->virtual_size
= dcs
->virtual_size
;
477 if (!dc
->hClipRgn
) dc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
478 CombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
482 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
487 if (!dc
->hMetaRgn
) dc
->hMetaRgn
= CreateRectRgn( 0, 0, 0, 0 );
488 CombineRgn( dc
->hMetaRgn
, dcs
->hMetaRgn
, 0, RGN_COPY
);
492 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
495 DC_UpdateXforms( dc
);
496 CLIPPING_UpdateGCRegion( dc
);
498 SelectObject( dev
->hdc
, dcs
->hBitmap
);
499 SelectObject( dev
->hdc
, dcs
->hBrush
);
500 SelectObject( dev
->hdc
, dcs
->hFont
);
501 SelectObject( dev
->hdc
, dcs
->hPen
);
502 SetBkColor( dev
->hdc
, dcs
->backgroundColor
);
503 SetTextColor( dev
->hdc
, dcs
->textColor
);
504 GDISelectPalette( dev
->hdc
, dcs
->hPalette
, FALSE
);
506 dc
->saved_dc
= dcs
->saved_dc
;
508 dc
->saveLevel
= save_level
- 1;
510 /* now destroy all the saved DCs */
514 DC
*next
= first_dcs
->saved_dc
;
515 free_dc_state( first_dcs
);
522 /***********************************************************************
525 INT WINAPI
SaveDC( HDC hdc
)
530 if ((dc
= get_dc_ptr( hdc
)))
532 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSaveDC
);
533 ret
= physdev
->funcs
->pSaveDC( physdev
);
534 release_dc_ptr( dc
);
540 /***********************************************************************
541 * RestoreDC (GDI32.@)
543 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
546 BOOL success
= FALSE
;
548 TRACE("%p %d\n", hdc
, level
);
549 if ((dc
= get_dc_ptr( hdc
)))
551 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRestoreDC
);
553 success
= physdev
->funcs
->pRestoreDC( physdev
, level
);
554 release_dc_ptr( dc
);
560 /***********************************************************************
561 * CreateDCW (GDI32.@)
563 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
564 const DEVMODEW
*initData
)
568 const struct gdi_dc_funcs
*funcs
;
573 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
577 ERR( "no device found for %s\n", debugstr_w(device
) );
580 strcpyW(buf
, driver
);
583 if (!(funcs
= DRIVER_load_driver( buf
)))
585 ERR( "no driver found for %s\n", debugstr_w(buf
) );
588 if (!(dc
= alloc_dc_ptr( OBJ_DC
))) return 0;
591 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
593 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
594 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
596 if (funcs
->pCreateDC
)
598 if (!funcs
->pCreateDC( &dc
->physDev
, buf
, device
, output
, initData
))
600 WARN("creation aborted by device\n" );
606 dc
->vis_rect
.left
= 0;
607 dc
->vis_rect
.top
= 0;
608 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
609 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
612 release_dc_ptr( dc
);
617 /***********************************************************************
618 * CreateDCA (GDI32.@)
620 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
621 const DEVMODEA
*initData
)
623 UNICODE_STRING driverW
, deviceW
, outputW
;
627 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
628 else driverW
.Buffer
= NULL
;
630 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
631 else deviceW
.Buffer
= NULL
;
633 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
634 else outputW
.Buffer
= NULL
;
639 /* don't convert initData for DISPLAY driver, it's not used */
640 if (!driverW
.Buffer
|| strcmpiW( driverW
.Buffer
, displayW
))
641 initDataW
= GdiConvertToDevmodeW(initData
);
644 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
646 RtlFreeUnicodeString(&driverW
);
647 RtlFreeUnicodeString(&deviceW
);
648 RtlFreeUnicodeString(&outputW
);
649 HeapFree(GetProcessHeap(), 0, initDataW
);
654 /***********************************************************************
655 * CreateICA (GDI32.@)
657 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
658 const DEVMODEA
* initData
)
660 /* Nothing special yet for ICs */
661 return CreateDCA( driver
, device
, output
, initData
);
665 /***********************************************************************
666 * CreateICW (GDI32.@)
668 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
669 const DEVMODEW
* initData
)
671 /* Nothing special yet for ICs */
672 return CreateDCW( driver
, device
, output
, initData
);
676 /***********************************************************************
677 * CreateCompatibleDC (GDI32.@)
679 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
683 const struct gdi_dc_funcs
*funcs
= &null_driver
;
684 PHYSDEV physDev
= NULL
;
690 if (!(origDC
= get_dc_ptr( hdc
))) return 0;
691 physDev
= GET_DC_PHYSDEV( origDC
, pCreateCompatibleDC
);
692 funcs
= physDev
->funcs
;
693 release_dc_ptr( origDC
);
696 if (!(dc
= alloc_dc_ptr( OBJ_MEMDC
))) return 0;
698 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
700 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
701 dc
->vis_rect
.left
= 0;
702 dc
->vis_rect
.top
= 0;
703 dc
->vis_rect
.right
= 1;
704 dc
->vis_rect
.bottom
= 1;
708 if (!funcs
->pCreateCompatibleDC( physDev
, &dc
->physDev
))
710 WARN("creation aborted by device\n");
715 release_dc_ptr( dc
);
720 /***********************************************************************
723 BOOL WINAPI
DeleteDC( HDC hdc
)
731 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
732 if (dc
->refcount
!= 1)
734 FIXME( "not deleting busy DC %p refcount %u\n", dc
->hSelf
, dc
->refcount
);
735 release_dc_ptr( dc
);
739 /* Call hook procedure to check whether is it OK to delete this DC */
740 if (dc
->hookProc
&& !dc
->hookProc( hdc
, DCHC_DELETEDC
, dc
->dwHookData
, 0 ))
742 release_dc_ptr( dc
);
746 while (dc
->saveLevel
)
748 DC
*dcs
= dc
->saved_dc
;
749 dc
->saved_dc
= dcs
->saved_dc
;
751 free_dc_state( dcs
);
755 SelectObject( hdc
, GetStockObject(BLACK_PEN
) );
756 SelectObject( hdc
, GetStockObject(WHITE_BRUSH
) );
757 SelectObject( hdc
, GetStockObject(SYSTEM_FONT
) );
758 SelectObject( hdc
, GetStockObject(DEFAULT_BITMAP
) );
765 /***********************************************************************
768 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
773 if ((dc
= get_dc_ptr( hdc
)))
775 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pResetDC
);
776 ret
= physdev
->funcs
->pResetDC( physdev
, devmode
);
777 if (ret
) /* reset the visible region */
780 dc
->vis_rect
.left
= 0;
781 dc
->vis_rect
.top
= 0;
782 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
783 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
784 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
786 CLIPPING_UpdateGCRegion( dc
);
788 release_dc_ptr( dc
);
794 /***********************************************************************
797 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
802 if (devmode
) devmodeW
= GdiConvertToDevmodeW(devmode
);
803 else devmodeW
= NULL
;
805 ret
= ResetDCW(hdc
, devmodeW
);
807 HeapFree(GetProcessHeap(), 0, devmodeW
);
812 /***********************************************************************
813 * GetDeviceCaps (GDI32.@)
815 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
820 if ((dc
= get_dc_ptr( hdc
)))
822 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceCaps
);
823 ret
= physdev
->funcs
->pGetDeviceCaps( physdev
, cap
);
824 release_dc_ptr( dc
);
830 /***********************************************************************
831 * GetBkColor (GDI32.@)
833 COLORREF WINAPI
GetBkColor( HDC hdc
)
836 DC
* dc
= get_dc_ptr( hdc
);
839 ret
= dc
->backgroundColor
;
840 release_dc_ptr( dc
);
846 /***********************************************************************
847 * SetBkColor (GDI32.@)
849 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
851 COLORREF ret
= CLR_INVALID
;
852 DC
* dc
= get_dc_ptr( hdc
);
854 TRACE("hdc=%p color=0x%08x\n", hdc
, color
);
858 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkColor
);
859 color
= physdev
->funcs
->pSetBkColor( physdev
, color
);
860 if (color
!= CLR_INVALID
)
862 ret
= dc
->backgroundColor
;
863 dc
->backgroundColor
= color
;
865 release_dc_ptr( dc
);
871 /***********************************************************************
872 * GetTextColor (GDI32.@)
874 COLORREF WINAPI
GetTextColor( HDC hdc
)
877 DC
* dc
= get_dc_ptr( hdc
);
881 release_dc_ptr( dc
);
887 /***********************************************************************
888 * SetTextColor (GDI32.@)
890 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
892 COLORREF ret
= CLR_INVALID
;
893 DC
* dc
= get_dc_ptr( hdc
);
895 TRACE(" hdc=%p color=0x%08x\n", hdc
, color
);
899 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextColor
);
900 color
= physdev
->funcs
->pSetTextColor( physdev
, color
);
901 if (color
!= CLR_INVALID
)
904 dc
->textColor
= color
;
906 release_dc_ptr( dc
);
912 /***********************************************************************
913 * GetTextAlign (GDI32.@)
915 UINT WINAPI
GetTextAlign( HDC hdc
)
918 DC
* dc
= get_dc_ptr( hdc
);
922 release_dc_ptr( dc
);
928 /***********************************************************************
929 * SetTextAlign (GDI32.@)
931 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
933 UINT ret
= GDI_ERROR
;
934 DC
*dc
= get_dc_ptr( hdc
);
936 TRACE("hdc=%p align=%d\n", hdc
, align
);
940 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextAlign
);
941 align
= physdev
->funcs
->pSetTextAlign( physdev
, align
);
942 if (align
!= GDI_ERROR
)
945 dc
->textAlign
= align
;
947 release_dc_ptr( dc
);
952 /***********************************************************************
953 * GetDCOrgEx (GDI32.@)
955 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
959 if (!lpp
) return FALSE
;
960 if (!(dc
= get_dc_ptr( hDC
))) return FALSE
;
961 lpp
->x
= dc
->vis_rect
.left
;
962 lpp
->y
= dc
->vis_rect
.top
;
963 release_dc_ptr( dc
);
968 /***********************************************************************
969 * GetGraphicsMode (GDI32.@)
971 INT WINAPI
GetGraphicsMode( HDC hdc
)
974 DC
* dc
= get_dc_ptr( hdc
);
977 ret
= dc
->GraphicsMode
;
978 release_dc_ptr( dc
);
984 /***********************************************************************
985 * SetGraphicsMode (GDI32.@)
987 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
990 DC
*dc
= get_dc_ptr( hdc
);
992 /* One would think that setting the graphics mode to GM_COMPATIBLE
993 * would also reset the world transformation matrix to the unity
994 * matrix. However, in Windows, this is not the case. This doesn't
995 * make a lot of sense to me, but that's the way it is.
998 if ((mode
> 0) && (mode
<= GM_LAST
))
1000 ret
= dc
->GraphicsMode
;
1001 dc
->GraphicsMode
= mode
;
1003 release_dc_ptr( dc
);
1008 /***********************************************************************
1009 * GetArcDirection (GDI32.@)
1011 INT WINAPI
GetArcDirection( HDC hdc
)
1014 DC
* dc
= get_dc_ptr( hdc
);
1017 ret
= dc
->ArcDirection
;
1018 release_dc_ptr( dc
);
1024 /***********************************************************************
1025 * SetArcDirection (GDI32.@)
1027 INT WINAPI
SetArcDirection( HDC hdc
, INT dir
)
1032 if (dir
!= AD_COUNTERCLOCKWISE
&& dir
!= AD_CLOCKWISE
)
1034 SetLastError(ERROR_INVALID_PARAMETER
);
1038 if ((dc
= get_dc_ptr( hdc
)))
1040 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetArcDirection
);
1041 dir
= physdev
->funcs
->pSetArcDirection( physdev
, dir
);
1044 ret
= dc
->ArcDirection
;
1045 dc
->ArcDirection
= dir
;
1047 release_dc_ptr( dc
);
1053 /***********************************************************************
1054 * GetWorldTransform (GDI32.@)
1056 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
1059 if (!xform
) return FALSE
;
1060 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
1061 *xform
= dc
->xformWorld2Wnd
;
1062 release_dc_ptr( dc
);
1067 /***********************************************************************
1068 * GetTransform (GDI32.@)
1072 * Returns one of the co-ordinate space transforms
1075 * hdc [I] Device context.
1076 * which [I] Which xform to return:
1077 * 0x203 World -> Page transform (that set by SetWorldTransform).
1078 * 0x304 Page -> Device transform (the mapping mode transform).
1079 * 0x204 World -> Device transform (the combination of the above two).
1080 * 0x402 Device -> World transform (the inversion of the above).
1081 * xform [O] The xform.
1084 BOOL WINAPI
GetTransform( HDC hdc
, DWORD which
, XFORM
*xform
)
1087 DC
*dc
= get_dc_ptr( hdc
);
1088 if (!dc
) return FALSE
;
1093 *xform
= dc
->xformWorld2Wnd
;
1097 construct_window_to_viewport(dc
, xform
);
1101 *xform
= dc
->xformWorld2Vport
;
1105 *xform
= dc
->xformVport2World
;
1109 FIXME("Unknown code %x\n", which
);
1113 release_dc_ptr( dc
);
1118 /****************************************************************************
1119 * CombineTransform [GDI32.@]
1120 * Combines two transformation matrices.
1123 * xformResult [O] Stores the result of combining the two matrices
1124 * xform1 [I] Specifies the first matrix to apply
1125 * xform2 [I] Specifies the second matrix to apply
1128 * The same matrix can be passed in for more than one of the parameters.
1132 * Failure: FALSE. Use GetLastError() to determine the cause.
1134 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1135 const XFORM
*xform2
)
1139 /* Check for illegal parameters */
1140 if (!xformResult
|| !xform1
|| !xform2
)
1143 /* Create the result in a temporary XFORM, since xformResult may be
1144 * equal to xform1 or xform2 */
1145 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1146 xform1
->eM12
* xform2
->eM21
;
1147 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1148 xform1
->eM12
* xform2
->eM22
;
1149 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1150 xform1
->eM22
* xform2
->eM21
;
1151 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1152 xform1
->eM22
* xform2
->eM22
;
1153 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1154 xform1
->eDy
* xform2
->eM21
+
1156 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1157 xform1
->eDy
* xform2
->eM22
+
1160 /* Copy the result to xformResult */
1161 *xformResult
= xformTemp
;
1167 /***********************************************************************
1168 * SetDCHook (GDI32.@)
1170 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1172 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD_PTR dwHookData
)
1174 DC
*dc
= get_dc_ptr( hdc
);
1176 if (!dc
) return FALSE
;
1178 dc
->dwHookData
= dwHookData
;
1179 dc
->hookProc
= hookProc
;
1180 release_dc_ptr( dc
);
1185 /***********************************************************************
1186 * GetDCHook (GDI32.@)
1188 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1190 DWORD_PTR WINAPI
GetDCHook( HDC hdc
, DCHOOKPROC
*proc
)
1192 DC
*dc
= get_dc_ptr( hdc
);
1196 if (proc
) *proc
= dc
->hookProc
;
1197 ret
= dc
->dwHookData
;
1198 release_dc_ptr( dc
);
1203 /***********************************************************************
1204 * SetHookFlags (GDI32.@)
1206 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1208 WORD WINAPI
SetHookFlags( HDC hdc
, WORD flags
)
1210 DC
*dc
= get_dc_obj( hdc
); /* not get_dc_ptr, this needs to work from any thread */
1215 /* "Undocumented Windows" info is slightly confusing. */
1217 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1219 if (flags
& DCHF_INVALIDATEVISRGN
)
1220 ret
= InterlockedExchange( &dc
->dirty
, 1 );
1221 else if (flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1222 ret
= InterlockedExchange( &dc
->dirty
, 0 );
1224 GDI_ReleaseObj( hdc
);
1228 /***********************************************************************
1229 * SetICMMode (GDI32.@)
1231 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1233 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1234 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1235 if (iEnableICM
== ICM_ON
) return 0;
1236 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1240 /***********************************************************************
1241 * GetDeviceGammaRamp (GDI32.@)
1243 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1246 DC
*dc
= get_dc_ptr( hDC
);
1248 TRACE("%p, %p\n", hDC
, ptr
);
1251 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceGammaRamp
);
1252 ret
= physdev
->funcs
->pGetDeviceGammaRamp( physdev
, ptr
);
1253 release_dc_ptr( dc
);
1258 /***********************************************************************
1259 * SetDeviceGammaRamp (GDI32.@)
1261 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1264 DC
*dc
= get_dc_ptr( hDC
);
1266 TRACE("%p, %p\n", hDC
, ptr
);
1269 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDeviceGammaRamp
);
1270 ret
= physdev
->funcs
->pSetDeviceGammaRamp( physdev
, ptr
);
1271 release_dc_ptr( dc
);
1276 /***********************************************************************
1277 * GetColorSpace (GDI32.@)
1279 HCOLORSPACE WINAPI
GetColorSpace(HDC hdc
)
1281 /*FIXME Need to do whatever GetColorSpace actually does */
1285 /***********************************************************************
1286 * CreateColorSpaceA (GDI32.@)
1288 HCOLORSPACE WINAPI
CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace
)
1294 /***********************************************************************
1295 * CreateColorSpaceW (GDI32.@)
1297 HCOLORSPACE WINAPI
CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace
)
1303 /***********************************************************************
1304 * DeleteColorSpace (GDI32.@)
1306 BOOL WINAPI
DeleteColorSpace( HCOLORSPACE hColorSpace
)
1313 /***********************************************************************
1314 * SetColorSpace (GDI32.@)
1316 HCOLORSPACE WINAPI
SetColorSpace( HDC hDC
, HCOLORSPACE hColorSpace
)
1323 /***********************************************************************
1324 * GetBoundsRect (GDI32.@)
1326 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1329 DC
*dc
= get_dc_ptr( hdc
);
1331 if ( !dc
) return 0;
1335 *rect
= dc
->BoundsRect
;
1336 ret
= is_rect_empty( rect
) ? DCB_RESET
: DCB_SET
;
1337 DPtoLP( hdc
, (POINT
*)rect
, 2 );
1339 if (flags
& DCB_RESET
)
1341 dc
->BoundsRect
.left
= 0;
1342 dc
->BoundsRect
.top
= 0;
1343 dc
->BoundsRect
.right
= 0;
1344 dc
->BoundsRect
.bottom
= 0;
1346 release_dc_ptr( dc
);
1351 /***********************************************************************
1352 * SetBoundsRect (GDI32.@)
1354 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1359 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
1360 if (!(dc
= get_dc_ptr( hdc
))) return 0;
1362 ret
= ((dc
->flags
& DC_BOUNDS_ENABLE
) ? DCB_ENABLE
: DCB_DISABLE
) |
1363 (is_rect_empty( &dc
->BoundsRect
) ? DCB_RESET
: DCB_SET
);
1365 if (flags
& DCB_RESET
)
1367 dc
->BoundsRect
.left
= 0;
1368 dc
->BoundsRect
.top
= 0;
1369 dc
->BoundsRect
.right
= 0;
1370 dc
->BoundsRect
.bottom
= 0;
1373 if ((flags
& DCB_ACCUMULATE
) && rect
)
1377 LPtoDP( hdc
, (POINT
*)&rc
, 2 );
1378 if (!is_rect_empty( &rc
))
1380 if (!is_rect_empty( &dc
->BoundsRect
))
1382 dc
->BoundsRect
.left
= min( dc
->BoundsRect
.left
, rc
.left
);
1383 dc
->BoundsRect
.top
= min( dc
->BoundsRect
.top
, rc
.top
);
1384 dc
->BoundsRect
.right
= max( dc
->BoundsRect
.right
, rc
.right
);
1385 dc
->BoundsRect
.bottom
= max( dc
->BoundsRect
.bottom
, rc
.bottom
);
1387 else dc
->BoundsRect
= rc
;
1391 if (flags
& DCB_ENABLE
) dc
->flags
|= DC_BOUNDS_ENABLE
;
1392 if (flags
& DCB_DISABLE
) dc
->flags
&= ~DC_BOUNDS_ENABLE
;
1394 release_dc_ptr( dc
);
1399 /***********************************************************************
1400 * GetRelAbs (GDI32.@)
1402 INT WINAPI
GetRelAbs( HDC hdc
, DWORD dwIgnore
)
1405 DC
*dc
= get_dc_ptr( hdc
);
1408 ret
= dc
->relAbsMode
;
1409 release_dc_ptr( dc
);
1417 /***********************************************************************
1418 * GetBkMode (GDI32.@)
1420 INT WINAPI
GetBkMode( HDC hdc
)
1423 DC
* dc
= get_dc_ptr( hdc
);
1426 ret
= dc
->backgroundMode
;
1427 release_dc_ptr( dc
);
1433 /***********************************************************************
1434 * SetBkMode (GDI32.@)
1436 INT WINAPI
SetBkMode( HDC hdc
, INT mode
)
1441 if ((mode
<= 0) || (mode
> BKMODE_LAST
))
1443 SetLastError(ERROR_INVALID_PARAMETER
);
1446 if ((dc
= get_dc_ptr( hdc
)))
1448 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkMode
);
1449 mode
= physdev
->funcs
->pSetBkMode( physdev
, mode
);
1452 ret
= dc
->backgroundMode
;
1453 dc
->backgroundMode
= mode
;
1455 release_dc_ptr( dc
);
1461 /***********************************************************************
1464 INT WINAPI
GetROP2( HDC hdc
)
1467 DC
* dc
= get_dc_ptr( hdc
);
1471 release_dc_ptr( dc
);
1477 /***********************************************************************
1480 INT WINAPI
SetROP2( HDC hdc
, INT mode
)
1485 if ((mode
< R2_BLACK
) || (mode
> R2_WHITE
))
1487 SetLastError(ERROR_INVALID_PARAMETER
);
1490 if ((dc
= get_dc_ptr( hdc
)))
1492 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetROP2
);
1493 mode
= physdev
->funcs
->pSetROP2( physdev
, mode
);
1499 release_dc_ptr( dc
);
1505 /***********************************************************************
1506 * SetRelAbs (GDI32.@)
1508 INT WINAPI
SetRelAbs( HDC hdc
, INT mode
)
1513 if ((mode
!= ABSOLUTE
) && (mode
!= RELATIVE
))
1515 SetLastError(ERROR_INVALID_PARAMETER
);
1518 if ((dc
= get_dc_ptr( hdc
)))
1520 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetRelAbs
);
1521 mode
= physdev
->funcs
->pSetRelAbs( physdev
, mode
);
1524 ret
= dc
->relAbsMode
;
1525 dc
->relAbsMode
= mode
;
1527 release_dc_ptr( dc
);
1533 /***********************************************************************
1534 * GetPolyFillMode (GDI32.@)
1536 INT WINAPI
GetPolyFillMode( HDC hdc
)
1539 DC
* dc
= get_dc_ptr( hdc
);
1542 ret
= dc
->polyFillMode
;
1543 release_dc_ptr( dc
);
1549 /***********************************************************************
1550 * SetPolyFillMode (GDI32.@)
1552 INT WINAPI
SetPolyFillMode( HDC hdc
, INT mode
)
1557 if ((mode
<= 0) || (mode
> POLYFILL_LAST
))
1559 SetLastError(ERROR_INVALID_PARAMETER
);
1562 if ((dc
= get_dc_ptr( hdc
)))
1564 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetPolyFillMode
);
1565 mode
= physdev
->funcs
->pSetPolyFillMode( physdev
, mode
);
1568 ret
= dc
->polyFillMode
;
1569 dc
->polyFillMode
= mode
;
1571 release_dc_ptr( dc
);
1577 /***********************************************************************
1578 * GetStretchBltMode (GDI32.@)
1580 INT WINAPI
GetStretchBltMode( HDC hdc
)
1583 DC
* dc
= get_dc_ptr( hdc
);
1586 ret
= dc
->stretchBltMode
;
1587 release_dc_ptr( dc
);
1593 /***********************************************************************
1594 * SetStretchBltMode (GDI32.@)
1596 INT WINAPI
SetStretchBltMode( HDC hdc
, INT mode
)
1601 if ((mode
<= 0) || (mode
> MAXSTRETCHBLTMODE
))
1603 SetLastError(ERROR_INVALID_PARAMETER
);
1606 if ((dc
= get_dc_ptr( hdc
)))
1608 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetStretchBltMode
);
1609 mode
= physdev
->funcs
->pSetStretchBltMode( physdev
, mode
);
1612 ret
= dc
->stretchBltMode
;
1613 dc
->stretchBltMode
= mode
;
1615 release_dc_ptr( dc
);
1621 /***********************************************************************
1622 * GetMapMode (GDI32.@)
1624 INT WINAPI
GetMapMode( HDC hdc
)
1627 DC
* dc
= get_dc_ptr( hdc
);
1631 release_dc_ptr( dc
);
1637 /***********************************************************************
1638 * GetBrushOrgEx (GDI32.@)
1640 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, LPPOINT pt
)
1642 DC
* dc
= get_dc_ptr( hdc
);
1643 if (!dc
) return FALSE
;
1644 pt
->x
= dc
->brushOrgX
;
1645 pt
->y
= dc
->brushOrgY
;
1646 release_dc_ptr( dc
);
1651 /***********************************************************************
1652 * GetCurrentPositionEx (GDI32.@)
1654 BOOL WINAPI
GetCurrentPositionEx( HDC hdc
, LPPOINT pt
)
1656 DC
* dc
= get_dc_ptr( hdc
);
1657 if (!dc
) return FALSE
;
1658 pt
->x
= dc
->CursPosX
;
1659 pt
->y
= dc
->CursPosY
;
1660 release_dc_ptr( dc
);
1665 /***********************************************************************
1666 * GetViewportExtEx (GDI32.@)
1668 BOOL WINAPI
GetViewportExtEx( HDC hdc
, LPSIZE size
)
1670 DC
* dc
= get_dc_ptr( hdc
);
1671 if (!dc
) return FALSE
;
1672 size
->cx
= dc
->vportExtX
;
1673 size
->cy
= dc
->vportExtY
;
1674 release_dc_ptr( dc
);
1679 /***********************************************************************
1680 * GetViewportOrgEx (GDI32.@)
1682 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, LPPOINT pt
)
1684 DC
* dc
= get_dc_ptr( hdc
);
1685 if (!dc
) return FALSE
;
1686 pt
->x
= dc
->vportOrgX
;
1687 pt
->y
= dc
->vportOrgY
;
1688 release_dc_ptr( dc
);
1693 /***********************************************************************
1694 * GetWindowExtEx (GDI32.@)
1696 BOOL WINAPI
GetWindowExtEx( HDC hdc
, LPSIZE size
)
1698 DC
* dc
= get_dc_ptr( hdc
);
1699 if (!dc
) return FALSE
;
1700 size
->cx
= dc
->wndExtX
;
1701 size
->cy
= dc
->wndExtY
;
1702 release_dc_ptr( dc
);
1707 /***********************************************************************
1708 * GetWindowOrgEx (GDI32.@)
1710 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, LPPOINT pt
)
1712 DC
* dc
= get_dc_ptr( hdc
);
1713 if (!dc
) return FALSE
;
1714 pt
->x
= dc
->wndOrgX
;
1715 pt
->y
= dc
->wndOrgY
;
1716 release_dc_ptr( dc
);
1721 /***********************************************************************
1722 * GetLayout (GDI32.@)
1724 * Gets left->right or right->left text layout flags of a dc.
1727 DWORD WINAPI
GetLayout(HDC hdc
)
1729 DWORD layout
= GDI_ERROR
;
1731 DC
* dc
= get_dc_ptr( hdc
);
1734 layout
= dc
->layout
;
1735 release_dc_ptr( dc
);
1738 TRACE("hdc : %p, layout : %08x\n", hdc
, layout
);
1743 /***********************************************************************
1744 * SetLayout (GDI32.@)
1746 * Sets left->right or right->left text layout flags of a dc.
1749 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1751 DWORD oldlayout
= GDI_ERROR
;
1753 DC
* dc
= get_dc_ptr( hdc
);
1756 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetLayout
);
1757 layout
= physdev
->funcs
->pSetLayout( physdev
, layout
);
1758 if (layout
!= GDI_ERROR
)
1760 oldlayout
= dc
->layout
;
1761 dc
->layout
= layout
;
1762 if (layout
!= oldlayout
)
1764 if (layout
& LAYOUT_RTL
) dc
->MapMode
= MM_ANISOTROPIC
;
1765 DC_UpdateXforms( dc
);
1768 release_dc_ptr( dc
);
1771 TRACE("hdc : %p, old layout : %08x, new layout : %08x\n", hdc
, oldlayout
, layout
);
1776 /***********************************************************************
1777 * GetDCBrushColor (GDI32.@)
1779 COLORREF WINAPI
GetDCBrushColor(HDC hdc
)
1782 COLORREF dcBrushColor
= CLR_INVALID
;
1784 TRACE("hdc(%p)\n", hdc
);
1786 dc
= get_dc_ptr( hdc
);
1789 dcBrushColor
= dc
->dcBrushColor
;
1790 release_dc_ptr( dc
);
1793 return dcBrushColor
;
1796 /***********************************************************************
1797 * SetDCBrushColor (GDI32.@)
1799 COLORREF WINAPI
SetDCBrushColor(HDC hdc
, COLORREF crColor
)
1802 COLORREF oldClr
= CLR_INVALID
;
1804 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1806 dc
= get_dc_ptr( hdc
);
1809 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCBrushColor
);
1810 crColor
= physdev
->funcs
->pSetDCBrushColor( physdev
, crColor
);
1811 if (crColor
!= CLR_INVALID
)
1813 oldClr
= dc
->dcBrushColor
;
1814 dc
->dcBrushColor
= crColor
;
1816 release_dc_ptr( dc
);
1822 /***********************************************************************
1823 * GetDCPenColor (GDI32.@)
1825 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
1828 COLORREF dcPenColor
= CLR_INVALID
;
1830 TRACE("hdc(%p)\n", hdc
);
1832 dc
= get_dc_ptr( hdc
);
1835 dcPenColor
= dc
->dcPenColor
;
1836 release_dc_ptr( dc
);
1842 /***********************************************************************
1843 * SetDCPenColor (GDI32.@)
1845 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1848 COLORREF oldClr
= CLR_INVALID
;
1850 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1852 dc
= get_dc_ptr( hdc
);
1855 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCPenColor
);
1856 crColor
= physdev
->funcs
->pSetDCPenColor( physdev
, crColor
);
1857 if (crColor
!= CLR_INVALID
)
1859 oldClr
= dc
->dcPenColor
;
1860 dc
->dcPenColor
= crColor
;
1862 release_dc_ptr( dc
);
1868 /***********************************************************************
1869 * CancelDC (GDI32.@)
1871 BOOL WINAPI
CancelDC(HDC hdc
)
1877 /*******************************************************************
1878 * GetMiterLimit [GDI32.@]
1882 BOOL WINAPI
GetMiterLimit(HDC hdc
, PFLOAT peLimit
)
1887 TRACE("(%p,%p)\n", hdc
, peLimit
);
1889 dc
= get_dc_ptr( hdc
);
1893 *peLimit
= dc
->miterLimit
;
1895 release_dc_ptr( dc
);
1901 /*******************************************************************
1902 * SetMiterLimit [GDI32.@]
1906 BOOL WINAPI
SetMiterLimit(HDC hdc
, FLOAT eNewLimit
, PFLOAT peOldLimit
)
1911 TRACE("(%p,%f,%p)\n", hdc
, eNewLimit
, peOldLimit
);
1913 dc
= get_dc_ptr( hdc
);
1917 *peOldLimit
= dc
->miterLimit
;
1918 dc
->miterLimit
= eNewLimit
;
1919 release_dc_ptr( dc
);
1925 /*******************************************************************
1926 * GdiIsMetaPrintDC [GDI32.@]
1928 BOOL WINAPI
GdiIsMetaPrintDC(HDC hdc
)
1934 /*******************************************************************
1935 * GdiIsMetaFileDC [GDI32.@]
1937 BOOL WINAPI
GdiIsMetaFileDC(HDC hdc
)
1941 switch( GetObjectType( hdc
) )
1950 /*******************************************************************
1951 * GdiIsPlayMetafileDC [GDI32.@]
1953 BOOL WINAPI
GdiIsPlayMetafileDC(HDC hdc
)