ReactOS 0.4.15-dev-7842-g558ab78
dcutil.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for dcutil.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL FASTCALL GreDPtoLP (HDC hdc, LPPOINT lpPoints, INT nCount)
 
BOOL FASTCALL GreLPtoDP (HDC hdc, LPPOINT lpPoints, INT nCount)
 
int FASTCALL GreGetBkMode (HDC hdc)
 
COLORREF FASTCALL GreGetBkColor (HDC hdc)
 
int FASTCALL GreGetMapMode (HDC hdc)
 
COLORREF FASTCALL GreGetTextColor (HDC hdc)
 
COLORREF FASTCALL IntGdiSetBkColor (HDC hDC, COLORREF color)
 
INT FASTCALL IntGdiSetBkMode (HDC hDC, INT Mode)
 
UINT FASTCALL IntGdiSetTextAlign (HDC hDC, UINT Mode)
 
COLORREF FASTCALL IntGdiSetTextColor (HDC hDC, COLORREF color)
 
COLORREF FASTCALL IntSetDCBrushColor (HDC hdc, COLORREF crColor)
 
BOOL FASTCALL GreSetBrushOrg (HDC hdc, INT x, INT y, LPPOINT pptOut)
 
COLORREF FASTCALL IntSetDCPenColor (HDC hdc, COLORREF crColor)
 
int FASTCALL GreSetStretchBltMode (HDC hDC, int iStretchMode)
 
int FASTCALL GreGetGraphicsMode (HDC hdc)
 
VOID FASTCALL DCU_SetDcUndeletable (HDC hDC)
 
BOOL FASTCALL IntSetDefaultRegion (PDC pdc)
 
BOOL APIENTRY NtGdiCancelDC (HDC hDC)
 
WORD APIENTRY IntGdiSetHookFlags (HDC hDC, WORD Flags)
 
BOOL APIENTRY NtGdiGetDCDword (HDC hDC, UINT u, DWORD *Result)
 
 _Success_ (return !=FALSE)
 
VOID FASTCALL IntUpdateBoundsRect (PDC pdc, PRECTL pRect)
 
DWORD APIENTRY NtGdiGetBoundsRect (IN HDC hdc, OUT LPRECT prc, IN DWORD flags)
 
DWORD APIENTRY NtGdiSetBoundsRect (IN HDC hdc, IN LPRECT prc, IN DWORD flags)
 
ULONG TranslateCOLORREF (PDC pdc, COLORREF crColor)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 3 of file dcutil.c.

Function Documentation

◆ _Success_()

_Success_ ( return = FALSE)

Definition at line 556 of file dcutil.c.

564{
565 BOOL Ret = TRUE;
566 PDC pdc;
567 PDC_ATTR pdcattr;
568
569 DWORD SafeResult = 0;
571
572 if (!pdwResult)
573 {
575 return FALSE;
576 }
577
578 pdc = DC_LockDc(hdc);
579 if (!pdc)
580 {
582 return FALSE;
583 }
584 pdcattr = pdc->pdcattr;
585
586 switch (u)
587 {
589 SafeResult = pdc->fs & DC_EPSPRINTINGESCAPE;
590 pdc->fs &= ~DC_EPSPRINTINGESCAPE;
591 break;
592
594 SafeResult = pdc->ulCopyCount;
595 pdc->ulCopyCount = dwIn;
596 break;
597
599 SafeResult = pdcattr->lTextAlign;
600 pdcattr->lTextAlign = dwIn;
601 // pdcattr->flTextAlign = dwIn; // Flags!
602 break;
603
604 case GdiGetSetRelAbs:
605 SafeResult = pdcattr->lRelAbs;
606 pdcattr->lRelAbs = dwIn;
607 break;
608
610 SafeResult = pdcattr->lTextExtra;
611 pdcattr->lTextExtra = dwIn;
612 break;
613
615 break;
616
618 if (dwIn & ~1)
619 {
621 Ret = FALSE;
622 break;
623 }
624 SafeResult = pdcattr->flFontMapper;
625 pdcattr->flFontMapper = dwIn;
626 break;
627
628 case GdiGetSetMapMode:
629 SafeResult = IntGdiSetMapMode(pdc, dwIn);
630 break;
631
634 {
636 Ret = FALSE;
637 break;
638 }
639 if (pdcattr->dwLayout & LAYOUT_RTL) // Right to Left
640 {
641 SafeResult = AD_CLOCKWISE - ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0);
642 if (dwIn == AD_CLOCKWISE)
643 {
644 pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
645 break;
646 }
647 pdc->dclevel.flPath |= DCPATH_CLOCKWISE;
648 }
649 else // Left to Right
650 {
651 SafeResult = ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0) +
654 {
655 pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
656 break;
657 }
658 pdc->dclevel.flPath |= DCPATH_CLOCKWISE;
659 }
660 break;
661
662 default:
664 Ret = FALSE;
665 break;
666 }
667
668 if (Ret)
669 {
671 {
672 ProbeForWrite(pdwResult, sizeof(DWORD), 1);
673 *pdwResult = SafeResult;
674 }
676 {
678 }
679 _SEH2_END;
680
681 if (!NT_SUCCESS(Status))
682 {
684 Ret = FALSE;
685 }
686 }
687
688 DC_UnlockDc(pdc);
689 return Ret;
690}
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
@ DC_EPSPRINTINGESCAPE
Definition: dc.h:28
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HDC hdc
Definition: main.c:9
int APIENTRY IntGdiSetMapMode(PDC dc, int MapMode)
Definition: coord.c:828
_In_ UINT _In_ DWORD dwIn
Definition: ntgdi.h:249
_In_ UINT _In_ DWORD _Out_ DWORD * pdwResult
Definition: ntgdi.h:250
@ GdiGetSetEPSPrintingEscape
Definition: ntgdityp.h:62
@ GdiGetSetTextAlign
Definition: ntgdityp.h:64
@ GdiGetSetMapMode
Definition: ntgdityp.h:69
@ GdiGetSetSelectFont
Definition: ntgdityp.h:67
@ GdiGetSetArcDirection
Definition: ntgdityp.h:70
@ GdiGetSetMapperFlagsInternal
Definition: ntgdityp.h:68
@ GdiGetSetRelAbs
Definition: ntgdityp.h:65
@ GdiGetSetTextCharExtra
Definition: ntgdityp.h:66
@ GdiGetSetCopyCount
Definition: ntgdityp.h:63
@ DCPATH_CLOCKWISE
Definition: path.h:8
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: polytest.cpp:41
DWORD dwLayout
Definition: ntgdihdl.h:339
LONG lTextAlign
Definition: ntgdihdl.h:325
LONG lTextExtra
Definition: ntgdihdl.h:326
LONG lRelAbs
Definition: ntgdihdl.h:327
FLONG flFontMapper
Definition: ntgdihdl.h:316
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:667
#define AD_CLOCKWISE
Definition: wingdi.h:668

