ReactOS  0.4.14-dev-49-gfb4591c
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)
 
- 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
ULONG iHatch
Definition: brush.h:16
POINT ptOrigin
Definition: brush.h:24
smooth NULL
Definition: ftsmooth.c:416
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:360
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1513
COLORREF crBack
Definition: brush.h:26
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:1155
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1143
VOID NTAPI GdiPoolFree(PGDI_POOL pPool, PVOID pvAlloc)
Definition: gdipool.c:233
PGDI_POOL GetBrushAttrPool(VOID)
HACK!
Definition: gdiobj.c:1609
ULONG flAttrs
Definition: brush.h:19
smooth NULL
Definition: ftsmooth.c:416
#define BR_IS_DEFAULTSTYLE
Definition: brush.h:107
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  }
static BASEOBJECT * LockShared(HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
Definition: baseobj.hpp:50
xD9 x84 xD8 xAD xD9 x80 xF0 x90 xAC x9A xE0 xA7 xA6 xE0 xA7 xAA xF0 x91 x84 xA4 xF0 x91 x84 x89 xF0 x91 x84 x9B xF0 x90 x8A xAB xF0 x90 x8B x89 xE2 xB2 x9E xE2 xB2 x9F xD0 xBE xD0 x9E xF0 x90 x90 x84 xF0 x90 x90 xAC xE1 x83 x98 xE1 x83 x94 xE1 x83 x90 xE2 xB0 x95 xE2 xB1 x85 xCE xBF xCE x9F xE0 xA8 xA0 xE0 xA8 xB0 xE0 xA9 xA6 Kayah xEA xA4 x8D xEA xA4 x80 Khmer xE1 xA7 xA1 xE1 xA7 xAA xE0 xBB x90 Latin Subscript xE2 x82 x92 xE2 x82 x80 xEA x93 xB3 xE1 x80 x9D xE1 x80 x84 xE1 x80 x82 NONE
Definition: afscript.h:258

◆ _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 91 of file brush.cpp.

93 {
95  NT_ASSERT(this->pBrushAttr == &this->BrushAttr);
96 
97  /* Allocate a brush attribute from the pool */
98  pBrushAttr = static_cast<PBRUSH_ATTR>(GdiPoolAllocate(GetBrushAttrPool()));
99  if (pBrushAttr == NULL)
100  {
101  ERR("Could not allocate brush attr\n");
102  return FALSE;
103  }
104 
105  /* Copy the content from the kernel mode brush attribute */
106  this->pBrushAttr = pBrushAttr;
107  *this->pBrushAttr = this->BrushAttr;
108 
109  /* Set the object attribute in the handle table */
110  vSetObjectAttr(pBrushAttr);
111 
112  return TRUE;
113 }
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
#define TRUE
Definition: types.h:120
PGDI_POOL GetBrushAttrPool(VOID)
HACK!
Definition: gdiobj.c:1609
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI GdiPoolAllocate(PGDI_POOL pPool)
Definition: gdipool.c:122
#define ERR(fmt,...)
Definition: debug.h:109
BRUSH_ATTR BrushAttr
Definition: brush.h:23
VOID vSetObjectAttr(_In_opt_ PVOID pvUserAttr)
Definition: baseobj.hpp:60
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ cjGetObject()

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

Definition at line 140 of file brush.cpp.

143 {
144  /* Check if only size is requested */
145  if (plb == NULL)
146  return sizeof(LOGBRUSH);
147 
148  /* Check if size is ok */
149  if (cjSize == 0)
150  return 0;
151 
152  /* Set color */
153  plb->lbColor = this->BrushAttr.lbColor;
154 
155  /* Set style and hatch based on the attribute flags */
156  if (this->flAttrs & BR_IS_SOLID)
157  {
158  plb->lbStyle = BS_SOLID;
159  plb->lbHatch = 0;
160  }
161  else if (this->flAttrs & BR_IS_HATCH)
162  {
163  plb->lbStyle = BS_HATCHED;
164  plb->lbHatch = this->iHatch;
165  }
166  else if (this->flAttrs & BR_IS_DIB)
167  {
168  plb->lbStyle = BS_DIBPATTERN;
169  plb->lbHatch = (ULONG_PTR)this->hbmClient;
170  }
171  else if (this->flAttrs & BR_IS_BITMAP)
172  {
173  plb->lbStyle = BS_PATTERN;
174  plb->lbHatch = (ULONG_PTR)this->hbmClient;
175  }
176  else if (this->flAttrs & BR_IS_NULL)
177  {
178  plb->lbStyle = BS_NULL;
179  plb->lbHatch = 0;
180  }
181  else
182  {
183  NT_ASSERT(FALSE);
184  }
185 
186  return sizeof(LOGBRUSH);
187 }
#define BS_DIBPATTERN
Definition: wingdi.h:1091
#define BR_IS_BITMAP
Definition: brush.h:99
ULONG flAttrs
Definition: brush.h:19
#define BS_NULL
Definition: wingdi.h:1086
#define BR_IS_SOLID
Definition: brush.h:97
#define BR_IS_DIB
Definition: brush.h:100
ULONG iHatch
Definition: brush.h:16
smooth NULL
Definition: ftsmooth.c:416
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:360
#define BS_PATTERN
Definition: wingdi.h:1089
_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:1088
#define BS_SOLID
Definition: wingdi.h:1085
struct tagLOGBRUSH LOGBRUSH
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ hbmGetBitmapHandle()

HBITMAP BRUSH::hbmGetBitmapHandle ( _Out_ PUINT  puUsage) const

Definition at line 128 of file brush.cpp.

130 {
131  /* Return the color usage based on flags */
132  *puUsage = (this->flAttrs & BR_IS_DIBPALCOLORS) ? DIB_PAL_COLORS :
135 
136  return this->hbmPattern;
137 }
#define DIB_PAL_COLORS
Definition: wingdi.h:365
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:366
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 80 of file brush.cpp.

82 {
83  PBRUSH pbr = static_cast<PBRUSH>(pvObject);
85  (GDI_HANDLE_GET_TYPE(pbr->hHmgr()) == GDILoObjType_LO_PEN_TYPE) ||
87  delete pbr;
88 }
Definition: types.h:100
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by BRUSH_vDeleteObject().

◆ vSetSolidColor()

VOID BRUSH::vSetSolidColor ( _In_ COLORREF  crColor)

Definition at line 116 of file brush.cpp.

118 {
119  NT_ASSERT(this->flAttrs & BR_IS_SOLID);
120 
121  /* Set new color and reset the pal times */
122  this->pBrushAttr->lbColor = crColor & 0xFFFFFF;
123  this->ulPalTime = -1;
124  this->ulSurfTime = -1;
125 }
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:360
#define NT_ASSERT
Definition: rtlfuncs.h:3312

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