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 = dc->physDev;
160 dc->physDev = physdev->next;
161 physdev->funcs->pDeleteDC( physdev );
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 update_dc_clipping( dc );
247 SetVirtualResolution( dc->hSelf, 0, 0, 0, 0 );
248 physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
249 physdev->funcs->pSetBoundsRect( physdev, &dc->bounds, dc->bounds_enabled ? DCB_ENABLE : DCB_DISABLE );
253 /***********************************************************************
256 * Computes the inverse of the transformation xformSrc and stores it to
257 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
260 static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
264 determinant = xformSrc->eM11*xformSrc->eM22 -
265 xformSrc->eM12*xformSrc->eM21;
266 if (determinant > -1e-12 && determinant < 1e-12)
269 xformDest->eM11 = xformSrc->eM22 / determinant;
270 xformDest->eM12 = -xformSrc->eM12 / determinant;
271 xformDest->eM21 = -xformSrc->eM21 / determinant;
272 xformDest->eM22 = xformSrc->eM11 / determinant;
273 xformDest->eDx = -xformSrc->eDx * xformDest->eM11 -
274 xformSrc->eDy * xformDest->eM21;
275 xformDest->eDy = -xformSrc->eDx * xformDest->eM12 -
276 xformSrc->eDy * xformDest->eM22;
281 /* Construct a transformation to do the window-to-viewport conversion */
282 static void construct_window_to_viewport(DC *dc, XFORM *xform)
284 double scaleX, scaleY;
285 scaleX = (double)dc->vportExtX / (double)dc->wndExtX;
286 scaleY = (double)dc->vportExtY / (double)dc->wndExtY;
288 if (dc->layout & LAYOUT_RTL) scaleX = -scaleX;
289 xform->eM11 = scaleX;
292 xform->eM22 = scaleY;
293 xform->eDx = (double)dc->vportOrgX - scaleX * (double)dc->wndOrgX;
294 xform->eDy = (double)dc->vportOrgY - scaleY * (double)dc->wndOrgY;
295 if (dc->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx;
298 /***********************************************************************
301 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
302 * fields of the specified DC by creating a transformation that
303 * represents the current mapping mode and combining it with the DC's
304 * world transform. This function should be called whenever the
305 * parameters associated with the mapping mode (window and viewport
306 * extents and origins) or the world transform change.
308 void DC_UpdateXforms( DC *dc )
310 XFORM xformWnd2Vport, oldworld2vport;
312 construct_window_to_viewport(dc, &xformWnd2Vport);
314 oldworld2vport = dc->xformWorld2Vport;
315 /* Combine with the world transformation */
316 CombineTransform( &dc->xformWorld2Vport, &dc->xformWorld2Wnd,
319 /* Create inverse of world-to-viewport transformation */
320 dc->vport2WorldValid = DC_InvertXform( &dc->xformWorld2Vport,
321 &dc->xformVport2World );
323 /* Reselect the font and pen back into the dc so that the size
325 if (memcmp(&oldworld2vport, &dc->xformWorld2Vport, sizeof(oldworld2vport)) &&
326 !GdiIsMetaFileDC(dc->hSelf))
328 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
329 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_PEN));
334 /***********************************************************************
337 INT nulldrv_SaveDC( PHYSDEV dev )
339 DC *newdc, *dc = get_nulldrv_dc( dev );
341 if (!(newdc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc )))) return 0;
342 newdc->layout = dc->layout;
343 newdc->hPen = dc->hPen;
344 newdc->hBrush = dc->hBrush;
345 newdc->hFont = dc->hFont;
346 newdc->hBitmap = dc->hBitmap;
347 newdc->hDevice = dc->hDevice;
348 newdc->hPalette = dc->hPalette;
349 newdc->ROPmode = dc->ROPmode;
350 newdc->polyFillMode = dc->polyFillMode;
351 newdc->stretchBltMode = dc->stretchBltMode;
352 newdc->relAbsMode = dc->relAbsMode;
353 newdc->backgroundMode = dc->backgroundMode;
354 newdc->backgroundColor = dc->backgroundColor;
355 newdc->textColor = dc->textColor;
356 newdc->dcBrushColor = dc->dcBrushColor;
357 newdc->dcPenColor = dc->dcPenColor;
358 newdc->brushOrgX = dc->brushOrgX;
359 newdc->brushOrgY = dc->brushOrgY;
360 newdc->mapperFlags = dc->mapperFlags;
361 newdc->textAlign = dc->textAlign;
362 newdc->charExtra = dc->charExtra;
363 newdc->breakExtra = dc->breakExtra;
364 newdc->breakRem = dc->breakRem;
365 newdc->MapMode = dc->MapMode;
366 newdc->GraphicsMode = dc->GraphicsMode;
367 newdc->CursPosX = dc->CursPosX;
368 newdc->CursPosY = dc->CursPosY;
369 newdc->ArcDirection = dc->ArcDirection;
370 newdc->xformWorld2Wnd = dc->xformWorld2Wnd;
371 newdc->xformWorld2Vport = dc->xformWorld2Vport;
372 newdc->xformVport2World = dc->xformVport2World;
373 newdc->vport2WorldValid = dc->vport2WorldValid;
374 newdc->wndOrgX = dc->wndOrgX;
375 newdc->wndOrgY = dc->wndOrgY;
376 newdc->wndExtX = dc->wndExtX;
377 newdc->wndExtY = dc->wndExtY;
378 newdc->vportOrgX = dc->vportOrgX;
379 newdc->vportOrgY = dc->vportOrgY;
380 newdc->vportExtX = dc->vportExtX;
381 newdc->vportExtY = dc->vportExtY;
382 newdc->virtual_res = dc->virtual_res;
383 newdc->virtual_size = dc->virtual_size;
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 if (!PATH_SavePath( newdc, dc ))
401 release_dc_ptr( dc );
402 free_dc_state( newdc );
406 newdc->saved_dc = dc->saved_dc;
407 dc->saved_dc = newdc;
408 return ++dc->saveLevel;
412 /***********************************************************************
415 BOOL nulldrv_RestoreDC( PHYSDEV dev, INT level )
417 DC *dcs, *first_dcs, *dc = get_nulldrv_dc( dev );
420 /* find the state level to restore */
422 if (abs(level) > dc->saveLevel || level == 0) return FALSE;
423 if (level < 0) level = dc->saveLevel + level + 1;
424 first_dcs = dc->saved_dc;
425 for (dcs = first_dcs, save_level = dc->saveLevel; save_level > level; save_level--)
428 /* restore the state */
430 if (!PATH_RestorePath( dc, dcs )) return FALSE;
432 dc->layout = dcs->layout;
433 dc->hDevice = dcs->hDevice;
434 dc->ROPmode = dcs->ROPmode;
435 dc->polyFillMode = dcs->polyFillMode;
436 dc->stretchBltMode = dcs->stretchBltMode;
437 dc->relAbsMode = dcs->relAbsMode;
438 dc->backgroundMode = dcs->backgroundMode;
439 dc->backgroundColor = dcs->backgroundColor;
440 dc->textColor = dcs->textColor;
441 dc->dcBrushColor = dcs->dcBrushColor;
442 dc->dcPenColor = dcs->dcPenColor;
443 dc->brushOrgX = dcs->brushOrgX;
444 dc->brushOrgY = dcs->brushOrgY;
445 dc->mapperFlags = dcs->mapperFlags;
446 dc->textAlign = dcs->textAlign;
447 dc->charExtra = dcs->charExtra;
448 dc->breakExtra = dcs->breakExtra;
449 dc->breakRem = dcs->breakRem;
450 dc->MapMode = dcs->MapMode;
451 dc->GraphicsMode = dcs->GraphicsMode;
452 dc->CursPosX = dcs->CursPosX;
453 dc->CursPosY = dcs->CursPosY;
454 dc->ArcDirection = dcs->ArcDirection;
455 dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
456 dc->xformWorld2Vport = dcs->xformWorld2Vport;
457 dc->xformVport2World = dcs->xformVport2World;
458 dc->vport2WorldValid = dcs->vport2WorldValid;
459 dc->wndOrgX = dcs->wndOrgX;
460 dc->wndOrgY = dcs->wndOrgY;
461 dc->wndExtX = dcs->wndExtX;
462 dc->wndExtY = dcs->wndExtY;
463 dc->vportOrgX = dcs->vportOrgX;
464 dc->vportOrgY = dcs->vportOrgY;
465 dc->vportExtX = dcs->vportExtX;
466 dc->vportExtY = dcs->vportExtY;
467 dc->virtual_res = dcs->virtual_res;
468 dc->virtual_size = dcs->virtual_size;
472 if (!dc->hClipRgn) dc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
473 CombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
477 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
482 if (!dc->hMetaRgn) dc->hMetaRgn = CreateRectRgn( 0, 0, 0, 0 );
483 CombineRgn( dc->hMetaRgn, dcs->hMetaRgn, 0, RGN_COPY );
487 if (dc->hMetaRgn) DeleteObject( dc->hMetaRgn );
490 DC_UpdateXforms( dc );
491 update_dc_clipping( dc );
493 SelectObject( dev->hdc, dcs->hBitmap );
494 SelectObject( dev->hdc, dcs->hBrush );
495 SelectObject( dev->hdc, dcs->hFont );
496 SelectObject( dev->hdc, dcs->hPen );
497 SetBkColor( dev->hdc, dcs->backgroundColor);
498 SetTextColor( dev->hdc, dcs->textColor);
499 GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
501 dc->saved_dc = dcs->saved_dc;
503 dc->saveLevel = save_level - 1;
505 /* now destroy all the saved DCs */
509 DC *next = first_dcs->saved_dc;
510 free_dc_state( first_dcs );
517 /***********************************************************************
520 INT WINAPI SaveDC( HDC hdc )
525 if ((dc = get_dc_ptr( hdc )))
527 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSaveDC );
528 ret = physdev->funcs->pSaveDC( physdev );
529 release_dc_ptr( dc );
535 /***********************************************************************
536 * RestoreDC (GDI32.@)
538 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 )))
548 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;
701 dc->device_rect = dc->vis_rect;
705 if (!funcs->pCreateCompatibleDC( physDev, &dc->physDev ))
707 WARN("creation aborted by device\n");
712 if (!dib_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
717 physDev = GET_DC_PHYSDEV( dc, pSelectBitmap );
718 physDev->funcs->pSelectBitmap( physDev, dc->hBitmap );
721 release_dc_ptr( dc );
726 /***********************************************************************
729 BOOL WINAPI DeleteDC( HDC hdc )
737 if (!(dc = get_dc_ptr( hdc ))) return FALSE;
738 if (dc->refcount != 1)
740 FIXME( "not deleting busy DC %p refcount %u\n", dc->hSelf, dc->refcount );
741 release_dc_ptr( dc );
745 /* Call hook procedure to check whether is it OK to delete this DC */
746 if (dc->hookProc && !dc->hookProc( hdc, DCHC_DELETEDC, dc->dwHookData, 0 ))
748 release_dc_ptr( dc );
752 while (dc->saveLevel)
754 DC *dcs = dc->saved_dc;
755 dc->saved_dc = dcs->saved_dc;
757 free_dc_state( dcs );
761 SelectObject( hdc, GetStockObject(BLACK_PEN) );
762 SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
763 SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
764 SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
771 /***********************************************************************
774 HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
779 if ((dc = get_dc_ptr( hdc )))
781 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pResetDC );
782 ret = physdev->funcs->pResetDC( physdev, devmode );
783 if (ret) /* reset the visible region */
786 dc->vis_rect.left = 0;
787 dc->vis_rect.top = 0;
788 dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
789 dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
790 if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
792 update_dc_clipping( dc );
794 release_dc_ptr( dc );
800 /***********************************************************************
803 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
808 if (devmode) devmodeW = GdiConvertToDevmodeW(devmode);
809 else devmodeW = NULL;
811 ret = ResetDCW(hdc, devmodeW);
813 HeapFree(GetProcessHeap(), 0, devmodeW);
818 /***********************************************************************
819 * GetDeviceCaps (GDI32.@)
821 INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
826 if ((dc = get_dc_ptr( hdc )))
828 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceCaps );
829 ret = physdev->funcs->pGetDeviceCaps( physdev, cap );
830 release_dc_ptr( dc );
836 /***********************************************************************
837 * GetBkColor (GDI32.@)
839 COLORREF WINAPI GetBkColor( HDC hdc )
842 DC * dc = get_dc_ptr( hdc );
845 ret = dc->backgroundColor;
846 release_dc_ptr( dc );
852 /***********************************************************************
853 * SetBkColor (GDI32.@)
855 COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
857 COLORREF ret = CLR_INVALID;
858 DC * dc = get_dc_ptr( hdc );
860 TRACE("hdc=%p color=0x%08x\n", hdc, color);
864 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
865 ret = dc->backgroundColor;
866 dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color );
867 release_dc_ptr( dc );
873 /***********************************************************************
874 * GetTextColor (GDI32.@)
876 COLORREF WINAPI GetTextColor( HDC hdc )
879 DC * dc = get_dc_ptr( hdc );
883 release_dc_ptr( dc );
889 /***********************************************************************
890 * SetTextColor (GDI32.@)
892 COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
894 COLORREF ret = CLR_INVALID;
895 DC * dc = get_dc_ptr( hdc );
897 TRACE(" hdc=%p color=0x%08x\n", hdc, color);
901 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor );
903 dc->textColor = physdev->funcs->pSetTextColor( physdev, color );
904 release_dc_ptr( dc );
910 /***********************************************************************
911 * GetTextAlign (GDI32.@)
913 UINT WINAPI GetTextAlign( HDC hdc )
916 DC * dc = get_dc_ptr( hdc );
920 release_dc_ptr( dc );
926 /***********************************************************************
927 * SetTextAlign (GDI32.@)
929 UINT WINAPI SetTextAlign( HDC hdc, UINT align )
931 UINT ret = GDI_ERROR;
932 DC *dc = get_dc_ptr( hdc );
934 TRACE("hdc=%p align=%d\n", hdc, align);
938 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextAlign );
939 align = physdev->funcs->pSetTextAlign( physdev, align );
940 if (align != GDI_ERROR)
943 dc->textAlign = align;
945 release_dc_ptr( dc );
950 /***********************************************************************
951 * GetDCOrgEx (GDI32.@)
953 BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
957 if (!lpp) return FALSE;
958 if (!(dc = get_dc_ptr( hDC ))) return FALSE;
959 lpp->x = dc->vis_rect.left;
960 lpp->y = dc->vis_rect.top;
961 release_dc_ptr( dc );
966 /***********************************************************************
967 * GetGraphicsMode (GDI32.@)
969 INT WINAPI GetGraphicsMode( HDC hdc )
972 DC * dc = get_dc_ptr( hdc );
975 ret = dc->GraphicsMode;
976 release_dc_ptr( dc );
982 /***********************************************************************
983 * SetGraphicsMode (GDI32.@)
985 INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
988 DC *dc = get_dc_ptr( hdc );
990 /* One would think that setting the graphics mode to GM_COMPATIBLE
991 * would also reset the world transformation matrix to the unity
992 * matrix. However, in Windows, this is not the case. This doesn't
993 * make a lot of sense to me, but that's the way it is.
996 if ((mode > 0) && (mode <= GM_LAST))
998 ret = dc->GraphicsMode;
999 dc->GraphicsMode = mode;
1001 release_dc_ptr( dc );
1006 /***********************************************************************
1007 * GetArcDirection (GDI32.@)
1009 INT WINAPI GetArcDirection( HDC hdc )
1012 DC * dc = get_dc_ptr( hdc );
1015 ret = dc->ArcDirection;
1016 release_dc_ptr( dc );
1022 /***********************************************************************
1023 * SetArcDirection (GDI32.@)
1025 INT WINAPI SetArcDirection( HDC hdc, INT dir )
1030 if (dir != AD_COUNTERCLOCKWISE && dir != AD_CLOCKWISE)
1032 SetLastError(ERROR_INVALID_PARAMETER);
1036 if ((dc = get_dc_ptr( hdc )))
1038 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetArcDirection );
1039 dir = physdev->funcs->pSetArcDirection( physdev, dir );
1042 ret = dc->ArcDirection;
1043 dc->ArcDirection = dir;
1045 release_dc_ptr( dc );
1051 /***********************************************************************
1052 * GetWorldTransform (GDI32.@)
1054 BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
1057 if (!xform) return FALSE;
1058 if (!(dc = get_dc_ptr( hdc ))) return FALSE;
1059 *xform = dc->xformWorld2Wnd;
1060 release_dc_ptr( dc );
1065 /***********************************************************************
1066 * GetTransform (GDI32.@)
1070 * Returns one of the co-ordinate space transforms
1073 * hdc [I] Device context.
1074 * which [I] Which xform to return:
1075 * 0x203 World -> Page transform (that set by SetWorldTransform).
1076 * 0x304 Page -> Device transform (the mapping mode transform).
1077 * 0x204 World -> Device transform (the combination of the above two).
1078 * 0x402 Device -> World transform (the inversion of the above).
1079 * xform [O] The xform.
1082 BOOL WINAPI GetTransform( HDC hdc, DWORD which, XFORM *xform )
1085 DC *dc = get_dc_ptr( hdc );
1086 if (!dc) return FALSE;
1091 *xform = dc->xformWorld2Wnd;
1095 construct_window_to_viewport(dc, xform);
1099 *xform = dc->xformWorld2Vport;
1103 *xform = dc->xformVport2World;
1107 FIXME("Unknown code %x\n", which);
1111 release_dc_ptr( dc );
1116 /****************************************************************************
1117 * CombineTransform [GDI32.@]
1118 * Combines two transformation matrices.
1121 * xformResult [O] Stores the result of combining the two matrices
1122 * xform1 [I] Specifies the first matrix to apply
1123 * xform2 [I] Specifies the second matrix to apply
1126 * The same matrix can be passed in for more than one of the parameters.
1130 * Failure: FALSE. Use GetLastError() to determine the cause.
1132 BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
1133 const XFORM *xform2 )
1137 /* Check for illegal parameters */
1138 if (!xformResult || !xform1 || !xform2)
1141 /* Create the result in a temporary XFORM, since xformResult may be
1142 * equal to xform1 or xform2 */
1143 xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1144 xform1->eM12 * xform2->eM21;
1145 xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1146 xform1->eM12 * xform2->eM22;
1147 xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1148 xform1->eM22 * xform2->eM21;
1149 xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1150 xform1->eM22 * xform2->eM22;
1151 xformTemp.eDx = xform1->eDx * xform2->eM11 +
1152 xform1->eDy * xform2->eM21 +
1154 xformTemp.eDy = xform1->eDx * xform2->eM12 +
1155 xform1->eDy * xform2->eM22 +
1158 /* Copy the result to xformResult */
1159 *xformResult = xformTemp;
1165 /***********************************************************************
1166 * SetDCHook (GDI32.@)
1168 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1170 BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD_PTR dwHookData )
1172 DC *dc = get_dc_ptr( hdc );
1174 if (!dc) return FALSE;
1176 dc->dwHookData = dwHookData;
1177 dc->hookProc = hookProc;
1178 release_dc_ptr( dc );
1183 /***********************************************************************
1184 * GetDCHook (GDI32.@)
1186 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1188 DWORD_PTR WINAPI GetDCHook( HDC hdc, DCHOOKPROC *proc )
1190 DC *dc = get_dc_ptr( hdc );
1194 if (proc) *proc = dc->hookProc;
1195 ret = dc->dwHookData;
1196 release_dc_ptr( dc );
1201 /***********************************************************************
1202 * SetHookFlags (GDI32.@)
1204 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1206 WORD WINAPI SetHookFlags( HDC hdc, WORD flags )
1208 DC *dc = get_dc_obj( hdc ); /* not get_dc_ptr, this needs to work from any thread */
1213 /* "Undocumented Windows" info is slightly confusing. */
1215 TRACE("hDC %p, flags %04x\n",hdc,flags);
1217 if (flags & DCHF_INVALIDATEVISRGN)
1218 ret = InterlockedExchange( &dc->dirty, 1 );
1219 else if (flags & DCHF_VALIDATEVISRGN || !flags)
1220 ret = InterlockedExchange( &dc->dirty, 0 );
1222 GDI_ReleaseObj( hdc );
1226 /***********************************************************************
1227 * SetICMMode (GDI32.@)
1229 INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
1231 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1232 if (iEnableICM == ICM_OFF) return ICM_OFF;
1233 if (iEnableICM == ICM_ON) return 0;
1234 if (iEnableICM == ICM_QUERY) return ICM_OFF;
1238 /***********************************************************************
1239 * GetDeviceGammaRamp (GDI32.@)
1241 BOOL WINAPI GetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1244 DC *dc = get_dc_ptr( hDC );
1246 TRACE("%p, %p\n", hDC, ptr);
1249 if (GetObjectType( hDC ) != OBJ_MEMDC)
1251 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceGammaRamp );
1252 ret = physdev->funcs->pGetDeviceGammaRamp( physdev, ptr );
1254 else SetLastError( ERROR_INVALID_PARAMETER );
1255 release_dc_ptr( dc );
1260 /***********************************************************************
1261 * SetDeviceGammaRamp (GDI32.@)
1263 BOOL WINAPI SetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1266 DC *dc = get_dc_ptr( hDC );
1268 TRACE("%p, %p\n", hDC, ptr);
1271 if (GetObjectType( hDC ) != OBJ_MEMDC)
1273 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDeviceGammaRamp );
1274 ret = physdev->funcs->pSetDeviceGammaRamp( physdev, ptr );
1276 else SetLastError( ERROR_INVALID_PARAMETER );
1277 release_dc_ptr( dc );
1282 /***********************************************************************
1283 * GetColorSpace (GDI32.@)
1285 HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
1287 /*FIXME Need to do whatever GetColorSpace actually does */
1291 /***********************************************************************
1292 * CreateColorSpaceA (GDI32.@)
1294 HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace )
1300 /***********************************************************************
1301 * CreateColorSpaceW (GDI32.@)
1303 HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace )
1309 /***********************************************************************
1310 * DeleteColorSpace (GDI32.@)
1312 BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace )
1319 /***********************************************************************
1320 * SetColorSpace (GDI32.@)
1322 HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace )
1329 /***********************************************************************
1330 * GetBoundsRect (GDI32.@)
1332 UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
1337 DC *dc = get_dc_ptr( hdc );
1339 if ( !dc ) return 0;
1341 physdev = GET_DC_PHYSDEV( dc, pGetBoundsRect );
1342 ret = physdev->funcs->pGetBoundsRect( physdev, &device_rect, DCB_RESET );
1345 release_dc_ptr( dc );
1348 if (dc->bounds_enabled && ret == DCB_SET) add_bounds_rect( &dc->bounds, &device_rect );
1352 if (is_rect_empty( &dc->bounds ))
1354 rect->left = rect->top = rect->right = rect->bottom = 0;
1360 rect->left = max( rect->left, 0 );
1361 rect->top = max( rect->top, 0 );
1362 rect->right = min( rect->right, dc->vis_rect.right - dc->vis_rect.left );
1363 rect->bottom = min( rect->bottom, dc->vis_rect.bottom - dc->vis_rect.top );
1366 DPtoLP( hdc, (POINT *)rect, 2 );
1370 if (flags & DCB_RESET) reset_bounds( &dc->bounds );
1371 release_dc_ptr( dc );
1376 /***********************************************************************
1377 * SetBoundsRect (GDI32.@)
1379 UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
1385 if ((flags & DCB_ENABLE) && (flags & DCB_DISABLE)) return 0;
1386 if (!(dc = get_dc_ptr( hdc ))) return 0;
1388 physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
1389 ret = physdev->funcs->pSetBoundsRect( physdev, &dc->bounds, flags );
1392 release_dc_ptr( dc );
1396 ret = (dc->bounds_enabled ? DCB_ENABLE : DCB_DISABLE) |
1397 (is_rect_empty( &dc->bounds ) ? ret & DCB_SET : DCB_SET);
1399 if (flags & DCB_RESET) reset_bounds( &dc->bounds );
1401 if ((flags & DCB_ACCUMULATE) && rect)
1405 LPtoDP( hdc, (POINT *)&rc, 2 );
1406 add_bounds_rect( &dc->bounds, &rc );
1409 if (flags & DCB_ENABLE) dc->bounds_enabled = TRUE;
1410 if (flags & DCB_DISABLE) dc->bounds_enabled = FALSE;
1412 release_dc_ptr( dc );
1417 /***********************************************************************
1418 * GetRelAbs (GDI32.@)
1420 INT WINAPI GetRelAbs( HDC hdc, DWORD dwIgnore )
1423 DC *dc = get_dc_ptr( hdc );
1426 ret = dc->relAbsMode;
1427 release_dc_ptr( dc );
1435 /***********************************************************************
1436 * GetBkMode (GDI32.@)
1438 INT WINAPI GetBkMode( HDC hdc )
1441 DC * dc = get_dc_ptr( hdc );
1444 ret = dc->backgroundMode;
1445 release_dc_ptr( dc );
1451 /***********************************************************************
1452 * SetBkMode (GDI32.@)
1454 INT WINAPI SetBkMode( HDC hdc, INT mode )
1459 if ((mode <= 0) || (mode > BKMODE_LAST))
1461 SetLastError(ERROR_INVALID_PARAMETER);
1464 if ((dc = get_dc_ptr( hdc )))
1466 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkMode );
1467 mode = physdev->funcs->pSetBkMode( physdev, mode );
1470 ret = dc->backgroundMode;
1471 dc->backgroundMode = mode;
1473 release_dc_ptr( dc );
1479 /***********************************************************************
1482 INT WINAPI GetROP2( HDC hdc )
1485 DC * dc = get_dc_ptr( hdc );
1489 release_dc_ptr( dc );
1495 /***********************************************************************
1498 INT WINAPI SetROP2( HDC hdc, INT mode )
1503 if ((mode < R2_BLACK) || (mode > R2_WHITE))
1505 SetLastError(ERROR_INVALID_PARAMETER);
1508 if ((dc = get_dc_ptr( hdc )))
1510 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetROP2 );
1511 mode = physdev->funcs->pSetROP2( physdev, mode );
1517 release_dc_ptr( dc );
1523 /***********************************************************************
1524 * SetRelAbs (GDI32.@)
1526 INT WINAPI SetRelAbs( HDC hdc, INT mode )
1531 if ((mode != ABSOLUTE) && (mode != RELATIVE))
1533 SetLastError(ERROR_INVALID_PARAMETER);
1536 if ((dc = get_dc_ptr( hdc )))
1538 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetRelAbs );
1539 mode = physdev->funcs->pSetRelAbs( physdev, mode );
1542 ret = dc->relAbsMode;
1543 dc->relAbsMode = mode;
1545 release_dc_ptr( dc );
1551 /***********************************************************************
1552 * GetPolyFillMode (GDI32.@)
1554 INT WINAPI GetPolyFillMode( HDC hdc )
1557 DC * dc = get_dc_ptr( hdc );
1560 ret = dc->polyFillMode;
1561 release_dc_ptr( dc );
1567 /***********************************************************************
1568 * SetPolyFillMode (GDI32.@)
1570 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
1575 if ((mode <= 0) || (mode > POLYFILL_LAST))
1577 SetLastError(ERROR_INVALID_PARAMETER);
1580 if ((dc = get_dc_ptr( hdc )))
1582 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetPolyFillMode );
1583 mode = physdev->funcs->pSetPolyFillMode( physdev, mode );
1586 ret = dc->polyFillMode;
1587 dc->polyFillMode = mode;
1589 release_dc_ptr( dc );
1595 /***********************************************************************
1596 * GetStretchBltMode (GDI32.@)
1598 INT WINAPI GetStretchBltMode( HDC hdc )
1601 DC * dc = get_dc_ptr( hdc );
1604 ret = dc->stretchBltMode;
1605 release_dc_ptr( dc );
1611 /***********************************************************************
1612 * SetStretchBltMode (GDI32.@)
1614 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
1619 if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
1621 SetLastError(ERROR_INVALID_PARAMETER);
1624 if ((dc = get_dc_ptr( hdc )))
1626 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetStretchBltMode );
1627 mode = physdev->funcs->pSetStretchBltMode( physdev, mode );
1630 ret = dc->stretchBltMode;
1631 dc->stretchBltMode = mode;
1633 release_dc_ptr( dc );
1639 /***********************************************************************
1640 * GetMapMode (GDI32.@)
1642 INT WINAPI GetMapMode( HDC hdc )
1645 DC * dc = get_dc_ptr( hdc );
1649 release_dc_ptr( dc );
1655 /***********************************************************************
1656 * GetBrushOrgEx (GDI32.@)
1658 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
1660 DC * dc = get_dc_ptr( hdc );
1661 if (!dc) return FALSE;
1662 pt->x = dc->brushOrgX;
1663 pt->y = dc->brushOrgY;
1664 release_dc_ptr( dc );
1669 /***********************************************************************
1670 * GetCurrentPositionEx (GDI32.@)
1672 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
1674 DC * dc = get_dc_ptr( hdc );
1675 if (!dc) return FALSE;
1676 pt->x = dc->CursPosX;
1677 pt->y = dc->CursPosY;
1678 release_dc_ptr( dc );
1683 /***********************************************************************
1684 * GetViewportExtEx (GDI32.@)
1686 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
1688 DC * dc = get_dc_ptr( hdc );
1689 if (!dc) return FALSE;
1690 size->cx = dc->vportExtX;
1691 size->cy = dc->vportExtY;
1692 release_dc_ptr( dc );
1697 /***********************************************************************
1698 * GetViewportOrgEx (GDI32.@)
1700 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
1702 DC * dc = get_dc_ptr( hdc );
1703 if (!dc) return FALSE;
1704 pt->x = dc->vportOrgX;
1705 pt->y = dc->vportOrgY;
1706 release_dc_ptr( dc );
1711 /***********************************************************************
1712 * GetWindowExtEx (GDI32.@)
1714 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
1716 DC * dc = get_dc_ptr( hdc );
1717 if (!dc) return FALSE;
1718 size->cx = dc->wndExtX;
1719 size->cy = dc->wndExtY;
1720 release_dc_ptr( dc );
1725 /***********************************************************************
1726 * GetWindowOrgEx (GDI32.@)
1728 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
1730 DC * dc = get_dc_ptr( hdc );
1731 if (!dc) return FALSE;
1732 pt->x = dc->wndOrgX;
1733 pt->y = dc->wndOrgY;
1734 release_dc_ptr( dc );
1739 /***********************************************************************
1740 * GetLayout (GDI32.@)
1742 * Gets left->right or right->left text layout flags of a dc.
1745 DWORD WINAPI GetLayout(HDC hdc)
1747 DWORD layout = GDI_ERROR;
1749 DC * dc = get_dc_ptr( hdc );
1752 layout = dc->layout;
1753 release_dc_ptr( dc );
1756 TRACE("hdc : %p, layout : %08x\n", hdc, layout);
1761 /***********************************************************************
1762 * SetLayout (GDI32.@)
1764 * Sets left->right or right->left text layout flags of a dc.
1767 DWORD WINAPI SetLayout(HDC hdc, DWORD layout)
1769 DWORD oldlayout = GDI_ERROR;
1771 DC * dc = get_dc_ptr( hdc );
1774 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetLayout );
1775 layout = physdev->funcs->pSetLayout( physdev, layout );
1776 if (layout != GDI_ERROR)
1778 oldlayout = dc->layout;
1779 dc->layout = layout;
1780 if (layout != oldlayout)
1782 if (layout & LAYOUT_RTL) dc->MapMode = MM_ANISOTROPIC;
1783 DC_UpdateXforms( dc );
1786 release_dc_ptr( dc );
1789 TRACE("hdc : %p, old layout : %08x, new layout : %08x\n", hdc, oldlayout, layout);
1794 /***********************************************************************
1795 * GetDCBrushColor (GDI32.@)
1797 COLORREF WINAPI GetDCBrushColor(HDC hdc)
1800 COLORREF dcBrushColor = CLR_INVALID;
1802 TRACE("hdc(%p)\n", hdc);
1804 dc = get_dc_ptr( hdc );
1807 dcBrushColor = dc->dcBrushColor;
1808 release_dc_ptr( dc );
1811 return dcBrushColor;
1814 /***********************************************************************
1815 * SetDCBrushColor (GDI32.@)
1817 COLORREF WINAPI SetDCBrushColor(HDC hdc, COLORREF crColor)
1820 COLORREF oldClr = CLR_INVALID;
1822 TRACE("hdc(%p) crColor(%08x)\n", hdc, crColor);
1824 dc = get_dc_ptr( hdc );
1827 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDCBrushColor );
1828 crColor = physdev->funcs->pSetDCBrushColor( physdev, crColor );
1829 if (crColor != CLR_INVALID)
1831 oldClr = dc->dcBrushColor;
1832 dc->dcBrushColor = crColor;
1834 release_dc_ptr( dc );
1840 /***********************************************************************
1841 * GetDCPenColor (GDI32.@)
1843 COLORREF WINAPI GetDCPenColor(HDC hdc)
1846 COLORREF dcPenColor = CLR_INVALID;
1848 TRACE("hdc(%p)\n", hdc);
1850 dc = get_dc_ptr( hdc );
1853 dcPenColor = dc->dcPenColor;
1854 release_dc_ptr( dc );
1860 /***********************************************************************
1861 * SetDCPenColor (GDI32.@)
1863 COLORREF WINAPI SetDCPenColor(HDC hdc, COLORREF crColor)
1866 COLORREF oldClr = CLR_INVALID;
1868 TRACE("hdc(%p) crColor(%08x)\n", hdc, crColor);
1870 dc = get_dc_ptr( hdc );
1873 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDCPenColor );
1874 crColor = physdev->funcs->pSetDCPenColor( physdev, crColor );
1875 if (crColor != CLR_INVALID)
1877 oldClr = dc->dcPenColor;
1878 dc->dcPenColor = crColor;
1880 release_dc_ptr( dc );
1886 /***********************************************************************
1887 * CancelDC (GDI32.@)
1889 BOOL WINAPI CancelDC(HDC hdc)
1895 /*******************************************************************
1896 * GetMiterLimit [GDI32.@]
1900 BOOL WINAPI GetMiterLimit(HDC hdc, PFLOAT peLimit)
1905 TRACE("(%p,%p)\n", hdc, peLimit);
1907 dc = get_dc_ptr( hdc );
1911 *peLimit = dc->miterLimit;
1913 release_dc_ptr( dc );
1919 /*******************************************************************
1920 * SetMiterLimit [GDI32.@]
1924 BOOL WINAPI SetMiterLimit(HDC hdc, FLOAT eNewLimit, PFLOAT peOldLimit)
1929 TRACE("(%p,%f,%p)\n", hdc, eNewLimit, peOldLimit);
1931 dc = get_dc_ptr( hdc );
1935 *peOldLimit = dc->miterLimit;
1936 dc->miterLimit = eNewLimit;
1937 release_dc_ptr( dc );
1943 /*******************************************************************
1944 * GdiIsMetaPrintDC [GDI32.@]
1946 BOOL WINAPI GdiIsMetaPrintDC(HDC hdc)
1952 /*******************************************************************
1953 * GdiIsMetaFileDC [GDI32.@]
1955 BOOL WINAPI GdiIsMetaFileDC(HDC hdc)
1959 switch( GetObjectType( hdc ) )
1968 /*******************************************************************
1969 * GdiIsPlayMetafileDC [GDI32.@]
1971 BOOL WINAPI GdiIsPlayMetafileDC(HDC hdc)