ReactOS 0.4.16-dev-289-g096a551
dcobjs.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for dcobjs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID FASTCALL DC_vUpdateFillBrush (PDC pdc)
 
VOID FASTCALL DC_vUpdateLineBrush (PDC pdc)
 
VOID FASTCALL DC_vUpdateTextBrush (PDC pdc)
 
VOID FASTCALL DC_vUpdateBackgroundBrush (PDC pdc)
 
VOID NTAPI DC_vSetBrushOrigin (PDC pdc, LONG x, LONG y)
 
NtGdiSetBrushOrg

Sets the brush origin that GDI uses when drawing with pattern brushes. The brush origin is relative to the DC origin.

@implemented

 _Success_ (return!=FALSE)
 
HPALETTE NTAPI GdiSelectPalette (HDC hDC, HPALETTE hpal, BOOL ForceBackground)
 
HBRUSH APIENTRY NtGdiSelectBrush (IN HDC hDC, IN HBRUSH hBrush)
 
HPEN APIENTRY NtGdiSelectPen (IN HDC hDC, IN HPEN hPen)
 
BOOL NTAPI DC_bIsBitmapCompatible (PDC pdc, PSURFACE psurf)
 
HBITMAP APIENTRY NtGdiSelectBitmap (IN HDC hdc, IN HBITMAP hbmp)
 
BOOL APIENTRY NtGdiSelectClipPath (HDC hDC, int Mode)
 
HFONT NTAPI DC_hSelectFont (_In_ PDC pdc, _In_ HFONT hlfntNew)
 
HFONT APIENTRY NtGdiSelectFont (_In_ HDC hdc, _In_ HFONT hfont)
 
HANDLE APIENTRY NtGdiGetDCObject (HDC hDC, INT ObjectType)
 
INT APIENTRY NtGdiGetRandomRgn (HDC hdc, HRGN hrgnDest, INT iCode)
 
ULONG APIENTRY NtGdiEnumObjects (IN HDC hdc, IN INT iObjectType, IN ULONG cjBuf, OUT OPTIONAL PVOID pvBuf)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file dcobjs.c.

Function Documentation

◆ _Success_()

_Success_ ( return!  = FALSE)

Definition at line 161 of file dcobjs.c.

170{
171
172 POINT ptOut;
173 /* Call the internal function */
174 BOOL Ret = GreSetBrushOrg( hdc, x, y, &ptOut);
175 if (Ret)
176 {
177 /* Check if the old origin was requested */
178 if (pptOut != NULL)
179 {
180 /* Enter SEH for buffer transfer */
182 {
183 /* Probe and copy the old origin */
184 ProbeForWrite(pptOut, sizeof(POINT), 1);
185 *pptOut = ptOut;
186 }
188 {
189 _SEH2_YIELD(return FALSE);
190 }
191 _SEH2_END;
192 }
193 }
194 return Ret;
195}
BOOL FASTCALL GreSetBrushOrg(HDC, INT, INT, LPPOINT)
Definition: dcutil.c:231
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HDC hdc
Definition: main.c:9
_In_ UINT _Out_ PPOINTL pptOut
Definition: ntgdi.h:2198
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168

◆ DC_bIsBitmapCompatible()

BOOL NTAPI DC_bIsBitmapCompatible ( PDC  pdc,
PSURFACE  psurf 
)

Definition at line 314 of file dcobjs.c.

315{
316 ULONG cBitsPixel;
317
318 /* Must be an API bitmap */
319 if (!(psurf->flags & API_BITMAP)) return FALSE;
320
321 /* DIB sections are always compatible */
322 if (psurf->hSecure != NULL) return TRUE;
323
324 /* See if this is the same PDEV */
325 if (psurf->SurfObj.hdev == (HDEV)pdc->ppdev)
326 return TRUE;
327
328 /* Get the bit depth of the bitmap */
329 cBitsPixel = gajBitsPerFormat[psurf->SurfObj.iBitmapFormat];
330
331 /* 1 BPP is compatible */
332 if ((cBitsPixel == 1) || (cBitsPixel == pdc->ppdev->gdiinfo.cBitsPixel))
333 return TRUE;
334
335 return FALSE;
336}
#define TRUE
Definition: types.h:120
SURFOBJ SurfObj
Definition: surface.h:8
HANDLE hSecure
Definition: surface.h:32
FLONG flags
Definition: surface.h:10
ULONG iBitmapFormat
Definition: winddi.h:1215
HDEV hdev
Definition: winddi.h:1208
uint32_t ULONG
Definition: typedefs.h:59
UCHAR gajBitsPerFormat[11]
Definition: surface.c:21
@ API_BITMAP
Definition: surface.h:76

Referenced by NtGdiSelectBitmap().

◆ DC_hSelectFont()

HFONT NTAPI DC_hSelectFont ( _In_ PDC  pdc,
_In_ HFONT  hlfntNew 
)

Definition at line 550 of file dcobjs.c.

553{
554 PLFONT plfntNew;
555 HFONT hlfntOld;
556
557 // Legacy crap that will die with font engine rewrite
558 if (!NT_SUCCESS(TextIntRealizeFont(hlfntNew, NULL)))
559 {
560 return NULL;
561 }
562
563 /* Get the current selected font */
564 hlfntOld = pdc->dclevel.plfnt->BaseObject.hHmgr;
565
566 /* Check if a new font should be selected */
567 if (hlfntNew != hlfntOld)
568 {
569 /* Lock the new font */
570 plfntNew = LFONT_ShareLockFont(hlfntNew);
571 if (plfntNew)
572 {
573 /* Success, dereference the old font */
574 LFONT_ShareUnlockFont(pdc->dclevel.plfnt);
575
576 /* Select the new font */
577 pdc->dclevel.plfnt = plfntNew;
578 pdc->pdcattr->hlfntNew = hlfntNew;
579
580 /* Update dirty flags */
581 pdc->pdcattr->ulDirty_ |= DIRTY_CHARSET;
582 pdc->pdcattr->ulDirty_ &= ~SLOW_WIDTHS;
583 }
584 else
585 {
586 /* Failed, restore old, return NULL */
587 pdc->pdcattr->hlfntNew = hlfntOld;
588 hlfntOld = NULL;
589 }
590 }
591
592 return hlfntOld;
593}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
Definition: freetype.c:5906
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define DIRTY_CHARSET
Definition: ntgdihdl.h:127
Definition: text.h:60
#define LFONT_ShareLockFont(hfont)
Definition: text.h:77
#define LFONT_ShareUnlockFont(plfnt)
Definition: text.h:78

Referenced by GdiFlushUserBatch(), and NtGdiSelectFont().

◆ DC_vSetBrushOrigin()

VOID NTAPI DC_vSetBrushOrigin ( PDC  pdc,
LONG  x,
LONG  y 
)

Definition at line 142 of file dcobjs.c.

143{
144 /* Set the brush origin */
145 pdc->dclevel.ptlBrushOrigin.x = x;
146 pdc->dclevel.ptlBrushOrigin.y = y;
147
148 /* Set the fill origin */
149 pdc->ptlFillOrigin.x = x + pdc->ptlDCOrig.x;
150 pdc->ptlFillOrigin.y = y + pdc->ptlDCOrig.y;
151}

Referenced by GdiFlushUserBatch(), and GreSetBrushOrg().

◆ DC_vUpdateBackgroundBrush()

VOID FASTCALL DC_vUpdateBackgroundBrush ( PDC  pdc)

Definition at line 126 of file dcobjs.c.

127{
128 PDC_ATTR pdcattr = pdc->pdcattr;
129
130 if(pdcattr->ulDirty_ & DIRTY_BACKGROUND)
131 EBRUSHOBJ_vUpdateFromDC(&pdc->eboBackground, pbrDefaultBrush, pdc);
132
133 /* Update the eboBackground's solid color */
134 EBRUSHOBJ_vSetSolidRGBColor(&pdc->eboBackground, pdcattr->crBackgroundClr);
135
136 /* Clear flag */
137 pdcattr->ulDirty_ &= ~DIRTY_BACKGROUND;
138}
_Notnull_ PBRUSH pbrDefaultBrush
Definition: dclife.c:18
VOID NTAPI EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
Definition: engbrush.c:194
VOID FASTCALL EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor)
Definition: engbrush.c:122
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:126
COLORREF crBackgroundClr
Definition: ntgdihdl.h:297
ULONG ulDirty_
Definition: ntgdihdl.h:294

Referenced by GdiFlushUserBatch(), IntExtTextOutW(), and IntGdiCleanDC().

◆ DC_vUpdateFillBrush()

VOID FASTCALL DC_vUpdateFillBrush ( PDC  pdc)

Definition at line 16 of file dcobjs.c.

17{
18 PDC_ATTR pdcattr = pdc->pdcattr;
19 PBRUSH pbrFill;
20
21 /* Check if the brush handle has changed */
22 if (pdcattr->hbrush != pdc->dclevel.pbrFill->BaseObject.hHmgr)
23 {
24 /* Try to lock the new brush */
25 pbrFill = BRUSH_ShareLockBrush(pdcattr->hbrush);
26 if (pbrFill)
27 {
28 /* Unlock old brush, set new brush */
29 BRUSH_ShareUnlockBrush(pdc->dclevel.pbrFill);
30 pdc->dclevel.pbrFill = pbrFill;
31
32 /* Mark eboFill as dirty */
33 pdcattr->ulDirty_ |= DIRTY_FILL;
34 }
35 else
36 {
37 /* Invalid brush handle, restore old one */
38 pdcattr->hbrush = pdc->dclevel.pbrFill->BaseObject.hHmgr;
39 }
40 }
41
42 /* Check if the EBRUSHOBJ needs update */
43 if (pdcattr->ulDirty_ & DIRTY_FILL)
44 {
45 /* Update eboFill */
46 EBRUSHOBJ_vUpdateFromDC(&pdc->eboFill, pdc->dclevel.pbrFill, pdc);
47 }
48
49 /* Check for DC brush */
50 if (pdcattr->hbrush == StockObjects[DC_BRUSH])
51 {
52 /* Update the eboFill's solid color */
53 EBRUSHOBJ_vSetSolidRGBColor(&pdc->eboFill, pdcattr->crBrushClr);
54 }
55
56 /* Clear flags */
57 pdcattr->ulDirty_ &= ~(DIRTY_FILL | DC_BRUSH_DIRTY);
58}
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:117
#define BRUSH_ShareUnlockBrush(pBrush)
Definition: brush.h:118
#define DIRTY_FILL
Definition: ntgdihdl.h:123
#define DC_BRUSH_DIRTY
Definition: ntgdihdl.h:135
Definition: types.h:101
HANDLE hbrush
Definition: ntgdihdl.h:295
COLORREF crBrushClr
Definition: ntgdihdl.h:301
HGDIOBJ StockObjects[]
Definition: stockobj.c:100

Referenced by DC_vPrepareDCsForBlit(), GdiFlushUserBatch(), GdiPolyDraw(), GreStretchBltMask(), IntGdiCleanDC(), IntGdiFillRgn(), IntGdiPolygon(), IntGdiSetTextColor(), IntRectangle(), IntRoundRect(), NtGdiAngleArc(), NtGdiArcInternal(), NtGdiEllipse(), NtGdiFillPath(), NtGdiGetDCObject(), NtGdiMaskBlt(), NtGdiPatBlt(), NtGdiPolyPolyDraw(), NtGdiSelectBrush(), and NtGdiStrokeAndFillPath().

◆ DC_vUpdateLineBrush()

VOID FASTCALL DC_vUpdateLineBrush ( PDC  pdc)

Definition at line 62 of file dcobjs.c.

63{
64 PDC_ATTR pdcattr = pdc->pdcattr;
65 PBRUSH pbrLine;
66
67 /* Check if the pen handle has changed */
68 if (pdcattr->hpen != pdc->dclevel.pbrLine->BaseObject.hHmgr)
69 {
70 /* Try to lock the new pen */
71 pbrLine = PEN_ShareLockPen(pdcattr->hpen);
72 if (pbrLine)
73 {
74 /* Unlock old brush, set new brush */
75 BRUSH_ShareUnlockBrush(pdc->dclevel.pbrLine);
76 pdc->dclevel.pbrLine = pbrLine;
77
78 /* Mark eboLine as dirty */
79 pdcattr->ulDirty_ |= DIRTY_LINE;
80 }
81 else
82 {
83 /* Invalid pen handle, restore old one */
84 pdcattr->hpen = pdc->dclevel.pbrLine->BaseObject.hHmgr;
85 }
86 }
87
88 /* Check if the EBRUSHOBJ needs update */
89 if (pdcattr->ulDirty_ & DIRTY_LINE)
90 {
91 /* Update eboLine */
92 EBRUSHOBJ_vUpdateFromDC(&pdc->eboLine, pdc->dclevel.pbrLine, pdc);
93 }
94
95 /* Check for DC pen */
96 if (pdcattr->hpen == StockObjects[DC_PEN])
97 {
98 /* Update the eboLine's solid color */
99 EBRUSHOBJ_vSetSolidRGBColor(&pdc->eboLine, pdcattr->crPenClr);
100 }
101
102 /* Clear flags */
103 pdcattr->ulDirty_ &= ~(DIRTY_LINE | DC_PEN_DIRTY);
104}
#define DC_PEN_DIRTY
Definition: ntgdihdl.h:136
#define DIRTY_LINE
Definition: ntgdihdl.h:124
HANDLE hpen
Definition: ntgdihdl.h:296
COLORREF crPenClr
Definition: ntgdihdl.h:303
PBRUSH FASTCALL PEN_ShareLockPen(HPEN hobj)
Definition: pen.c:61

Referenced by DC_vPrepareDCsForBlit(), GdiPolyDraw(), IntGdiCleanDC(), IntGdiPolygon(), IntGdiSetTextColor(), IntRectangle(), IntRoundRect(), NtGdiAngleArc(), NtGdiArcInternal(), NtGdiEllipse(), NtGdiFillPath(), NtGdiGetDCObject(), NtGdiPolyPolyDraw(), NtGdiSelectPen(), NtGdiStrokeAndFillPath(), and NtGdiStrokePath().

◆ DC_vUpdateTextBrush()

VOID FASTCALL DC_vUpdateTextBrush ( PDC  pdc)

Definition at line 108 of file dcobjs.c.

109{
110 PDC_ATTR pdcattr = pdc->pdcattr;
111
112 /* Timo : The text brush should never be changed.
113 * Jérôme : Yeah, but its palette must be updated anyway! */
114 if(pdcattr->ulDirty_ & DIRTY_TEXT)
115 EBRUSHOBJ_vUpdateFromDC(&pdc->eboText, pbrDefaultBrush, pdc);
116
117 /* Update the eboText's solid color */
118 EBRUSHOBJ_vSetSolidRGBColor(&pdc->eboText, pdcattr->crForegroundClr);
119
120 /* Clear flag */
121 pdcattr->ulDirty_ &= ~DIRTY_TEXT;
122}
#define DIRTY_TEXT
Definition: ntgdihdl.h:125
COLORREF crForegroundClr
Definition: ntgdihdl.h:299

Referenced by DC_vPrepareDCsForBlit(), GdiFlushUserBatch(), IntExtTextOutW(), IntGdiCleanDC(), and IntGdiSetTextColor().

◆ GdiSelectPalette()

HPALETTE NTAPI GdiSelectPalette ( HDC  hDC,
HPALETTE  hpal,
BOOL  ForceBackground 
)

FIXME: we shouldn't dereference pSurface when the PDEV is not locked

Definition at line 199 of file dcobjs.c.

203{
204 PDC pdc;
205 HPALETTE oldPal = NULL;
206 PPALETTE ppal;
207
208 // FIXME: Mark the palette as a [fore\back]ground pal
209 pdc = DC_LockDc(hDC);
210 if (!pdc)
211 {
212 return NULL;
213 }
214
215 /* Check if this is a valid palette handle */
216 ppal = PALETTE_ShareLockPalette(hpal);
217 if (!ppal)
218 {
219 DC_UnlockDc(pdc);
220 return NULL;
221 }
222
224 /* Is this a valid palette for this depth? */
225 if ((!pdc->dclevel.pSurface) ||
226 (BitsPerFormat(pdc->dclevel.pSurface->SurfObj.iBitmapFormat) <= 8
227 && (ppal->flFlags & PAL_INDEXED)) ||
228 (BitsPerFormat(pdc->dclevel.pSurface->SurfObj.iBitmapFormat) > 8))
229 {
230 /* Get old palette, set new one */
231 oldPal = pdc->dclevel.hpal;
232 pdc->dclevel.hpal = hpal;
233 DC_vSelectPalette(pdc, ppal);
234
235 /* Mark the brushes invalid */
236 pdc->pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE |
238 }
239
240 if(pdc->dctype == DCTYPE_MEMORY)
241 {
242 // This didn't work anyway
243 //IntGdiRealizePalette(hDC);
244 }
245
247 DC_UnlockDc(pdc);
248
249 return oldPal;
250}
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_vSelectPalette(PDC pdc, PPALETTE ppal)
Definition: dc.h:287
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
@ DCTYPE_MEMORY
Definition: dc.h:42
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
Definition: polytest.cpp:41
FLONG flFlags
Definition: palette.h:40
#define BitsPerFormat(Format)
Definition: surface.h:109
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define PAL_INDEXED
Definition: winddi.h:1561

◆ NtGdiEnumObjects()

ULONG APIENTRY NtGdiEnumObjects ( IN HDC  hdc,
IN INT  iObjectType,
IN ULONG  cjBuf,
OUT OPTIONAL PVOID  pvBuf 
)

Definition at line 784 of file dcobjs.c.

789{
791 return 0;
792}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15

◆ NtGdiGetDCObject()

HANDLE APIENTRY NtGdiGetDCObject ( HDC  hDC,
INT  ObjectType 
)

Definition at line 629 of file dcobjs.c.

630{
631 HGDIOBJ SelObject;
632 DC *pdc;
633 PDC_ATTR pdcattr;
634
635 /* From Wine: GetCurrentObject does not SetLastError() on a null object */
636 if(!hDC) return NULL;
637
638 if(!(pdc = DC_LockDc(hDC)))
639 {
640 return NULL;
641 }
642 pdcattr = pdc->pdcattr;
643
644 if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
646
647 if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
649
650 switch(ObjectType)
651 {
654 SelObject = pdcattr->hpen;
655 break;
656
658 SelObject = pdcattr->hbrush;
659 break;
660
662 SelObject = pdc->dclevel.hpal;
663 break;
664
666 SelObject = pdcattr->hlfntNew;
667 break;
668
670 {
671 SURFACE *psurf = pdc->dclevel.pSurface;
672 SelObject = psurf ? psurf->BaseObject.hHmgr : StockObjects[DEFAULT_BITMAP];
673 break;
674 }
675
677 DPRINT1("FIXME: NtGdiGetCurrentObject() ObjectType OBJ_COLORSPACE not supported yet!\n");
678 // SelObject = dc->dclevel.pColorSpace.BaseObject.hHmgr; ?
679 SelObject = NULL;
680 break;
681
682 default:
683 SelObject = NULL;
685 break;
686 }
687
688 DC_UnlockDc(pdc);
689 return SelObject;
690}
#define DPRINT1
Definition: precomp.h:8
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
VOID FASTCALL DC_vUpdateLineBrush(PDC pdc)
Definition: dcobjs.c:62
VOID FASTCALL DC_vUpdateFillBrush(PDC pdc)
Definition: dcobjs.c:16
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GDI_OBJECT_TYPE_BRUSH
Definition: gdi.h:52
#define GDI_OBJECT_TYPE_COLORSPACE
Definition: gdi.h:56
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
#define GDI_OBJECT_TYPE_PALETTE
Definition: gdi.h:49
#define GDI_OBJECT_TYPE_EXTPEN
Definition: gdi.h:55
#define GDI_OBJECT_TYPE_FONT
Definition: gdi.h:50
#define GDI_OBJECT_TYPE_PEN
Definition: gdi.h:54
ObjectType
Definition: metafile.c:81
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
HANDLE hlfntNew
Definition: ntgdihdl.h:330
BASEOBJECT BaseObject
Definition: surface.h:6
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22

◆ NtGdiGetRandomRgn()

INT APIENTRY NtGdiGetRandomRgn ( HDC  hdc,
HRGN  hrgnDest,
INT  iCode 
)
Todo:
FIXME This is not really correct, since we already modified the region

Definition at line 709 of file dcobjs.c.

