ReactOS  0.4.15-dev-3440-g915569a
BRUSH Class Reference

#include <brush.hpp>

Inheritance diagram for BRUSH:
Collaboration diagram for BRUSH:

Public Member Functions

 _Analysis_mode_ (_Analysis_operator_new_null_) inline void *__cdecl operator new(_In_ size_t cjSize) throw ()
 
void operator delete (void *pvObject)
 
 BRUSH (_In_ FLONG flAttrs, _In_ COLORREF crColor, _In_ ULONG iHatch, _In_opt_ HBITMAP hbmPattern, _In_opt_ PVOID pvClient, _In_ GDILOOBJTYPE objtype)
 
 ~BRUSH (VOID)
 
BOOL bAllocateBrushAttr (VOID)
 
_Check_return_ _Ret_opt_bytecount_ (sizeof(BRUSH)) static inline PBRUSH LockForRead(_In_ HBRUSH hbr)
 
_Check_return_ _Ret_opt_bytecount_ (sizeof(BRUSH)) static inline PBRUSH LockForWrite(_In_ HBRUSH hbr)
 
_Check_return_ _Ret_opt_bytecap_ (sizeof(BRUSH)) static inline PBRUSH LockAny(_In_ HBRUSH hbr)
 
UINT cjGetObject (_In_ UINT cjBuffer, _Out_bytecap_(cjBuffer) PLOGBRUSH plbBuffer) const
 
HBITMAP hbmGetBitmapHandle (_Out_ PUINT puUsage) const
 
VOID vSetSolidColor (_In_ COLORREF crColor)
 
VOID vReleaseAttribute (VOID)
 
- Public Member Functions inherited from BASEOBJECT
VOID vUnlock (VOID)
 
HGDIOBJ hHmgr (VOID)
 
HGDIOBJ hInsertObject (OWNER owner)
 

Static Public Member Functions

static VOID vDeleteObject (_In_ PVOID pvObject)
 
- Static Public Member Functions inherited from BASEOBJECT
static PVOID pvAllocate (_In_ GDIOBJTYPE objtype, _In_ SIZE_T cjSize)
 

Additional Inherited Members

- Public Types inherited from BASEOBJECT
enum  OWNER { POWNED = GDI_OBJ_HMGR_POWNED, PUBLIC = GDI_OBJ_HMGR_PUBLIC, NONE = GDI_OBJ_HMGR_NONE }
 
- Protected Member Functions inherited from BASEOBJECT
 BASEOBJECT (_In_ GDILOOBJTYPE loobjtype)
 
VOID vSetObjectAttr (_In_opt_ PVOID pvUserAttr)
 
- Static Protected Member Functions inherited from BASEOBJECT
static BASEOBJECTLockExclusive (HGDIOBJ hobj, GDIOBJTYPE objtype)
 
static BASEOBJECTLockExclusive (HGDIOBJ hobj, GDILOOBJTYPE loobjtype)
 
