ReactOS 0.4.17-dev-966-gf06eace
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 BASEOBJECT * LockExclusive (HGDIOBJ hobj, GDIOBJTYPE objtype)
 
static BASEOBJECT * LockExclusive (HGDIOBJ hobj, GDILOOBJTYPE loobjtype)
 
static BASEOBJECT * LockShared (HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
 
- Protected Attributes inherited from _BRUSHBODY
ULONG iHatch
 
HBITMAP hbmPattern
 
HBITMAP hbmClient
 
ULONG flAttrs
 
ULONG ulBrushUnique
 
BRUSH_ATTR * pBrushAttr
 
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
 
DWORD * pStyle
 
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}
#define BASEOBJECT
Definition: baseobj.hpp:6
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1544
static HBITMAP
Definition: button.c:44
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
ULONG bCacheGrabbed
Definition: brush.h:25
HBITMAP hbmClient
Definition: brush.h:18
HBITMAP hbmPattern
Definition: brush.h:17
ULONG ulPalTime
Definition: brush.h:28
DWORD * pStyle
Definition: brush.h:38
COLORREF crBack
Definition: brush.h:26
PVOID pvRBrush
Definition: brush.h:30
ULONG dwStyleCount
Definition: brush.h:39
ULONG flAttrs
Definition: brush.h:19
ULONG ulBrushUnique
Definition: brush.h:21
BRUSH_ATTR BrushAttr
Definition: brush.h:23
ULONG iHatch
Definition: brush.h:16
COLORREF crFore
Definition: brush.h:27
POINT ptOrigin
Definition: brush.h:24
BRUSH_ATTR * pBrushAttr
Definition: brush.h:22
ULONG ulSurfTime
Definition: brush.h:29
COLORREF lbColor
Definition: ntgdihdl.h:356
uint32_t ULONG
Definition: typedefs.h:59
_In_ HDEV hdev
Definition: winddi.h:3449
_Inout_ SURFOBJ _In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_opt_ XLATEOBJ _In_ ULONG iHatch
Definition: winddi.h:3963

Referenced by BRUSH().

◆ ~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}
BOOL NTAPI GreSetBitmapOwner(_In_ HBITMAP hbmp, _In_ ULONG ulOwner)
Definition: bitmaps.c:17
PGDI_POOL GetBrushAttrPool(VOID)
#define BR_IS_DEFAULTSTYLE
Definition: brush.h:111
VOID NTAPI GdiPoolFree(PGDI_POOL pPool, PVOID pvAlloc)
Definition: gdipool.c:233
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
#define GDITAG_PENSTYLE
Definition: tags.h:165

Referenced by ~BRUSH().

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 ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define GDITAG_HMGR_BRUSH_TYPE
Definition: tags.h:104
_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>(
101 BASEOBJECT::OWNER::NONE));
102 }
static BASEOBJECT * LockShared(HGDIOBJ hobj, GDILOOBJTYPE loobjtype, OWNER owner)
Definition: baseobj.hpp:50
@ GDILoObjType_LO_BRUSH_TYPE
Definition: gdi_private.h:33
Definition: types.h:101

◆ _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 }

◆ _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 }

◆ 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}
#define ERR(fmt,...)
Definition: precomp.h:57
VOID vSetObjectAttr(_In_opt_ PVOID pvUserAttr)
Definition: baseobj.hpp:60
#define TRUE
Definition: types.h:120
PVOID NTAPI GdiPoolAllocate(PGDI_POOL pPool)
Definition: gdipool.c:122
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by bAllocateBrushAttr().

◆ 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 {
195 }
196
197 return sizeof(LOGBRUSH);
198}
#define ULONG_PTR
Definition: config.h:101
#define BR_IS_SOLID
Definition: brush.h:101
#define BR_IS_DIB
Definition: brush.h:104
#define BR_IS_NULL
Definition: brush.h:105
#define BR_IS_BITMAP
Definition: brush.h:103
#define BR_IS_HATCH
Definition: brush.h:102
#define BS_HATCHED
Definition: wingdi.h:1089
#define BS_PATTERN
Definition: wingdi.h:1090
#define BS_DIBPATTERN
Definition: wingdi.h:1092
#define BS_NULL
Definition: wingdi.h:1087
#define BS_SOLID
Definition: wingdi.h:1086
struct tagLOGBRUSH LOGBRUSH

Referenced by cjGetObject().

◆ 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_INDICES
#define BR_IS_DIBPALINDICES
Definition: brush.h:110
#define BR_IS_DIBPALCOLORS
Definition: brush.h:109
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define DIB_PAL_COLORS
Definition: wingdi.h:366

Referenced by hbmGetBitmapHandle().

◆ 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);
98 delete pbr;
99}
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
@ GDILoObjType_LO_EXTPEN_TYPE
Definition: gdi_private.h:45
@ GDILoObjType_LO_PEN_TYPE
Definition: gdi_private.h:44

Referenced by 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}

Referenced by vReleaseAttribute().

◆ vSetSolidColor()

VOID BRUSH::vSetSolidColor ( _In_ COLORREF  crColor)

Definition at line 127 of file brush.cpp.

129{
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}

Referenced by vSetSolidColor().


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