713{
714 INT ret = 0;
715 PDC pdc;
716 PREGION prgnSrc = NULL;
717
718 pdc = DC_LockDc(hdc);
719 if (!pdc)
720 {
722 return -1;
723 }
724
725 switch (iCode)
726 {
727 case CLIPRGN:
728 prgnSrc = pdc->dclevel.prgnClip;
729 break;
730
731 case METARGN:
732 prgnSrc = pdc->dclevel.prgnMeta;
733 break;
734
735 case APIRGN:
736 if (pdc->fs & DC_DIRTY_RAO)
738 if (pdc->prgnAPI)
739 {
740 prgnSrc = pdc->prgnAPI;
741 }
742 else if (pdc->dclevel.prgnClip)
743 {
744 prgnSrc = pdc->dclevel.prgnClip;
745 }
746 else if (pdc->dclevel.prgnMeta)
747 {
748 prgnSrc = pdc->dclevel.prgnMeta;
749 }
750 break;
751
752 case SYSRGN:
753 prgnSrc = pdc->prgnVis;
754 break;
755
756 default:
757 break;
758 }
759
760 if (prgnSrc)
761 {
762 PREGION prgnDest = REGION_LockRgn(hrgnDest);
763 if (prgnDest)
764 {
765 ret = IntGdiCombineRgn(prgnDest, prgnSrc, 0, RGN_COPY) == ERROR ? -1 : 1;
766 if ((ret == 1) && (iCode == SYSRGN))
767 {
769 ret = REGION_bOffsetRgn(prgnDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
770 }
771 REGION_UnlockRgn(prgnDest);
772 }
773 else
774 ret = -1;
775 }
776
777 DC_UnlockDc(pdc);
778
779 return ret;
780}
#define APIRGN
Definition: GetRandomRgn.c:12
#define METARGN
Definition: GetRandomRgn.c:11
#define SYSRGN
Definition: GetRandomRgn.c:13
VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC)
Definition: cliprgn.c:741
@ DC_DIRTY_RAO
Definition: dc.h:23
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR(name)
Definition: error_private.h:53
#define CLIPRGN
Definition: precomp.h:18
static HRGN INT iCode
Definition: mapping.c:33
Definition: region.h:8
int32_t INT
Definition: typedefs.h:58
int ret
PREGION FASTCALL REGION_LockRgn(_In_ HRGN hrgn)
Definition: region.c:2358
VOID FASTCALL REGION_UnlockRgn(_In_ PREGION prgn)
Definition: region.c:2373
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2707
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2487
#define RGN_COPY
Definition: wingdi.h:357

◆ NtGdiSelectBitmap()

HBITMAP APIENTRY NtGdiSelectBitmap ( IN HDC  hdc,
IN HBITMAP  hbmp 
)

Definition at line 343 of file dcobjs.c.