static BASEOBJECTLockShared (HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
 
- Protected Attributes inherited from _BRUSHBODY
ULONG iHatch
 
HBITMAP hbmPattern
 
HBITMAP hbmClient
 
ULONG flAttrs
 
ULONG ulBrushUnique
 
BRUSH_ATTRpBrushAttr
 
BRUSH_ATTR BrushAttr
 
POINT ptOrigin
 
ULONG bCacheGrabbed
 
COLORREF crBack
 
COLORREF crFore
 
ULONG ulPalTime
 
ULONG ulSurfTime
 
PVOID pvRBrush
 
HDEV hdev
 
LONG lWidth
 
FLOATOBJ eWidth
 
ULONG ulPenStyle
 
DWORDpStyle
 
ULONG dwStyleCount
 
BYTE jJoin
 
BYTE jEndCap
 
INT iBrushStyle
 
ULONG ulStyleSize
 
LIST_ENTRY ListHead
 

Detailed Description

Definition at line 15 of file brush.hpp.

Constructor & Destructor Documentation

◆ BRUSH()

BRUSH::BRUSH ( _In_ FLONG  flAttrs,
_In_ COLORREF  crColor,
_In_ ULONG  iHatch,
_In_opt_ HBITMAP  hbmPattern,
_In_opt_ PVOID  pvClient,
_In_ GDILOOBJTYPE  objtype = GDILoObjType_LO_BRUSH_TYPE 
)

Definition at line 14 of file brush.cpp.

21  : BASEOBJECT(loobjtype)
22 {
23  static ULONG ulGlobalBrushUnique = 0;
24 
25  /* Get a unique value */
26  this->ulBrushUnique = InterlockedIncrementUL(&ulGlobalBrushUnique);
27 
28  /* Start with kmode brush attribute */
29  this->pBrushAttr = &this->BrushAttr;
30 
31  /* Set parameters */
32  this->flAttrs = flAttrs;
33  this->iHatch = iHatch;
34  this->hbmPattern = hbmPattern;
35  this->hbmClient = (HBITMAP)pvClient;
36  this->pBrushAttr->lbColor = crColor;
37 
38  /* Initialize the other fields */
39  this->ptOrigin.x = 0;
40  this->ptOrigin.y = 0;
41  this->bCacheGrabbed = FALSE;
42  this->crBack = 0;
43  this->crFore = 0;
44  this->ulPalTime = 0;
45  this->ulSurfTime = 0;
46  this->pvRBrush = NULL;
47  this->hdev = NULL;
48 
49  /* FIXME: should be done only in PEN constructor,
50  but our destructor needs it! */
51  this->dwStyleCount = 0;
52  this->pStyle = NULL;
53 }
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
ULONG dwStyleCount
Definition: brush.h:39
ULONG ulSurfTime
Definition: brush.h:29
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
PVOID pvRBrush
Definition: brush.h:30
ULONG ulBrushUnique
Definition: brush.h:21
ULONG flAttrs
Definition: brush.h:19
ULONG ulPalTime
Definition: brush.h:28
#define FALSE
Definition: types.h:117
ULONG iHatch
Definition: brush.h:16
POINT ptOrigin
Definition: brush.h:24
HBITMAP hbmClient
Definition: brush.h:18
BASEOBJECT(_In_ GDILOOBJTYPE loobjtype)
Definition: baseobj.hpp:21
_Inout_ SURFOBJ _In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_opt_ XLATEOBJ _In_ ULONG iHatch
Definition: winddi.h:3959
COLORREF lbColor
Definition: ntgdihdl.h:374
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1525
COLORREF crBack
Definition: brush.h:26
#define NULL
Definition: types.h:112
COLORREF crFore
Definition: brush.h:27
unsigned int ULONG
Definition: retypes.h:1
BRUSH_ATTR BrushAttr
Definition: brush.h:23
DWORD * pStyle
Definition: brush.h:38
static HBITMAP
Definition: button.c:44
ULONG bCacheGrabbed
Definition: brush.h:25
HBITMAP hbmPattern
Definition: brush.h:17
_In_ HDEV hdev
Definition: winddi.h:3449

◆ ~BRUSH()

BRUSH::~BRUSH ( VOID  )

Definition at line 55 of file brush.cpp.

57 {
58  /* Check if we have a user mode brush attribute */
59  if (this->pBrushAttr != &this->BrushAttr)
60  {
61  /* Free memory to the process GDI pool */
63  }
64 
65  /* Delete the pattern bitmap (may have already been deleted during gdi cleanup) */
66  if (this->hbmPattern != NULL && GreIsHandleValid(this->hbmPattern))
67  {
68  GreSetBitmapOwner(this->hbmPattern, BASEOBJECT::OWNER::POWNED);
70  }
71 
72  /* Delete styles */
73  if ((this->pStyle != NULL) && !(this->flAttrs & BR_IS_DEFAULTSTYLE))
74  {
76  }
77 }
#define GDITAG_PENSTYLE
Definition: tags.h:164
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
VOID NTAPI GdiPoolFree(PGDI_POOL pPool, PVOID pvAlloc)
Definition: gdipool.c:233
PGDI_POOL GetBrushAttrPool(VOID)
HACK!
Definition: gdiobj.c:1646
ULONG flAttrs
Definition: brush.h:19
#define BR_IS_DEFAULTSTYLE
Definition: brush.h:107
#define NULL
Definition: types.h:112
BOOL NTAPI GreSetBitmapOwner(_In_ HBITMAP hbmp, _In_ ULONG ulOwner)
Definition: bitmaps.c:17
BRUSH_ATTR BrushAttr
Definition: brush.h:23
DWORD * pStyle
Definition: brush.h:38
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
HBITMAP hbmPattern
Definition: brush.h:17

Member Function Documentation

◆ _Analysis_mode_()

BRUSH::_Analysis_mode_ ( _Analysis_operator_new_null_  )
throw (
)
inlinenew

Definition at line 19 of file brush.hpp.

26  {
28  //return BASEOBJECT::pvAllocate(GDIObjType_BRUSH_TYPE, cjSize);
29  }
#define GDITAG_HMGR_BRUSH_TYPE
Definition: tags.h:103
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_ ULONG cjSize
Definition: winddi.h:3634

◆ _Ret_opt_bytecap_()

_Check_return_ BRUSH::_Ret_opt_bytecap_ ( sizeof(BRUSH )
inline

Definition at line 91 of file brush.hpp.

97  {
98  return static_cast<PBRUSH>(
102  }
#define NONE
Definition: ntddpar.h:94
static BASEOBJECT * LockShared(HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
Definition: baseobj.hpp:50

◆ _Ret_opt_bytecount_() [1/2]

_Check_return_ BRUSH::_Ret_opt_bytecount_ ( sizeof(BRUSH )
inline

Definition at line 63 of file brush.hpp.

69  {
70  return static_cast<PBRUSH>(
73  BASEOBJECT::OWNER::PUBLIC));
74  }
static BASEOBJECT * LockShared(HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
Definition: baseobj.hpp:50

◆ _Ret_opt_bytecount_() [2/2]

_Check_return_ BRUSH::_Ret_opt_bytecount_ ( sizeof(BRUSH )
inline

Definition at line 77 of file brush.hpp.

83  {
84  return static_cast<PBRUSH>(
87  BASEOBJECT::OWNER::POWNED));
88  }
static BASEOBJECT * LockShared(HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
Definition: baseobj.hpp:50

◆ bAllocateBrushAttr()

BOOL BRUSH::bAllocateBrushAttr ( VOID  )

Definition at line 102 of file brush.cpp.

104 {
106  NT_ASSERT(this->pBrushAttr == &this->BrushAttr);
107 
108  /* Allocate a brush attribute from the pool */
109  pBrushAttr = static_cast<PBRUSH_ATTR>(GdiPoolAllocate(GetBrushAttrPool()));
110  if (pBrushAttr == NULL)
111  {
112  ERR("Could not allocate brush attr\n");
113  return FALSE;
114  }
115 
116  /* Copy the content from the kernel mode brush attribute */
117  this->pBrushAttr = pBrushAttr;
118  *this->pBrushAttr = this->BrushAttr;
119 
120  /* Set the object attribute in the handle table */
121  vSetObjectAttr(pBrushAttr);
122 
123  return TRUE;
124 }
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
#define TRUE
Definition: types.h:120
PGDI_POOL GetBrushAttrPool(VOID)
HACK!
Definition: gdiobj.c:1646
#define FALSE
Definition: types.h:117
PVOID NTAPI GdiPoolAllocate(PGDI_POOL pPool)
Definition: gdipool.c:122
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
BRUSH_ATTR BrushAttr
Definition: brush.h:23
VOID vSetObjectAttr(_In_opt_ PVOID pvUserAttr)
Definition: baseobj.hpp:60
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ cjGetObject()

UINT BRUSH::cjGetObject ( _In_ UINT  cjBuffer,
_Out_bytecap_(cjBuffer) PLOGBRUSH  plbBuffer 
) const

Definition at line 151 of file brush.cpp.

154 {
155  /* Check if only size is requested */
156  if (plb == NULL)
157  return sizeof(LOGBRUSH);
158 
159  /* Check if size is ok */
160  if (cjSize == 0)
161  return 0;
162 
163  /* Set color */
164  plb->lbColor = this->BrushAttr.lbColor;
165 
166  /* Set style and hatch based on the attribute flags */
167  if (this->flAttrs & BR_IS_SOLID)
168  {
169  plb->lbStyle = BS_SOLID;
170  plb->lbHatch = 0;
171  }
172  else if (this->flAttrs & BR_IS_HATCH)
173  {
174  plb->lbStyle = BS_HATCHED;
175  plb->lbHatch = this->iHatch;
176  }
177  else if (this->flAttrs & BR_IS_DIB)
178  {
179  plb->lbStyle = BS_DIBPATTERN;
180  plb->lbHatch = (ULONG_PTR)this->hbmClient;
181  }
182  else if (this->flAttrs & BR_IS_BITMAP)
183  {
184  plb->lbStyle = BS_PATTERN;
185  plb->lbHatch = (ULONG_PTR)this->hbmClient;
186  }
187  else if (this->flAttrs & BR_IS_NULL)
188  {
189  plb->lbStyle = BS_NULL;
190  plb->lbHatch = 0;
191  }
192  else
193  {
194  NT_ASSERT(FALSE);
195  }
196 
197  return sizeof(LOGBRUSH);
198 }
#define BS_DIBPATTERN
Definition: wingdi.h:1092
#define BR_IS_BITMAP
Definition: brush.h:99
ULONG flAttrs
Definition: brush.h:19
#define BS_NULL
Definition: wingdi.h:1087
#define BR_IS_SOLID
Definition: brush.h:97
#define FALSE
Definition: types.h:117
#define BR_IS_DIB
Definition: brush.h:100
ULONG iHatch
Definition: brush.h:16
HBITMAP hbmClient
Definition: brush.h:18
#define BR_IS_NULL
Definition: brush.h:101
#define BR_IS_HATCH
Definition: brush.h:98
COLORREF lbColor
Definition: ntgdihdl.h:374
#define NULL
Definition: types.h:112
#define BS_PATTERN
Definition: wingdi.h:1090
_In_ ULONG cjSize
Definition: winddi.h:3634
BRUSH_ATTR BrushAttr
Definition: brush.h:23
#define ULONG_PTR
Definition: config.h:101
#define BS_HATCHED
Definition: wingdi.h:1089
#define BS_SOLID
Definition: wingdi.h:1086
struct tagLOGBRUSH LOGBRUSH
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ hbmGetBitmapHandle()

HBITMAP BRUSH::hbmGetBitmapHandle ( _Out_ PUINT  puUsage) const

Definition at line 139 of file brush.cpp.

141 {
142  /* Return the color usage based on flags */
143  *puUsage = (this->flAttrs & BR_IS_DIBPALCOLORS) ? DIB_PAL_COLORS :
146 
147  return this->hbmPattern;
148 }
#define DIB_PAL_COLORS
Definition: wingdi.h:366
ULONG flAttrs
Definition: brush.h:19
#define BR_IS_DIBPALINDICES
Definition: brush.h:106
#define BR_IS_DIBPALCOLORS
Definition: brush.h:105
#define DIB_PAL_INDICES
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HBITMAP hbmPattern
Definition: brush.h:17

◆ operator delete()

void BRUSH::operator delete ( void pvObject)
inline

HACK! better would be to extract the exact object type's tag

Definition at line 33 of file brush.hpp.

35  {
37  ExFreePool(pvObject);
38  //ExFreePoolWithTag(pvObject, GDITAG_HMGR_BRUSH_TYPE);
39  //BASEOBJECT::pvFree(GDIObjType_BRUSH_TYPE, cjSize);
40  }
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ vDeleteObject()

VOID BRUSH::vDeleteObject ( _In_ PVOID  pvObject)
static

Definition at line 91 of file brush.cpp.

93 {
94  PBRUSH pbr = static_cast<PBRUSH>(pvObject);
96  (GDI_HANDLE_GET_TYPE(pbr->hHmgr()) == GDILoObjType_LO_PEN_TYPE) ||
98  delete pbr;
99 }
Definition: types.h:100
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by BRUSH_vDeleteObject().

◆ vReleaseAttribute()

VOID BRUSH::vReleaseAttribute ( VOID  )

Definition at line 80 of file brush.cpp.

81 {
82  if (this->pBrushAttr != &this->BrushAttr)
83  {
84  this->BrushAttr = *this->pBrushAttr;
86  this->pBrushAttr = &this->BrushAttr;
87  }
88 }
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
VOID NTAPI GdiPoolFree(PGDI_POOL pPool, PVOID pvAlloc)
Definition: gdipool.c:233
PGDI_POOL GetBrushAttrPool(VOID)
HACK!
Definition: gdiobj.c:1646
BRUSH_ATTR BrushAttr
Definition: brush.h:23

◆ vSetSolidColor()

VOID BRUSH::vSetSolidColor ( _In_ COLORREF  crColor)

Definition at line 127 of file brush.cpp.

129 {
130  NT_ASSERT(this->flAttrs & BR_IS_SOLID);
131 
132  /* Set new color and reset the pal times */
133  this->pBrushAttr->lbColor = crColor & 0xFFFFFF;
134  this->ulPalTime = -1;
135  this->ulSurfTime = -1;
136 }
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
ULONG ulSurfTime
Definition: brush.h:29
ULONG flAttrs
Definition: brush.h:19
ULONG ulPalTime
Definition: brush.h:28
#define BR_IS_SOLID
Definition: brush.h:97
COLORREF lbColor
Definition: ntgdihdl.h:374
#define NT_ASSERT
Definition: rtlfuncs.h:3310

The documentation for this class was generated from the following files: