7 GreDPtoLP(HDC hdc
, LPPOINT lpPoints
, INT nCount
)
10 if (!(dc
= DC_LockDc(hdc
)))
12 EngSetLastError(ERROR_INVALID_HANDLE
);
15 IntDPtoLP(dc
, lpPoints
, nCount
);
21 GreLPtoDP(HDC hdc
, LPPOINT lpPoints
, INT nCount
)
24 if (!(dc
= DC_LockDc(hdc
)))
26 EngSetLastError(ERROR_INVALID_HANDLE
);
29 IntLPtoDP(dc
, lpPoints
, nCount
);
39 if (!(dc
= DC_LockDc(hdc
)))
41 EngSetLastError(ERROR_INVALID_HANDLE
);
44 lBkMode
= dc
->pdcattr
->lBkMode
;
50 GreGetMapMode(HDC hdc
)
54 if (!(dc
= DC_LockDc(hdc
)))
56 EngSetLastError(ERROR_INVALID_HANDLE
);
59 iMapMode
= dc
->pdcattr
->iMapMode
;
65 GreGetTextColor(HDC hdc
)
68 ULONG ulForegroundClr
;
69 if (!(dc
= DC_LockDc(hdc
)))
71 EngSetLastError(ERROR_INVALID_HANDLE
);
74 ulForegroundClr
= dc
->pdcattr
->ulForegroundClr
;
76 return ulForegroundClr
;
80 IntGdiSetBkColor(HDC hDC
, COLORREF color
)
87 if (!(dc
= DC_LockDc(hDC
)))
89 EngSetLastError(ERROR_INVALID_HANDLE
);
92 pdcattr
= dc
->pdcattr
;
93 oldColor
= pdcattr
->crBackgroundClr
;
94 pdcattr
->crBackgroundClr
= color
;
95 pdcattr
->ulBackgroundClr
= (ULONG
)color
;
96 pdcattr
->ulDirty_
|= DIRTY_BACKGROUND
|DIRTY_LINE
|DIRTY_FILL
; // Clear Flag if set.
97 hBrush
= pdcattr
->hbrush
;
99 NtGdiSelectBrush(hDC
, hBrush
);
104 IntGdiSetBkMode(HDC hDC
, INT Mode
)
110 if (!(dc
= DC_LockDc(hDC
)))
112 EngSetLastError(ERROR_INVALID_HANDLE
);
115 pdcattr
= dc
->pdcattr
;
116 oldMode
= pdcattr
->lBkMode
;
117 pdcattr
->jBkMode
= Mode
;
118 pdcattr
->lBkMode
= Mode
;
125 IntGdiSetTextAlign(HDC hDC
,
135 EngSetLastError(ERROR_INVALID_HANDLE
);
138 pdcattr
= dc
->pdcattr
;
139 prevAlign
= pdcattr
->lTextAlign
;
140 pdcattr
->lTextAlign
= Mode
;
147 IntGdiSetTextColor(HDC hDC
,
154 pdc
= DC_LockDc(hDC
);
157 EngSetLastError(ERROR_INVALID_HANDLE
);
160 pdcattr
= pdc
->pdcattr
;
162 // What about ulForegroundClr, like in gdi32?
163 crOldColor
= pdcattr
->crForegroundClr
;
164 pdcattr
->crForegroundClr
= color
;
165 DC_vUpdateTextBrush(pdc
);
173 IntSetDCBrushColor(HDC hdc
, COLORREF crColor
)
175 COLORREF OldColor
= CLR_INVALID
;
177 if (!(dc
= DC_LockDc(hdc
)))
179 EngSetLastError(ERROR_INVALID_HANDLE
);
184 OldColor
= (COLORREF
) dc
->pdcattr
->ulBrushClr
;
185 dc
->pdcattr
->ulBrushClr
= (ULONG
) crColor
;
187 if ( dc
->pdcattr
->crBrushClr
!= crColor
)
189 dc
->pdcattr
->ulDirty_
|= DIRTY_FILL
;
190 dc
->pdcattr
->crBrushClr
= crColor
;
198 IntSetDCPenColor(HDC hdc
, COLORREF crColor
)
202 if (!(dc
= DC_LockDc(hdc
)))
204 EngSetLastError(ERROR_INVALID_PARAMETER
);
208 OldColor
= (COLORREF
)dc
->pdcattr
->ulPenClr
;
209 dc
->pdcattr
->ulPenClr
= (ULONG
)crColor
;
211 if (dc
->pdcattr
->crPenClr
!= crColor
)
213 dc
->pdcattr
->ulDirty_
|= DIRTY_LINE
;
214 dc
->pdcattr
->crPenClr
= crColor
;
222 GreSetStretchBltMode(HDC hDC
, int iStretchMode
)
228 pdc
= DC_LockDc(hDC
);
231 pdcattr
= pdc
->pdcattr
;
232 oSMode
= pdcattr
->lStretchBltMode
;
233 pdcattr
->lStretchBltMode
= iStretchMode
;
235 // Wine returns an error here. We set the default.
236 if ((iStretchMode
<= 0) || (iStretchMode
> MAXSTRETCHBLTMODE
)) iStretchMode
= WHITEONBLACK
;
238 pdcattr
->jStretchBltMode
= iStretchMode
;
246 DCU_SetDcUndeletable(HDC hDC
)
248 PDC dc
= DC_LockDc(hDC
);
251 EngSetLastError(ERROR_INVALID_HANDLE
);
255 dc
->fs
|= DC_FLAG_PERMANENT
;
262 IntIsPrimarySurface(SURFOBJ
*SurfObj
)
264 if (PrimarySurface
.pSurface
== NULL
)
268 return SurfObj
->hsurf
== PrimarySurface
.pSurface
; // <- FIXME: WTF?
274 IntSetDefaultRegion(PDC pdc
)
278 RECTL rclWnd
, rclClip
;
280 IntGdiReleaseRaoRgn(pdc
);
284 rclWnd
.right
= pdc
->dclevel
.sizl
.cx
;
285 rclWnd
.bottom
= pdc
->dclevel
.sizl
.cy
;
288 //EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
289 if (pdc
->ppdev
->flFlags
& PDEV_META_DEVICE
)
291 pSurface
= pdc
->dclevel
.pSurface
;
292 if (pSurface
&& pSurface
->flags
& PDEV_SURFACE
)
294 rclClip
.left
+= pdc
->ppdev
->ptlOrigion
.x
;
295 rclClip
.top
+= pdc
->ppdev
->ptlOrigion
.y
;
296 rclClip
.right
+= pdc
->ppdev
->ptlOrigion
.x
;
297 rclClip
.bottom
+= pdc
->ppdev
->ptlOrigion
.y
;
300 //EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
304 if (prgn
&& prgn
!= prgnDefault
)
306 REGION_SetRectRgn( prgn
,
314 prgn
= IntSysCreateRectpRgn( rclClip
.left
,
323 pdc
->ptlDCOrig
.x
= 0;
324 pdc
->ptlDCOrig
.y
= 0;
325 pdc
->erclWindow
= rclWnd
;
326 pdc
->erclClip
= rclClip
;
327 /* Might be an InitDC or DCE... */
328 pdc
->ptlFillOrigin
.x
= pdc
->dcattr
.VisRectRegion
.Rect
.right
;
329 pdc
->ptlFillOrigin
.y
= pdc
->dcattr
.VisRectRegion
.Rect
.bottom
;
333 pdc
->prgnVis
= prgnDefault
;
339 NtGdiCancelDC(HDC hDC
)
347 IntGdiSetHookFlags(HDC hDC
, WORD Flags
)
350 DC
*dc
= DC_LockDc(hDC
);
354 EngSetLastError(ERROR_INVALID_HANDLE
);
358 wRet
= dc
->fs
& DC_FLAG_DIRTY_RAO
; // FIXME: Wrong flag!
360 /* Info in "Undocumented Windows" is slightly confusing. */
361 DPRINT("DC %p, Flags %04x\n", hDC
, Flags
);
363 if (Flags
& DCHF_INVALIDATEVISRGN
)
365 /* hVisRgn has to be updated */
366 dc
->fs
|= DC_FLAG_DIRTY_RAO
;
368 else if (Flags
& DCHF_VALIDATEVISRGN
|| 0 == Flags
)
370 dc
->fs
&= ~DC_FLAG_DIRTY_RAO
;
390 DWORD SafeResult
= 0;
391 NTSTATUS Status
= STATUS_SUCCESS
;
395 EngSetLastError(ERROR_INVALID_PARAMETER
);
399 pdc
= DC_LockDc(hDC
);
402 EngSetLastError(ERROR_INVALID_HANDLE
);
405 pdcattr
= pdc
->pdcattr
;
413 SafeResult
= pdcattr
->lRelAbs
;
416 case GdiGetBreakExtra
:
417 SafeResult
= pdcattr
->lBreakExtra
;
420 case GdiGerCharBreak
:
421 SafeResult
= pdcattr
->cBreak
;
424 case GdiGetArcDirection
:
425 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
426 SafeResult
= AD_CLOCKWISE
- ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0);
428 SafeResult
= ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0) + AD_COUNTERCLOCKWISE
;
431 case GdiGetEMFRestorDc
:
434 case GdiGetFontLanguageInfo
:
435 SafeResult
= IntGetFontLanguageInfo(pdc
);
439 SafeResult
= pdc
->dctype
;
443 SafeResult
= pdcattr
->iMapMode
;
446 case GdiGetTextCharExtra
:
447 SafeResult
= pdcattr
->lTextExtra
;
451 EngSetLastError(ERROR_INVALID_PARAMETER
);
460 ProbeForWrite(Result
, sizeof(DWORD
), 1);
461 *Result
= SafeResult
;
463 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
465 Status
= _SEH2_GetExceptionCode();
469 if (!NT_SUCCESS(Status
))
471 SetLastNtError(Status
);
480 _Success_(return != FALSE
)
483 NtGdiGetAndSetDCDword(
487 _Out_ DWORD
*pdwResult
)
493 DWORD SafeResult
= 0;
494 NTSTATUS Status
= STATUS_SUCCESS
;
498 EngSetLastError(ERROR_INVALID_PARAMETER
);
502 pdc
= DC_LockDc(hdc
);
505 EngSetLastError(ERROR_INVALID_HANDLE
);
508 pdcattr
= pdc
->pdcattr
;
512 case GdiGetSetCopyCount
:
513 SafeResult
= pdc
->ulCopyCount
;
514 pdc
->ulCopyCount
= dwIn
;
517 case GdiGetSetTextAlign
:
518 SafeResult
= pdcattr
->lTextAlign
;
519 pdcattr
->lTextAlign
= dwIn
;
520 // pdcattr->flTextAlign = dwIn; // Flags!
523 case GdiGetSetRelAbs
:
524 SafeResult
= pdcattr
->lRelAbs
;
525 pdcattr
->lRelAbs
= dwIn
;
528 case GdiGetSetTextCharExtra
:
529 SafeResult
= pdcattr
->lTextExtra
;
530 pdcattr
->lTextExtra
= dwIn
;
533 case GdiGetSetSelectFont
:
536 case GdiGetSetMapperFlagsInternal
:
539 EngSetLastError(ERROR_INVALID_PARAMETER
);
543 SafeResult
= pdcattr
->flFontMapper
;
544 pdcattr
->flFontMapper
= dwIn
;
547 case GdiGetSetMapMode
:
548 SafeResult
= IntGdiSetMapMode(pdc
, dwIn
);
551 case GdiGetSetArcDirection
:
552 if (dwIn
!= AD_COUNTERCLOCKWISE
&& dwIn
!= AD_CLOCKWISE
)
554 EngSetLastError(ERROR_INVALID_PARAMETER
);
558 if (pdcattr
->dwLayout
& LAYOUT_RTL
) // Right to Left
560 SafeResult
= AD_CLOCKWISE
- ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0);
561 if (dwIn
== AD_CLOCKWISE
)
563 pdc
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
566 pdc
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
568 else // Left to Right
570 SafeResult
= ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0) +
572 if (dwIn
== AD_COUNTERCLOCKWISE
)
574 pdc
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
577 pdc
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
582 EngSetLastError(ERROR_INVALID_PARAMETER
);
591 ProbeForWrite(pdwResult
, sizeof(DWORD
), 1);
592 *pdwResult
= SafeResult
;
594 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
596 Status
= _SEH2_GetExceptionCode();
600 if (!NT_SUCCESS(Status
))
602 SetLastNtError(Status
);
622 if (!(pdc
= DC_LockDc(hdc
))) return 0;
624 /* Get the return value */
625 ret
= pdc
->fs
& DC_ACCUM_APP
? DCB_ENABLE
: DCB_DISABLE
;
626 ret
|= RECTL_bIsEmptyRect(&pdc
->erclBoundsApp
) ? DCB_RESET
: DCB_SET
;
628 /* Copy the rect to the caller */
631 ProbeForWrite(prc
, sizeof(RECT
), 1);
632 *prc
= pdc
->erclBoundsApp
;
634 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
640 if (flags
& DCB_RESET
)
642 RECTL_vSetEmptyRect(&pdc
->erclBoundsApp
);
661 /* Verify arguments */
662 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
665 if (!(pdc
= DC_LockDc(hdc
))) return 0;
667 /* Get the return value */
668 ret
= pdc
->fs
& DC_ACCUM_APP
? DCB_ENABLE
: DCB_DISABLE
;
669 ret
|= RECTL_bIsEmptyRect(&pdc
->erclBoundsApp
) ? DCB_RESET
: DCB_SET
;
671 if (flags
& DCB_RESET
)
673 RECTL_vSetEmptyRect(&pdc
->erclBoundsApp
);
676 if (flags
& DCB_ACCUMULATE
)
678 /* Capture the rect */
681 ProbeForRead(prc
, sizeof(RECT
), 1);
684 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
687 _SEH2_YIELD(return 0;)
691 RECTL_vMakeWellOrdered(&rcl
);
692 RECTL_bUnionRect(&pdc
->erclBoundsApp
, &pdc
->erclBoundsApp
, &rcl
);
695 if (flags
& DCB_ENABLE
) pdc
->fs
|= DC_ACCUM_APP
;
696 if (flags
& DCB_DISABLE
) pdc
->fs
&= ~DC_ACCUM_APP
;
701 /* Translates a COLORREF to the right color in the specified DC color space */
703 TranslateCOLORREF(PDC pdc
, COLORREF crColor
)
707 ULONG index
, ulColor
, iBitmapFormat
;
710 /* Get the DC surface */
711 psurfDC
= pdc
->dclevel
.pSurface
;
713 /* If no surface is selected, use the default bitmap */
715 psurfDC
= psurfDefaultBitmap
;
717 /* Check what color type this is */
718 switch (crColor
>> 24)
720 case 0x00: /* RGB color */
723 case 0x01: /* PALETTEINDEX */
724 index
= crColor
& 0xFFFFFF;
725 ppalDC
= pdc
->dclevel
.ppal
;
726 if (index
>= ppalDC
->NumColors
) index
= 0;
728 /* Get the RGB value */
729 crColor
= PALETTE_ulGetRGBColorFromIndex(ppalDC
, index
);
732 case 0x02: /* PALETTERGB */
734 if (pdc
->dclevel
.hpal
!= StockObjects
[DEFAULT_PALETTE
])
736 /* First find the nearest index in the dc palette */
737 ppalDC
= pdc
->dclevel
.ppal
;
738 index
= PALETTE_ulGetNearestIndex(ppalDC
, crColor
& 0xFFFFFF);
740 /* Get the RGB value */
741 crColor
= PALETTE_ulGetRGBColorFromIndex(ppalDC
, index
);
745 /* Use the pure color */
746 crColor
= crColor
& 0x00FFFFFF;
750 case 0x10: /* DIBINDEX */
751 /* Mask the value to match the target bpp */
752 iBitmapFormat
= psurfDC
->SurfObj
.iBitmapFormat
;
753 if (iBitmapFormat
== BMF_1BPP
) index
= crColor
& 0x1;
754 else if (iBitmapFormat
== BMF_4BPP
) index
= crColor
& 0xf;
755 else if (iBitmapFormat
== BMF_8BPP
) index
= crColor
& 0xFF;
756 else if (iBitmapFormat
== BMF_16BPP
) index
= crColor
& 0xFFFF;
757 else index
= crColor
& 0xFFFFFF;
761 DPRINT("Unsupported color type %u passed\n", crColor
>> 24);
765 /* Initialize an XLATEOBJ from RGB to the target surface */
766 EXLATEOBJ_vInitialize(&exlo
, &gpalRGB
, psurfDC
->ppal
, 0xFFFFFF, 0, 0);
768 /* Translate the color to the target format */
769 ulColor
= XLATEOBJ_iXlate(&exlo
.xlo
, crColor
);
771 /* Cleanup the XLATEOBJ */
772 EXLATEOBJ_vCleanup(&exlo
);