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
32 #include "ntgdi_private.h"
33 #include "gdi_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dc
);
38 static BOOL
DC_DeleteObject( HGDIOBJ handle
);
40 static const struct gdi_obj_funcs dc_funcs
=
42 NULL
, /* pGetObjectW */
43 NULL
, /* pUnrealizeObject */
44 DC_DeleteObject
/* pDeleteObject */
48 static inline DC
*get_dc_obj( HDC hdc
)
51 DC
*dc
= get_any_obj_ptr( hdc
, &type
);
58 case NTGDI_OBJ_METADC
:
59 case NTGDI_OBJ_ENHMETADC
:
62 GDI_ReleaseObj( hdc
);
63 SetLastError( ERROR_INVALID_HANDLE
);
69 /***********************************************************************
70 * set_initial_dc_state
72 static void set_initial_dc_state( DC
*dc
)
82 dc
->miterLimit
= 10.0f
; /* 10.0 is the default, from MSDN */
84 dc
->font_code_page
= CP_ACP
;
85 dc
->attr
->rop_mode
= R2_COPYPEN
;
86 dc
->attr
->poly_fill_mode
= ALTERNATE
;
87 dc
->attr
->stretch_blt_mode
= BLACKONWHITE
;
88 dc
->attr
->rel_abs_mode
= ABSOLUTE
;
89 dc
->attr
->background_mode
= OPAQUE
;
90 dc
->attr
->background_color
= RGB( 255, 255, 255 );
91 dc
->attr
->brush_color
= RGB( 255, 255, 255 );
92 dc
->dcPenColor
= RGB( 0, 0, 0 );
93 dc
->attr
->text_color
= RGB( 0, 0, 0 );
97 dc
->attr
->text_align
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
101 dc
->attr
->map_mode
= MM_TEXT
;
102 dc
->attr
->graphics_mode
= GM_COMPATIBLE
;
103 dc
->attr
->cur_pos
.x
= 0;
104 dc
->attr
->cur_pos
.y
= 0;
105 dc
->attr
->arc_direction
= AD_COUNTERCLOCKWISE
;
106 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
107 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
108 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
109 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
110 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
111 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
112 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
113 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
114 dc
->vport2WorldValid
= TRUE
;
116 reset_bounds( &dc
->bounds
);
119 /***********************************************************************
122 DC
*alloc_dc_ptr( WORD magic
)
126 if (!(dc
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*dc
) ))) return NULL
;
127 if (!(dc
->attr
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*dc
->attr
))))
129 HeapFree( GetProcessHeap(), 0, dc
->attr
);
133 dc
->nulldrv
.funcs
= &null_driver
;
134 dc
->physDev
= &dc
->nulldrv
;
135 dc
->thread
= GetCurrentThreadId();
137 dc
->hPen
= GDI_inc_ref_count( GetStockObject( BLACK_PEN
));
138 dc
->hBrush
= GDI_inc_ref_count( GetStockObject( WHITE_BRUSH
));
139 dc
->hFont
= GDI_inc_ref_count( GetStockObject( SYSTEM_FONT
));
140 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
142 set_initial_dc_state( dc
);
144 if (!(dc
->hSelf
= alloc_gdi_handle( &dc
->obj
, magic
, &dc_funcs
)))
146 HeapFree( GetProcessHeap(), 0, dc
->attr
);
147 HeapFree( GetProcessHeap(), 0, dc
);
150 dc
->nulldrv
.hdc
= dc
->hSelf
;
151 set_gdi_client_ptr( dc
->hSelf
, dc
->attr
);
153 if (!font_driver
.pCreateDC( &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
163 /***********************************************************************
166 static void free_dc_state( DC
*dc
)
168 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
169 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
170 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
171 if (dc
->region
) DeleteObject( dc
->region
);
172 if (dc
->path
) free_gdi_path( dc
->path
);
173 HeapFree( GetProcessHeap(), 0, dc
->attr
);
174 HeapFree( GetProcessHeap(), 0, dc
);
178 /***********************************************************************
181 void free_dc_ptr( DC
*dc
)
183 assert( dc
->refcount
== 1 );
185 while (dc
->physDev
!= &dc
->nulldrv
)
187 PHYSDEV physdev
= dc
->physDev
;
188 dc
->physDev
= physdev
->next
;
189 physdev
->funcs
->pDeleteDC( physdev
);
191 GDI_dec_ref_count( dc
->hPen
);
192 GDI_dec_ref_count( dc
->hBrush
);
193 GDI_dec_ref_count( dc
->hFont
);
194 if (dc
->hBitmap
) GDI_dec_ref_count( dc
->hBitmap
);
195 free_gdi_handle( dc
->hSelf
);
200 /***********************************************************************
203 * Retrieve a DC pointer but release the GDI lock.
205 DC
*get_dc_ptr( HDC hdc
)
207 DC
*dc
= get_dc_obj( hdc
);
208 if (!dc
) return NULL
;
209 if (dc
->attr
->disabled
)
211 GDI_ReleaseObj( hdc
);
215 if (!InterlockedCompareExchange( &dc
->refcount
, 1, 0 ))
217 dc
->thread
= GetCurrentThreadId();
219 else if (dc
->thread
!= GetCurrentThreadId())
221 WARN( "dc %p belongs to thread %04x\n", hdc
, dc
->thread
);
222 GDI_ReleaseObj( hdc
);
225 else InterlockedIncrement( &dc
->refcount
);
227 GDI_ReleaseObj( hdc
);
232 /***********************************************************************
235 void release_dc_ptr( DC
*dc
)
240 ref
= InterlockedDecrement( &dc
->refcount
);
242 if (ref
) dc
->thread
= GetCurrentThreadId(); /* we still own it */
246 /***********************************************************************
249 * Make sure the DC vis region is up to date.
250 * This function may call up to USER so the GDI lock should _not_
251 * be held when calling it.
253 void update_dc( DC
*dc
)
255 if (InterlockedExchange( &dc
->dirty
, 0 ) && dc
->hookProc
)
256 dc
->hookProc( dc
->hSelf
, DCHC_INVALIDVISRGN
, dc
->dwHookData
, 0 );
260 /***********************************************************************
263 static BOOL
DC_DeleteObject( HGDIOBJ handle
)
265 return DeleteDC( handle
);
269 /***********************************************************************
272 * Setup device-specific DC values for a newly created DC.
274 void DC_InitDC( DC
* dc
)
276 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRealizeDefaultPalette
);
277 physdev
->funcs
->pRealizeDefaultPalette( physdev
);
278 SetTextColor( dc
->hSelf
, dc
->attr
->text_color
);
279 SetBkColor( dc
->hSelf
, dc
->attr
->background_color
);
280 NtGdiSelectPen( dc
->hSelf
, dc
->hPen
);
281 NtGdiSelectBrush( dc
->hSelf
, dc
->hBrush
);
282 NtGdiSelectFont( dc
->hSelf
, dc
->hFont
);
283 update_dc_clipping( dc
);
284 SetVirtualResolution( dc
->hSelf
, 0, 0, 0, 0 );
285 physdev
= GET_DC_PHYSDEV( dc
, pSetBoundsRect
);
286 physdev
->funcs
->pSetBoundsRect( physdev
, &dc
->bounds
, dc
->bounds_enabled
? DCB_ENABLE
: DCB_DISABLE
);
290 /***********************************************************************
293 * Computes the inverse of the transformation xformSrc and stores it to
294 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
297 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
301 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
302 xformSrc
->eM12
*xformSrc
->eM21
;
303 if (determinant
> -1e-12 && determinant
< 1e-12)
306 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
307 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
308 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
309 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
310 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
311 xformSrc
->eDy
* xformDest
->eM21
;
312 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
313 xformSrc
->eDy
* xformDest
->eM22
;
318 /* Construct a transformation to do the window-to-viewport conversion */
319 static void construct_window_to_viewport(DC
*dc
, XFORM
*xform
)
321 double scaleX
, scaleY
;
322 scaleX
= (double)dc
->vport_ext
.cx
/ (double)dc
->wnd_ext
.cx
;
323 scaleY
= (double)dc
->vport_ext
.cy
/ (double)dc
->wnd_ext
.cy
;
325 if (dc
->attr
->layout
& LAYOUT_RTL
) scaleX
= -scaleX
;
326 xform
->eM11
= scaleX
;
329 xform
->eM22
= scaleY
;
330 xform
->eDx
= (double)dc
->vport_org
.x
- scaleX
* (double)dc
->wnd_org
.x
;
331 xform
->eDy
= (double)dc
->vport_org
.y
- scaleY
* (double)dc
->wnd_org
.y
;
332 if (dc
->attr
->layout
& LAYOUT_RTL
) xform
->eDx
= dc
->vis_rect
.right
- dc
->vis_rect
.left
- 1 - xform
->eDx
;
335 /***********************************************************************
338 * Compares the linear transform portion of two XFORMs (i.e. the 2x2 submatrix).
339 * Returns 0 if they match.
341 static inline int linear_xform_cmp( const XFORM
*a
, const XFORM
*b
)
343 return memcmp( a
, b
, FIELD_OFFSET( XFORM
, eDx
) );
346 /***********************************************************************
349 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
350 * fields of the specified DC by creating a transformation that
351 * represents the current mapping mode and combining it with the DC's
352 * world transform. This function should be called whenever the
353 * parameters associated with the mapping mode (window and viewport
354 * extents and origins) or the world transform change.
356 void DC_UpdateXforms( DC
*dc
)
358 XFORM xformWnd2Vport
, oldworld2vport
;
360 construct_window_to_viewport(dc
, &xformWnd2Vport
);
362 oldworld2vport
= dc
->xformWorld2Vport
;
363 /* Combine with the world transformation */
364 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
367 /* Create inverse of world-to-viewport transformation */
368 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
369 &dc
->xformVport2World
);
371 /* Reselect the font and pen back into the dc so that the size
373 if (linear_xform_cmp( &oldworld2vport
, &dc
->xformWorld2Vport
) &&
374 GetObjectType( dc
->hSelf
) != OBJ_METADC
)
376 NtGdiSelectFont(dc
->hSelf
, dc
->hFont
);
377 NtGdiSelectPen(dc
->hSelf
, dc
->hPen
);
382 /***********************************************************************
385 INT CDECL
nulldrv_SaveDC( PHYSDEV dev
)
387 DC
*newdc
, *dc
= get_nulldrv_dc( dev
);
389 if (!(newdc
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*newdc
)))) return 0;
390 if (!(newdc
->attr
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*newdc
->attr
) )))
392 HeapFree( GetProcessHeap(), 0, newdc
);
395 *newdc
->attr
= *dc
->attr
;
396 newdc
->hPen
= dc
->hPen
;
397 newdc
->hBrush
= dc
->hBrush
;
398 newdc
->hFont
= dc
->hFont
;
399 newdc
->hBitmap
= dc
->hBitmap
;
400 newdc
->hPalette
= dc
->hPalette
;
401 newdc
->dcPenColor
= dc
->dcPenColor
;
402 newdc
->brush_org
= dc
->brush_org
;
403 newdc
->mapperFlags
= dc
->mapperFlags
;
404 newdc
->charExtra
= dc
->charExtra
;
405 newdc
->breakExtra
= dc
->breakExtra
;
406 newdc
->breakRem
= dc
->breakRem
;
407 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
408 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
409 newdc
->xformVport2World
= dc
->xformVport2World
;
410 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
411 newdc
->wnd_org
= dc
->wnd_org
;
412 newdc
->wnd_ext
= dc
->wnd_ext
;
413 newdc
->vport_org
= dc
->vport_org
;
414 newdc
->vport_ext
= dc
->vport_ext
;
415 newdc
->virtual_res
= dc
->virtual_res
;
416 newdc
->virtual_size
= dc
->virtual_size
;
418 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
422 newdc
->hClipRgn
= NtGdiCreateRectRgn( 0, 0, 0, 0 );
423 NtGdiCombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
427 newdc
->hMetaRgn
= NtGdiCreateRectRgn( 0, 0, 0, 0 );
428 NtGdiCombineRgn( newdc
->hMetaRgn
, dc
->hMetaRgn
, 0, RGN_COPY
);
431 if (!PATH_SavePath( newdc
, dc
))
433 release_dc_ptr( dc
);
434 free_dc_state( newdc
);
438 newdc
->saved_dc
= dc
->saved_dc
;
439 dc
->saved_dc
= newdc
;
440 return ++dc
->saveLevel
;
444 /***********************************************************************
447 BOOL CDECL
nulldrv_RestoreDC( PHYSDEV dev
, INT level
)
449 DC
*dcs
, *first_dcs
, *dc
= get_nulldrv_dc( dev
);
452 /* find the state level to restore */
454 if (abs(level
) > dc
->saveLevel
|| level
== 0) return FALSE
;
455 if (level
< 0) level
= dc
->saveLevel
+ level
+ 1;
456 first_dcs
= dc
->saved_dc
;
457 for (dcs
= first_dcs
, save_level
= dc
->saveLevel
; save_level
> level
; save_level
--)
460 /* restore the state */
462 if (!PATH_RestorePath( dc
, dcs
)) return FALSE
;
464 dc
->attr
->layout
= dcs
->attr
->layout
;
465 dc
->attr
->rop_mode
= dcs
->attr
->rop_mode
;
466 dc
->attr
->poly_fill_mode
= dcs
->attr
->poly_fill_mode
;
467 dc
->attr
->stretch_blt_mode
= dcs
->attr
->stretch_blt_mode
;
468 dc
->attr
->rel_abs_mode
= dcs
->attr
->rel_abs_mode
;
469 dc
->attr
->background_mode
= dcs
->attr
->background_mode
;
470 dc
->attr
->background_color
= dcs
->attr
->background_color
;
471 dc
->attr
->text_color
= dcs
->attr
->text_color
;
472 dc
->attr
->brush_color
= dcs
->attr
->brush_color
;
473 dc
->dcPenColor
= dcs
->dcPenColor
;
474 dc
->brush_org
= dcs
->brush_org
;
475 dc
->mapperFlags
= dcs
->mapperFlags
;
476 dc
->attr
->text_align
= dcs
->attr
->text_align
;
477 dc
->charExtra
= dcs
->charExtra
;
478 dc
->breakExtra
= dcs
->breakExtra
;
479 dc
->breakRem
= dcs
->breakRem
;
480 dc
->attr
->map_mode
= dcs
->attr
->map_mode
;
481 dc
->attr
->graphics_mode
= dcs
->attr
->graphics_mode
;
482 dc
->attr
->cur_pos
= dcs
->attr
->cur_pos
;
483 dc
->attr
->arc_direction
= dcs
->attr
->arc_direction
;
484 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
485 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
486 dc
->xformVport2World
= dcs
->xformVport2World
;
487 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
488 dc
->wnd_org
= dcs
->wnd_org
;
489 dc
->wnd_ext
= dcs
->wnd_ext
;
490 dc
->vport_org
= dcs
->vport_org
;
491 dc
->vport_ext
= dcs
->vport_ext
;
492 dc
->virtual_res
= dcs
->virtual_res
;
493 dc
->virtual_size
= dcs
->virtual_size
;
497 if (!dc
->hClipRgn
) dc
->hClipRgn
= NtGdiCreateRectRgn( 0, 0, 0, 0 );
498 NtGdiCombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
502 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
507 if (!dc
->hMetaRgn
) dc
->hMetaRgn
= NtGdiCreateRectRgn( 0, 0, 0, 0 );
508 NtGdiCombineRgn( dc
->hMetaRgn
, dcs
->hMetaRgn
, 0, RGN_COPY
);
512 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
515 DC_UpdateXforms( dc
);
516 update_dc_clipping( dc
);
518 NtGdiSelectBitmap( dev
->hdc
, dcs
->hBitmap
);
519 NtGdiSelectBrush( dev
->hdc
, dcs
->hBrush
);
520 NtGdiSelectFont( dev
->hdc
, dcs
->hFont
);
521 NtGdiSelectPen( dev
->hdc
, dcs
->hPen
);
522 SetBkColor( dev
->hdc
, dcs
->attr
->background_color
);
523 SetTextColor( dev
->hdc
, dcs
->attr
->text_color
);
524 GDISelectPalette( dev
->hdc
, dcs
->hPalette
, FALSE
);
526 dc
->saved_dc
= dcs
->saved_dc
;
528 dc
->saveLevel
= save_level
- 1;
530 /* now destroy all the saved DCs */
534 DC
*next
= first_dcs
->saved_dc
;
535 free_dc_state( first_dcs
);
542 /***********************************************************************
545 static BOOL
reset_dc_state( HDC hdc
)
549 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
551 set_initial_dc_state( dc
);
552 SetBkColor( hdc
, RGB( 255, 255, 255 ));
553 SetTextColor( hdc
, RGB( 0, 0, 0 ));
554 NtGdiSelectBrush( hdc
, GetStockObject( WHITE_BRUSH
));
555 NtGdiSelectFont( hdc
, GetStockObject( SYSTEM_FONT
));
556 NtGdiSelectPen( hdc
, GetStockObject( BLACK_PEN
));
557 SetVirtualResolution( hdc
, 0, 0, 0, 0 );
558 GDISelectPalette( hdc
, GetStockObject( DEFAULT_PALETTE
), FALSE
);
559 SetBoundsRect( hdc
, NULL
, DCB_DISABLE
);
562 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
563 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
566 update_dc_clipping( dc
);
568 for (dcs
= dc
->saved_dc
; dcs
; dcs
= next
)
570 next
= dcs
->saved_dc
;
571 free_dc_state( dcs
);
575 release_dc_ptr( dc
);
580 /***********************************************************************
583 INT WINAPI
SaveDC( HDC hdc
)
588 if ((dc
= get_dc_ptr( hdc
)))
590 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSaveDC
);
591 ret
= physdev
->funcs
->pSaveDC( physdev
);
592 release_dc_ptr( dc
);
598 /***********************************************************************
599 * RestoreDC (GDI32.@)
601 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
605 BOOL success
= FALSE
;
607 TRACE("%p %d\n", hdc
, level
);
608 if ((dc
= get_dc_ptr( hdc
)))
611 physdev
= GET_DC_PHYSDEV( dc
, pRestoreDC
);
612 success
= physdev
->funcs
->pRestoreDC( physdev
, level
);
613 release_dc_ptr( dc
);
619 /***********************************************************************
620 * CreateDCW (GDI32.@)
622 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
623 const DEVMODEW
*initData
)
625 const WCHAR
*display
, *p
;
628 const struct gdi_dc_funcs
*funcs
;
633 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
637 ERR( "no device found for %s\n", debugstr_w(device
) );
640 lstrcpyW(buf
, driver
);
643 if (!(funcs
= DRIVER_load_driver( buf
)))
645 ERR( "no driver found for %s\n", debugstr_w(buf
) );
648 if (!(dc
= alloc_dc_ptr( NTGDI_OBJ_DC
))) return 0;
651 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
653 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
654 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
656 if (funcs
->pCreateDC
)
658 if (!funcs
->pCreateDC( &dc
->physDev
, buf
, device
, output
, initData
))
660 WARN("creation aborted by device\n" );
666 if (is_display_device( driver
))
668 else if (is_display_device( device
))
675 /* Copy only the display name. For example, \\.\DISPLAY1 in \\.\DISPLAY1\Monitor0 */
677 while (iswdigit( *p
))
679 lstrcpynW( dc
->display
, display
, p
- display
+ 1 );
680 dc
->display
[p
- display
] = '\0';
683 dc
->vis_rect
.left
= 0;
684 dc
->vis_rect
.top
= 0;
685 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
686 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
689 release_dc_ptr( dc
);
694 /***********************************************************************
695 * CreateDCA (GDI32.@)
697 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
698 const DEVMODEA
*initData
)
700 UNICODE_STRING driverW
, deviceW
, outputW
;
704 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
705 else driverW
.Buffer
= NULL
;
707 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
708 else deviceW
.Buffer
= NULL
;
710 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
711 else outputW
.Buffer
= NULL
;
716 /* don't convert initData for DISPLAY driver, it's not used */
717 if (!driverW
.Buffer
|| wcsicmp( driverW
.Buffer
, L
"display" ))
718 initDataW
= GdiConvertToDevmodeW(initData
);
721 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
723 RtlFreeUnicodeString(&driverW
);
724 RtlFreeUnicodeString(&deviceW
);
725 RtlFreeUnicodeString(&outputW
);
726 HeapFree(GetProcessHeap(), 0, initDataW
);
731 /***********************************************************************
732 * CreateICA (GDI32.@)
734 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
735 const DEVMODEA
* initData
)
737 /* Nothing special yet for ICs */
738 return CreateDCA( driver
, device
, output
, initData
);
742 /***********************************************************************
743 * CreateICW (GDI32.@)
745 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
746 const DEVMODEW
* initData
)
748 /* Nothing special yet for ICs */
749 return CreateDCW( driver
, device
, output
, initData
);
753 /***********************************************************************
754 * CreateCompatibleDC (GDI32.@)
756 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
760 const struct gdi_dc_funcs
*funcs
;
761 PHYSDEV physDev
= NULL
;
767 if (!(origDC
= get_dc_ptr( hdc
))) return 0;
768 physDev
= GET_DC_PHYSDEV( origDC
, pCreateCompatibleDC
);
769 funcs
= physDev
->funcs
;
770 release_dc_ptr( origDC
);
772 else funcs
= DRIVER_load_driver( L
"display" );
774 if (!(dc
= alloc_dc_ptr( NTGDI_OBJ_MEMDC
))) return 0;
776 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
778 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
779 dc
->vis_rect
.left
= 0;
780 dc
->vis_rect
.top
= 0;
781 dc
->vis_rect
.right
= 1;
782 dc
->vis_rect
.bottom
= 1;
783 dc
->device_rect
= dc
->vis_rect
;
787 if (funcs
->pCreateCompatibleDC
&& !funcs
->pCreateCompatibleDC( physDev
, &dc
->physDev
))
789 WARN("creation aborted by device\n");
794 if (!dib_driver
.pCreateDC( &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
799 physDev
= GET_DC_PHYSDEV( dc
, pSelectBitmap
);
800 physDev
->funcs
->pSelectBitmap( physDev
, dc
->hBitmap
);
803 release_dc_ptr( dc
);
808 /***********************************************************************
811 BOOL WINAPI
DeleteDC( HDC hdc
)
819 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
820 if (dc
->refcount
!= 1)
822 FIXME( "not deleting busy DC %p refcount %u\n", dc
->hSelf
, dc
->refcount
);
823 release_dc_ptr( dc
);
827 /* Call hook procedure to check whether is it OK to delete this DC */
828 if (dc
->hookProc
&& !dc
->hookProc( dc
->hSelf
, DCHC_DELETEDC
, dc
->dwHookData
, 0 ))
830 release_dc_ptr( dc
);
833 reset_dc_state( hdc
);
839 /***********************************************************************
842 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
847 if ((dc
= get_dc_ptr( hdc
)))
849 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pResetDC
);
850 ret
= physdev
->funcs
->pResetDC( physdev
, devmode
);
851 if (ret
) /* reset the visible region */
854 dc
->vis_rect
.left
= 0;
855 dc
->vis_rect
.top
= 0;
856 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
857 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
858 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
860 update_dc_clipping( dc
);
862 release_dc_ptr( dc
);
868 /***********************************************************************
871 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
876 if (devmode
) devmodeW
= GdiConvertToDevmodeW(devmode
);
877 else devmodeW
= NULL
;
879 ret
= ResetDCW(hdc
, devmodeW
);
881 HeapFree(GetProcessHeap(), 0, devmodeW
);
886 /***********************************************************************
887 * GetDeviceCaps (GDI32.@)
889 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
894 if ((dc
= get_dc_ptr( hdc
)))
896 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceCaps
);
897 ret
= physdev
->funcs
->pGetDeviceCaps( physdev
, cap
);
898 release_dc_ptr( dc
);
904 /***********************************************************************
905 * SetBkColor (GDI32.@)
907 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
909 COLORREF ret
= CLR_INVALID
;
910 DC
* dc
= get_dc_ptr( hdc
);
912 TRACE("hdc=%p color=0x%08x\n", hdc
, color
);
916 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkColor
);
917 ret
= dc
->attr
->background_color
;
918 dc
->attr
->background_color
= physdev
->funcs
->pSetBkColor( physdev
, color
);
919 release_dc_ptr( dc
);
925 /***********************************************************************
926 * SetTextColor (GDI32.@)
928 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
930 COLORREF ret
= CLR_INVALID
;
931 DC
* dc
= get_dc_ptr( hdc
);
933 TRACE(" hdc=%p color=0x%08x\n", hdc
, color
);
937 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextColor
);
938 ret
= dc
->attr
->text_color
;
939 dc
->attr
->text_color
= physdev
->funcs
->pSetTextColor( physdev
, color
);
940 release_dc_ptr( dc
);
946 /***********************************************************************
947 * GetDCOrgEx (GDI32.@)
949 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
953 if (!lpp
) return FALSE
;
954 if (!(dc
= get_dc_ptr( hDC
))) return FALSE
;
955 lpp
->x
= dc
->vis_rect
.left
;
956 lpp
->y
= dc
->vis_rect
.top
;
957 release_dc_ptr( dc
);
962 /***********************************************************************
963 * SetGraphicsMode (GDI32.@)
965 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
968 DC
*dc
= get_dc_ptr( hdc
);
970 /* One would think that setting the graphics mode to GM_COMPATIBLE
971 * would also reset the world transformation matrix to the unity
972 * matrix. However, in Windows, this is not the case. This doesn't
973 * make a lot of sense to me, but that's the way it is.
976 if ((mode
> 0) && (mode
<= GM_LAST
))
978 ret
= dc
->attr
->graphics_mode
;
979 dc
->attr
->graphics_mode
= mode
;
981 /* font metrics depend on the graphics mode */
982 if (ret
!= mode
) NtGdiSelectFont(dc
->hSelf
, dc
->hFont
);
983 release_dc_ptr( dc
);
988 /***********************************************************************
989 * GetWorldTransform (GDI32.@)
991 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
994 if (!xform
) return FALSE
;
995 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
996 *xform
= dc
->xformWorld2Wnd
;
997 release_dc_ptr( dc
);
1002 /***********************************************************************
1003 * GetTransform (GDI32.@)
1007 * Returns one of the co-ordinate space transforms
1010 * hdc [I] Device context.
1011 * which [I] Which xform to return:
1012 * 0x203 World -> Page transform (that set by SetWorldTransform).
1013 * 0x304 Page -> Device transform (the mapping mode transform).
1014 * 0x204 World -> Device transform (the combination of the above two).
1015 * 0x402 Device -> World transform (the inversion of the above).
1016 * xform [O] The xform.
1019 BOOL WINAPI
GetTransform( HDC hdc
, DWORD which
, XFORM
*xform
)
1022 DC
*dc
= get_dc_ptr( hdc
);
1023 if (!dc
) return FALSE
;
1028 *xform
= dc
->xformWorld2Wnd
;
1032 construct_window_to_viewport(dc
, xform
);
1036 *xform
= dc
->xformWorld2Vport
;
1040 *xform
= dc
->xformVport2World
;
1044 FIXME("Unknown code %x\n", which
);
1048 release_dc_ptr( dc
);
1053 /****************************************************************************
1054 * CombineTransform [GDI32.@]
1055 * Combines two transformation matrices.
1058 * xformResult [O] Stores the result of combining the two matrices
1059 * xform1 [I] Specifies the first matrix to apply
1060 * xform2 [I] Specifies the second matrix to apply
1063 * The same matrix can be passed in for more than one of the parameters.
1067 * Failure: FALSE. Use GetLastError() to determine the cause.
1069 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1070 const XFORM
*xform2
)
1074 /* Check for illegal parameters */
1075 if (!xformResult
|| !xform1
|| !xform2
)
1078 /* Create the result in a temporary XFORM, since xformResult may be
1079 * equal to xform1 or xform2 */
1080 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1081 xform1
->eM12
* xform2
->eM21
;
1082 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1083 xform1
->eM12
* xform2
->eM22
;
1084 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1085 xform1
->eM22
* xform2
->eM21
;
1086 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1087 xform1
->eM22
* xform2
->eM22
;
1088 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1089 xform1
->eDy
* xform2
->eM21
+
1091 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1092 xform1
->eDy
* xform2
->eM22
+
1095 /* Copy the result to xformResult */
1096 *xformResult
= xformTemp
;
1102 /***********************************************************************
1103 * SetDCHook (GDI32.@)
1105 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1107 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD_PTR dwHookData
)
1109 DC
*dc
= get_dc_ptr( hdc
);
1111 if (!dc
) return FALSE
;
1113 dc
->dwHookData
= dwHookData
;
1114 dc
->hookProc
= hookProc
;
1115 release_dc_ptr( dc
);
1120 /***********************************************************************
1121 * GetDCHook (GDI32.@)
1123 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1125 DWORD_PTR WINAPI
GetDCHook( HDC hdc
, DCHOOKPROC
*proc
)
1127 DC
*dc
= get_dc_ptr( hdc
);
1131 if (proc
) *proc
= dc
->hookProc
;
1132 ret
= dc
->dwHookData
;
1133 release_dc_ptr( dc
);
1138 /***********************************************************************
1139 * SetHookFlags (GDI32.@)
1141 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1143 WORD WINAPI
SetHookFlags( HDC hdc
, WORD flags
)
1145 DC
*dc
= get_dc_obj( hdc
); /* not get_dc_ptr, this needs to work from any thread */
1150 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1152 if (flags
& DCHF_INVALIDATEVISRGN
)
1153 ret
= InterlockedExchange( &dc
->dirty
, 1 );
1154 else if (flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1155 ret
= InterlockedExchange( &dc
->dirty
, 0 );
1157 if (flags
& DCHF_DISABLEDC
)
1158 ret
= InterlockedExchange( &dc
->attr
->disabled
, 1 );
1159 else if (flags
& DCHF_ENABLEDC
)
1160 ret
= InterlockedExchange( &dc
->attr
->disabled
, 0 );
1162 GDI_ReleaseObj( hdc
);
1164 if (flags
& DCHF_RESETDC
) ret
= reset_dc_state( hdc
);
1168 /***********************************************************************
1169 * SetICMMode (GDI32.@)
1171 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1173 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1174 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1175 if (iEnableICM
== ICM_ON
) return 0;
1176 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1180 /***********************************************************************
1181 * GetDeviceGammaRamp (GDI32.@)
1183 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1186 DC
*dc
= get_dc_ptr( hDC
);
1188 TRACE("%p, %p\n", hDC
, ptr
);
1191 if (GetObjectType( hDC
) != OBJ_MEMDC
)
1193 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceGammaRamp
);
1194 ret
= physdev
->funcs
->pGetDeviceGammaRamp( physdev
, ptr
);
1196 else SetLastError( ERROR_INVALID_PARAMETER
);
1197 release_dc_ptr( dc
);
1202 static BOOL
check_gamma_ramps(void *ptr
)
1206 while (ramp
< (WORD
*)ptr
+ 3 * 256)
1208 float r_x
, r_y
, r_lx
, r_ly
, r_d
, r_v
, r_e
, g_avg
, g_min
, g_max
;
1209 unsigned i
, f
, l
, g_n
, c
;
1215 TRACE("inverted or flat gamma ramp (%d->%d), rejected\n", f
, l
);
1219 g_min
= g_max
= g_avg
= 0.0;
1221 /* check gamma ramp entries to estimate the gamma */
1222 TRACE("analyzing gamma ramp (%d->%d)\n", f
, l
);
1223 for (i
=1, g_n
=0; i
<255; i
++)
1225 if (ramp
[i
] < f
|| ramp
[i
] > l
)
1227 TRACE("strange gamma ramp ([%d]=%d for %d->%d), rejected\n", i
, ramp
[i
], f
, l
);
1231 if (!c
) continue; /* avoid log(0) */
1233 /* normalize entry values into 0..1 range */
1234 r_x
= i
/255.0; r_y
= c
/ r_d
;
1235 /* compute logarithms of values */
1236 r_lx
= log(r_x
); r_ly
= log(r_y
);
1237 /* compute gamma for this entry */
1239 /* compute differential (error estimate) for this entry */
1240 /* some games use table-based logarithms that magnifies the error by 128 */
1241 r_e
= -r_lx
* 128 / (c
* r_lx
* r_lx
);
1243 /* compute min & max while compensating for estimated error */
1244 if (!g_n
|| g_min
> (r_v
+ r_e
)) g_min
= r_v
+ r_e
;
1245 if (!g_n
|| g_max
< (r_v
- r_e
)) g_max
= r_v
- r_e
;
1247 /* add to average */
1254 TRACE("no gamma data, shouldn't happen\n");
1258 TRACE("low bias is %d, high is %d, gamma is %5.3f\n", f
, 65535-l
, g_avg
);
1260 /* check that the gamma is reasonably uniform across the ramp */
1261 if (g_max
- g_min
> 12.8)
1263 TRACE("ramp not uniform (max=%f, min=%f, avg=%f), rejected\n", g_max
, g_min
, g_avg
);
1267 /* check that the gamma is not too bright */
1270 TRACE("too bright gamma ( %5.3f), rejected\n", g_avg
);
1280 /***********************************************************************
1281 * SetDeviceGammaRamp (GDI32.@)
1283 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1286 DC
*dc
= get_dc_ptr( hDC
);
1288 TRACE("%p, %p\n", hDC
, ptr
);
1291 if (GetObjectType( hDC
) != OBJ_MEMDC
)
1293 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDeviceGammaRamp
);
1295 if (check_gamma_ramps(ptr
))
1296 ret
= physdev
->funcs
->pSetDeviceGammaRamp( physdev
, ptr
);
1298 else SetLastError( ERROR_INVALID_PARAMETER
);
1299 release_dc_ptr( dc
);
1305 /***********************************************************************
1306 * GetBoundsRect (GDI32.@)
1308 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1313 DC
*dc
= get_dc_ptr( hdc
);
1315 if ( !dc
) return 0;
1317 physdev
= GET_DC_PHYSDEV( dc
, pGetBoundsRect
);
1318 ret
= physdev
->funcs
->pGetBoundsRect( physdev
, &device_rect
, DCB_RESET
);
1321 release_dc_ptr( dc
);
1324 if (dc
->bounds_enabled
&& ret
== DCB_SET
) add_bounds_rect( &dc
->bounds
, &device_rect
);
1328 if (is_rect_empty( &dc
->bounds
))
1330 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
1336 rect
->left
= max( rect
->left
, 0 );
1337 rect
->top
= max( rect
->top
, 0 );
1338 rect
->right
= min( rect
->right
, dc
->vis_rect
.right
- dc
->vis_rect
.left
);
1339 rect
->bottom
= min( rect
->bottom
, dc
->vis_rect
.bottom
- dc
->vis_rect
.top
);
1342 dp_to_lp( dc
, (POINT
*)rect
, 2 );
1346 if (flags
& DCB_RESET
) reset_bounds( &dc
->bounds
);
1347 release_dc_ptr( dc
);
1352 /***********************************************************************
1353 * SetBoundsRect (GDI32.@)
1355 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1361 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
1362 if (!(dc
= get_dc_ptr( hdc
))) return 0;
1364 physdev
= GET_DC_PHYSDEV( dc
, pSetBoundsRect
);
1365 ret
= physdev
->funcs
->pSetBoundsRect( physdev
, &dc
->bounds
, flags
);
1368 release_dc_ptr( dc
);
1372 ret
= (dc
->bounds_enabled
? DCB_ENABLE
: DCB_DISABLE
) |
1373 (is_rect_empty( &dc
->bounds
) ? ret
& DCB_SET
: DCB_SET
);
1375 if (flags
& DCB_RESET
) reset_bounds( &dc
->bounds
);
1377 if ((flags
& DCB_ACCUMULATE
) && rect
)
1381 lp_to_dp( dc
, (POINT
*)&rc
, 2 );
1382 add_bounds_rect( &dc
->bounds
, &rc
);
1385 if (flags
& DCB_ENABLE
) dc
->bounds_enabled
= TRUE
;
1386 if (flags
& DCB_DISABLE
) dc
->bounds_enabled
= FALSE
;
1388 release_dc_ptr( dc
);
1393 /***********************************************************************
1394 * GetBrushOrgEx (GDI32.@)
1396 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, LPPOINT pt
)
1398 DC
* dc
= get_dc_ptr( hdc
);
1399 if (!dc
) return FALSE
;
1400 *pt
= dc
->brush_org
;
1401 release_dc_ptr( dc
);
1406 /***********************************************************************
1407 * GetViewportExtEx (GDI32.@)
1409 BOOL WINAPI
GetViewportExtEx( HDC hdc
, LPSIZE size
)
1411 DC
* dc
= get_dc_ptr( hdc
);
1412 if (!dc
) return FALSE
;
1413 *size
= dc
->vport_ext
;
1414 release_dc_ptr( dc
);
1419 /***********************************************************************
1420 * GetViewportOrgEx (GDI32.@)
1422 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, LPPOINT pt
)
1424 DC
* dc
= get_dc_ptr( hdc
);
1425 if (!dc
) return FALSE
;
1426 *pt
= dc
->vport_org
;
1427 release_dc_ptr( dc
);
1432 /***********************************************************************
1433 * GetWindowExtEx (GDI32.@)
1435 BOOL WINAPI
GetWindowExtEx( HDC hdc
, LPSIZE size
)
1437 DC
* dc
= get_dc_ptr( hdc
);
1438 if (!dc
) return FALSE
;
1439 *size
= dc
->wnd_ext
;
1440 release_dc_ptr( dc
);
1445 /***********************************************************************
1446 * GetWindowOrgEx (GDI32.@)
1448 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, LPPOINT pt
)
1450 DC
* dc
= get_dc_ptr( hdc
);
1451 if (!dc
) return FALSE
;
1453 release_dc_ptr( dc
);
1458 /***********************************************************************
1459 * SetLayout (GDI32.@)
1461 * Sets left->right or right->left text layout flags of a dc.
1464 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1466 DWORD oldlayout
= GDI_ERROR
;
1468 DC
* dc
= get_dc_ptr( hdc
);
1471 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetLayout
);
1472 oldlayout
= physdev
->funcs
->pSetLayout( physdev
, layout
);
1473 release_dc_ptr( dc
);
1476 TRACE("hdc : %p, old layout : %08x, new layout : %08x\n", hdc
, oldlayout
, layout
);
1481 /***********************************************************************
1482 * SetDCBrushColor (GDI32.@)
1484 COLORREF WINAPI
SetDCBrushColor(HDC hdc
, COLORREF crColor
)
1487 COLORREF oldClr
= CLR_INVALID
;
1489 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1491 dc
= get_dc_ptr( hdc
);
1494 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCBrushColor
);
1495 crColor
= physdev
->funcs
->pSetDCBrushColor( physdev
, crColor
);
1496 if (crColor
!= CLR_INVALID
)
1498 oldClr
= dc
->attr
->brush_color
;
1499 dc
->attr
->brush_color
= crColor
;
1501 release_dc_ptr( dc
);
1507 /***********************************************************************
1508 * GetDCPenColor (GDI32.@)
1510 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
1513 COLORREF dcPenColor
= CLR_INVALID
;
1515 TRACE("hdc(%p)\n", hdc
);
1517 dc
= get_dc_ptr( hdc
);
1520 dcPenColor
= dc
->dcPenColor
;
1521 release_dc_ptr( dc
);
1527 /***********************************************************************
1528 * SetDCPenColor (GDI32.@)
1530 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1533 COLORREF oldClr
= CLR_INVALID
;
1535 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1537 dc
= get_dc_ptr( hdc
);
1540 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCPenColor
);
1541 crColor
= physdev
->funcs
->pSetDCPenColor( physdev
, crColor
);
1542 if (crColor
!= CLR_INVALID
)
1544 oldClr
= dc
->dcPenColor
;
1545 dc
->dcPenColor
= crColor
;
1547 release_dc_ptr( dc
);
1553 /***********************************************************************
1554 * CancelDC (GDI32.@)
1556 BOOL WINAPI
CancelDC(HDC hdc
)
1562 /*******************************************************************
1563 * GetMiterLimit [GDI32.@]
1567 BOOL WINAPI
GetMiterLimit(HDC hdc
, PFLOAT peLimit
)
1572 TRACE("(%p,%p)\n", hdc
, peLimit
);
1574 dc
= get_dc_ptr( hdc
);
1578 *peLimit
= dc
->miterLimit
;
1580 release_dc_ptr( dc
);
1586 /*******************************************************************
1587 * SetMiterLimit [GDI32.@]
1591 BOOL WINAPI
SetMiterLimit(HDC hdc
, FLOAT eNewLimit
, PFLOAT peOldLimit
)
1596 TRACE("(%p,%f,%p)\n", hdc
, eNewLimit
, peOldLimit
);
1598 dc
= get_dc_ptr( hdc
);
1602 *peOldLimit
= dc
->miterLimit
;
1603 dc
->miterLimit
= eNewLimit
;
1604 release_dc_ptr( dc
);
1610 /*******************************************************************
1611 * GdiIsMetaPrintDC [GDI32.@]
1613 BOOL WINAPI
GdiIsMetaPrintDC(HDC hdc
)
1619 /*******************************************************************
1620 * GdiIsMetaFileDC [GDI32.@]
1622 BOOL WINAPI
GdiIsMetaFileDC(HDC hdc
)
1626 switch( GetObjectType( hdc
) )
1635 /*******************************************************************
1636 * GdiIsPlayMetafileDC [GDI32.@]
1638 BOOL WINAPI
GdiIsPlayMetafileDC(HDC hdc
)