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 switch (GetObjectType( hdc ))
66 GDI_ReleaseObj( hdc );
67 SetLastError( ERROR_INVALID_HANDLE );
73 /***********************************************************************
76 DC *alloc_dc_ptr( WORD magic )
80 if (!(dc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dc) ))) return NULL;
82 dc->nulldrv.funcs = &null_driver;
83 dc->physDev = &dc->nulldrv;
84 dc->thread = GetCurrentThreadId();
90 dc->miterLimit = 10.0f; /* 10.0 is the default, from MSDN */
91 dc->hPen = GDI_inc_ref_count( GetStockObject( BLACK_PEN ));
92 dc->hBrush = GDI_inc_ref_count( GetStockObject( WHITE_BRUSH ));
93 dc->hFont = GDI_inc_ref_count( GetStockObject( SYSTEM_FONT ));
94 dc->hPalette = GetStockObject( DEFAULT_PALETTE );
95 dc->font_code_page = CP_ACP;
96 dc->ROPmode = R2_COPYPEN;
97 dc->polyFillMode = ALTERNATE;
98 dc->stretchBltMode = BLACKONWHITE;
99 dc->relAbsMode = ABSOLUTE;
100 dc->backgroundMode = OPAQUE;
101 dc->backgroundColor = RGB( 255, 255, 255 );
102 dc->dcBrushColor = RGB( 255, 255, 255 );
103 dc->dcPenColor = RGB( 0, 0, 0 );
104 dc->textColor = RGB( 0, 0, 0 );
105 dc->textAlign = TA_LEFT | TA_TOP | TA_NOUPDATECP;
106 dc->MapMode = MM_TEXT;
107 dc->GraphicsMode = GM_COMPATIBLE;
108 dc->ArcDirection = AD_COUNTERCLOCKWISE;
109 dc->xformWorld2Wnd.eM11 = 1.0f;
110 dc->xformWorld2Wnd.eM12 = 0.0f;
111 dc->xformWorld2Wnd.eM21 = 0.0f;
112 dc->xformWorld2Wnd.eM22 = 1.0f;
113 dc->xformWorld2Wnd.eDx = 0.0f;
114 dc->xformWorld2Wnd.eDy = 0.0f;
115 dc->xformWorld2Vport = dc->xformWorld2Wnd;
116 dc->xformVport2World = dc->xformWorld2Wnd;
117 dc->vport2WorldValid = TRUE;
119 reset_bounds( &dc->bounds );
121 if (!(dc->hSelf = alloc_gdi_handle( dc, magic, &dc_funcs )))
123 HeapFree( GetProcessHeap(), 0, dc );
126 dc->nulldrv.hdc = dc->hSelf;
128 if (font_driver && !font_driver->pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
138 /***********************************************************************
141 static void free_dc_state( DC *dc )
143 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
144 if (dc->hMetaRgn) DeleteObject( dc->hMetaRgn );
145 if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
146 if (dc->region) DeleteObject( dc->region );
147 if (dc->path) free_gdi_path( dc->path );
148 HeapFree( GetProcessHeap(), 0, dc );
152 /***********************************************************************
155 void free_dc_ptr( DC *dc )
157 assert( dc->refcount == 1 );
159 while (dc->physDev != &dc->nulldrv)
161 PHYSDEV physdev = dc->physDev;
162 dc->physDev = physdev->next;
163 physdev->funcs->pDeleteDC( physdev );
165 GDI_dec_ref_count( dc->hPen );
166 GDI_dec_ref_count( dc->hBrush );
167 GDI_dec_ref_count( dc->hFont );
168 if (dc->hBitmap) GDI_dec_ref_count( dc->hBitmap );
169 free_gdi_handle( dc->hSelf );
174 /***********************************************************************
177 * Retrieve a DC pointer but release the GDI lock.
179 DC *get_dc_ptr( HDC hdc )
181 DC *dc = get_dc_obj( hdc );
182 if (!dc) return NULL;
184 if (!InterlockedCompareExchange( &dc->refcount, 1, 0 ))
186 dc->thread = GetCurrentThreadId();
188 else if (dc->thread != GetCurrentThreadId())
190 WARN( "dc %p belongs to thread %04x\n", hdc, dc->thread );
191 GDI_ReleaseObj( hdc );
194 else InterlockedIncrement( &dc->refcount );
196 GDI_ReleaseObj( hdc );
201 /***********************************************************************
204 void release_dc_ptr( DC *dc )
209 ref = InterlockedDecrement( &dc->refcount );
211 if (ref) dc->thread = GetCurrentThreadId(); /* we still own it */
215 /***********************************************************************
218 * Make sure the DC vis region is up to date.
219 * This function may call up to USER so the GDI lock should _not_
220 * be held when calling it.
222 void update_dc( DC *dc )
224 if (InterlockedExchange( &dc->dirty, 0 ) && dc->hookProc)
225 dc->hookProc( dc->hSelf, DCHC_INVALIDVISRGN, dc->dwHookData, 0 );
229 /***********************************************************************
232 static BOOL DC_DeleteObject( HGDIOBJ handle )
234 return DeleteDC( handle );
238 /***********************************************************************
241 * Setup device-specific DC values for a newly created DC.
243 void DC_InitDC( DC* dc )
245 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette );
246 physdev->funcs->pRealizeDefaultPalette( physdev );
247 SetTextColor( dc->hSelf, dc->textColor );
248 SetBkColor( dc->hSelf, dc->backgroundColor );
249 SelectObject( dc->hSelf, dc->hPen );
250 SelectObject( dc->hSelf, dc->hBrush );
251 SelectObject( dc->hSelf, dc->hFont );
252 update_dc_clipping( dc );
253 SetVirtualResolution( dc->hSelf, 0, 0, 0, 0 );
254 physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
255 physdev->funcs->pSetBoundsRect( physdev, &dc->bounds, dc->bounds_enabled ? DCB_ENABLE : DCB_DISABLE );
259 /***********************************************************************
262 * Computes the inverse of the transformation xformSrc and stores it to
263 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
266 static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
270 determinant = xformSrc->eM11*xformSrc->eM22 -
271 xformSrc->eM12*xformSrc->eM21;
272 if (determinant > -1e-12 && determinant < 1e-12)
275 xformDest->eM11 = xformSrc->eM22 / determinant;
276 xformDest->eM12 = -xformSrc->eM12 / determinant;
277 xformDest->eM21 = -xformSrc->eM21 / determinant;
278 xformDest->eM22 = xformSrc->eM11 / determinant;
279 xformDest->eDx = -xformSrc->eDx * xformDest->eM11 -
280 xformSrc->eDy * xformDest->eM21;
281 xformDest->eDy = -xformSrc->eDx * xformDest->eM12 -
282 xformSrc->eDy * xformDest->eM22;
287 /* Construct a transformation to do the window-to-viewport conversion */
288 static void construct_window_to_viewport(DC *dc, XFORM *xform)
290 double scaleX, scaleY;
291 scaleX = (double)dc->vportExtX / (double)dc->wndExtX;
292 scaleY = (double)dc->vportExtY / (double)dc->wndExtY;
294 if (dc->layout & LAYOUT_RTL) scaleX = -scaleX;
295 xform->eM11 = scaleX;
298 xform->eM22 = scaleY;
299 xform->eDx = (double)dc->vportOrgX - scaleX * (double)dc->wndOrgX;
300 xform->eDy = (double)dc->vportOrgY - scaleY * (double)dc->wndOrgY;
301 if (dc->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx;
304 /***********************************************************************
307 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
308 * fields of the specified DC by creating a transformation that
309 * represents the current mapping mode and combining it with the DC's
310 * world transform. This function should be called whenever the
311 * parameters associated with the mapping mode (window and viewport
312 * extents and origins) or the world transform change.
314 void DC_UpdateXforms( DC *dc )
316 XFORM xformWnd2Vport, oldworld2vport;
318 construct_window_to_viewport(dc, &xformWnd2Vport);
320 oldworld2vport = dc->xformWorld2Vport;
321 /* Combine with the world transformation */
322 CombineTransform( &dc->xformWorld2Vport, &dc->xformWorld2Wnd,
325 /* Create inverse of world-to-viewport transformation */
326 dc->vport2WorldValid = DC_InvertXform( &dc->xformWorld2Vport,
327 &dc->xformVport2World );
329 /* Reselect the font and pen back into the dc so that the size
331 if (memcmp(&oldworld2vport, &dc->xformWorld2Vport, sizeof(oldworld2vport)) &&
332 !GdiIsMetaFileDC(dc->hSelf))
334 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
335 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_PEN));
340 /***********************************************************************
343 INT nulldrv_SaveDC( PHYSDEV dev )
345 DC *newdc, *dc = get_nulldrv_dc( dev );
347 if (!(newdc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc )))) return 0;
348 newdc->layout = dc->layout;
349 newdc->hPen = dc->hPen;
350 newdc->hBrush = dc->hBrush;
351 newdc->hFont = dc->hFont;
352 newdc->hBitmap = dc->hBitmap;
353 newdc->hDevice = dc->hDevice;
354 newdc->hPalette = dc->hPalette;
355 newdc->ROPmode = dc->ROPmode;
356 newdc->polyFillMode = dc->polyFillMode;
357 newdc->stretchBltMode = dc->stretchBltMode;
358 newdc->relAbsMode = dc->relAbsMode;
359 newdc->backgroundMode = dc->backgroundMode;
360 newdc->backgroundColor = dc->backgroundColor;
361 newdc->textColor = dc->textColor;
362 newdc->dcBrushColor = dc->dcBrushColor;
363 newdc->dcPenColor = dc->dcPenColor;
364 newdc->brushOrgX = dc->brushOrgX;
365 newdc->brushOrgY = dc->brushOrgY;
366 newdc->mapperFlags = dc->mapperFlags;
367 newdc->textAlign = dc->textAlign;
368 newdc->charExtra = dc->charExtra;
369 newdc->breakExtra = dc->breakExtra;
370 newdc->breakRem = dc->breakRem;
371 newdc->MapMode = dc->MapMode;
372 newdc->GraphicsMode = dc->GraphicsMode;
373 newdc->CursPosX = dc->CursPosX;
374 newdc->CursPosY = dc->CursPosY;
375 newdc->ArcDirection = dc->ArcDirection;
376 newdc->xformWorld2Wnd = dc->xformWorld2Wnd;
377 newdc->xformWorld2Vport = dc->xformWorld2Vport;
378 newdc->xformVport2World = dc->xformVport2World;
379 newdc->vport2WorldValid = dc->vport2WorldValid;
380 newdc->wndOrgX = dc->wndOrgX;
381 newdc->wndOrgY = dc->wndOrgY;
382 newdc->wndExtX = dc->wndExtX;
383 newdc->wndExtY = dc->wndExtY;
384 newdc->vportOrgX = dc->vportOrgX;
385 newdc->vportOrgY = dc->vportOrgY;
386 newdc->vportExtX = dc->vportExtX;
387 newdc->vportExtY = dc->vportExtY;
388 newdc->virtual_res = dc->virtual_res;
389 newdc->virtual_size = dc->virtual_size;
390 newdc->gdiFont = dc->gdiFont;
392 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
396 newdc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
397 CombineRgn( newdc->hClipRgn, dc->hClipRgn, 0, RGN_COPY );
401 newdc->hMetaRgn = CreateRectRgn( 0, 0, 0, 0 );
402 CombineRgn( newdc->hMetaRgn, dc->hMetaRgn, 0, RGN_COPY );
405 if (!PATH_SavePath( newdc, dc ))
407 release_dc_ptr( dc );
408 free_dc_state( newdc );
412 newdc->saved_dc = dc->saved_dc;
413 dc->saved_dc = newdc;
414 return ++dc->saveLevel;
418 /***********************************************************************
421 BOOL nulldrv_RestoreDC( PHYSDEV dev, INT level )
423 DC *dcs, *first_dcs, *dc = get_nulldrv_dc( dev );
426 /* find the state level to restore */
428 if (abs(level) > dc->saveLevel || level == 0) return FALSE;
429 if (level < 0) level = dc->saveLevel + level + 1;
430 first_dcs = dc->saved_dc;
431 for (dcs = first_dcs, save_level = dc->saveLevel; save_level > level; save_level--)
434 /* restore the state */
436 if (!PATH_RestorePath( dc, dcs )) return FALSE;
438 dc->layout = dcs->layout;
439 dc->hDevice = dcs->hDevice;
440 dc->ROPmode = dcs->ROPmode;
441 dc->polyFillMode = dcs->polyFillMode;
442 dc->stretchBltMode = dcs->stretchBltMode;
443 dc->relAbsMode = dcs->relAbsMode;
444 dc->backgroundMode = dcs->backgroundMode;
445 dc->backgroundColor = dcs->backgroundColor;
446 dc->textColor = dcs->textColor;
447 dc->dcBrushColor = dcs->dcBrushColor;
448 dc->dcPenColor = dcs->dcPenColor;
449 dc->brushOrgX = dcs->brushOrgX;
450 dc->brushOrgY = dcs->brushOrgY;
451 dc->mapperFlags = dcs->mapperFlags;
452 dc->textAlign = dcs->textAlign;
453 dc->charExtra = dcs->charExtra;
454 dc->breakExtra = dcs->breakExtra;
455 dc->breakRem = dcs->breakRem;
456 dc->MapMode = dcs->MapMode;
457 dc->GraphicsMode = dcs->GraphicsMode;
458 dc->CursPosX = dcs->CursPosX;
459 dc->CursPosY = dcs->CursPosY;
460 dc->ArcDirection = dcs->ArcDirection;
461 dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
462 dc->xformWorld2Vport = dcs->xformWorld2Vport;
463 dc->xformVport2World = dcs->xformVport2World;
464 dc->vport2WorldValid = dcs->vport2WorldValid;
465 dc->wndOrgX = dcs->wndOrgX;
466 dc->wndOrgY = dcs->wndOrgY;
467 dc->wndExtX = dcs->wndExtX;
468 dc->wndExtY = dcs->wndExtY;
469 dc->vportOrgX = dcs->vportOrgX;
470 dc->vportOrgY = dcs->vportOrgY;
471 dc->vportExtX = dcs->vportExtX;
472 dc->vportExtY = dcs->vportExtY;
473 dc->virtual_res = dcs->virtual_res;
474 dc->virtual_size = dcs->virtual_size;
478 if (!dc->hClipRgn) dc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
479 CombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
483 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
488 if (!dc->hMetaRgn) dc->hMetaRgn = CreateRectRgn( 0, 0, 0, 0 );
489 CombineRgn( dc->hMetaRgn, dcs->hMetaRgn, 0, RGN_COPY );
493 if (dc->hMetaRgn) DeleteObject( dc->hMetaRgn );
496 DC_UpdateXforms( dc );
497 update_dc_clipping( dc );
499 SelectObject( dev->hdc, dcs->hBitmap );
500 SelectObject( dev->hdc, dcs->hBrush );
501 SelectObject( dev->hdc, dcs->hFont );
502 SelectObject( dev->hdc, dcs->hPen );
503 SetBkColor( dev->hdc, dcs->backgroundColor);
504 SetTextColor( dev->hdc, dcs->textColor);
505 GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
507 dc->saved_dc = dcs->saved_dc;
509 dc->saveLevel = save_level - 1;
511 /* now destroy all the saved DCs */
515 DC *next = first_dcs->saved_dc;
516 free_dc_state( first_dcs );
523 /***********************************************************************
526 INT WINAPI SaveDC( HDC hdc )
531 if ((dc = get_dc_ptr( hdc )))
533 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSaveDC );
534 ret = physdev->funcs->pSaveDC( physdev );
535 release_dc_ptr( dc );
541 /***********************************************************************
542 * RestoreDC (GDI32.@)
544 BOOL WINAPI RestoreDC( HDC hdc, INT level )
548 BOOL success = FALSE;
550 TRACE("%p %d\n", hdc, level );
551 if ((dc = get_dc_ptr( hdc )))
554 physdev = GET_DC_PHYSDEV( dc, pRestoreDC );
555 success = physdev->funcs->pRestoreDC( physdev, level );
556 release_dc_ptr( dc );
562 /***********************************************************************
563 * CreateDCW (GDI32.@)
565 HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
566 const DEVMODEW *initData )
570 const struct gdi_dc_funcs *funcs;
575 if (!device || !DRIVER_GetDriverName( device, buf, 300 ))
579 ERR( "no device found for %s\n", debugstr_w(device) );
582 strcpyW(buf, driver);
585 if (!(funcs = DRIVER_load_driver( buf )))
587 ERR( "no driver found for %s\n", debugstr_w(buf) );
590 if (!(dc = alloc_dc_ptr( OBJ_DC ))) return 0;
593 dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
595 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
596 debugstr_w(driver), debugstr_w(device), debugstr_w(output), dc->hSelf );
598 if (funcs->pCreateDC)
600 if (!funcs->pCreateDC( &dc->physDev, buf, device, output, initData ))
602 WARN("creation aborted by device\n" );
608 dc->vis_rect.left = 0;
609 dc->vis_rect.top = 0;
610 dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
611 dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
614 release_dc_ptr( dc );
619 /***********************************************************************
620 * CreateDCA (GDI32.@)
622 HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
623 const DEVMODEA *initData )
625 UNICODE_STRING driverW, deviceW, outputW;
629 if (driver) RtlCreateUnicodeStringFromAsciiz(&driverW, driver);
630 else driverW.Buffer = NULL;
632 if (device) RtlCreateUnicodeStringFromAsciiz(&deviceW, device);
633 else deviceW.Buffer = NULL;
635 if (output) RtlCreateUnicodeStringFromAsciiz(&outputW, output);
636 else outputW.Buffer = NULL;
641 /* don't convert initData for DISPLAY driver, it's not used */
642 if (!driverW.Buffer || strcmpiW( driverW.Buffer, displayW ))
643 initDataW = GdiConvertToDevmodeW(initData);
646 ret = CreateDCW( driverW.Buffer, deviceW.Buffer, outputW.Buffer, initDataW );
648 RtlFreeUnicodeString(&driverW);
649 RtlFreeUnicodeString(&deviceW);
650 RtlFreeUnicodeString(&outputW);
651 HeapFree(GetProcessHeap(), 0, initDataW);
656 /***********************************************************************
657 * CreateICA (GDI32.@)
659 HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output,
660 const DEVMODEA* initData )
662 /* Nothing special yet for ICs */
663 return CreateDCA( driver, device, output, initData );
667 /***********************************************************************
668 * CreateICW (GDI32.@)
670 HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
671 const DEVMODEW* initData )
673 /* Nothing special yet for ICs */
674 return CreateDCW( driver, device, output, initData );
678 /***********************************************************************
679 * CreateCompatibleDC (GDI32.@)
681 HDC WINAPI CreateCompatibleDC( HDC hdc )
685 const struct gdi_dc_funcs *funcs = &null_driver;
686 PHYSDEV physDev = NULL;
692 if (!(origDC = get_dc_ptr( hdc ))) return 0;
693 physDev = GET_DC_PHYSDEV( origDC, pCreateCompatibleDC );
694 funcs = physDev->funcs;
695 release_dc_ptr( origDC );
698 if (!(dc = alloc_dc_ptr( OBJ_MEMDC ))) return 0;
700 TRACE("(%p): returning %p\n", hdc, dc->hSelf );
702 dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
703 dc->vis_rect.left = 0;
704 dc->vis_rect.top = 0;
705 dc->vis_rect.right = 1;
706 dc->vis_rect.bottom = 1;
707 dc->device_rect = dc->vis_rect;
711 if (!funcs->pCreateCompatibleDC( physDev, &dc->physDev ))
713 WARN("creation aborted by device\n");
718 if (!dib_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
723 physDev = GET_DC_PHYSDEV( dc, pSelectBitmap );
724 physDev->funcs->pSelectBitmap( physDev, dc->hBitmap );
727 release_dc_ptr( dc );
732 /***********************************************************************
735 BOOL WINAPI DeleteDC( HDC hdc )
743 if (!(dc = get_dc_ptr( hdc ))) return FALSE;
744 if (dc->refcount != 1)
746 FIXME( "not deleting busy DC %p refcount %u\n", dc->hSelf, dc->refcount );
747 release_dc_ptr( dc );
751 /* Call hook procedure to check whether is it OK to delete this DC */
752 if (dc->hookProc && !dc->hookProc( hdc, DCHC_DELETEDC, dc->dwHookData, 0 ))
754 release_dc_ptr( dc );
758 while (dc->saveLevel)
760 DC *dcs = dc->saved_dc;
761 dc->saved_dc = dcs->saved_dc;
763 free_dc_state( dcs );
767 SelectObject( hdc, GetStockObject(BLACK_PEN) );
768 SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
769 SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
770 SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
777 /***********************************************************************
780 HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
785 if ((dc = get_dc_ptr( hdc )))
787 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pResetDC );
788 ret = physdev->funcs->pResetDC( physdev, devmode );
789 if (ret) /* reset the visible region */
792 dc->vis_rect.left = 0;
793 dc->vis_rect.top = 0;
794 dc->vis_rect.right = GetDeviceCaps( hdc, DESKTOPHORZRES );
795 dc->vis_rect.bottom = GetDeviceCaps( hdc, DESKTOPVERTRES );
796 if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
798 update_dc_clipping( dc );
800 release_dc_ptr( dc );
806 /***********************************************************************
809 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
814 if (devmode) devmodeW = GdiConvertToDevmodeW(devmode);
815 else devmodeW = NULL;
817 ret = ResetDCW(hdc, devmodeW);
819 HeapFree(GetProcessHeap(), 0, devmodeW);
824 /***********************************************************************
825 * GetDeviceCaps (GDI32.@)
827 INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
832 if ((dc = get_dc_ptr( hdc )))
834 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceCaps );
835 ret = physdev->funcs->pGetDeviceCaps( physdev, cap );
836 release_dc_ptr( dc );
842 /***********************************************************************
843 * GetBkColor (GDI32.@)
845 COLORREF WINAPI GetBkColor( HDC hdc )
848 DC * dc = get_dc_ptr( hdc );
851 ret = dc->backgroundColor;
852 release_dc_ptr( dc );
858 /***********************************************************************
859 * SetBkColor (GDI32.@)
861 COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
863 COLORREF ret = CLR_INVALID;
864 DC * dc = get_dc_ptr( hdc );
866 TRACE("hdc=%p color=0x%08x\n", hdc, color);
870 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
871 ret = dc->backgroundColor;
872 dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color );
873 release_dc_ptr( dc );
879 /***********************************************************************
880 * GetTextColor (GDI32.@)
882 COLORREF WINAPI GetTextColor( HDC hdc )
885 DC * dc = get_dc_ptr( hdc );
889 release_dc_ptr( dc );
895 /***********************************************************************
896 * SetTextColor (GDI32.@)
898 COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
900 COLORREF ret = CLR_INVALID;
901 DC * dc = get_dc_ptr( hdc );
903 TRACE(" hdc=%p color=0x%08x\n", hdc, color);
907 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor );
909 dc->textColor = physdev->funcs->pSetTextColor( physdev, color );
910 release_dc_ptr( dc );
916 /***********************************************************************
917 * GetTextAlign (GDI32.@)
919 UINT WINAPI GetTextAlign( HDC hdc )
922 DC * dc = get_dc_ptr( hdc );
926 release_dc_ptr( dc );
932 /***********************************************************************
933 * SetTextAlign (GDI32.@)
935 UINT WINAPI SetTextAlign( HDC hdc, UINT align )
937 UINT ret = GDI_ERROR;
938 DC *dc = get_dc_ptr( hdc );
940 TRACE("hdc=%p align=%d\n", hdc, align);
944 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextAlign );
945 align = physdev->funcs->pSetTextAlign( physdev, align );
946 if (align != GDI_ERROR)
949 dc->textAlign = align;
951 release_dc_ptr( dc );
956 /***********************************************************************
957 * GetDCOrgEx (GDI32.@)
959 BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
963 if (!lpp) return FALSE;
964 if (!(dc = get_dc_ptr( hDC ))) return FALSE;
965 lpp->x = dc->vis_rect.left;
966 lpp->y = dc->vis_rect.top;
967 release_dc_ptr( dc );
972 /***********************************************************************
973 * GetGraphicsMode (GDI32.@)
975 INT WINAPI GetGraphicsMode( HDC hdc )
978 DC * dc = get_dc_ptr( hdc );
981 ret = dc->GraphicsMode;
982 release_dc_ptr( dc );
988 /***********************************************************************
989 * SetGraphicsMode (GDI32.@)
991 INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
994 DC *dc = get_dc_ptr( hdc );
996 /* One would think that setting the graphics mode to GM_COMPATIBLE
997 * would also reset the world transformation matrix to the unity
998 * matrix. However, in Windows, this is not the case. This doesn't
999 * make a lot of sense to me, but that's the way it is.
1002 if ((mode > 0) && (mode <= GM_LAST))
1004 ret = dc->GraphicsMode;
1005 dc->GraphicsMode = mode;
1007 release_dc_ptr( dc );
1012 /***********************************************************************
1013 * GetArcDirection (GDI32.@)
1015 INT WINAPI GetArcDirection( HDC hdc )
1018 DC * dc = get_dc_ptr( hdc );
1021 ret = dc->ArcDirection;
1022 release_dc_ptr( dc );
1028 /***********************************************************************
1029 * SetArcDirection (GDI32.@)
1031 INT WINAPI SetArcDirection( HDC hdc, INT dir )
1036 if (dir != AD_COUNTERCLOCKWISE && dir != AD_CLOCKWISE)
1038 SetLastError(ERROR_INVALID_PARAMETER);
1042 if ((dc = get_dc_ptr( hdc )))
1044 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetArcDirection );
1045 dir = physdev->funcs->pSetArcDirection( physdev, dir );
1048 ret = dc->ArcDirection;
1049 dc->ArcDirection = dir;
1051 release_dc_ptr( dc );
1057 /***********************************************************************
1058 * GetWorldTransform (GDI32.@)
1060 BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
1063 if (!xform) return FALSE;
1064 if (!(dc = get_dc_ptr( hdc ))) return FALSE;
1065 *xform = dc->xformWorld2Wnd;
1066 release_dc_ptr( dc );
1071 /***********************************************************************
1072 * GetTransform (GDI32.@)
1076 * Returns one of the co-ordinate space transforms
1079 * hdc [I] Device context.
1080 * which [I] Which xform to return:
1081 * 0x203 World -> Page transform (that set by SetWorldTransform).
1082 * 0x304 Page -> Device transform (the mapping mode transform).
1083 * 0x204 World -> Device transform (the combination of the above two).
1084 * 0x402 Device -> World transform (the inversion of the above).
1085 * xform [O] The xform.
1088 BOOL WINAPI GetTransform( HDC hdc, DWORD which, XFORM *xform )
1091 DC *dc = get_dc_ptr( hdc );
1092 if (!dc) return FALSE;
1097 *xform = dc->xformWorld2Wnd;
1101 construct_window_to_viewport(dc, xform);
1105 *xform = dc->xformWorld2Vport;
1109 *xform = dc->xformVport2World;
1113 FIXME("Unknown code %x\n", which);
1117 release_dc_ptr( dc );
1122 /****************************************************************************
1123 * CombineTransform [GDI32.@]
1124 * Combines two transformation matrices.
1127 * xformResult [O] Stores the result of combining the two matrices
1128 * xform1 [I] Specifies the first matrix to apply
1129 * xform2 [I] Specifies the second matrix to apply
1132 * The same matrix can be passed in for more than one of the parameters.
1136 * Failure: FALSE. Use GetLastError() to determine the cause.
1138 BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
1139 const XFORM *xform2 )
1143 /* Check for illegal parameters */
1144 if (!xformResult || !xform1 || !xform2)
1147 /* Create the result in a temporary XFORM, since xformResult may be
1148 * equal to xform1 or xform2 */
1149 xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1150 xform1->eM12 * xform2->eM21;
1151 xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1152 xform1->eM12 * xform2->eM22;
1153 xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1154 xform1->eM22 * xform2->eM21;
1155 xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1156 xform1->eM22 * xform2->eM22;
1157 xformTemp.eDx = xform1->eDx * xform2->eM11 +
1158 xform1->eDy * xform2->eM21 +
1160 xformTemp.eDy = xform1->eDx * xform2->eM12 +
1161 xform1->eDy * xform2->eM22 +
1164 /* Copy the result to xformResult */
1165 *xformResult = xformTemp;
1171 /***********************************************************************
1172 * SetDCHook (GDI32.@)
1174 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1176 BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD_PTR dwHookData )
1178 DC *dc = get_dc_ptr( hdc );
1180 if (!dc) return FALSE;
1182 dc->dwHookData = dwHookData;
1183 dc->hookProc = hookProc;
1184 release_dc_ptr( dc );
1189 /***********************************************************************
1190 * GetDCHook (GDI32.@)
1192 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1194 DWORD_PTR WINAPI GetDCHook( HDC hdc, DCHOOKPROC *proc )
1196 DC *dc = get_dc_ptr( hdc );
1200 if (proc) *proc = dc->hookProc;
1201 ret = dc->dwHookData;
1202 release_dc_ptr( dc );
1207 /***********************************************************************
1208 * SetHookFlags (GDI32.@)
1210 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1212 WORD WINAPI SetHookFlags( HDC hdc, WORD flags )
1214 DC *dc = get_dc_obj( hdc ); /* not get_dc_ptr, this needs to work from any thread */
1219 /* "Undocumented Windows" info is slightly confusing. */
1221 TRACE("hDC %p, flags %04x\n",hdc,flags);
1223 if (flags & DCHF_INVALIDATEVISRGN)
1224 ret = InterlockedExchange( &dc->dirty, 1 );
1225 else if (flags & DCHF_VALIDATEVISRGN || !flags)
1226 ret = InterlockedExchange( &dc->dirty, 0 );
1228 GDI_ReleaseObj( hdc );
1232 /***********************************************************************
1233 * SetICMMode (GDI32.@)
1235 INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
1237 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1238 if (iEnableICM == ICM_OFF) return ICM_OFF;
1239 if (iEnableICM == ICM_ON) return 0;
1240 if (iEnableICM == ICM_QUERY) return ICM_OFF;
1244 /***********************************************************************
1245 * GetDeviceGammaRamp (GDI32.@)
1247 BOOL WINAPI GetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1250 DC *dc = get_dc_ptr( hDC );
1252 TRACE("%p, %p\n", hDC, ptr);
1255 if (GetObjectType( hDC ) != OBJ_MEMDC)
1257 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceGammaRamp );
1258 ret = physdev->funcs->pGetDeviceGammaRamp( physdev, ptr );
1260 else SetLastError( ERROR_INVALID_PARAMETER );
1261 release_dc_ptr( dc );
1266 /***********************************************************************
1267 * SetDeviceGammaRamp (GDI32.@)
1269 BOOL WINAPI SetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1272 DC *dc = get_dc_ptr( hDC );
1274 TRACE("%p, %p\n", hDC, ptr);
1277 if (GetObjectType( hDC ) != OBJ_MEMDC)
1279 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDeviceGammaRamp );
1280 ret = physdev->funcs->pSetDeviceGammaRamp( physdev, ptr );
1282 else SetLastError( ERROR_INVALID_PARAMETER );
1283 release_dc_ptr( dc );
1288 /***********************************************************************
1289 * GetColorSpace (GDI32.@)
1291 HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
1293 /*FIXME Need to do whatever GetColorSpace actually does */
1297 /***********************************************************************
1298 * CreateColorSpaceA (GDI32.@)
1300 HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace )
1306 /***********************************************************************
1307 * CreateColorSpaceW (GDI32.@)
1309 HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace )
1315 /***********************************************************************
1316 * DeleteColorSpace (GDI32.@)
1318 BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace )
1325 /***********************************************************************
1326 * SetColorSpace (GDI32.@)
1328 HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace )
1335 /***********************************************************************
1336 * GetBoundsRect (GDI32.@)
1338 UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
1343 DC *dc = get_dc_ptr( hdc );
1345 if ( !dc ) return 0;
1347 physdev = GET_DC_PHYSDEV( dc, pGetBoundsRect );
1348 ret = physdev->funcs->pGetBoundsRect( physdev, &device_rect, DCB_RESET );
1351 release_dc_ptr( dc );
1354 if (dc->bounds_enabled && ret == DCB_SET) add_bounds_rect( &dc->bounds, &device_rect );
1358 if (is_rect_empty( &dc->bounds ))
1360 rect->left = rect->top = rect->right = rect->bottom = 0;
1366 rect->left = max( rect->left, 0 );
1367 rect->top = max( rect->top, 0 );
1368 rect->right = min( rect->right, dc->vis_rect.right - dc->vis_rect.left );
1369 rect->bottom = min( rect->bottom, dc->vis_rect.bottom - dc->vis_rect.top );
1372 DPtoLP( hdc, (POINT *)rect, 2 );
1376 if (flags & DCB_RESET) reset_bounds( &dc->bounds );
1377 release_dc_ptr( dc );
1382 /***********************************************************************
1383 * SetBoundsRect (GDI32.@)
1385 UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
1391 if ((flags & DCB_ENABLE) && (flags & DCB_DISABLE)) return 0;
1392 if (!(dc = get_dc_ptr( hdc ))) return 0;
1394 physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
1395 ret = physdev->funcs->pSetBoundsRect( physdev, &dc->bounds, flags );
1398 release_dc_ptr( dc );
1402 ret = (dc->bounds_enabled ? DCB_ENABLE : DCB_DISABLE) |
1403 (is_rect_empty( &dc->bounds ) ? ret & DCB_SET : DCB_SET);
1405 if (flags & DCB_RESET) reset_bounds( &dc->bounds );
1407 if ((flags & DCB_ACCUMULATE) && rect)
1411 LPtoDP( hdc, (POINT *)&rc, 2 );
1412 add_bounds_rect( &dc->bounds, &rc );
1415 if (flags & DCB_ENABLE) dc->bounds_enabled = TRUE;
1416 if (flags & DCB_DISABLE) dc->bounds_enabled = FALSE;
1418 release_dc_ptr( dc );
1423 /***********************************************************************
1424 * GetRelAbs (GDI32.@)
1426 INT WINAPI GetRelAbs( HDC hdc, DWORD dwIgnore )
1429 DC *dc = get_dc_ptr( hdc );
1432 ret = dc->relAbsMode;
1433 release_dc_ptr( dc );
1441 /***********************************************************************
1442 * GetBkMode (GDI32.@)
1444 INT WINAPI GetBkMode( HDC hdc )
1447 DC * dc = get_dc_ptr( hdc );
1450 ret = dc->backgroundMode;
1451 release_dc_ptr( dc );
1457 /***********************************************************************
1458 * SetBkMode (GDI32.@)
1460 INT WINAPI SetBkMode( HDC hdc, INT mode )
1465 if ((mode <= 0) || (mode > BKMODE_LAST))
1467 SetLastError(ERROR_INVALID_PARAMETER);
1470 if ((dc = get_dc_ptr( hdc )))
1472 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkMode );
1473 mode = physdev->funcs->pSetBkMode( physdev, mode );
1476 ret = dc->backgroundMode;
1477 dc->backgroundMode = mode;
1479 release_dc_ptr( dc );
1485 /***********************************************************************
1488 INT WINAPI GetROP2( HDC hdc )
1491 DC * dc = get_dc_ptr( hdc );
1495 release_dc_ptr( dc );
1501 /***********************************************************************
1504 INT WINAPI SetROP2( HDC hdc, INT mode )
1509 if ((mode < R2_BLACK) || (mode > R2_WHITE))
1511 SetLastError(ERROR_INVALID_PARAMETER);
1514 if ((dc = get_dc_ptr( hdc )))
1516 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetROP2 );
1517 mode = physdev->funcs->pSetROP2( physdev, mode );
1523 release_dc_ptr( dc );
1529 /***********************************************************************
1530 * SetRelAbs (GDI32.@)
1532 INT WINAPI SetRelAbs( HDC hdc, INT mode )
1537 if ((mode != ABSOLUTE) && (mode != RELATIVE))
1539 SetLastError(ERROR_INVALID_PARAMETER);
1542 if ((dc = get_dc_ptr( hdc )))
1544 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetRelAbs );
1545 mode = physdev->funcs->pSetRelAbs( physdev, mode );
1548 ret = dc->relAbsMode;
1549 dc->relAbsMode = mode;
1551 release_dc_ptr( dc );
1557 /***********************************************************************
1558 * GetPolyFillMode (GDI32.@)
1560 INT WINAPI GetPolyFillMode( HDC hdc )
1563 DC * dc = get_dc_ptr( hdc );
1566 ret = dc->polyFillMode;
1567 release_dc_ptr( dc );
1573 /***********************************************************************
1574 * SetPolyFillMode (GDI32.@)
1576 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
1581 if ((mode <= 0) || (mode > POLYFILL_LAST))
1583 SetLastError(ERROR_INVALID_PARAMETER);
1586 if ((dc = get_dc_ptr( hdc )))
1588 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetPolyFillMode );
1589 mode = physdev->funcs->pSetPolyFillMode( physdev, mode );
1592 ret = dc->polyFillMode;
1593 dc->polyFillMode = mode;
1595 release_dc_ptr( dc );
1601 /***********************************************************************
1602 * GetStretchBltMode (GDI32.@)
1604 INT WINAPI GetStretchBltMode( HDC hdc )
1607 DC * dc = get_dc_ptr( hdc );
1610 ret = dc->stretchBltMode;
1611 release_dc_ptr( dc );
1617 /***********************************************************************
1618 * SetStretchBltMode (GDI32.@)
1620 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
1625 if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
1627 SetLastError(ERROR_INVALID_PARAMETER);
1630 if ((dc = get_dc_ptr( hdc )))
1632 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetStretchBltMode );
1633 mode = physdev->funcs->pSetStretchBltMode( physdev, mode );
1636 ret = dc->stretchBltMode;
1637 dc->stretchBltMode = mode;
1639 release_dc_ptr( dc );
1645 /***********************************************************************
1646 * GetMapMode (GDI32.@)
1648 INT WINAPI GetMapMode( HDC hdc )
1651 DC * dc = get_dc_ptr( hdc );
1655 release_dc_ptr( dc );
1661 /***********************************************************************
1662 * GetBrushOrgEx (GDI32.@)
1664 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
1666 DC * dc = get_dc_ptr( hdc );
1667 if (!dc) return FALSE;
1668 pt->x = dc->brushOrgX;
1669 pt->y = dc->brushOrgY;
1670 release_dc_ptr( dc );
1675 /***********************************************************************
1676 * GetCurrentPositionEx (GDI32.@)
1678 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
1680 DC * dc = get_dc_ptr( hdc );
1681 if (!dc) return FALSE;
1682 pt->x = dc->CursPosX;
1683 pt->y = dc->CursPosY;
1684 release_dc_ptr( dc );
1689 /***********************************************************************
1690 * GetViewportExtEx (GDI32.@)
1692 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
1694 DC * dc = get_dc_ptr( hdc );
1695 if (!dc) return FALSE;
1696 size->cx = dc->vportExtX;
1697 size->cy = dc->vportExtY;
1698 release_dc_ptr( dc );
1703 /***********************************************************************
1704 * GetViewportOrgEx (GDI32.@)
1706 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
1708 DC * dc = get_dc_ptr( hdc );
1709 if (!dc) return FALSE;
1710 pt->x = dc->vportOrgX;
1711 pt->y = dc->vportOrgY;
1712 release_dc_ptr( dc );
1717 /***********************************************************************
1718 * GetWindowExtEx (GDI32.@)
1720 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
1722 DC * dc = get_dc_ptr( hdc );
1723 if (!dc) return FALSE;
1724 size->cx = dc->wndExtX;
1725 size->cy = dc->wndExtY;
1726 release_dc_ptr( dc );
1731 /***********************************************************************
1732 * GetWindowOrgEx (GDI32.@)
1734 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
1736 DC * dc = get_dc_ptr( hdc );
1737 if (!dc) return FALSE;
1738 pt->x = dc->wndOrgX;
1739 pt->y = dc->wndOrgY;
1740 release_dc_ptr( dc );
1745 /***********************************************************************
1746 * GetLayout (GDI32.@)
1748 * Gets left->right or right->left text layout flags of a dc.
1751 DWORD WINAPI GetLayout(HDC hdc)
1753 DWORD layout = GDI_ERROR;
1755 DC * dc = get_dc_ptr( hdc );
1758 layout = dc->layout;
1759 release_dc_ptr( dc );
1762 TRACE("hdc : %p, layout : %08x\n", hdc, layout);
1767 /***********************************************************************
1768 * SetLayout (GDI32.@)
1770 * Sets left->right or right->left text layout flags of a dc.
1773 DWORD WINAPI SetLayout(HDC hdc, DWORD layout)
1775 DWORD oldlayout = GDI_ERROR;
1777 DC * dc = get_dc_ptr( hdc );
1780 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetLayout );
1781 layout = physdev->funcs->pSetLayout( physdev, layout );
1782 if (layout != GDI_ERROR)
1784 oldlayout = dc->layout;
1785 dc->layout = layout;
1786 if (layout != oldlayout)
1788 if (layout & LAYOUT_RTL) dc->MapMode = MM_ANISOTROPIC;
1789 DC_UpdateXforms( dc );
1792 release_dc_ptr( dc );
1795 TRACE("hdc : %p, old layout : %08x, new layout : %08x\n", hdc, oldlayout, layout);
1800 /***********************************************************************
1801 * GetDCBrushColor (GDI32.@)
1803 COLORREF WINAPI GetDCBrushColor(HDC hdc)
1806 COLORREF dcBrushColor = CLR_INVALID;
1808 TRACE("hdc(%p)\n", hdc);
1810 dc = get_dc_ptr( hdc );
1813 dcBrushColor = dc->dcBrushColor;
1814 release_dc_ptr( dc );
1817 return dcBrushColor;
1820 /***********************************************************************
1821 * SetDCBrushColor (GDI32.@)
1823 COLORREF WINAPI SetDCBrushColor(HDC hdc, COLORREF crColor)
1826 COLORREF oldClr = CLR_INVALID;
1828 TRACE("hdc(%p) crColor(%08x)\n", hdc, crColor);
1830 dc = get_dc_ptr( hdc );
1833 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDCBrushColor );
1834 crColor = physdev->funcs->pSetDCBrushColor( physdev, crColor );
1835 if (crColor != CLR_INVALID)
1837 oldClr = dc->dcBrushColor;
1838 dc->dcBrushColor = crColor;
1840 release_dc_ptr( dc );
1846 /***********************************************************************
1847 * GetDCPenColor (GDI32.@)
1849 COLORREF WINAPI GetDCPenColor(HDC hdc)
1852 COLORREF dcPenColor = CLR_INVALID;
1854 TRACE("hdc(%p)\n", hdc);
1856 dc = get_dc_ptr( hdc );
1859 dcPenColor = dc->dcPenColor;
1860 release_dc_ptr( dc );
1866 /***********************************************************************
1867 * SetDCPenColor (GDI32.@)
1869 COLORREF WINAPI SetDCPenColor(HDC hdc, COLORREF crColor)
1872 COLORREF oldClr = CLR_INVALID;
1874 TRACE("hdc(%p) crColor(%08x)\n", hdc, crColor);
1876 dc = get_dc_ptr( hdc );
1879 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDCPenColor );
1880 crColor = physdev->funcs->pSetDCPenColor( physdev, crColor );
1881 if (crColor != CLR_INVALID)
1883 oldClr = dc->dcPenColor;
1884 dc->dcPenColor = crColor;
1886 release_dc_ptr( dc );
1892 /***********************************************************************
1893 * CancelDC (GDI32.@)
1895 BOOL WINAPI CancelDC(HDC hdc)
1901 /*******************************************************************
1902 * GetMiterLimit [GDI32.@]
1906 BOOL WINAPI GetMiterLimit(HDC hdc, PFLOAT peLimit)
1911 TRACE("(%p,%p)\n", hdc, peLimit);
1913 dc = get_dc_ptr( hdc );
1917 *peLimit = dc->miterLimit;
1919 release_dc_ptr( dc );
1925 /*******************************************************************
1926 * SetMiterLimit [GDI32.@]
1930 BOOL WINAPI SetMiterLimit(HDC hdc, FLOAT eNewLimit, PFLOAT peOldLimit)
1935 TRACE("(%p,%f,%p)\n", hdc, eNewLimit, peOldLimit);
1937 dc = get_dc_ptr( hdc );
1941 *peOldLimit = dc->miterLimit;
1942 dc->miterLimit = eNewLimit;
1943 release_dc_ptr( dc );
1949 /*******************************************************************
1950 * GdiIsMetaPrintDC [GDI32.@]
1952 BOOL WINAPI GdiIsMetaPrintDC(HDC hdc)
1958 /*******************************************************************
1959 * GdiIsMetaFileDC [GDI32.@]
1961 BOOL WINAPI GdiIsMetaFileDC(HDC hdc)
1965 switch( GetObjectType( hdc ) )
1974 /*******************************************************************
1975 * GdiIsPlayMetafileDC [GDI32.@]
1977 BOOL WINAPI GdiIsPlayMetafileDC(HDC hdc)