ReactOS  0.4.12-dev-75-g00dd17e
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.

 _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 */
181  _SEH2_TRY
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 }
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
INT INT y
Definition: msvc.h:62
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
_In_ UINT _Out_ PPOINTL pptOut
Definition: ntgdi.h:2197
BOOL FASTCALL GreSetBrushOrg(HDC, INT, INT, LPPOINT)
Definition: dcutil.c:226
_SEH2_END
Definition: create.c:4424
INT x
Definition: msvc.h:62
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

◆ DC_bIsBitmapCompatible()

BOOL NTAPI DC_bIsBitmapCompatible ( PDC  pdc,
PSURFACE  psurf 
)

Definition at line 314 of file dcobjs.c.

Referenced by NtGdiSelectBitmap().

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
ULONG iBitmapFormat
Definition: winddi.h:1215
SURFOBJ SurfObj
Definition: surface.h:8
smooth NULL
Definition: ftsmooth.c:416
HANDLE hSecure
Definition: surface.h:32
HDEV hdev
Definition: winddi.h:1208
FLONG flags
Definition: surface.h:10
unsigned int ULONG
Definition: retypes.h:1
UCHAR gajBitsPerFormat[11]
Definition: surface.c:21

◆ DC_hSelectFont()

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

Definition at line 550 of file dcobjs.c.

Referenced by GdiFlushUserBatch(), and NtGdiSelectFont().

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 DIRTY_CHARSET
Definition: ntgdihdl.h:149
#define LFONT_ShareUnlockFont(plfnt)
Definition: text.h:78
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
Definition: freetype.c:4939
Definition: text.h:59
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define SLOW_WIDTHS
Definition: ntgdihdl.h:150
#define LFONT_ShareLockFont(hfont)
Definition: text.h:77
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

◆ DC_vSetBrushOrigin()

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

Definition at line 142 of file dcobjs.c.

Referenced by GdiFlushUserBatch(), and GreSetBrushOrg().

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 }
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62

◆ DC_vUpdateBackgroundBrush()

VOID FASTCALL DC_vUpdateBackgroundBrush ( PDC  pdc)

Definition at line 126 of file dcobjs.c.

Referenced by GreExtTextOutW(), and IntGdiCleanDC().

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 }
VOID FASTCALL EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor)
Definition: engbrush.c:122
_Notnull_ PBRUSH pbrDefaultBrush
Definition: dclife.c:18
VOID NTAPI EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
Definition: engbrush.c:194
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:148
ULONG ulDirty_
Definition: ntgdihdl.h:291
COLORREF crBackgroundClr
Definition: ntgdihdl.h:294

◆ DC_vUpdateFillBrush()

VOID FASTCALL DC_vUpdateFillBrush ( PDC  pdc)

Definition at line 16 of file dcobjs.c.

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

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_ShareUnlockBrush(pBrush)
Definition: brush.h:114
VOID FASTCALL EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor)
Definition: engbrush.c:122
HANDLE hbrush
Definition: ntgdihdl.h:292
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:113
VOID NTAPI EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
Definition: engbrush.c:194
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
ULONG ulDirty_
Definition: ntgdihdl.h:291
Definition: types.h:100
COLORREF crBrushClr
Definition: ntgdihdl.h:298
#define DIRTY_FILL
Definition: ntgdihdl.h:145
#define DC_BRUSH_DIRTY
Definition: ntgdihdl.h:157

◆ DC_vUpdateLineBrush()

VOID FASTCALL DC_vUpdateLineBrush ( PDC  pdc)

Definition at line 62 of file dcobjs.c.

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

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 BRUSH_ShareUnlockBrush(pBrush)
Definition: brush.h:114
VOID FASTCALL EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor)
Definition: engbrush.c:122
HANDLE hpen
Definition: ntgdihdl.h:293
#define DC_PEN_DIRTY
Definition: ntgdihdl.h:158
COLORREF crPenClr
Definition: ntgdihdl.h:300
VOID NTAPI EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
Definition: engbrush.c:194
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
ULONG ulDirty_
Definition: ntgdihdl.h:291
Definition: types.h:100
#define DIRTY_LINE
Definition: ntgdihdl.h:146
PBRUSH FASTCALL PEN_ShareLockPen(HPEN hobj)
Definition: pen.c:61

