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 reset_bounds( &dc->bounds );
119 if (!(dc->hSelf = alloc_gdi_handle( &dc->header, magic, &dc_funcs )))
121 HeapFree( GetProcessHeap(), 0, dc );
124 dc->nulldrv.hdc = dc->hSelf;
126 if (font_driver && !font_driver->pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
136 /***********************************************************************
139 static void free_dc_state( DC *dc )
141 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
142 if (dc->hMetaRgn) DeleteObject( dc->hMetaRgn );
143 if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
144 if (dc->region) DeleteObject( dc->region );
145 if (dc->path) free_gdi_path( dc->path );
146 HeapFree( GetProcessHeap(), 0, dc );
150 /***********************************************************************
153 void free_dc_ptr( DC *dc )
155 assert( dc->refcount == 1 );
157 while (dc->physDev != &dc->nulldrv)
159 PHYSDEV physdev = pop_dc_driver( &dc->physDev );
160 physdev->funcs->pDeleteDC( physdev );
161 if (physdev == dc->dibdrv) dc->dibdrv = NULL;
163 if (dc->dibdrv) dc->dibdrv->funcs->pDeleteDC( dc->dibdrv );
164 free_gdi_handle( dc->hSelf );
169 /***********************************************************************
172 * Retrieve a DC pointer but release the GDI lock.
174 DC *get_dc_ptr( HDC hdc )
176 DC *dc = get_dc_obj( hdc );
177 if (!dc) return NULL;
179 if (!InterlockedCompareExchange( &dc->refcount, 1, 0 ))
181 dc->thread = GetCurrentThreadId();
183 else if (dc->thread != GetCurrentThreadId())
185 WARN( "dc %p belongs to thread %04x\n", hdc, dc->thread );
186 GDI_ReleaseObj( hdc );
189 else InterlockedIncrement( &dc->refcount );
191 GDI_ReleaseObj( hdc );
196 /***********************************************************************
199 void release_dc_ptr( DC *dc )
204 ref = InterlockedDecrement( &dc->refcount );
206 if (ref) dc->thread = GetCurrentThreadId(); /* we still own it */
210 /***********************************************************************
213 * Make sure the DC vis region is up to date.
214 * This function may call up to USER so the GDI lock should _not_
215 * be held when calling it.
217 void update_dc( DC *dc )
219 if (InterlockedExchange( &dc->dirty, 0 ) && dc->hookProc)
220 dc->hookProc( dc->hSelf, DCHC_INVALIDVISRGN, dc->dwHookData, 0 );
224 /***********************************************************************
227 static BOOL DC_DeleteObject( HGDIOBJ handle )
229 return DeleteDC( handle );
233 /***********************************************************************
236 * Setup device-specific DC values for a newly created DC.
238 void DC_InitDC( DC* dc )
240 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette );
241 physdev->funcs->pRealizeDefaultPalette( physdev );
242 SetTextColor( dc->hSelf, dc->textColor );
243 SetBkColor( dc->hSelf, dc->backgroundColor );
244 SelectObject( dc->hSelf, dc->hPen );
245 SelectObject( dc->hSelf, dc->hBrush );
246 SelectObject( dc->hSelf, dc->hFont );
247 update_dc_clipping( dc );
248 SetVirtualResolution( dc->hSelf, 0, 0, 0, 0 );
249 physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
250 physdev->funcs->pSetBoundsRect( physdev, &dc->bounds, dc->bounds_enabled ? DCB_ENABLE : DCB_DISABLE );
254 /***********************************************************************
257 * Computes the inverse of the transformation xformSrc and stores it to
258 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
261 static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
265 determinant = xformSrc->eM11*xformSrc->eM22 -
266 xformSrc->eM12*xformSrc->eM21;
267 if (determinant > -1e-12 && determinant < 1e-12)
270 xformDest->eM11 = xformSrc->eM22 / determinant;
271 xformDest->eM12 = -xformSrc->eM12 / determinant;
272 xformDest->eM21 = -xformSrc->eM21 / determinant;
273 xformDest->eM22 = xformSrc->eM11 / determinant;
274 xformDest->eDx = -xformSrc->eDx * xformDest->eM11 -
275 xformSrc->eDy * xformDest->eM21;
276 xformDest->eDy = -xformSrc->eDx * xformDest->eM12 -
277 xformSrc->eDy * xformDest->eM22;
282 /* Construct a transformation to do the window-to-viewport conversion */
283 static void construct_window_to_viewport(DC *dc, XFORM *xform)
285 double scaleX, scaleY;
286 scaleX = (double)dc->vportExtX / (double)dc->wndExtX;
287 scaleY = (double)dc->vportExtY / (double)dc->wndExtY;
289 if (dc->layout & LAYOUT_RTL) scaleX = -scaleX;
290 xform->eM11 = scaleX;
293 xform->eM22 = scaleY;
294 xform->eDx = (double)dc->vportOrgX - scaleX * (double)dc->wndOrgX;
295 xform->eDy = (double)dc->vportOrgY - scaleY * (double)dc->wndOrgY;
296 if (dc->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx;
299 /***********************************************************************
302 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
303 * fields of the specified DC by creating a transformation that
304 * represents the current mapping mode and combining it with the DC's
305 * world transform. This function should be called whenever the
306 * parameters associated with the mapping mode (window and viewport
307 * extents and origins) or the world transform change.
309 void DC_UpdateXforms( DC *dc )
311 XFORM xformWnd2Vport, oldworld2vport;
313 construct_window_to_viewport(dc, &xformWnd2Vport);
315 oldworld2vport = dc->xformWorld2Vport;
316 /* Combine with the world transformation */
317 CombineTransform( &dc->xformWorld2Vport, &dc->xformWorld2Wnd,
320 /* Create inverse of world-to-viewport transformation */
321 dc->vport2WorldValid = DC_InvertXform( &dc->xformWorld2Vport,
322 &dc->xformVport2World );
324 /* Reselect the font and pen back into the dc so that the size
326 if (memcmp(&oldworld2vport, &dc->xformWorld2Vport, sizeof(oldworld2vport)) &&
327 !GdiIsMetaFileDC(dc->hSelf))
329 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
330 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_PEN));
335 /***********************************************************************
338 INT nulldrv_SaveDC( PHYSDEV dev )
340 DC *newdc, *dc = get_nulldrv_dc( dev );
342 if (!(newdc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc )))) return 0;
343 newdc->layout = dc->layout;
344 newdc->hPen = dc->hPen;
345 newdc->hBrush = dc->hBrush;
346 newdc->hFont = dc->hFont;
347 newdc->hBitmap = dc->hBitmap;
348 newdc->hDevice = dc->hDevice;
349 newdc->hPalette = dc->hPalette;
350 newdc->ROPmode = dc->ROPmode;
351 newdc->polyFillMode = dc->polyFillMode;
352 newdc->stretchBltMode = dc->stretchBltMode;
353 newdc->relAbsMode = dc->relAbsMode;
354 newdc->backgroundMode = dc->backgroundMode;
355 newdc->backgroundColor = dc->backgroundColor;
356 newdc->textColor = dc->textColor;
357 newdc->dcBrushColor = dc->dcBrushColor;
358 newdc->dcPenColor = dc->dcPenColor;
359 newdc->brushOrgX = dc->brushOrgX;
360 newdc->brushOrgY = dc->brushOrgY;
361 newdc->mapperFlags = dc->mapperFlags;
362 newdc->textAlign = dc->textAlign;
363 newdc->charExtra = dc->charExtra;
364 newdc->breakExtra = dc->breakExtra;
365 newdc->breakRem = dc->breakRem;
366 newdc->MapMode = dc->MapMode;
367 newdc->GraphicsMode = dc->GraphicsMode;
368 newdc->CursPosX = dc->CursPosX;
369 newdc->CursPosY = dc->CursPosY;
370 newdc->ArcDirection = dc->ArcDirection;
371 newdc->xformWorld2Wnd = dc->xformWorld2Wnd;
372 newdc->xformWorld2Vport = dc->xformWorld2Vport;
373 newdc->xformVport2World = dc->xformVport2World;
374 newdc->vport2WorldValid = dc->vport2WorldValid;
375 newdc->wndOrgX = dc->wndOrgX;
376 newdc->wndOrgY = dc->wndOrgY;
377 newdc->wndExtX = dc->wndExtX;
378 newdc->wndExtY = dc->wndExtY;
379 newdc->vportOrgX = dc->vportOrgX;
380 newdc->vportOrgY = dc->vportOrgY;
381 newdc->vportExtX = dc->vportExtX;
382 newdc->vportExtY = dc->vportExtY;
383 newdc->virtual_res = dc->virtual_res;
384 newdc->virtual_size = dc->virtual_size;
385 newdc->gdiFont = dc->gdiFont;
387 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
391 newdc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
392 CombineRgn( newdc->hClipRgn, dc->hClipRgn, 0, RGN_COPY );
396 newdc->hMetaRgn = CreateRectRgn( 0, 0, 0, 0 );
397 CombineRgn( newdc->hMetaRgn, dc->hMetaRgn, 0, RGN_COPY );
400 if (!PATH_SavePath( newdc, dc ))
402 release_dc_ptr( dc );
403 free_dc_state( newdc );
407 newdc->saved_dc = dc->saved_dc;
408 dc->saved_dc = newdc;
409 return ++dc->saveLevel;
413 /***********************************************************************
416 BOOL nulldrv_RestoreDC( PHYSDEV dev, INT level )
418 DC *dcs, *first_dcs, *dc = get_nulldrv_dc( dev );
421 /* find the state level to restore */
423 if (abs(level) > dc->saveLevel || level == 0) return FALSE;
424 if (level < 0) level = dc->saveLevel + level + 1;
425 first_dcs = dc->saved_dc;
426 for (dcs = first_dcs, save_level = dc->saveLevel; save_level > level; save_level--)
429 /* restore the state */
431 if (!PATH_RestorePath( dc, dcs )) return FALSE;
433 dc->layout = dcs->layout;
434 dc->hDevice = dcs->hDevice;
435 dc->ROPmode = dcs->ROPmode;
436 dc->polyFillMode = dcs->polyFillMode;
437 dc->stretchBltMode = dcs->stretchBltMode;
438 dc->relAbsMode = dcs->relAbsMode;
439 dc->backgroundMode = dcs->backgroundMode;
440 dc->backgroundColor = dcs->backgroundColor;
441 dc->textColor = dcs->textColor;
442 dc->dcBrushColor = dcs->dcBrushColor;
443 dc->dcPenColor = dcs->dcPenColor;
444 dc->brushOrgX = dcs->brushOrgX;
445 dc->brushOrgY = dcs->brushOrgY;
446 dc->mapperFlags = dcs->mapperFlags;
447 dc->textAlign = dcs->textAlign;
448 dc->charExtra = dcs->charExtra;
449 dc->breakExtra = dcs->breakExtra;
450 dc->breakRem = dcs->breakRem;
451 dc->MapMode = dcs->MapMode;
452 dc->GraphicsMode = dcs->GraphicsMode;
453 dc->CursPosX = dcs->CursPosX;
454 dc->CursPosY = dcs->CursPosY;
455 dc->ArcDirection = dcs->ArcDirection;
456 dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
457 dc->xformWorld2Vport = dcs->xformWorld2Vport;
458 dc->xformVport2World = dcs->xformVport2World;
459 dc->vport2WorldValid = dcs->vport2WorldValid;
460 dc->wndOrgX = dcs->wndOrgX;
461 dc->wndOrgY = dcs->wndOrgY;
462 dc->wndExtX = dcs->wndExtX;
463 dc->wndExtY = dcs->wndExtY;
464 dc->vportOrgX = dcs->vportOrgX;
465 dc->vportOrgY = dcs->vportOrgY;
466 dc->vportExtX = dcs->vportExtX;
467 dc->vportExtY = dcs->vportExtY;
468 dc->virtual_res = dcs->virtual_res;
469 dc->virtual_size = dcs->virtual_size;
473 if (!dc->hClipRgn) dc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
474 CombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
478 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
483 if (!dc->hMetaRgn) dc->hMetaRgn = CreateRectRgn( 0, 0, 0, 0 );
484 CombineRgn( dc->hMetaRgn, dcs->hMetaRgn, 0, RGN_COPY );
488 if (dc->hMetaRgn) DeleteObject( dc->hMetaRgn );
491 DC_UpdateXforms( dc );
492 update_dc_clipping( dc );
494 SelectObject( dev->hdc, dcs->hBitmap );
495 SelectObject( dev->hdc, dcs->hBrush );
496 SelectObject( dev->hdc, dcs->hFont );
497 SelectObject( dev->hdc, dcs->hPen );
498 SetBkColor( dev->hdc, dcs->backgroundColor);
499 SetTextColor( dev->hdc, dcs->textColor);
500 GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
502 dc->saved_dc = dcs->saved_dc;
504 dc->saveLevel = save_level - 1;
506 /* now destroy all the saved DCs */
510 DC *next = first_dcs->saved_dc;
511 free_dc_state( first_dcs );
518 /***********************************************************************
521 INT WINAPI SaveDC( HDC hdc )
526 if ((dc = get_dc_ptr( hdc )))
528 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSaveDC );
529 ret = physdev->funcs->pSaveDC( physdev );
530 release_dc_ptr( dc );
536 /***********************************************************************
537 * RestoreDC (GDI32.@)
539 BOOL WINAPI RestoreDC( HDC hdc, INT level )
542 BOOL success = FALSE;
544 TRACE("%p %d\n", hdc, level );
545 if ((dc = get_dc_ptr( hdc )))
547 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRestoreDC );
549 success = physdev->funcs->pRestoreDC( physdev, level );
550 release_dc_ptr( dc );
556 /***********************************************************************
557 * CreateDCW (GDI32.@)
559 HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
560 const DEVMODEW *initData )
564 const struct gdi_dc_funcs *funcs;
569 if (!device || !DRIVER_GetDriverName( device, buf, 300 ))
573 ERR( "no device found for %s\n", debugstr_w(device) );
576 strcpyW(buf, driver);
579 if (!(funcs = DRIVER_load_driver( buf )))
581 ERR( "no driver found for %s\n", debugstr_w(buf) );
584 if (!(dc = alloc_dc_ptr( OBJ_DC ))) return 0;
587 dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
589 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
590 debugstr_w(driver), debugstr_w(device), debugstr_w(output), dc->hSelf );
592 if (funcs->pCreateDC)
594 if (!funcs->pCreateDC( &dc->physDev, buf, device, output, initData ))
596 WARN("creation aborted by device\n" );
602 dc->vis_rect.left = 0;
603 dc->vis_rect.top = 0;
604 dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
605 dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
608 release_dc_ptr( dc );
613 /***********************************************************************
614 * CreateDCA (GDI32.@)
616 HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
617 const DEVMODEA *initData )
619 UNICODE_STRING driverW, deviceW, outputW;
623 if (driver) RtlCreateUnicodeStringFromAsciiz(&driverW, driver);
624 else driverW.Buffer = NULL;
626 if (device) RtlCreateUnicodeStringFromAsciiz(&deviceW, device);
627 else deviceW.Buffer = NULL;
629 if (output) RtlCreateUnicodeStringFromAsciiz(&outputW, output);
630 else outputW.Buffer = NULL;
635 /* don't convert initData for DISPLAY driver, it's not used */
636 if (!driverW.Buffer || strcmpiW( driverW.Buffer, displayW ))
637 initDataW = GdiConvertToDevmodeW(initData);
640 ret = CreateDCW( driverW.Buffer, deviceW.Buffer, outputW.Buffer, initDataW );
642 RtlFreeUnicodeString(&driverW);
643 RtlFreeUnicodeString(&deviceW);
644 RtlFreeUnicodeString(&outputW);
645 HeapFree(GetProcessHeap(), 0, initDataW);
650 /***********************************************************************
651 * CreateICA (GDI32.@)
653 HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output,
654 const DEVMODEA* initData )
656 /* Nothing special yet for ICs */
657 return CreateDCA( driver, device, output, initData );
661 /***********************************************************************
662 * CreateICW (GDI32.@)
664 HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
665 const DEVMODEW* initData )
667 /* Nothing special yet for ICs */
668 return CreateDCW( driver, device, output, initData );
672 /***********************************************************************
673 * CreateCompatibleDC (GDI32.@)
675 HDC WINAPI CreateCompatibleDC( HDC hdc )
679 const struct gdi_dc_funcs *funcs = &null_driver;
680 PHYSDEV physDev = NULL;
686 if (!(origDC = get_dc_ptr( hdc ))) return 0;
687 physDev = GET_DC_PHYSDEV( origDC, pCreateCompatibleDC );
688 funcs = physDev->funcs;
689 release_dc_ptr( origDC );
692 if (!(dc = alloc_dc_ptr( OBJ_MEMDC ))) return 0;
694 TRACE("(%p): returning %p\n", hdc, dc->hSelf );
696 dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
697 dc->vis_rect.left = 0;
698 dc->vis_rect.top = 0;
699 dc->vis_rect.right = 1;
700 dc->vis_rect.bottom = 1;
704 if (!funcs->pCreateCompatibleDC( physDev, &dc->physDev ))
706 WARN("creation aborted by device\n");
711 release_dc_ptr( dc );
716 /***********************************************************************
719 BOOL WINAPI DeleteDC( HDC hdc )
727 if (!(dc = get_dc_ptr( hdc ))) return FALSE;
728 if (dc->refcount != 1)
730 FIXME( "not deleting busy DC %p refcount %u\n", dc->hSelf, dc->refcount );
731 release_dc_ptr( dc );
735 /* Call hook procedure to check whether is it OK to delete this DC */
736 if (dc->hookProc && !dc->hookProc( hdc, DCHC_DELETEDC, dc->dwHookData, 0 ))
738 release_dc_ptr( dc );
742 while (dc->saveLevel)
744 DC *dcs = dc->saved_dc;
745 dc->saved_dc = dcs->saved_dc;
747 free_dc_state( dcs );
751 SelectObject( hdc, GetStockObject(BLACK_PEN) );
752 SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
753 SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
754 SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
761 /***********************************************************************
764 HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
769 if ((dc = get_dc_ptr( hdc )))
771 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pResetDC );
772 ret = physdev->funcs->pResetDC( physdev, devmode );
773 if (ret) /* reset the visible region */
776 dc->vis_rect.left = 0;
777 dc->vis_rect.top = 0;
778 dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
779 dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
780 if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
782 update_dc_clipping( dc );
784 release_dc_ptr( dc );
790 /***********************************************************************
793 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
798 if (devmode) devmodeW = GdiConvertToDevmodeW(devmode);
799 else devmodeW = NULL;
801 ret = ResetDCW(hdc, devmodeW);
803 HeapFree(GetProcessHeap(), 0, devmodeW);
808 /***********************************************************************
809 * GetDeviceCaps (GDI32.@)
811 INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
816 if ((dc = get_dc_ptr( hdc )))
818 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceCaps );
819 ret = physdev->funcs->pGetDeviceCaps( physdev, cap );
820 release_dc_ptr( dc );
826 /***********************************************************************
827 * GetBkColor (GDI32.@)
829 COLORREF WINAPI GetBkColor( HDC hdc )
832 DC * dc = get_dc_ptr( hdc );
835 ret = dc->backgroundColor;
836 release_dc_ptr( dc );
842 /***********************************************************************
843 * SetBkColor (GDI32.@)
845 COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
847 COLORREF ret = CLR_INVALID;
848 DC * dc = get_dc_ptr( hdc );
850 TRACE("hdc=%p color=0x%08x\n", hdc, color);
854 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
855 ret = dc->backgroundColor;
856 dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color );
857 release_dc_ptr( dc );
863 /***********************************************************************
864 * GetTextColor (GDI32.@)
866 COLORREF WINAPI GetTextColor( HDC hdc )
869 DC * dc = get_dc_ptr( hdc );
873 release_dc_ptr( dc );
879 /***********************************************************************
880 * SetTextColor (GDI32.@)
882 COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
884 COLORREF ret = CLR_INVALID;
885 DC * dc = get_dc_ptr( hdc );
887 TRACE(" hdc=%p color=0x%08x\n", hdc, color);
891 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor );
893 dc->textColor = physdev->funcs->pSetTextColor( physdev, color );
894 release_dc_ptr( dc );
900 /***********************************************************************
901 * GetTextAlign (GDI32.@)
903 UINT WINAPI GetTextAlign( HDC hdc )
906 DC * dc = get_dc_ptr( hdc );
910 release_dc_ptr( dc );
916 /***********************************************************************
917 * SetTextAlign (GDI32.@)
919 UINT WINAPI SetTextAlign( HDC hdc, UINT align )
921 UINT ret = GDI_ERROR;
922 DC *dc = get_dc_ptr( hdc );
924 TRACE("hdc=%p align=%d\n", hdc, align);
928 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextAlign );
929 align = physdev->funcs->pSetTextAlign( physdev, align );
930 if (align != GDI_ERROR)
933 dc->textAlign = align;
935 release_dc_ptr( dc );
940 /***********************************************************************
941 * GetDCOrgEx (GDI32.@)
943 BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
947 if (!lpp) return FALSE;
948 if (!(dc = get_dc_ptr( hDC ))) return FALSE;
949 lpp->x = dc->vis_rect.left;
950 lpp->y = dc->vis_rect.top;
951 release_dc_ptr( dc );
956 /***********************************************************************
957 * GetGraphicsMode (GDI32.@)
959 INT WINAPI GetGraphicsMode( HDC hdc )
962 DC * dc = get_dc_ptr( hdc );
965 ret = dc->GraphicsMode;
966 release_dc_ptr( dc );
972 /***********************************************************************
973 * SetGraphicsMode (GDI32.@)
975 INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
978 DC *dc = get_dc_ptr( hdc );
980 /* One would think that setting the graphics mode to GM_COMPATIBLE
981 * would also reset the world transformation matrix to the unity
982 * matrix. However, in Windows, this is not the case. This doesn't
983 * make a lot of sense to me, but that's the way it is.
986 if ((mode > 0) && (mode <= GM_LAST))
988 ret = dc->GraphicsMode;
989 dc->GraphicsMode = mode;
991 release_dc_ptr( dc );
996 /***********************************************************************
997 * GetArcDirection (GDI32.@)
999 INT WINAPI GetArcDirection( HDC hdc )
1002 DC * dc = get_dc_ptr( hdc );
1005 ret = dc->ArcDirection;
1006 release_dc_ptr( dc );
1012 /***********************************************************************
1013 * SetArcDirection (GDI32.@)
1015 INT WINAPI SetArcDirection( HDC hdc, INT dir )
1020 if (dir != AD_COUNTERCLOCKWISE && dir != AD_CLOCKWISE)
1022 SetLastError(ERROR_INVALID_PARAMETER);
1026 if ((dc = get_dc_ptr( hdc )))
1028 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetArcDirection );
1029 dir = physdev->funcs->pSetArcDirection( physdev, dir );
1032 ret = dc->ArcDirection;
1033 dc->ArcDirection = dir;
1035 release_dc_ptr( dc );
1041 /***********************************************************************
1042 * GetWorldTransform (GDI32.@)
1044 BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
1047 if (!xform) return FALSE;
1048 if (!(dc = get_dc_ptr( hdc ))) return FALSE;
1049 *xform = dc->xformWorld2Wnd;
1050 release_dc_ptr( dc );
1055 /***********************************************************************
1056 * GetTransform (GDI32.@)
1060 * Returns one of the co-ordinate space transforms
1063 * hdc [I] Device context.
1064 * which [I] Which xform to return:
1065 * 0x203 World -> Page transform (that set by SetWorldTransform).
1066 * 0x304 Page -> Device transform (the mapping mode transform).
1067 * 0x204 World -> Device transform (the combination of the above two).
1068 * 0x402 Device -> World transform (the inversion of the above).
1069 * xform [O] The xform.
1072 BOOL WINAPI GetTransform( HDC hdc, DWORD which, XFORM *xform )
1075 DC *dc = get_dc_ptr( hdc );
1076 if (!dc) return FALSE;
1081 *xform = dc->xformWorld2Wnd;
1085 construct_window_to_viewport(dc, xform);
1089 *xform = dc->xformWorld2Vport;
1093 *xform = dc->xformVport2World;
1097 FIXME("Unknown code %x\n", which);
1101 release_dc_ptr( dc );
1106 /****************************************************************************
1107 * CombineTransform [GDI32.@]
1108 * Combines two transformation matrices.
1111 * xformResult [O] Stores the result of combining the two matrices
1112 * xform1 [I] Specifies the first matrix to apply
1113 * xform2 [I] Specifies the second matrix to apply
1116 * The same matrix can be passed in for more than one of the parameters.
1120 * Failure: FALSE. Use GetLastError() to determine the cause.
1122 BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
1123 const XFORM *xform2 )
1127 /* Check for illegal parameters */
1128 if (!xformResult || !xform1 || !xform2)
1131 /* Create the result in a temporary XFORM, since xformResult may be
1132 * equal to xform1 or xform2 */
1133 xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1134 xform1->eM12 * xform2->eM21;
1135 xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1136 xform1->eM12 * xform2->eM22;
1137 xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1138 xform1->eM22 * xform2->eM21;
1139 xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1140 xform1->eM22 * xform2->eM22;
1141 xformTemp.eDx = xform1->eDx * xform2->eM11 +
1142 xform1->eDy * xform2->eM21 +
1144 xformTemp.eDy = xform1->eDx * xform2->eM12 +
1145 xform1->eDy * xform2->eM22 +
1148 /* Copy the result to xformResult */
1149 *xformResult = xformTemp;
1155 /***********************************************************************
1156 * SetDCHook (GDI32.@)
1158 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1160 BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD_PTR dwHookData )
1162 DC *dc = get_dc_ptr( hdc );
1164 if (!dc) return FALSE;
1166 dc->dwHookData = dwHookData;
1167 dc->hookProc = hookProc;
1168 release_dc_ptr( dc );
1173 /***********************************************************************
1174 * GetDCHook (GDI32.@)
1176 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1178 DWORD_PTR WINAPI GetDCHook( HDC hdc, DCHOOKPROC *proc )
1180 DC *dc = get_dc_ptr( hdc );
1184 if (proc) *proc = dc->hookProc;
1185 ret = dc->dwHookData;
1186 release_dc_ptr( dc );
1191 /***********************************************************************
1192 * SetHookFlags (GDI32.@)
1194 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1196 WORD WINAPI SetHookFlags( HDC hdc, WORD flags )
1198 DC *dc = get_dc_obj( hdc ); /* not get_dc_ptr, this needs to work from any thread */
1203 /* "Undocumented Windows" info is slightly confusing. */
1205 TRACE("hDC %p, flags %04x\n",hdc,flags);
1207 if (flags & DCHF_INVALIDATEVISRGN)
1208 ret = InterlockedExchange( &dc->dirty, 1 );
1209 else if (flags & DCHF_VALIDATEVISRGN || !flags)
1210 ret = InterlockedExchange( &dc->dirty, 0 );
1212 GDI_ReleaseObj( hdc );
1216 /***********************************************************************
1217 * SetICMMode (GDI32.@)
1219 INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
1221 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1222 if (iEnableICM == ICM_OFF) return ICM_OFF;
1223 if (iEnableICM == ICM_ON) return 0;
1224 if (iEnableICM == ICM_QUERY) return ICM_OFF;
1228 /***********************************************************************
1229 * GetDeviceGammaRamp (GDI32.@)
1231 BOOL WINAPI GetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1234 DC *dc = get_dc_ptr( hDC );
1236 TRACE("%p, %p\n", hDC, ptr);
1239 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceGammaRamp );
1240 ret = physdev->funcs->pGetDeviceGammaRamp( physdev, ptr );
1241 release_dc_ptr( dc );
1246 /***********************************************************************
1247 * SetDeviceGammaRamp (GDI32.@)
1249 BOOL WINAPI SetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1252 DC *dc = get_dc_ptr( hDC );
1254 TRACE("%p, %p\n", hDC, ptr);
1257 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDeviceGammaRamp );
1258 ret = physdev->funcs->pSetDeviceGammaRamp( physdev, ptr );
1259 release_dc_ptr( dc );
1264 /***********************************************************************
1265 * GetColorSpace (GDI32.@)
1267 HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
1269 /*FIXME Need to do whatever GetColorSpace actually does */
1273 /***********************************************************************
1274 * CreateColorSpaceA (GDI32.@)
1276 HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace )
1282 /***********************************************************************
1283 * CreateColorSpaceW (GDI32.@)
1285 HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace )
1291 /***********************************************************************
1292 * DeleteColorSpace (GDI32.@)
1294 BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace )
1301 /***********************************************************************
1302 * SetColorSpace (GDI32.@)
1304 HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace )
1311 /***********************************************************************
1312 * GetBoundsRect (GDI32.@)
1314 UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
1319 DC *dc = get_dc_ptr( hdc );
1321 if ( !dc ) return 0;
1323 physdev = GET_DC_PHYSDEV( dc, pGetBoundsRect );
1324 ret = physdev->funcs->pGetBoundsRect( physdev, &device_rect, DCB_RESET );
1327 release_dc_ptr( dc );
1330 if (dc->bounds_enabled && ret == DCB_SET) add_bounds_rect( &dc->bounds, &device_rect );
1334 if (is_rect_empty( &dc->bounds ))
1336 rect->left = rect->top = rect->right = rect->bottom = 0;
1342 rect->left = max( rect->left, 0 );
1343 rect->top = max( rect->top, 0 );
1344 rect->right = min( rect->right, dc->vis_rect.right - dc->vis_rect.left );
1345 rect->bottom = min( rect->bottom, dc->vis_rect.bottom - dc->vis_rect.top );
1348 DPtoLP( hdc, (POINT *)rect, 2 );
1352 if (flags & DCB_RESET) reset_bounds( &dc->bounds );
1353 release_dc_ptr( dc );
1358 /***********************************************************************
1359 * SetBoundsRect (GDI32.@)
1361 UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
1367 if ((flags & DCB_ENABLE) && (flags & DCB_DISABLE)) return 0;
1368 if (!(dc = get_dc_ptr( hdc ))) return 0;
1370 physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
1371 ret = physdev->funcs->pSetBoundsRect( physdev, &dc->bounds, flags );
1374 release_dc_ptr( dc );
1378 ret = (dc->bounds_enabled ? DCB_ENABLE : DCB_DISABLE) |
1379 (is_rect_empty( &dc->bounds ) ? ret & DCB_SET : DCB_SET);
1381 if (flags & DCB_RESET) reset_bounds( &dc->bounds );
1383 if ((flags & DCB_ACCUMULATE) && rect)
1387 LPtoDP( hdc, (POINT *)&rc, 2 );
1388 add_bounds_rect( &dc->bounds, &rc );
1391 if (flags & DCB_ENABLE) dc->bounds_enabled = TRUE;
1392 if (flags & DCB_DISABLE) dc->bounds_enabled = FALSE;
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)