◆ DCU_SetDcUndeletable()

VOID FASTCALL DCU_SetDcUndeletable ( HDC  hDC)

Definition at line 322 of file dcutil.c.

323{
324 PDC dc = DC_LockDc(hDC);
325 if (!dc)
326 {
328 return;
329 }
330
331 dc->fs |= DC_PERMANANT;
333 return;
334}
static HDC hDC
Definition: 3dtext.c:33
@ DC_PERMANANT
Definition: dc.h:22
static const WCHAR dc[]

Referenced by DceAllocDCE().

◆ GreDPtoLP()

BOOL FASTCALL GreDPtoLP ( HDC  hdc,
LPPOINT  lpPoints,
INT  nCount 
)

Definition at line 7 of file dcutil.c.

8{
9 PDC dc;
10 if (!(dc = DC_LockDc(hdc)))
11 {
13 return FALSE;
14 }
15 IntDPtoLP(dc, lpPoints, nCount);
17 return TRUE;
18}
static BOOLEAN IntDPtoLP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:192

Referenced by co_UserGetUpdateRect(), and IntDefWindowProc().

◆ GreGetBkColor()

COLORREF FASTCALL GreGetBkColor ( HDC  hdc)

Definition at line 50 of file dcutil.c.

51{
52 PDC dc;
53 COLORREF crBk;
54 if (!(dc = DC_LockDc(hdc)))
55 {
57 return CLR_INVALID;
58 }
59 crBk = dc->pdcattr->ulBackgroundClr;
61 return crBk;
62}
DWORD COLORREF
Definition: windef.h:300
#define CLR_INVALID
Definition: wingdi.h:883

Referenced by MENU_DrawMenuItem().

◆ GreGetBkMode()

int FASTCALL GreGetBkMode ( HDC  hdc)

Definition at line 35 of file dcutil.c.

36{
37 PDC dc;
38 LONG lBkMode;
39 if (!(dc = DC_LockDc(hdc)))
40 {
42 return CLR_INVALID;
43 }
44 lBkMode = dc->pdcattr->lBkMode;
46 return lBkMode;
47}
long LONG
Definition: pedump.c:60

Referenced by MENU_DrawPopupGlyph(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), and UITOOLS95_DrawFrameScroll().

◆ GreGetGraphicsMode()

int FASTCALL GreGetGraphicsMode ( HDC  hdc)

Definition at line 306 of file dcutil.c.

307{
308 PDC dc;
309 int GraphicsMode;
310 if (!(dc = DC_LockDc(hdc)))
311 {
313 return CLR_INVALID;
314 }
315 GraphicsMode = dc->pdcattr->iGraphicsMode;
317 return GraphicsMode;
318}

Referenced by DrawTextExWorker().

◆ GreGetMapMode()

int FASTCALL GreGetMapMode ( HDC  hdc)

Definition at line 65 of file dcutil.c.

66{
67 PDC dc;
68 INT iMapMode;
69 if (!(dc = DC_LockDc(hdc)))
70 {
72 return CLR_INVALID;
73 }
74 iMapMode = dc->pdcattr->iMapMode;
76 return iMapMode;
77}
int32_t INT
Definition: typedefs.h:58