◆ DC_vUpdateTextBrush()

VOID FASTCALL DC_vUpdateTextBrush ( PDC  pdc)

Definition at line 108 of file dcobjs.c.

Referenced by DC_vPrepareDCsForBlit(), GreExtTextOutW(), IntGdiCleanDC(), and IntGdiSetTextColor().

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 }
VOID FASTCALL EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor)
Definition: engbrush.c:122
_Notnull_ PBRUSH pbrDefaultBrush
Definition: dclife.c:18
VOID NTAPI EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
Definition: engbrush.c:194
ULONG ulDirty_
Definition: ntgdihdl.h:291
#define DIRTY_TEXT
Definition: ntgdihdl.h:147
COLORREF crForegroundClr
Definition: ntgdihdl.h:296

◆ 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 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID DC_vSelectPalette(PDC pdc, PPALETTE ppal)
Definition: dc.h:286
#define BitsPerFormat(Format)
Definition: surface.h:109
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:148
smooth NULL
Definition: ftsmooth.c:416
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
Definition: polytest.cpp:40
#define DIRTY_TEXT
Definition: ntgdihdl.h:147
#define DIRTY_FILL
Definition: ntgdihdl.h:145
FLONG flFlags
Definition: palette.h:40
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define DIRTY_LINE
Definition: ntgdihdl.h:146

◆ 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: debug.h:114