346{
347 PDC pdc;
349 PSURFACE psurfNew, psurfOld;
350 HDC hdcOld;
352
353 /* Verify parameters */
354 if (hdc == NULL || hbmp == NULL) return NULL;
355
356 /* First lock the DC */
357 pdc = DC_LockDc(hdc);
358 if (!pdc)
359 {
360 return NULL;
361 }
362
363 /* Must be a memory dc to select a bitmap */
364 if (pdc->dctype != DCTYPE_MEMORY)
365 {
366 DC_UnlockDc(pdc);
367 return NULL;
368 }
369
370 /* Save the old bitmap */
371 psurfOld = pdc->dclevel.pSurface;
372
373 /* Check if there is a bitmap selected */
374 if (psurfOld)
375 {
376 /* Get the old bitmap's handle */
377 hbmpOld = psurfOld->BaseObject.hHmgr;
378 }
379 else
380 {
381 /* Use the default bitmap */
383 }
384
385 /* Check if the new bitmap is already selected */
386 if (hbmp == hbmpOld)
387 {
388 /* Unlock the DC and return the old bitmap */
389 DC_UnlockDc(pdc);
390 return hbmpOld;
391 }
392
393 /* Check if the default bitmap was passed */
395 {
396 psurfNew = NULL;
397
398 /* Default bitmap is 1x1 pixel */
399 pdc->dclevel.sizl.cx = 1;
400 pdc->dclevel.sizl.cy = 1;
401 }
402 else
403 {
404 /* Reference the new bitmap and check if it's valid */
405 psurfNew = SURFACE_ShareLockSurface(hbmp);
406 if (!psurfNew)
407 {
408 DC_UnlockDc(pdc);
409 return NULL;
410 }
411
412 /* Check if the bitmap is compatible with the dc */
413 if (!DC_bIsBitmapCompatible(pdc, psurfNew))
414 {
415 /* Dereference the bitmap, unlock the DC and fail. */
417 DC_UnlockDc(pdc);
418 return NULL;
419 }
420
421 /* Set the bitmap's hdc and check if it was set before */
422 hdcOld = InterlockedCompareExchangePointer((PVOID*)&psurfNew->hdc, hdc, 0);
423 if (hdcOld != NULL)
424 {
425 /* The bitmap is already selected into a different DC */
426 ASSERT(hdcOld != hdc);
427
428 /* Dereference the bitmap, unlock the DC and fail. */
430 DC_UnlockDc(pdc);
431 return NULL;
432 }
433
434 /* Copy the bitmap size */
435 pdc->dclevel.sizl = psurfNew->SurfObj.sizlBitmap;
436
437 /* Check if the bitmap is a dibsection */
438 if (psurfNew->hSecure)
439 {
440 /* Set DIBSECTION attribute */
441 pdc->pdcattr->ulDirty_ |= DC_DIBSECTION;
442 }
443 else
444 {
445 /* Remove DIBSECTION attribute */
446 pdc->pdcattr->ulDirty_ &= ~DC_DIBSECTION;
447 }
448 }
449
450 /* Select the new bitmap */
451 pdc->dclevel.pSurface = psurfNew;
452
453 /* Check if there was a bitmap selected before */
454 if (psurfOld)
455 {
456 /* Reset hdc of the old bitmap, it isn't selected anymore */
457 psurfOld->hdc = NULL;
458
459 /* Dereference the old bitmap */
461 }
462
463 /* Mark the DC brushes and the RAO region invalid */
464 pdc->pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;
465 pdc->fs |= DC_DIRTY_RAO;
466
467 /* Update the system region */
468 REGION_SetRectRgn(pdc->prgnVis,
469 0,
470 0,
471 pdc->dclevel.sizl.cx,
472 pdc->dclevel.sizl.cy);
473
474 /* Unlock the DC */
475 DC_UnlockDc(pdc);
476
477 /* Return the old bitmap handle */
478 return hbmpOld;
479}
HBITMAP hbmp
BOOL NTAPI DC_bIsBitmapCompatible(PDC pdc, PSURFACE psurf)
Definition: dcobjs.c:314
#define ASSERT_NOGDILOCKS()
Definition: gdidebug.h:10
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
HANDLE hbmpOld
Definition: magnifier.c:54
#define ASSERT(a)
Definition: mode.c:44
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define DC_DIBSECTION
Definition: ntgdihdl.h:137
HDC hdc
Definition: surface.h:26
SIZEL sizlBitmap
Definition: winddi.h:1209
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
VOID FASTCALL REGION_SetRectRgn(PREGION rgn, INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2665

◆ NtGdiSelectBrush()

HBRUSH APIENTRY NtGdiSelectBrush ( IN HDC  hDC,
IN HBRUSH  hBrush 
)

Definition at line 257 of file dcobjs.c.

260{
261 PDC pDC;
262 HBRUSH hOrgBrush;
263
264 if (hDC == NULL || hBrush == NULL) return NULL;
265
266 pDC = DC_LockDc(hDC);
267 if (!pDC)
268 {
269 return NULL;
270 }
271
272 /* Simply return the user mode value, without checking */
273 hOrgBrush = pDC->pdcattr->hbrush;
274 pDC->pdcattr->hbrush = hBrush;
276
277 DC_UnlockDc(pDC);
278
279 return hOrgBrush;
280}

◆ NtGdiSelectClipPath()

BOOL APIENTRY NtGdiSelectClipPath ( HDC  hDC,
int  Mode 
)

Definition at line 484 of file dcobjs.c.

487{
488 PREGION RgnPath;
489 PPATH pPath, pNewPath;
491 PDC_ATTR pdcattr;
492 PDC pdc;
493
494 pdc = DC_LockDc(hDC);
495 if (!pdc)
496 {
498 return FALSE;
499 }
500 pdcattr = pdc->pdcattr;
501
502 pPath = PATH_LockPath(pdc->dclevel.hPath);
503 if (!pPath)
504 {
505 DC_UnlockDc(pdc);
506 return FALSE;
507 }
508
509 /* Check that path is closed */
510 if (pPath->state != PATH_Closed)
511 {
513 success = FALSE;
514 goto Exit;
515 }
516
517 /* Construct a region from the path */
518 RgnPath = IntSysCreateRectpRgn(0, 0, 0, 0);
519 if (!RgnPath)
520 {
522 DC_UnlockDc(pdc);
523 return FALSE;
524 }
525
526 pNewPath = PATH_FlattenPath(pPath);
527
528 success = PATH_PathToRegion(pNewPath, pdcattr->jFillMode, RgnPath);
529
530 PATH_UnlockPath(pNewPath);
531 PATH_Delete(pNewPath->BaseObject.hHmgr);
532
533 if (success) success = IntGdiExtSelectClipRgn(pdc, RgnPath, Mode) != ERROR;
534
535 REGION_Delete(RgnPath);
536
537Exit:
538 PATH_UnlockPath(pPath);
539 PATH_Delete(pdc->dclevel.hPath);
540 pdc->dclevel.flPath &= ~DCPATH_ACTIVE;
541 pdc->dclevel.hPath = NULL;
542
543 DC_UnlockDc(pdc);
544
545 return success;
546}
INT FASTCALL IntGdiExtSelectClipRgn(PDC dc, PREGION prgn, int fnMode)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
_In_ ULONG Mode
Definition: hubbusif.h:303
#define PATH_UnlockPath(pPath)
Definition: path.h:71
@ PATH_Closed
Definition: path.h:20
#define PATH_LockPath(hPath)
Definition: path.h:70
static void Exit(void)
Definition: sock.c:1330
BYTE jFillMode
Definition: ntgdihdl.h:309
Definition: path.h:35
BASEOBJECT BaseObject
Definition: path.h:36
FLONG state
Definition: path.h:52
BOOL FASTCALL PATH_PathToRegion(PPATH pPath, INT Mode, PREGION Rgn)
Definition: path.c:1450
BOOL FASTCALL PATH_Delete(HPATH hPath)
Definition: path.c:90
PPATH FASTCALL PATH_FlattenPath(PPATH pPath)
Definition: path.c:1407
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2449
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2407
#define success(from, fromstr, to, tostr)
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582

◆ NtGdiSelectFont()

HFONT APIENTRY NtGdiSelectFont ( _In_ HDC  hdc,
_In_ HFONT  hfont 
)

Definition at line 597 of file dcobjs.c.

600{
601 HFONT hfontOld;
602 PDC pdc;
603
604 /* Check parameters */
605 if ((hdc == NULL) || (hfont == NULL))
606 {
607 return NULL;
608 }
609
610 /* Lock the DC */
611 pdc = DC_LockDc(hdc);
612 if (!pdc)
613 {
614 return NULL;
615 }
616
617 /* Call the internal function */
618 hfontOld = DC_hSelectFont(pdc, hfont);
619
620 /* Unlock the DC */
621 DC_UnlockDc(pdc);
622
623 /* Return the previously selected font */
624 return hfontOld;
625}
static HFONT hfont
HFONT NTAPI DC_hSelectFont(_In_ PDC pdc, _In_ HFONT hlfntNew)
Definition: dcobjs.c:550

Referenced by co_IntInitializeDesktopGraphics(), GdiSelectFont(), IntDrawMenuBarTemp(), IntPaintDesktop(), MENU_CalcItemSize(), MENU_DrawMenuBar(), MENU_DrawMenuItem(), MENU_DrawPopupGlyph(), MENU_DrawPopupMenu(), MENU_PopupMenuCalcSize(), MENU_SelectItem(), MENU_ShowSubPopup(), START_TEST(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), UITOOLS95_DrawFrameScroll(), and UserDrawCaptionText().

◆ NtGdiSelectPen()

HPEN APIENTRY NtGdiSelectPen ( IN HDC  hDC,
IN HPEN  hPen 
)

Definition at line 287 of file dcobjs.c.

290{
291 PDC pDC;
292 HPEN hOrgPen;
293
294 if (hDC == NULL || hPen == NULL) return NULL;
295
296 pDC = DC_LockDc(hDC);
297 if (!pDC)
298 {
299 return NULL;
300 }
301
302 /* Simply return the user mode value, without checking */
303 hOrgPen = pDC->pdcattr->hpen;
304 pDC->pdcattr->hpen = hPen;
306
307 DC_UnlockDc(pDC);
308
309 return hOrgPen;
310}