Referenced by DrawFrameControl().

◆ GreGetTextColor()

COLORREF FASTCALL GreGetTextColor ( HDC  hdc)

Definition at line 80 of file dcutil.c.

81{
82 PDC dc;
83 ULONG ulForegroundClr;
84 if (!(dc = DC_LockDc(hdc)))
85 {
87 return CLR_INVALID;
88 }
89 ulForegroundClr = dc->pdcattr->ulForegroundClr;
91 return ulForegroundClr;
92}
uint32_t ULONG
Definition: typedefs.h:59

Referenced by MENU_DrawMenuItem(), MENU_DrawPopupGlyph(), TEXT_DrawUnderscore(), UITOOLS95_DrawFrameCaption(), and UITOOLS95_DrawFrameScroll().

◆ GreLPtoDP()

BOOL FASTCALL GreLPtoDP ( HDC  hdc,
LPPOINT  lpPoints,
INT  nCount 
)

Definition at line 21 of file dcutil.c.

22{
23 PDC dc;
24 if (!(dc = DC_LockDc(hdc)))
25 {
27 return FALSE;
28 }
29 IntLPtoDP(dc, lpPoints, nCount);
31 return TRUE;
32}
static BOOLEAN IntLPtoDP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:182

◆ GreSetBrushOrg()

BOOL FASTCALL GreSetBrushOrg ( HDC  hdc,
INT  x,
INT  y,
LPPOINT  pptOut 
)

Definition at line 231 of file dcutil.c.

236{
237 PDC pdc = DC_LockDc(hdc);
238 if (pdc == NULL)
239 {
241 return FALSE;
242 }
243
244 if (pptOut != NULL)
245 {
246 *pptOut = pdc->pdcattr->ptlBrushOrigin;
247 }
248
249 pdc->pdcattr->ptlBrushOrigin.x = x;
250 pdc->pdcattr->ptlBrushOrigin.y = y;
251
252 DC_vSetBrushOrigin(pdc, x, y);
253
254 DC_UnlockDc(pdc);
255 return TRUE;
256}
VOID NTAPI DC_vSetBrushOrigin(PDC pdc, LONG x, LONG y)
Definition: dcobjs.c:142
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _Out_ PPOINTL pptOut
Definition: ntgdi.h:2198

Referenced by _Success_(), and IntFillWindow().

◆ GreSetStretchBltMode()

int FASTCALL GreSetStretchBltMode ( HDC  hDC,
int  iStretchMode 
)

Definition at line 283 of file dcutil.c.

284{
285 PDC pdc;
286 PDC_ATTR pdcattr;
287 INT oSMode = 0;
288
289 pdc = DC_LockDc(hDC);
290 if (pdc)
291 {
292 pdcattr = pdc->pdcattr;
293 oSMode = pdcattr->lStretchBltMode;
294 pdcattr->lStretchBltMode = iStretchMode;
295
296 // Wine returns an error here. We set the default.
297 if ((iStretchMode <= 0) || (iStretchMode > MAXSTRETCHBLTMODE)) iStretchMode = WHITEONBLACK;
298
299 pdcattr->jStretchBltMode = iStretchMode;
300 DC_UnlockDc(pdc);
301 }
302 return oSMode;
303}
LONG lStretchBltMode
Definition: ntgdihdl.h:315
BYTE jStretchBltMode
Definition: ntgdihdl.h:310
#define WHITEONBLACK
Definition: wingdi.h:953
#define MAXSTRETCHBLTMODE
Definition: wingdi.h:956

◆ IntGdiSetBkColor()

COLORREF FASTCALL IntGdiSetBkColor ( HDC  hDC,
COLORREF  color 
)

Definition at line 95 of file dcutil.c.

96{
97 COLORREF oldColor;
98 PDC dc;
99 PDC_ATTR pdcattr;
100 HBRUSH hBrush;
101
102 if (!(dc = DC_LockDc(hDC)))
103 {
105 return CLR_INVALID;
106 }
107 pdcattr = dc->pdcattr;
108
109 oldColor = pdcattr->ulBackgroundClr;
110 pdcattr->ulBackgroundClr = color;
111
112 if (pdcattr->crBackgroundClr != color)
113 {
114 pdcattr->ulDirty_ |= (DIRTY_BACKGROUND|DIRTY_LINE|DIRTY_FILL); // Clear Flag if set.
115 pdcattr->crBackgroundClr = color;
116 }
117 hBrush = pdcattr->hbrush;
119 NtGdiSelectBrush(hDC, hBrush);
120 return oldColor;
121}
GLuint color
Definition: glext.h:6243
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
#define DIRTY_FILL
Definition: ntgdihdl.h:123
#define DIRTY_LINE
Definition: ntgdihdl.h:124
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:126
HANDLE hbrush
Definition: ntgdihdl.h:295
ULONG ulBackgroundClr
Definition: ntgdihdl.h:298
COLORREF crBackgroundClr
Definition: ntgdihdl.h:297
ULONG ulDirty_
Definition: ntgdihdl.h:294