◆ 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))
645  DC_vUpdateFillBrush(pdc);
646 
647  if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
648  DC_vUpdateLineBrush(pdc);
649 
650  switch(ObjectType)
651  {
653  case GDI_OBJECT_TYPE_PEN:
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 ERROR_INVALID_PARAMETER
Definition: compat.h:91
ObjectType
Definition: metafile.c:80
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
HANDLE hbrush
Definition: ntgdihdl.h:292
HANDLE hpen
Definition: ntgdihdl.h:293
#define DC_PEN_DIRTY
Definition: ntgdihdl.h:158
VOID FASTCALL DC_vUpdateFillBrush(PDC pdc)
Definition: dcobjs.c:16
#define GDI_OBJECT_TYPE_EXTPEN
Definition: gdi.h:55
#define GDI_OBJECT_TYPE_COLORSPACE
Definition: gdi.h:56
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
#define GDI_OBJECT_TYPE_BRUSH
Definition: gdi.h:52
HANDLE hlfntNew
Definition: ntgdihdl.h:327
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
#define GDI_OBJECT_TYPE_PALETTE
Definition: gdi.h:49
ULONG ulDirty_
Definition: ntgdihdl.h:291
BASEOBJECT BaseObject
Definition: surface.h:6
Definition: polytest.cpp:40
#define GDI_OBJECT_TYPE_PEN
Definition: gdi.h:54
VOID FASTCALL DC_vUpdateLineBrush(PDC pdc)
Definition: dcobjs.c:62
#define DIRTY_FILL
Definition: ntgdihdl.h:145
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DC_BRUSH_DIRTY
Definition: ntgdihdl.h:157
#define DPRINT1
Definition: precomp.h:8
#define DIRTY_LINE
Definition: ntgdihdl.h:146
#define GDI_OBJECT_TYPE_FONT
Definition: gdi.h:50
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ 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_FLAG_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 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HRGN INT iCode
Definition: mapping.c:33
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2686
#define ERROR(err)
Definition: vbo_exec_api.c:413
PREGION FASTCALL REGION_LockRgn(_In_ HRGN hrgn)
Definition: region.c:2337
int32_t INT
Definition: typedefs.h:56
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2466
#define APIRGN
Definition: GetRandomRgn.c:11
Definition: polytest.cpp:40
#define METARGN
Definition: GetRandomRgn.c:10
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC)
Definition: cliprgn.c:544
#define CLIPRGN
Definition: precomp.h:18
int ret
#define RGN_COPY
Definition: wingdi.h:355
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
VOID FASTCALL REGION_UnlockRgn(_In_ PREGION prgn)
Definition: region.c:2352
#define SYSRGN
Definition: GetRandomRgn.c:12
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ 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 != DC_TYPE_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 */
382  hbmpOld = StockObjects[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. */
416  SURFACE_ShareUnlockSurface(psurfNew);
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. */
429  SURFACE_ShareUnlockSurface(psurfNew);
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 */
460  SURFACE_ShareUnlockSurface(psurfOld);
461  }
462 
463  /* Mark the DC brushes and the RAO region invalid */
464  pdc->pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;
465  pdc->fs |= DC_FLAG_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 }
#define HDC
Definition: msvc.h:22
SIZEL sizlBitmap
Definition: winddi.h:1209
#define HBITMAP
Definition: msvc.h:28
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define DC_DIBSECTION
Definition: ntgdihdl.h:159
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
HANDLE hbmpOld
Definition: magnifier.c:55
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
SURFOBJ SurfObj
Definition: surface.h:8
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
BASEOBJECT BaseObject
Definition: surface.h:6
Definition: polytest.cpp:40
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DC_TYPE_MEMORY
Definition: ntgdihdl.h:124
#define DIRTY_FILL
Definition: ntgdihdl.h:145
HANDLE hSecure
Definition: surface.h:32
BOOL NTAPI DC_bIsBitmapCompatible(PDC pdc, PSURFACE psurf)
Definition: dcobjs.c:314
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
HDC hdc
Definition: surface.h:26
#define DIRTY_LINE
Definition: ntgdihdl.h:146
VOID FASTCALL REGION_SetRectRgn(PREGION rgn, INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2644
#define ASSERT_NOGDILOCKS()
Definition: gdidebug.h:10
HBITMAP hbmp
Definition: msvc.h:60

◆ 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;
275  DC_vUpdateFillBrush(pDC);
276 
277  DC_UnlockDc(pDC);
278 
279  return hOrgBrush;
280 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
VOID FASTCALL DC_vUpdateFillBrush(PDC pdc)
Definition: dcobjs.c:16
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237

◆ NtGdiSelectClipPath()

BOOL APIENTRY NtGdiSelectClipPath ( HDC  hDC,
int  Mode 
)

Definition at line 484 of file dcobjs.c.

487 {
488  PREGION RgnPath;
489  PPATH pPath, pNewPath;
490  BOOL success = FALSE;
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 
537 Exit:
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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
_In_ ULONG Mode
Definition: hubbusif.h:303
Definition: path.h:34
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
int FASTCALL IntGdiExtSelectClipRgn(PDC dc, PREGION prgn, int fnMode)
Definition: cliprgn.c:68
#define ERROR(err)
Definition: vbo_exec_api.c:413
#define PATH_LockPath(hPath)
Definition: path.h:70
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2386
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
BOOL FASTCALL PATH_PathToRegion(PPATH pPath, INT Mode, PREGION Rgn)
Definition: path.c:1403
PPATH FASTCALL PATH_FlattenPath(PPATH pPath)
Definition: path.c:1359
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
#define PATH_UnlockPath(pPath)
Definition: path.h:71
Definition: region.h:7
Definition: polytest.cpp:40
unsigned int BOOL
Definition: ntddk_ex.h:94
static void Exit(void)
Definition: sock.c:1331
#define success(from, fromstr, to, tostr)
BYTE jFillMode
Definition: ntgdihdl.h:306
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
BASEOBJECT BaseObject
Definition: path.h:36
FLONG state
Definition: path.h:52
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2428
BOOL FASTCALL PATH_Delete(HPATH hPath)
Definition: path.c:91
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiSelectFont()

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

Definition at line 597 of file dcobjs.c.

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().

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 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
HFONT NTAPI DC_hSelectFont(_In_ PDC pdc, _In_ HFONT hlfntNew)
Definition: dcobjs.c:550
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
static HFONT hfont
Definition: polytest.cpp:40
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

◆ 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;
305  DC_vUpdateLineBrush(pDC);
306 
307  DC_UnlockDc(pDC);
308 
309  return hOrgPen;
310 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
VOID FASTCALL DC_vUpdateLineBrush(PDC pdc)
Definition: dcobjs.c:62
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237