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(), 0, sizeof(*dc
) ))) return NULL
;
80 dc
->nulldrv
.funcs
= &null_driver
;
81 dc
->nulldrv
.next
= NULL
;
83 dc
->physDev
= &dc
->nulldrv
;
84 dc
->thread
= GetCurrentThreadId();
99 dc
->miterLimit
= 10.0f
; /* 10.0 is the default, from MSDN */
104 dc
->hMetaClipRgn
= 0;
106 dc
->hPen
= GDI_inc_ref_count( GetStockObject( BLACK_PEN
));
107 dc
->hBrush
= GDI_inc_ref_count( GetStockObject( WHITE_BRUSH
));
108 dc
->hFont
= GDI_inc_ref_count( GetStockObject( SYSTEM_FONT
));
111 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
113 dc
->font_code_page
= CP_ACP
;
114 dc
->ROPmode
= R2_COPYPEN
;
115 dc
->polyFillMode
= ALTERNATE
;
116 dc
->stretchBltMode
= BLACKONWHITE
;
117 dc
->relAbsMode
= ABSOLUTE
;
118 dc
->backgroundMode
= OPAQUE
;
119 dc
->backgroundColor
= RGB( 255, 255, 255 );
120 dc
->dcBrushColor
= RGB( 255, 255, 255 );
121 dc
->dcPenColor
= RGB( 0, 0, 0 );
122 dc
->textColor
= RGB( 0, 0, 0 );
126 dc
->textAlign
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
130 dc
->MapMode
= MM_TEXT
;
131 dc
->GraphicsMode
= GM_COMPATIBLE
;
132 dc
->pAbortProc
= NULL
;
135 dc
->ArcDirection
= AD_COUNTERCLOCKWISE
;
136 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
137 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
138 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
139 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
140 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
141 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
142 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
143 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
144 dc
->vport2WorldValid
= TRUE
;
145 dc
->BoundsRect
.left
= 0;
146 dc
->BoundsRect
.top
= 0;
147 dc
->BoundsRect
.right
= 0;
148 dc
->BoundsRect
.bottom
= 0;
149 PATH_InitGdiPath(&dc
->path
);
151 if (!(dc
->hSelf
= alloc_gdi_handle( &dc
->header
, magic
, &dc_funcs
)))
153 HeapFree( GetProcessHeap(), 0, dc
);
156 dc
->nulldrv
.hdc
= dc
->hSelf
;
162 /***********************************************************************
165 static void free_dc_state( DC
*dc
)
167 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
168 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
169 if (dc
->hMetaClipRgn
) DeleteObject( dc
->hMetaClipRgn
);
170 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
171 PATH_DestroyGdiPath( &dc
->path
);
172 HeapFree( GetProcessHeap(), 0, dc
);
176 /***********************************************************************
179 void free_dc_ptr( DC
*dc
)
181 assert( dc
->refcount
== 1 );
183 while (dc
->physDev
!= &dc
->nulldrv
)
185 PHYSDEV physdev
= pop_dc_driver( &dc
->physDev
);
186 physdev
->funcs
->pDeleteDC( physdev
);
187 if (physdev
== dc
->dibdrv
) dc
->dibdrv
= NULL
;
189 if (dc
->dibdrv
) dc
->dibdrv
->funcs
->pDeleteDC( dc
->dibdrv
);
190 free_gdi_handle( dc
->hSelf
);
195 /***********************************************************************
198 * Retrieve a DC pointer but release the GDI lock.
200 DC
*get_dc_ptr( HDC hdc
)
202 DC
*dc
= get_dc_obj( hdc
);
203 if (!dc
) return NULL
;
205 if (!InterlockedCompareExchange( &dc
->refcount
, 1, 0 ))
207 dc
->thread
= GetCurrentThreadId();
209 else if (dc
->thread
!= GetCurrentThreadId())
211 WARN( "dc %p belongs to thread %04x\n", hdc
, dc
->thread
);
212 GDI_ReleaseObj( hdc
);
215 else InterlockedIncrement( &dc
->refcount
);
217 GDI_ReleaseObj( hdc
);
222 /***********************************************************************
225 void release_dc_ptr( DC
*dc
)
230 ref
= InterlockedDecrement( &dc
->refcount
);
232 if (ref
) dc
->thread
= GetCurrentThreadId(); /* we still own it */
236 /***********************************************************************
239 * Make sure the DC vis region is up to date.
240 * This function may call up to USER so the GDI lock should _not_
241 * be held when calling it.
243 void update_dc( DC
*dc
)
245 if (InterlockedExchange( &dc
->dirty
, 0 ) && dc
->hookProc
)
246 dc
->hookProc( dc
->hSelf
, DCHC_INVALIDVISRGN
, dc
->dwHookData
, 0 );
250 /***********************************************************************
253 static BOOL
DC_DeleteObject( HGDIOBJ handle
)
255 return DeleteDC( handle
);
259 /***********************************************************************
262 * Setup device-specific DC values for a newly created DC.
264 void DC_InitDC( DC
* dc
)
266 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRealizeDefaultPalette
);
267 physdev
->funcs
->pRealizeDefaultPalette( physdev
);
268 SetTextColor( dc
->hSelf
, dc
->textColor
);
269 SetBkColor( dc
->hSelf
, dc
->backgroundColor
);
270 SelectObject( dc
->hSelf
, dc
->hPen
);
271 SelectObject( dc
->hSelf
, dc
->hBrush
);
272 SelectObject( dc
->hSelf
, dc
->hFont
);
273 CLIPPING_UpdateGCRegion( dc
);
274 SetVirtualResolution( dc
->hSelf
, 0, 0, 0, 0 );
278 /***********************************************************************
281 * Computes the inverse of the transformation xformSrc and stores it to
282 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
285 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
289 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
290 xformSrc
->eM12
*xformSrc
->eM21
;
291 if (determinant
> -1e-12 && determinant
< 1e-12)
294 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
295 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
296 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
297 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
298 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
299 xformSrc
->eDy
* xformDest
->eM21
;
300 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
301 xformSrc
->eDy
* xformDest
->eM22
;
306 /* Construct a transformation to do the window-to-viewport conversion */
307 static void construct_window_to_viewport(DC
*dc
, XFORM
*xform
)
309 double scaleX
, scaleY
;
310 scaleX
= (double)dc
->vportExtX
/ (double)dc
->wndExtX
;
311 scaleY
= (double)dc
->vportExtY
/ (double)dc
->wndExtY
;
313 if (dc
->layout
& LAYOUT_RTL
) scaleX
= -scaleX
;
314 xform
->eM11
= scaleX
;
317 xform
->eM22
= scaleY
;
318 xform
->eDx
= (double)dc
->vportOrgX
- scaleX
* (double)dc
->wndOrgX
;
319 xform
->eDy
= (double)dc
->vportOrgY
- scaleY
* (double)dc
->wndOrgY
;
320 if (dc
->layout
& LAYOUT_RTL
) xform
->eDx
= dc
->vis_rect
.right
- dc
->vis_rect
.left
- 1 - xform
->eDx
;
323 /***********************************************************************
326 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
327 * fields of the specified DC by creating a transformation that
328 * represents the current mapping mode and combining it with the DC's
329 * world transform. This function should be called whenever the
330 * parameters associated with the mapping mode (window and viewport
331 * extents and origins) or the world transform change.
333 void DC_UpdateXforms( DC
*dc
)
335 XFORM xformWnd2Vport
, oldworld2vport
;
337 construct_window_to_viewport(dc
, &xformWnd2Vport
);
339 oldworld2vport
= dc
->xformWorld2Vport
;
340 /* Combine with the world transformation */
341 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
344 /* Create inverse of world-to-viewport transformation */
345 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
346 &dc
->xformVport2World
);
348 /* Reselect the font and pen back into the dc so that the size
350 if (memcmp(&oldworld2vport
, &dc
->xformWorld2Vport
, sizeof(oldworld2vport
)) &&
351 !GdiIsMetaFileDC(dc
->hSelf
))
353 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_FONT
));
354 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_PEN
));
359 /***********************************************************************
362 INT
nulldrv_SaveDC( PHYSDEV dev
)
364 DC
*newdc
, *dc
= get_nulldrv_dc( dev
);
366 if (!(newdc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*newdc
)))) return 0;
367 newdc
->flags
= dc
->flags
;
368 newdc
->layout
= dc
->layout
;
369 newdc
->hPen
= dc
->hPen
;
370 newdc
->hBrush
= dc
->hBrush
;
371 newdc
->hFont
= dc
->hFont
;
372 newdc
->hBitmap
= dc
->hBitmap
;
373 newdc
->hDevice
= dc
->hDevice
;
374 newdc
->hPalette
= dc
->hPalette
;
375 newdc
->ROPmode
= dc
->ROPmode
;
376 newdc
->polyFillMode
= dc
->polyFillMode
;
377 newdc
->stretchBltMode
= dc
->stretchBltMode
;
378 newdc
->relAbsMode
= dc
->relAbsMode
;
379 newdc
->backgroundMode
= dc
->backgroundMode
;
380 newdc
->backgroundColor
= dc
->backgroundColor
;
381 newdc
->textColor
= dc
->textColor
;
382 newdc
->dcBrushColor
= dc
->dcBrushColor
;
383 newdc
->dcPenColor
= dc
->dcPenColor
;
384 newdc
->brushOrgX
= dc
->brushOrgX
;
385 newdc
->brushOrgY
= dc
->brushOrgY
;
386 newdc
->mapperFlags
= dc
->mapperFlags
;
387 newdc
->textAlign
= dc
->textAlign
;
388 newdc
->charExtra
= dc
->charExtra
;
389 newdc
->breakExtra
= dc
->breakExtra
;
390 newdc
->breakRem
= dc
->breakRem
;
391 newdc
->MapMode
= dc
->MapMode
;
392 newdc
->GraphicsMode
= dc
->GraphicsMode
;
393 newdc
->CursPosX
= dc
->CursPosX
;
394 newdc
->CursPosY
= dc
->CursPosY
;
395 newdc
->ArcDirection
= dc
->ArcDirection
;
396 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
397 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
398 newdc
->xformVport2World
= dc
->xformVport2World
;
399 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
400 newdc
->wndOrgX
= dc
->wndOrgX
;
401 newdc
->wndOrgY
= dc
->wndOrgY
;
402 newdc
->wndExtX
= dc
->wndExtX
;
403 newdc
->wndExtY
= dc
->wndExtY
;
404 newdc
->vportOrgX
= dc
->vportOrgX
;
405 newdc
->vportOrgY
= dc
->vportOrgY
;
406 newdc
->vportExtX
= dc
->vportExtX
;
407 newdc
->vportExtY
= dc
->vportExtY
;
408 newdc
->virtual_res
= dc
->virtual_res
;
409 newdc
->virtual_size
= dc
->virtual_size
;
410 newdc
->BoundsRect
= dc
->BoundsRect
;
411 newdc
->gdiFont
= dc
->gdiFont
;
413 PATH_InitGdiPath( &newdc
->path
);
415 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
420 newdc
->hMetaClipRgn
= 0;
423 newdc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
424 CombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
428 newdc
->hMetaRgn
= CreateRectRgn( 0, 0, 0, 0 );
429 CombineRgn( newdc
->hMetaRgn
, dc
->hMetaRgn
, 0, RGN_COPY
);
432 /* don't bother recomputing hMetaClipRgn, we'll do that in SetDCState */
434 if (!PATH_AssignGdiPath( &newdc
->path
, &dc
->path
))
436 release_dc_ptr( dc
);
437 free_dc_state( newdc
);
441 newdc
->saved_dc
= dc
->saved_dc
;
442 dc
->saved_dc
= newdc
;
443 return ++dc
->saveLevel
;
447 /***********************************************************************
450 BOOL
nulldrv_RestoreDC( PHYSDEV dev
, INT level
)
452 DC
*dcs
, *first_dcs
, *dc
= get_nulldrv_dc( dev
);
455 /* find the state level to restore */
457 if (abs(level
) > dc
->saveLevel
|| level
== 0) return FALSE
;
458 if (level
< 0) level
= dc
->saveLevel
+ level
+ 1;
459 first_dcs
= dc
->saved_dc
;
460 for (dcs
= first_dcs
, save_level
= dc
->saveLevel
; save_level
> level
; save_level
--)
463 /* restore the state */
465 if (!PATH_AssignGdiPath( &dc
->path
, &dcs
->path
)) return FALSE
;
467 dc
->flags
= dcs
->flags
;
468 dc
->layout
= dcs
->layout
;
469 dc
->hDevice
= dcs
->hDevice
;
470 dc
->ROPmode
= dcs
->ROPmode
;
471 dc
->polyFillMode
= dcs
->polyFillMode
;
472 dc
->stretchBltMode
= dcs
->stretchBltMode
;
473 dc
->relAbsMode
= dcs
->relAbsMode
;
474 dc
->backgroundMode
= dcs
->backgroundMode
;
475 dc
->backgroundColor
= dcs
->backgroundColor
;
476 dc
->textColor
= dcs
->textColor
;
477 dc
->dcBrushColor
= dcs
->dcBrushColor
;
478 dc
->dcPenColor
= dcs
->dcPenColor
;
479 dc
->brushOrgX
= dcs
->brushOrgX
;
480 dc
->brushOrgY
= dcs
->brushOrgY
;
481 dc
->mapperFlags
= dcs
->mapperFlags
;
482 dc
->textAlign
= dcs
->textAlign
;
483 dc
->charExtra
= dcs
->charExtra
;
484 dc
->breakExtra
= dcs
->breakExtra
;
485 dc
->breakRem
= dcs
->breakRem
;
486 dc
->MapMode
= dcs
->MapMode
;
487 dc
->GraphicsMode
= dcs
->GraphicsMode
;
488 dc
->CursPosX
= dcs
->CursPosX
;
489 dc
->CursPosY
= dcs
->CursPosY
;
490 dc
->ArcDirection
= dcs
->ArcDirection
;
491 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
492 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
493 dc
->xformVport2World
= dcs
->xformVport2World
;
494 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
495 dc
->BoundsRect
= dcs
->BoundsRect
;
497 dc
->wndOrgX
= dcs
->wndOrgX
;
498 dc
->wndOrgY
= dcs
->wndOrgY
;
499 dc
->wndExtX
= dcs
->wndExtX
;
500 dc
->wndExtY
= dcs
->wndExtY
;
501 dc
->vportOrgX
= dcs
->vportOrgX
;
502 dc
->vportOrgY
= dcs
->vportOrgY
;
503 dc
->vportExtX
= dcs
->vportExtX
;
504 dc
->vportExtY
= dcs
->vportExtY
;
505 dc
->virtual_res
= dcs
->virtual_res
;
506 dc
->virtual_size
= dcs
->virtual_size
;
510 if (!dc
->hClipRgn
) dc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
511 CombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
515 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
520 if (!dc
->hMetaRgn
) dc
->hMetaRgn
= CreateRectRgn( 0, 0, 0, 0 );
521 CombineRgn( dc
->hMetaRgn
, dcs
->hMetaRgn
, 0, RGN_COPY
);
525 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
528 DC_UpdateXforms( dc
);
529 CLIPPING_UpdateGCRegion( dc
);
531 SelectObject( dev
->hdc
, dcs
->hBitmap
);
532 SelectObject( dev
->hdc
, dcs
->hBrush
);
533 SelectObject( dev
->hdc
, dcs
->hFont
);
534 SelectObject( dev
->hdc
, dcs
->hPen
);
535 SetBkColor( dev
->hdc
, dcs
->backgroundColor
);
536 SetTextColor( dev
->hdc
, dcs
->textColor
);
537 GDISelectPalette( dev
->hdc
, dcs
->hPalette
, FALSE
);
539 dc
->saved_dc
= dcs
->saved_dc
;
541 dc
->saveLevel
= save_level
- 1;
543 /* now destroy all the saved DCs */
547 DC
*next
= first_dcs
->saved_dc
;
548 free_dc_state( first_dcs
);
555 /***********************************************************************
558 INT WINAPI
SaveDC( HDC hdc
)
563 if ((dc
= get_dc_ptr( hdc
)))
565 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSaveDC
);
566 ret
= physdev
->funcs
->pSaveDC( physdev
);
567 release_dc_ptr( dc
);
573 /***********************************************************************
574 * RestoreDC (GDI32.@)
576 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
579 BOOL success
= FALSE
;
581 TRACE("%p %d\n", hdc
, level
);
582 if ((dc
= get_dc_ptr( hdc
)))
584 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRestoreDC
);
586 success
= physdev
->funcs
->pRestoreDC( physdev
, level
);
587 release_dc_ptr( dc
);
593 /***********************************************************************
594 * CreateDCW (GDI32.@)
596 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
597 const DEVMODEW
*initData
)
601 const DC_FUNCTIONS
*funcs
;
606 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
610 ERR( "no device found for %s\n", debugstr_w(device
) );
613 strcpyW(buf
, driver
);
616 if (!(funcs
= DRIVER_load_driver( buf
)))
618 ERR( "no driver found for %s\n", debugstr_w(buf
) );
621 if (!(dc
= alloc_dc_ptr( OBJ_DC
))) goto error
;
624 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
625 if (!(dc
->hVisRgn
= CreateRectRgn( 0, 0, 1, 1 ))) goto error
;
627 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
628 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
630 if (funcs
->pCreateDC
)
632 if (!funcs
->pCreateDC( &dc
->physDev
, buf
, device
, output
, initData
))
634 WARN("creation aborted by device\n" );
639 dc
->vis_rect
.left
= 0;
640 dc
->vis_rect
.top
= 0;
641 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
642 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
643 SetRectRgn(dc
->hVisRgn
, dc
->vis_rect
.left
, dc
->vis_rect
.top
, dc
->vis_rect
.right
, dc
->vis_rect
.bottom
);
646 release_dc_ptr( dc
);
650 if (dc
) free_dc_ptr( dc
);
655 /***********************************************************************
656 * CreateDCA (GDI32.@)
658 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
659 const DEVMODEA
*initData
)
661 UNICODE_STRING driverW
, deviceW
, outputW
;
665 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
666 else driverW
.Buffer
= NULL
;
668 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
669 else deviceW
.Buffer
= NULL
;
671 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
672 else outputW
.Buffer
= NULL
;
677 /* don't convert initData for DISPLAY driver, it's not used */
678 if (!driverW
.Buffer
|| strcmpiW( driverW
.Buffer
, displayW
))
679 initDataW
= GdiConvertToDevmodeW(initData
);
682 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
684 RtlFreeUnicodeString(&driverW
);
685 RtlFreeUnicodeString(&deviceW
);
686 RtlFreeUnicodeString(&outputW
);
687 HeapFree(GetProcessHeap(), 0, initDataW
);
692 /***********************************************************************
693 * CreateICA (GDI32.@)
695 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
696 const DEVMODEA
* initData
)
698 /* Nothing special yet for ICs */
699 return CreateDCA( driver
, device
, output
, initData
);
703 /***********************************************************************
704 * CreateICW (GDI32.@)
706 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
707 const DEVMODEW
* initData
)
709 /* Nothing special yet for ICs */
710 return CreateDCW( driver
, device
, output
, initData
);
714 /***********************************************************************
715 * CreateCompatibleDC (GDI32.@)
717 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
721 const struct gdi_dc_funcs
*funcs
= &null_driver
;
722 PHYSDEV physDev
= NULL
;
728 if (!(origDC
= get_dc_ptr( hdc
))) return 0;
729 physDev
= GET_DC_PHYSDEV( origDC
, pCreateCompatibleDC
);
730 funcs
= physDev
->funcs
;
731 release_dc_ptr( origDC
);
734 if (!(dc
= alloc_dc_ptr( OBJ_MEMDC
))) goto error
;
736 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
738 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
739 dc
->vis_rect
.left
= 0;
740 dc
->vis_rect
.top
= 0;
741 dc
->vis_rect
.right
= 1;
742 dc
->vis_rect
.bottom
= 1;
743 if (!(dc
->hVisRgn
= CreateRectRgn( 0, 0, 1, 1 ))) goto error
; /* default bitmap is 1x1 */
747 if (!funcs
->pCreateCompatibleDC( physDev
, &dc
->physDev
))
749 WARN("creation aborted by device\n");
753 release_dc_ptr( dc
);
757 if (dc
) free_dc_ptr( dc
);
762 /***********************************************************************
765 BOOL WINAPI
DeleteDC( HDC hdc
)
773 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
774 if (dc
->refcount
!= 1)
776 FIXME( "not deleting busy DC %p refcount %u\n", dc
->hSelf
, dc
->refcount
);
777 release_dc_ptr( dc
);
781 /* Call hook procedure to check whether is it OK to delete this DC */
782 if (dc
->hookProc
&& !dc
->hookProc( hdc
, DCHC_DELETEDC
, dc
->dwHookData
, 0 ))
784 release_dc_ptr( dc
);
788 while (dc
->saveLevel
)
790 DC
*dcs
= dc
->saved_dc
;
791 dc
->saved_dc
= dcs
->saved_dc
;
793 free_dc_state( dcs
);
796 SelectObject( hdc
, GetStockObject(BLACK_PEN
) );
797 SelectObject( hdc
, GetStockObject(WHITE_BRUSH
) );
798 SelectObject( hdc
, GetStockObject(SYSTEM_FONT
) );
799 SelectObject( hdc
, GetStockObject(DEFAULT_BITMAP
) );
806 /***********************************************************************
809 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
814 if ((dc
= get_dc_ptr( hdc
)))
816 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pResetDC
);
817 ret
= physdev
->funcs
->pResetDC( physdev
, devmode
);
818 if (ret
) /* reset the visible region */
821 dc
->vis_rect
.left
= 0;
822 dc
->vis_rect
.top
= 0;
823 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
824 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
825 SetRectRgn( dc
->hVisRgn
, dc
->vis_rect
.left
, dc
->vis_rect
.top
,
826 dc
->vis_rect
.right
, dc
->vis_rect
.bottom
);
827 CLIPPING_UpdateGCRegion( dc
);
829 release_dc_ptr( dc
);
835 /***********************************************************************
838 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
843 if (devmode
) devmodeW
= GdiConvertToDevmodeW(devmode
);
844 else devmodeW
= NULL
;
846 ret
= ResetDCW(hdc
, devmodeW
);
848 HeapFree(GetProcessHeap(), 0, devmodeW
);
853 /***********************************************************************
854 * GetDeviceCaps (GDI32.@)
856 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
861 if ((dc
= get_dc_ptr( hdc
)))
863 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceCaps
);
864 ret
= physdev
->funcs
->pGetDeviceCaps( physdev
, cap
);
865 release_dc_ptr( dc
);
871 /***********************************************************************
872 * GetBkColor (GDI32.@)
874 COLORREF WINAPI
GetBkColor( HDC hdc
)
877 DC
* dc
= get_dc_ptr( hdc
);
880 ret
= dc
->backgroundColor
;
881 release_dc_ptr( dc
);
887 /***********************************************************************
888 * SetBkColor (GDI32.@)
890 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
892 COLORREF ret
= CLR_INVALID
;
893 DC
* dc
= get_dc_ptr( hdc
);
895 TRACE("hdc=%p color=0x%08x\n", hdc
, color
);
899 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkColor
);
900 color
= physdev
->funcs
->pSetBkColor( physdev
, color
);
901 if (color
!= CLR_INVALID
)
903 ret
= dc
->backgroundColor
;
904 dc
->backgroundColor
= color
;
906 release_dc_ptr( dc
);
912 /***********************************************************************
913 * GetTextColor (GDI32.@)
915 COLORREF WINAPI
GetTextColor( HDC hdc
)
918 DC
* dc
= get_dc_ptr( hdc
);
922 release_dc_ptr( dc
);
928 /***********************************************************************
929 * SetTextColor (GDI32.@)
931 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
933 COLORREF ret
= CLR_INVALID
;
934 DC
* dc
= get_dc_ptr( hdc
);
936 TRACE(" hdc=%p color=0x%08x\n", hdc
, color
);
940 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextColor
);
941 color
= physdev
->funcs
->pSetTextColor( physdev
, color
);
942 if (color
!= CLR_INVALID
)
945 dc
->textColor
= color
;
947 release_dc_ptr( dc
);
953 /***********************************************************************
954 * GetTextAlign (GDI32.@)
956 UINT WINAPI
GetTextAlign( HDC hdc
)
959 DC
* dc
= get_dc_ptr( hdc
);
963 release_dc_ptr( dc
);
969 /***********************************************************************
970 * SetTextAlign (GDI32.@)
972 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
974 UINT ret
= GDI_ERROR
;
975 DC
*dc
= get_dc_ptr( hdc
);
977 TRACE("hdc=%p align=%d\n", hdc
, align
);
981 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextAlign
);
982 align
= physdev
->funcs
->pSetTextAlign( physdev
, align
);
983 if (align
!= GDI_ERROR
)
986 dc
->textAlign
= align
;
988 release_dc_ptr( dc
);
993 /***********************************************************************
994 * GetDCOrgEx (GDI32.@)
996 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
1000 if (!lpp
) return FALSE
;
1001 if (!(dc
= get_dc_ptr( hDC
))) return FALSE
;
1002 lpp
->x
= dc
->vis_rect
.left
;
1003 lpp
->y
= dc
->vis_rect
.top
;
1004 release_dc_ptr( dc
);
1009 /***********************************************************************
1010 * GetGraphicsMode (GDI32.@)
1012 INT WINAPI
GetGraphicsMode( HDC hdc
)
1015 DC
* dc
= get_dc_ptr( hdc
);
1018 ret
= dc
->GraphicsMode
;
1019 release_dc_ptr( dc
);
1025 /***********************************************************************
1026 * SetGraphicsMode (GDI32.@)
1028 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
1031 DC
*dc
= get_dc_ptr( hdc
);
1033 /* One would think that setting the graphics mode to GM_COMPATIBLE
1034 * would also reset the world transformation matrix to the unity
1035 * matrix. However, in Windows, this is not the case. This doesn't
1036 * make a lot of sense to me, but that's the way it is.
1039 if ((mode
> 0) && (mode
<= GM_LAST
))
1041 ret
= dc
->GraphicsMode
;
1042 dc
->GraphicsMode
= mode
;
1044 release_dc_ptr( dc
);
1049 /***********************************************************************
1050 * GetArcDirection (GDI32.@)
1052 INT WINAPI
GetArcDirection( HDC hdc
)
1055 DC
* dc
= get_dc_ptr( hdc
);
1058 ret
= dc
->ArcDirection
;
1059 release_dc_ptr( dc
);
1065 /***********************************************************************
1066 * SetArcDirection (GDI32.@)
1068 INT WINAPI
SetArcDirection( HDC hdc
, INT dir
)
1073 if (dir
!= AD_COUNTERCLOCKWISE
&& dir
!= AD_CLOCKWISE
)
1075 SetLastError(ERROR_INVALID_PARAMETER
);
1079 if ((dc
= get_dc_ptr( hdc
)))
1081 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetArcDirection
);
1082 dir
= physdev
->funcs
->pSetArcDirection( physdev
, dir
);
1085 ret
= dc
->ArcDirection
;
1086 dc
->ArcDirection
= dir
;
1088 release_dc_ptr( dc
);
1094 /***********************************************************************
1095 * GetWorldTransform (GDI32.@)
1097 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
1100 if (!xform
) return FALSE
;
1101 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
1102 *xform
= dc
->xformWorld2Wnd
;
1103 release_dc_ptr( dc
);
1108 /***********************************************************************
1109 * GetTransform (GDI32.@)
1113 * Returns one of the co-ordinate space transforms
1116 * hdc [I] Device context.
1117 * which [I] Which xform to return:
1118 * 0x203 World -> Page transform (that set by SetWorldTransform).
1119 * 0x304 Page -> Device transform (the mapping mode transform).
1120 * 0x204 World -> Device transform (the combination of the above two).
1121 * 0x402 Device -> World transform (the inversion of the above).
1122 * xform [O] The xform.
1125 BOOL WINAPI
GetTransform( HDC hdc
, DWORD which
, XFORM
*xform
)
1128 DC
*dc
= get_dc_ptr( hdc
);
1129 if (!dc
) return FALSE
;
1134 *xform
= dc
->xformWorld2Wnd
;
1138 construct_window_to_viewport(dc
, xform
);
1142 *xform
= dc
->xformWorld2Vport
;
1146 *xform
= dc
->xformVport2World
;
1150 FIXME("Unknown code %x\n", which
);
1154 release_dc_ptr( dc
);
1159 /****************************************************************************
1160 * CombineTransform [GDI32.@]
1161 * Combines two transformation matrices.
1164 * xformResult [O] Stores the result of combining the two matrices
1165 * xform1 [I] Specifies the first matrix to apply
1166 * xform2 [I] Specifies the second matrix to apply
1169 * The same matrix can be passed in for more than one of the parameters.
1173 * Failure: FALSE. Use GetLastError() to determine the cause.
1175 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1176 const XFORM
*xform2
)
1180 /* Check for illegal parameters */
1181 if (!xformResult
|| !xform1
|| !xform2
)
1184 /* Create the result in a temporary XFORM, since xformResult may be
1185 * equal to xform1 or xform2 */
1186 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1187 xform1
->eM12
* xform2
->eM21
;
1188 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1189 xform1
->eM12
* xform2
->eM22
;
1190 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1191 xform1
->eM22
* xform2
->eM21
;
1192 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1193 xform1
->eM22
* xform2
->eM22
;
1194 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1195 xform1
->eDy
* xform2
->eM21
+
1197 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1198 xform1
->eDy
* xform2
->eM22
+
1201 /* Copy the result to xformResult */
1202 *xformResult
= xformTemp
;
1208 /***********************************************************************
1209 * SetDCHook (GDI32.@)
1211 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1213 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD_PTR dwHookData
)
1215 DC
*dc
= get_dc_ptr( hdc
);
1217 if (!dc
) return FALSE
;
1219 dc
->dwHookData
= dwHookData
;
1220 dc
->hookProc
= hookProc
;
1221 release_dc_ptr( dc
);
1226 /***********************************************************************
1227 * GetDCHook (GDI32.@)
1229 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1231 DWORD_PTR WINAPI
GetDCHook( HDC hdc
, DCHOOKPROC
*proc
)
1233 DC
*dc
= get_dc_ptr( hdc
);
1237 if (proc
) *proc
= dc
->hookProc
;
1238 ret
= dc
->dwHookData
;
1239 release_dc_ptr( dc
);
1244 /***********************************************************************
1245 * SetHookFlags (GDI32.@)
1247 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1249 WORD WINAPI
SetHookFlags( HDC hdc
, WORD flags
)
1251 DC
*dc
= get_dc_obj( hdc
); /* not get_dc_ptr, this needs to work from any thread */
1256 /* "Undocumented Windows" info is slightly confusing. */
1258 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1260 if (flags
& DCHF_INVALIDATEVISRGN
)
1261 ret
= InterlockedExchange( &dc
->dirty
, 1 );
1262 else if (flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1263 ret
= InterlockedExchange( &dc
->dirty
, 0 );
1265 GDI_ReleaseObj( hdc
);
1269 /***********************************************************************
1270 * SetICMMode (GDI32.@)
1272 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1274 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1275 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1276 if (iEnableICM
== ICM_ON
) return 0;
1277 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1281 /***********************************************************************
1282 * GetDeviceGammaRamp (GDI32.@)
1284 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1287 DC
*dc
= get_dc_ptr( hDC
);
1289 TRACE("%p, %p\n", hDC
, ptr
);
1292 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceGammaRamp
);
1293 ret
= physdev
->funcs
->pGetDeviceGammaRamp( physdev
, ptr
);
1294 release_dc_ptr( dc
);
1299 /***********************************************************************
1300 * SetDeviceGammaRamp (GDI32.@)
1302 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1305 DC
*dc
= get_dc_ptr( hDC
);
1307 TRACE("%p, %p\n", hDC
, ptr
);
1310 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDeviceGammaRamp
);
1311 ret
= physdev
->funcs
->pSetDeviceGammaRamp( physdev
, ptr
);
1312 release_dc_ptr( dc
);
1317 /***********************************************************************
1318 * GetColorSpace (GDI32.@)
1320 HCOLORSPACE WINAPI
GetColorSpace(HDC hdc
)
1322 /*FIXME Need to do whatever GetColorSpace actually does */
1326 /***********************************************************************
1327 * CreateColorSpaceA (GDI32.@)
1329 HCOLORSPACE WINAPI
CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace
)
1335 /***********************************************************************
1336 * CreateColorSpaceW (GDI32.@)
1338 HCOLORSPACE WINAPI
CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace
)
1344 /***********************************************************************
1345 * DeleteColorSpace (GDI32.@)
1347 BOOL WINAPI
DeleteColorSpace( HCOLORSPACE hColorSpace
)
1354 /***********************************************************************
1355 * SetColorSpace (GDI32.@)
1357 HCOLORSPACE WINAPI
SetColorSpace( HDC hDC
, HCOLORSPACE hColorSpace
)
1364 /***********************************************************************
1365 * GetBoundsRect (GDI32.@)
1367 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1370 DC
*dc
= get_dc_ptr( hdc
);
1372 if ( !dc
) return 0;
1376 *rect
= dc
->BoundsRect
;
1377 ret
= is_rect_empty( rect
) ? DCB_RESET
: DCB_SET
;
1378 DPtoLP( hdc
, (POINT
*)rect
, 2 );
1380 if (flags
& DCB_RESET
)
1382 dc
->BoundsRect
.left
= 0;
1383 dc
->BoundsRect
.top
= 0;
1384 dc
->BoundsRect
.right
= 0;
1385 dc
->BoundsRect
.bottom
= 0;
1387 release_dc_ptr( dc
);
1392 /***********************************************************************
1393 * SetBoundsRect (GDI32.@)
1395 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1400 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
1401 if (!(dc
= get_dc_ptr( hdc
))) return 0;
1403 ret
= ((dc
->flags
& DC_BOUNDS_ENABLE
) ? DCB_ENABLE
: DCB_DISABLE
) |
1404 (is_rect_empty( &dc
->BoundsRect
) ? DCB_RESET
: DCB_SET
);
1406 if (flags
& DCB_RESET
)
1408 dc
->BoundsRect
.left
= 0;
1409 dc
->BoundsRect
.top
= 0;
1410 dc
->BoundsRect
.right
= 0;
1411 dc
->BoundsRect
.bottom
= 0;
1414 if ((flags
& DCB_ACCUMULATE
) && rect
)
1418 LPtoDP( hdc
, (POINT
*)&rc
, 2 );
1419 if (!is_rect_empty( &rc
))
1421 if (!is_rect_empty( &dc
->BoundsRect
))
1423 dc
->BoundsRect
.left
= min( dc
->BoundsRect
.left
, rc
.left
);
1424 dc
->BoundsRect
.top
= min( dc
->BoundsRect
.top
, rc
.top
);
1425 dc
->BoundsRect
.right
= max( dc
->BoundsRect
.right
, rc
.right
);
1426 dc
->BoundsRect
.bottom
= max( dc
->BoundsRect
.bottom
, rc
.bottom
);
1428 else dc
->BoundsRect
= rc
;
1432 if (flags
& DCB_ENABLE
) dc
->flags
|= DC_BOUNDS_ENABLE
;
1433 if (flags
& DCB_DISABLE
) dc
->flags
&= ~DC_BOUNDS_ENABLE
;
1435 release_dc_ptr( dc
);
1440 /***********************************************************************
1441 * GetRelAbs (GDI32.@)
1443 INT WINAPI
GetRelAbs( HDC hdc
, DWORD dwIgnore
)
1446 DC
*dc
= get_dc_ptr( hdc
);
1449 ret
= dc
->relAbsMode
;
1450 release_dc_ptr( dc
);
1458 /***********************************************************************
1459 * GetBkMode (GDI32.@)
1461 INT WINAPI
GetBkMode( HDC hdc
)
1464 DC
* dc
= get_dc_ptr( hdc
);
1467 ret
= dc
->backgroundMode
;
1468 release_dc_ptr( dc
);
1474 /***********************************************************************
1475 * SetBkMode (GDI32.@)
1477 INT WINAPI
SetBkMode( HDC hdc
, INT mode
)
1482 if ((mode
<= 0) || (mode
> BKMODE_LAST
))
1484 SetLastError(ERROR_INVALID_PARAMETER
);
1487 if ((dc
= get_dc_ptr( hdc
)))
1489 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkMode
);
1490 mode
= physdev
->funcs
->pSetBkMode( physdev
, mode
);
1493 ret
= dc
->backgroundMode
;
1494 dc
->backgroundMode
= mode
;
1496 release_dc_ptr( dc
);
1502 /***********************************************************************
1505 INT WINAPI
GetROP2( HDC hdc
)
1508 DC
* dc
= get_dc_ptr( hdc
);
1512 release_dc_ptr( dc
);
1518 /***********************************************************************
1521 INT WINAPI
SetROP2( HDC hdc
, INT mode
)
1526 if ((mode
< R2_BLACK
) || (mode
> R2_WHITE
))
1528 SetLastError(ERROR_INVALID_PARAMETER
);
1531 if ((dc
= get_dc_ptr( hdc
)))
1533 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetROP2
);
1534 mode
= physdev
->funcs
->pSetROP2( physdev
, mode
);
1540 release_dc_ptr( dc
);
1546 /***********************************************************************
1547 * SetRelAbs (GDI32.@)
1549 INT WINAPI
SetRelAbs( HDC hdc
, INT mode
)
1554 if ((mode
!= ABSOLUTE
) && (mode
!= RELATIVE
))
1556 SetLastError(ERROR_INVALID_PARAMETER
);
1559 if ((dc
= get_dc_ptr( hdc
)))
1561 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetRelAbs
);
1562 mode
= physdev
->funcs
->pSetRelAbs( physdev
, mode
);
1565 ret
= dc
->relAbsMode
;
1566 dc
->relAbsMode
= mode
;
1568 release_dc_ptr( dc
);
1574 /***********************************************************************
1575 * GetPolyFillMode (GDI32.@)
1577 INT WINAPI
GetPolyFillMode( HDC hdc
)
1580 DC
* dc
= get_dc_ptr( hdc
);
1583 ret
= dc
->polyFillMode
;
1584 release_dc_ptr( dc
);
1590 /***********************************************************************
1591 * SetPolyFillMode (GDI32.@)
1593 INT WINAPI
SetPolyFillMode( HDC hdc
, INT mode
)
1598 if ((mode
<= 0) || (mode
> POLYFILL_LAST
))
1600 SetLastError(ERROR_INVALID_PARAMETER
);
1603 if ((dc
= get_dc_ptr( hdc
)))
1605 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetPolyFillMode
);
1606 mode
= physdev
->funcs
->pSetPolyFillMode( physdev
, mode
);
1609 ret
= dc
->polyFillMode
;
1610 dc
->polyFillMode
= mode
;
1612 release_dc_ptr( dc
);
1618 /***********************************************************************
1619 * GetStretchBltMode (GDI32.@)
1621 INT WINAPI
GetStretchBltMode( HDC hdc
)
1624 DC
* dc
= get_dc_ptr( hdc
);
1627 ret
= dc
->stretchBltMode
;
1628 release_dc_ptr( dc
);
1634 /***********************************************************************
1635 * SetStretchBltMode (GDI32.@)
1637 INT WINAPI
SetStretchBltMode( HDC hdc
, INT mode
)
1642 if ((mode
<= 0) || (mode
> MAXSTRETCHBLTMODE
))
1644 SetLastError(ERROR_INVALID_PARAMETER
);
1647 if ((dc
= get_dc_ptr( hdc
)))
1649 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetStretchBltMode
);
1650 mode
= physdev
->funcs
->pSetStretchBltMode( physdev
, mode
);
1653 ret
= dc
->stretchBltMode
;
1654 dc
->stretchBltMode
= mode
;
1656 release_dc_ptr( dc
);
1662 /***********************************************************************
1663 * GetMapMode (GDI32.@)
1665 INT WINAPI
GetMapMode( HDC hdc
)
1668 DC
* dc
= get_dc_ptr( hdc
);
1672 release_dc_ptr( dc
);
1678 /***********************************************************************
1679 * GetBrushOrgEx (GDI32.@)
1681 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, LPPOINT pt
)
1683 DC
* dc
= get_dc_ptr( hdc
);
1684 if (!dc
) return FALSE
;
1685 pt
->x
= dc
->brushOrgX
;
1686 pt
->y
= dc
->brushOrgY
;
1687 release_dc_ptr( dc
);
1692 /***********************************************************************
1693 * GetCurrentPositionEx (GDI32.@)
1695 BOOL WINAPI
GetCurrentPositionEx( HDC hdc
, LPPOINT pt
)
1697 DC
* dc
= get_dc_ptr( hdc
);
1698 if (!dc
) return FALSE
;
1699 pt
->x
= dc
->CursPosX
;
1700 pt
->y
= dc
->CursPosY
;
1701 release_dc_ptr( dc
);
1706 /***********************************************************************
1707 * GetViewportExtEx (GDI32.@)
1709 BOOL WINAPI
GetViewportExtEx( HDC hdc
, LPSIZE size
)
1711 DC
* dc
= get_dc_ptr( hdc
);
1712 if (!dc
) return FALSE
;
1713 size
->cx
= dc
->vportExtX
;
1714 size
->cy
= dc
->vportExtY
;
1715 release_dc_ptr( dc
);
1720 /***********************************************************************
1721 * GetViewportOrgEx (GDI32.@)
1723 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, LPPOINT pt
)
1725 DC
* dc
= get_dc_ptr( hdc
);
1726 if (!dc
) return FALSE
;
1727 pt
->x
= dc
->vportOrgX
;
1728 pt
->y
= dc
->vportOrgY
;
1729 release_dc_ptr( dc
);
1734 /***********************************************************************
1735 * GetWindowExtEx (GDI32.@)
1737 BOOL WINAPI
GetWindowExtEx( HDC hdc
, LPSIZE size
)
1739 DC
* dc
= get_dc_ptr( hdc
);
1740 if (!dc
) return FALSE
;
1741 size
->cx
= dc
->wndExtX
;
1742 size
->cy
= dc
->wndExtY
;
1743 release_dc_ptr( dc
);
1748 /***********************************************************************
1749 * GetWindowOrgEx (GDI32.@)
1751 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, LPPOINT pt
)
1753 DC
* dc
= get_dc_ptr( hdc
);
1754 if (!dc
) return FALSE
;
1755 pt
->x
= dc
->wndOrgX
;
1756 pt
->y
= dc
->wndOrgY
;
1757 release_dc_ptr( dc
);
1762 /***********************************************************************
1763 * GetLayout (GDI32.@)
1765 * Gets left->right or right->left text layout flags of a dc.
1768 DWORD WINAPI
GetLayout(HDC hdc
)
1770 DWORD layout
= GDI_ERROR
;
1772 DC
* dc
= get_dc_ptr( hdc
);
1775 layout
= dc
->layout
;
1776 release_dc_ptr( dc
);
1779 TRACE("hdc : %p, layout : %08x\n", hdc
, layout
);
1784 /***********************************************************************
1785 * SetLayout (GDI32.@)
1787 * Sets left->right or right->left text layout flags of a dc.
1790 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1792 DWORD oldlayout
= GDI_ERROR
;
1794 DC
* dc
= get_dc_ptr( hdc
);
1797 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetLayout
);
1798 layout
= physdev
->funcs
->pSetLayout( physdev
, layout
);
1799 if (layout
!= GDI_ERROR
)
1801 oldlayout
= dc
->layout
;
1802 dc
->layout
= layout
;
1803 if (layout
!= oldlayout
)
1805 if (layout
& LAYOUT_RTL
) dc
->MapMode
= MM_ANISOTROPIC
;
1806 DC_UpdateXforms( dc
);
1809 release_dc_ptr( dc
);
1812 TRACE("hdc : %p, old layout : %08x, new layout : %08x\n", hdc
, oldlayout
, layout
);
1817 /***********************************************************************
1818 * GetDCBrushColor (GDI32.@)
1820 COLORREF WINAPI
GetDCBrushColor(HDC hdc
)
1823 COLORREF dcBrushColor
= CLR_INVALID
;
1825 TRACE("hdc(%p)\n", hdc
);
1827 dc
= get_dc_ptr( hdc
);
1830 dcBrushColor
= dc
->dcBrushColor
;
1831 release_dc_ptr( dc
);
1834 return dcBrushColor
;
1837 /***********************************************************************
1838 * SetDCBrushColor (GDI32.@)
1840 COLORREF WINAPI
SetDCBrushColor(HDC hdc
, COLORREF crColor
)
1843 COLORREF oldClr
= CLR_INVALID
;
1845 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1847 dc
= get_dc_ptr( hdc
);
1850 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCBrushColor
);
1851 crColor
= physdev
->funcs
->pSetDCBrushColor( physdev
, crColor
);
1852 if (crColor
!= CLR_INVALID
)
1854 oldClr
= dc
->dcBrushColor
;
1855 dc
->dcBrushColor
= crColor
;
1857 release_dc_ptr( dc
);
1863 /***********************************************************************
1864 * GetDCPenColor (GDI32.@)
1866 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
1869 COLORREF dcPenColor
= CLR_INVALID
;
1871 TRACE("hdc(%p)\n", hdc
);
1873 dc
= get_dc_ptr( hdc
);
1876 dcPenColor
= dc
->dcPenColor
;
1877 release_dc_ptr( dc
);
1883 /***********************************************************************
1884 * SetDCPenColor (GDI32.@)
1886 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1889 COLORREF oldClr
= CLR_INVALID
;
1891 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1893 dc
= get_dc_ptr( hdc
);
1896 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCPenColor
);
1897 crColor
= physdev
->funcs
->pSetDCPenColor( physdev
, crColor
);
1898 if (crColor
!= CLR_INVALID
)
1900 oldClr
= dc
->dcPenColor
;
1901 dc
->dcPenColor
= crColor
;
1903 release_dc_ptr( dc
);
1909 /***********************************************************************
1910 * CancelDC (GDI32.@)
1912 BOOL WINAPI
CancelDC(HDC hdc
)
1918 /*******************************************************************
1919 * GetMiterLimit [GDI32.@]
1923 BOOL WINAPI
GetMiterLimit(HDC hdc
, PFLOAT peLimit
)
1928 TRACE("(%p,%p)\n", hdc
, peLimit
);
1930 dc
= get_dc_ptr( hdc
);
1934 *peLimit
= dc
->miterLimit
;
1936 release_dc_ptr( dc
);
1942 /*******************************************************************
1943 * SetMiterLimit [GDI32.@]
1947 BOOL WINAPI
SetMiterLimit(HDC hdc
, FLOAT eNewLimit
, PFLOAT peOldLimit
)
1952 TRACE("(%p,%f,%p)\n", hdc
, eNewLimit
, peOldLimit
);
1954 dc
= get_dc_ptr( hdc
);
1958 *peOldLimit
= dc
->miterLimit
;
1959 dc
->miterLimit
= eNewLimit
;
1960 release_dc_ptr( dc
);
1966 /*******************************************************************
1967 * GdiIsMetaPrintDC [GDI32.@]
1969 BOOL WINAPI
GdiIsMetaPrintDC(HDC hdc
)
1975 /*******************************************************************
1976 * GdiIsMetaFileDC [GDI32.@]
1978 BOOL WINAPI
GdiIsMetaFileDC(HDC hdc
)
1982 switch( GetObjectType( hdc
) )
1991 /*******************************************************************
1992 * GdiIsPlayMetafileDC [GDI32.@]
1994 BOOL WINAPI
GdiIsPlayMetafileDC(HDC hdc
)