◆ IntGdiSetBkMode()

INT FASTCALL IntGdiSetBkMode ( HDC  hDC,
INT  Mode 
)

Definition at line 124 of file dcutil.c.

125{
126 COLORREF oldMode;
127 PDC dc;
128 PDC_ATTR pdcattr;
129
130 if (!(dc = DC_LockDc(hDC)))
131 {
133 return CLR_INVALID;
134 }
135 pdcattr = dc->pdcattr;
136 oldMode = pdcattr->lBkMode;
137 pdcattr->jBkMode = Mode;
138 pdcattr->lBkMode = Mode;
140 return oldMode;
141}
_In_ ULONG Mode
Definition: hubbusif.h:303
LONG lBkMode
Definition: ntgdihdl.h:313
BYTE jBkMode
Definition: ntgdihdl.h:308

Referenced by DrawFrameControl(), IntPaintDesktop(), MENU_DrawMenuItem(), MENU_DrawPopupGlyph(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameScroll(), and UserDrawCaptionText().

◆ IntGdiSetHookFlags()

WORD APIENTRY IntGdiSetHookFlags ( HDC  hDC,
WORD  Flags 
)

Definition at line 422 of file dcutil.c.

423{
424 WORD wRet;
425 DC *dc = DC_LockDc(hDC);
426
427 if (NULL == dc)
428 {
430 return 0;
431 }
432
433 wRet = dc->fs & DC_DIRTY_RAO; // FIXME: Wrong flag!
434
435 /* Info in "Undocumented Windows" is slightly confusing. */
436 DPRINT("DC %p, Flags %04x\n", hDC, Flags);
437
439 {
440 /* hVisRgn has to be updated */
441 dc->fs |= DC_DIRTY_RAO;
442 }
443 else if (Flags & DCHF_VALIDATEVISRGN || 0 == Flags)
444 {
445 //dc->fs &= ~DC_DIRTY_RAO;
446 }
447
449
450 return wRet;
451}
@ DC_DIRTY_RAO
Definition: dc.h:23
unsigned short WORD
Definition: ntddk_ex.h:93
#define DCHF_INVALIDATEVISRGN
Definition: gdi_driver.h:267
#define DCHF_VALIDATEVISRGN
Definition: gdi_driver.h:268
#define DPRINT
Definition: sndvol32.h:71
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by DceDeleteClipRgn(), DceResetActiveDCEs(), and UserGetDCEx().

◆ IntGdiSetTextAlign()

UINT FASTCALL IntGdiSetTextAlign ( HDC  hDC,
UINT  Mode 
)

Definition at line 145 of file dcutil.c.

147{
148 UINT prevAlign;
149 DC *dc;
150 PDC_ATTR pdcattr;
151
152 dc = DC_LockDc(hDC);
153 if (!dc)
154 {
156 return GDI_ERROR;
157 }
158 pdcattr = dc->pdcattr;
159 prevAlign = pdcattr->lTextAlign;
160 pdcattr->lTextAlign = Mode;
161 if (pdcattr->dwLayout & LAYOUT_RTL)
162 {
163 if ((Mode & TA_CENTER) != TA_CENTER) Mode ^= TA_RIGHT;
164 }
165 pdcattr->flTextAlign = Mode & TA_MASK;
167 return prevAlign;
168}
unsigned int UINT
Definition: ndis.h:50
FLONG flTextAlign
Definition: ntgdihdl.h:324
#define TA_RIGHT
Definition: wingdi.h:933
#define TA_MASK
Definition: wingdi.h:937
#define GDI_ERROR
Definition: wingdi.h:1309
#define TA_CENTER
Definition: wingdi.h:931

Referenced by IntPaintDesktop().

◆ IntGdiSetTextColor()

COLORREF FASTCALL IntGdiSetTextColor ( HDC  hDC,
COLORREF  color 
)

Definition at line 172 of file dcutil.c.

174{
175 COLORREF crOldColor;
176 PDC pdc;
177 PDC_ATTR pdcattr;
178
179 pdc = DC_LockDc(hDC);
180 if (!pdc)
181 {
183 return CLR_INVALID;
184 }
185 pdcattr = pdc->pdcattr;
186
187 crOldColor = (COLORREF) pdcattr->ulForegroundClr;
188 pdcattr->ulForegroundClr = (ULONG)color;
189
190 if (pdcattr->crForegroundClr != color)
191 {
193 pdcattr->crForegroundClr = color;
194 }
195
199
200 DC_UnlockDc(pdc);
201
202 return crOldColor;
203}
VOID FASTCALL DC_vUpdateLineBrush(PDC pdc)
Definition: dcobjs.c:62
VOID FASTCALL DC_vUpdateTextBrush(PDC pdc)
Definition: dcobjs.c:108
VOID FASTCALL DC_vUpdateFillBrush(PDC pdc)
Definition: dcobjs.c:16
#define DIRTY_TEXT
Definition: ntgdihdl.h:125
ULONG ulForegroundClr
Definition: ntgdihdl.h:300
COLORREF crForegroundClr
Definition: ntgdihdl.h:299

Referenced by DefWndControlColor(), DrawFrameControl(), IntPaintDesktop(), MENU_DrawMenuItem(), MENU_DrawPopupGlyph(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), UITOOLS95_DrawFrameScroll(), and UserDrawCaptionText().

◆ IntSetDCBrushColor()

COLORREF FASTCALL IntSetDCBrushColor ( HDC  hdc,
COLORREF  crColor 
)

Definition at line 206 of file dcutil.c.

207{
208 COLORREF OldColor = CLR_INVALID;
209 PDC dc;
210 if (!(dc = DC_LockDc(hdc)))
211 {
213 return CLR_INVALID;
214 }
215 else
216 {
217 OldColor = (COLORREF) dc->pdcattr->ulBrushClr;
218 dc->pdcattr->ulBrushClr = (ULONG) crColor;
219
220 if ( dc->pdcattr->crBrushClr != crColor )
221 {
222 dc->pdcattr->ulDirty_ |= DIRTY_FILL;
223 dc->pdcattr->crBrushClr = crColor;
224 }
225 }
227 return OldColor;
228}

Referenced by IntDrawDiagEdge().

◆ IntSetDCPenColor()

COLORREF FASTCALL IntSetDCPenColor ( HDC  hdc,
COLORREF  crColor 
)

Definition at line 259 of file dcutil.c.

260{
261 COLORREF OldColor;
262 PDC dc;
263 if (!(dc = DC_LockDc(hdc)))
264 {
266 return CLR_INVALID;
267 }
268
269 OldColor = (COLORREF)dc->pdcattr->ulPenClr;
270 dc->pdcattr->ulPenClr = (ULONG)crColor;
271
272 if (dc->pdcattr->crPenClr != crColor)
273 {
274 dc->pdcattr->ulDirty_ |= DIRTY_LINE;
275 dc->pdcattr->crPenClr = crColor;
276 }
278 return OldColor;
279}

Referenced by IntDrawDiagEdge(), IntDrawMenuBarTemp(), IntDrawRectEdge(), MENU_DrawMenuItem(), NC_DoNCPaint(), and UserDrawCaptionBar().

◆ IntSetDefaultRegion()

BOOL FASTCALL IntSetDefaultRegion ( PDC  pdc)

Definition at line 350 of file dcutil.c.

351{
353 PREGION prgn;
354 RECTL rclWnd, rclClip;
355
357
358 rclWnd.left = 0;
359 rclWnd.top = 0;
360 rclWnd.right = pdc->dclevel.sizl.cx;
361 rclWnd.bottom = pdc->dclevel.sizl.cy;
362 rclClip = rclWnd;
363
364 //EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
365 if (pdc->ppdev->flFlags & PDEV_META_DEVICE)
366 {
367 pSurface = pdc->dclevel.pSurface;
368 if (pSurface && pSurface->flags & PDEV_SURFACE)
369 {
370 rclClip.left += pdc->ppdev->ptlOrigion.x;
371 rclClip.top += pdc->ppdev->ptlOrigion.y;
372 rclClip.right += pdc->ppdev->ptlOrigion.x;
373 rclClip.bottom += pdc->ppdev->ptlOrigion.y;
374 }
375 }
376 //EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
377
378 prgn = pdc->prgnVis;
379
380 if (prgn && prgn != prgnDefault)
381 {
382 REGION_SetRectRgn( prgn,
383 rclClip.left,
384 rclClip.top,
385 rclClip.right ,
386 rclClip.bottom );
387 }
388 else
389 {
390 prgn = IntSysCreateRectpRgn( rclClip.left,
391 rclClip.top,
392 rclClip.right ,
393 rclClip.bottom );
394 pdc->prgnVis = prgn;
395 }
396
397 if (prgn)
398 {
399 pdc->ptlDCOrig.x = 0;
400 pdc->ptlDCOrig.y = 0;
401 pdc->erclWindow = rclWnd;
402 pdc->erclClip = rclClip;
403 /* Might be an InitDC or DCE... */
404 pdc->ptlFillOrigin = pdc->dcattr.ptlBrushOrigin;
405 return TRUE;
406 }
407 // No Vis use the Default System Region.
408 pdc->prgnVis = prgnDefault;
409 return FALSE;
410}
VOID FASTCALL IntGdiReleaseRaoRgn(PDC pDC)
Definition: cliprgn.c:16
@ PDEV_META_DEVICE
Definition: pdevobj.h:20
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
Definition: region.h:8
@ PDEV_SURFACE
Definition: surface.h:81
PREGION prgnDefault
Definition: region.c:129
VOID FASTCALL REGION_SetRectRgn(PREGION rgn, INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2665
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2407
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481

Referenced by GdiSelectVisRgn(), and MakeInfoDC().

◆ IntUpdateBoundsRect()

VOID FASTCALL IntUpdateBoundsRect ( PDC  pdc,
PRECTL  pRect 
)

Definition at line 694 of file dcutil.c.

695{
696 if (pdc->fs & DC_ACCUM_APP)
697 {
698 RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, pRect);
699 }
700 if (pdc->fs & DC_ACCUM_WMGR)
701 {
702 RECTL_bUnionRect(&pdc->erclBounds, &pdc->erclBounds, pRect);
703 }
704}
@ DC_ACCUM_APP
Definition: dc.h:25
@ DC_ACCUM_WMGR
Definition: dc.h:24
BOOL FASTCALL RECTL_bUnionRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:18

Referenced by AddPenLinesBounds(), GreGradientFill(), GreStretchBltMask(), IntGdiBitBltRgn(), IntGdiFillRgn(), IntPatBlt(), IntRectangle(), NtGdiAlphaBlend(), NtGdiExtFloodFill(), NtGdiMaskBlt(), NtGdiSetDIBitsToDeviceInternal(), NtGdiSetPixel(), NtGdiStretchDIBitsInternal(), and NtGdiTransparentBlt().

◆ NtGdiCancelDC()

BOOL APIENTRY NtGdiCancelDC ( HDC  hDC)

Definition at line 414 of file dcutil.c.

415{
417 return FALSE;
418}
#define UNIMPLEMENTED
Definition: debug.h:115

◆ NtGdiGetBoundsRect()

DWORD APIENTRY NtGdiGetBoundsRect ( IN HDC  hdc,
OUT LPRECT  prc,
IN DWORD  flags 
)

Definition at line 708 of file dcutil.c.

712{
713 DWORD ret;
714 PDC pdc;
715 RECT rc;
716
717 /* Lock the DC */
718 if (!(pdc = DC_LockDc(hdc))) return 0;
719
720 if (!(flags & DCB_WINDOWMGR))
721 {
722 rc = pdc->erclBoundsApp;
723
724 if (RECTL_bIsEmptyRect(&rc))
725 {
726 rc.left = rc.top = rc.right = rc.bottom = 0;
727 ret = DCB_RESET;
728 }
729 else
730 {
731 RECTL rcRgn;
732 if (pdc->fs & DC_DIRTY_RAO) CLIPPING_UpdateGCRegion(pdc);
733 if(!REGION_GetRgnBox(pdc->prgnRao, &rcRgn))
734 {
735 REGION_GetRgnBox(pdc->prgnVis, &rcRgn);
736 }
737 rc.left = max( rc.left, 0 );
738 rc.top = max( rc.top, 0 );
739 rc.right = min( rc.right, rcRgn.right - rcRgn.left );
740 rc.bottom = min( rc.bottom, rcRgn.bottom - rcRgn.top );
741 DPRINT("Rao dc %p r %d b %d\n",pdc,rcRgn.right - rcRgn.left, rcRgn.bottom - rcRgn.top);
742 DPRINT("rc l %d t %d\n",rc.left,rc.top);
743 DPRINT(" r %d b %d\n",rc.right,rc.bottom);
744 ret = DCB_SET;
745 }
746 IntDPtoLP(pdc, (PPOINTL)&rc, 2);
747 DPRINT("rc1 l %d t %d\n",rc.left,rc.top);
748 DPRINT(" r %d b %d\n",rc.right,rc.bottom);
749 }
750 else
751 {
752 rc = pdc->erclBounds;
753 ret = DCB_SET;
754 }
755
756 /* Copy the rect to the caller */
758 {
759 ProbeForWrite(prc, sizeof(RECT), 1);
760 *prc = rc;
761 }
763 {
764 ret = 0;
765 }
766 _SEH2_END;
767
768 if (flags & DCB_RESET)
769 {
770 if (!(flags & DCB_WINDOWMGR))
771 {
772 pdc->erclBoundsApp.left = pdc->erclBoundsApp.top = INT_MAX;
773 pdc->erclBoundsApp.right = pdc->erclBoundsApp.bottom = INT_MIN;
774 }
775 else
776 {
777 pdc->erclBounds.left = pdc->erclBounds.top = INT_MAX;
778 pdc->erclBounds.right = pdc->erclBounds.bottom = INT_MIN;
779 }
780 }
781
782 DC_UnlockDc(pdc);
783 return ret;
784}
VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC)
Definition: cliprgn.c:739
#define DCB_WINDOWMGR
Definition: gdi_private.h:62
GLbitfield flags
Definition: glext.h:7161
#define INT_MIN
Definition: limits.h:39
#define INT_MAX
Definition: limits.h:40
#define min(a, b)
Definition: monoChain.cc:55
_Out_ LPRECT prc
Definition: ntgdi.h:1658
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define max(a, b)
Definition: svc.c:63
int ret
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2543
#define DCB_RESET
Definition: wingdi.h:687
#define DCB_SET
Definition: wingdi.h:688

Referenced by GetBoundsRect(), and GetBoundsRectAlt().

◆ NtGdiGetDCDword()

BOOL APIENTRY NtGdiGetDCDword ( HDC  hDC,
UINT  u,
DWORD Result 
)

Definition at line 456 of file dcutil.c.

460{
461 BOOL Ret = TRUE;
462 PDC pdc;
463 PDC_ATTR pdcattr;
464
465 DWORD SafeResult = 0;
467
468 if (!Result)
469 {
471 return FALSE;
472 }
473
474 pdc = DC_LockDc(hDC);
475 if (!pdc)
476 {
478 return FALSE;
479 }
480 pdcattr = pdc->pdcattr;
481
482 switch (u)
483 {
484 case GdiGetJournal:
485 break;
486
487 case GdiGetRelAbs:
488 SafeResult = pdcattr->lRelAbs;
489 break;
490
491 case GdiGetBreakExtra:
492 SafeResult = pdcattr->lBreakExtra;
493 break;
494
495 case GdiGetCharBreak:
496 SafeResult = pdcattr->cBreak;
497 break;
498
500 if (pdcattr->dwLayout & LAYOUT_RTL)
501 SafeResult = AD_CLOCKWISE - ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0);
502 else
503 SafeResult = ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0) + AD_COUNTERCLOCKWISE;
504 break;
505
507 SafeResult = pdc->dclevel.lSaveDepth;
508 break;
509
511 SafeResult = IntGetFontLanguageInfo(pdc);
512 break;
513
514 case GdiGetIsMemDc:
515 SafeResult = pdc->dctype;
516 break;
517
518 case GdiGetMapMode:
519 SafeResult = pdcattr->iMapMode;
520 break;
521
523 SafeResult = pdcattr->lTextExtra;
524 break;
525
526 default:
528 Ret = FALSE;
529 break;
530 }
531
532 if (Ret)
533 {
535 {
536 ProbeForWrite(Result, sizeof(DWORD), 1);
537 *Result = SafeResult;
538 }
540 {
542 }
543 _SEH2_END;
544
545 if (!NT_SUCCESS(Status))
546 {
548 Ret = FALSE;
549 }
550 }
551
552 DC_UnlockDc(pdc);
553 return Ret;
554}
#define GdiGetEMFRestorDc
Definition: emfdc.c:1836
@ GdiGetCharBreak
Definition: ntgdityp.h:51
@ GdiGetFontLanguageInfo
Definition: ntgdityp.h:54
@ GdiGetMapMode
Definition: ntgdityp.h:56
@ GdiGetJournal
Definition: ntgdityp.h:48
@ GdiGetTextCharExtra
Definition: ntgdityp.h:57
@ GdiGetIsMemDc
Definition: ntgdityp.h:55
@ GdiGetBreakExtra
Definition: ntgdityp.h:50
@ GdiGetArcDirection
Definition: ntgdityp.h:52
@ GdiGetRelAbs
Definition: ntgdityp.h:49
LONG lBreakExtra
Definition: ntgdihdl.h:328
LONG cBreak
Definition: ntgdihdl.h:329
INT iMapMode
Definition: ntgdihdl.h:338
DWORD FASTCALL IntGetFontLanguageInfo(PDC Dc)
Definition: font.c:371
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ NtGdiSetBoundsRect()

DWORD APIENTRY NtGdiSetBoundsRect ( IN HDC  hdc,
IN LPRECT  prc,
IN DWORD  flags 
)

Definition at line 788 of file dcutil.c.

792{
793 DWORD ret;
794 PDC pdc;
795 RECTL rcl;
796
797 /* Verify arguments */
798 if ((flags & DCB_ENABLE) && (flags & DCB_DISABLE)) return 0;
799
800 /* Lock the DC */
801 if (!(pdc = DC_LockDc(hdc))) return 0;
802
803 /* Get the return value */
804 ret = DCB_RESET; /* we don't have device-specific bounds */
806 (RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? ret & DCB_SET : DCB_SET );
807 ret |= (flags & DCB_WINDOWMGR);
808
809 if (flags & DCB_RESET)
810 {
811 if (!(flags & DCB_WINDOWMGR))
812 {
813 pdc->erclBoundsApp.left = pdc->erclBoundsApp.top = INT_MAX;
814 pdc->erclBoundsApp.right = pdc->erclBoundsApp.bottom = INT_MIN;
815 }
816 else
817 {
818 pdc->erclBounds.left = pdc->erclBounds.top = INT_MAX;
819 pdc->erclBounds.right = pdc->erclBounds.bottom = INT_MIN;
820 }
821 }
822
823 if (flags & DCB_ACCUMULATE && prc != NULL)
824 {
825 /* Capture the rect */
827 {
828 ProbeForRead(prc, sizeof(RECT), 1);
829 rcl = *prc;
830 }
832 {
833 DC_UnlockDc(pdc);
834 _SEH2_YIELD(return 0;)
835 }
836 _SEH2_END;
837
839
840 if (!(flags & DCB_WINDOWMGR))
841 {
842 IntLPtoDP( pdc, (POINT *)&rcl, 2 );
843 RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, &rcl);
844 }
845 else
846 RECTL_bUnionRect(&pdc->erclBounds, &pdc->erclBounds, &rcl);
847 }
848
849 if (flags & DCB_ENABLE)
850 {
851 if (!(flags & DCB_WINDOWMGR))
852 pdc->fs |= DC_ACCUM_APP;
853 else
854 pdc->fs |= DC_ACCUM_WMGR;
855 }
856 if (flags & DCB_DISABLE)
857 {
858 if (!(flags & DCB_WINDOWMGR))
859 pdc->fs &= ~DC_ACCUM_APP;
860 else
861 pdc->fs &= ~DC_ACCUM_WMGR;
862 }
863 DC_UnlockDc(pdc);
864 return ret;
865}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
#define DCB_DISABLE
Definition: wingdi.h:685
#define DCB_ACCUMULATE
Definition: wingdi.h:689
#define DCB_ENABLE
Definition: wingdi.h:686

◆ TranslateCOLORREF()

ULONG TranslateCOLORREF ( PDC  pdc,
COLORREF  crColor 
)

Definition at line 869 of file dcutil.c.

870{
871 PSURFACE psurfDC;
872 PPALETTE ppalDC;
873 ULONG index, ulColor, iBitmapFormat;
874 EXLATEOBJ exlo;
875
876 /* Get the DC surface */
877 psurfDC = pdc->dclevel.pSurface;
878
879 /* If no surface is selected, use the default bitmap */
880 if (!psurfDC)
881 psurfDC = psurfDefaultBitmap;
882
883 /* Check what color type this is */
884 switch (crColor >> 24)
885 {
886 case 0x00: /* RGB color */
887 break;
888
889 case 0x01: /* PALETTEINDEX */
890 index = crColor & 0xFFFFFF;
891 ppalDC = pdc->dclevel.ppal;
892 if (index >= ppalDC->NumColors) index = 0;
893
894 /* Get the RGB value */
895 crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, index);
896 break;
897
898 case 0x02: /* PALETTERGB */
899
900 if (pdc->dclevel.hpal != StockObjects[DEFAULT_PALETTE])
901 {
902 /* First find the nearest index in the dc palette */
903 ppalDC = pdc->dclevel.ppal;
904 index = PALETTE_ulGetNearestIndex(ppalDC, crColor & 0xFFFFFF);
905
906 /* Get the RGB value */
907 crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, index);
908 }
909 else
910 {
911 /* Use the pure color */
912 crColor = crColor & 0x00FFFFFF;
913 }
914 break;
915
916 case 0x10: /* DIBINDEX */
917 /* Mask the value to match the target bpp */
918 iBitmapFormat = psurfDC->SurfObj.iBitmapFormat;
919 if (iBitmapFormat == BMF_1BPP) index = crColor & 0x1;
920 else if (iBitmapFormat == BMF_4BPP) index = crColor & 0xf;
921 else if (iBitmapFormat == BMF_8BPP) index = crColor & 0xFF;
922 else if (iBitmapFormat == BMF_16BPP) index = crColor & 0xFFFF;
923 else index = crColor & 0xFFFFFF;
924 return index;
925
926 default:
927 DPRINT("Unsupported color type %u passed\n", crColor >> 24);
928 crColor &= 0xFFFFFF;
929 }
930
931 /* Initialize an XLATEOBJ from RGB to the target surface */
932 EXLATEOBJ_vInitialize(&exlo, &gpalRGB, psurfDC->ppal, 0xFFFFFF, 0, 0);
933
934 /* Translate the color to the target format */
935 ulColor = XLATEOBJ_iXlate(&exlo.xlo, crColor);
936
937 /* Cleanup the XLATEOBJ */
938 EXLATEOBJ_vCleanup(&exlo);
939
940 return ulColor;
941}
#define index(s, c)
Definition: various.h:29
_Notnull_ PSURFACE psurfDefaultBitmap
Definition: dclife.c:17
GLuint index
Definition: glext.h:6031
XLATEOBJ xlo
Definition: xlateobj.h:21
ULONG NumColors
Definition: palette.h:41
SURFOBJ SurfObj
Definition: surface.h:8
struct _PALETTE *const ppal
Definition: surface.h:11
ULONG iBitmapFormat
Definition: winddi.h:1215
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
PALETTE gpalRGB
Definition: palette.c:20
ULONG NTAPI PALETTE_ulGetNearestIndex(PALETTE *ppal, ULONG ulColor)
Definition: palette.c:312
FORCEINLINE ULONG PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal, ULONG ulIndex)
Definition: palette.h:142
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
#define BMF_1BPP
Definition: winddi.h:355
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:664
#define BMF_4BPP
Definition: winddi.h:356
#define DEFAULT_PALETTE
Definition: wingdi.h:913
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649

Referenced by NtGdiGetNearestColor(), and NtGdiSetPixel().