xref: /reactos/win32ss/gdi/ntgdi/brush.h (revision 0bc6bd64)
1 #pragma once
2 
3 /* Internal interface */
4 
5 #define NB_HATCH_STYLES  6
6 
7 /*
8  * The layout of this structure is taken from "Windows Graphics Programming"
9  * book written by Feng Yuan.
10  *
11  * DON'T MODIFY THIS STRUCTURE UNLESS REALLY NEEDED AND EVEN THEN ASK ON
12  * A MAILING LIST FIRST.
13  */
14 typedef struct _BRUSHBODY
15 {
16     ULONG iHatch;           // This is not the brush style, but the hatch style!
17     HBITMAP hbmPattern;
18     HBITMAP hbmClient;
19     ULONG flAttrs;
20 
21     ULONG ulBrushUnique;
22     BRUSH_ATTR *pBrushAttr; // Pointer to the currently active brush attribute
23     BRUSH_ATTR BrushAttr;   // Internal brush attribute for global brushes
24     POINT ptOrigin;
25     ULONG bCacheGrabbed;
26     COLORREF crBack;
27     COLORREF crFore;
28     ULONG ulPalTime;
29     ULONG ulSurfTime;
30     PVOID pvRBrush;
31     HDEV hdev;
32     //DWORD unk054;
33 
34     /* The following members are for PENs only */
35     LONG lWidth;
36     FLOATOBJ eWidth;
37     ULONG ulPenStyle;
38     DWORD *pStyle;
39     ULONG dwStyleCount;
40     BYTE jJoin;             // 0x06c Join styles for geometric wide lines
41     BYTE jEndCap;           //       end cap style for a geometric wide line
42     //WORD unk06e;          // 0x06e
43     INT iBrushStyle;        // 0x070
44     //PREGION prgn;           // 0x074
45     //DWORD unk078;         // 0x078
46     //DWORD unk07c;           // 0x07c
47     ULONG ulStyleSize;
48     LIST_ENTRY ListHead;    // 0x080
49 } BRUSHBODY;
50 
51 #ifndef __cplusplus
52 typedef struct _BRUSH
53 {
54     /* Header for all gdi objects in the handle table.
55        Do not (re)move this. */
56     BASEOBJECT BaseObject;
57 
58     BRUSHBODY;
59 } BRUSH, *PBRUSH;
60 #else
61 class BRUSH;
62 typedef class BRUSH *PBRUSH;
63 #endif
64 
65 /*
66  * EBRUSHOBJ structure.
67  * See also: https://reactos.org/wiki/Techwiki:Win32k/EBRUSHOBJ
68  */
69 typedef struct _EBRUSHOBJ
70 {
71     BRUSHOBJ    BrushObject;
72 
73     COLORREF    crRealize;
74     ULONG       ulRGBColor;
75     PVOID       pengbrush;
76     ULONG       ulSurfPalTime;
77     ULONG       ulDCPalTime;
78     COLORREF    crCurrentText;
79     COLORREF    crCurrentBack;
80     COLORADJUSTMENT *pca;
81 //    DWORD       dwUnknown2c;
82 //    DWORD       dwUnknown30;
83     SURFACE *   psurfTrg;
84     struct _PALETTE *   ppalSurf;
85     struct _PALETTE *   ppalDC;
86     struct _PALETTE *   ppalDIB;
87 //    DWORD       dwUnknown44;
88     PBRUSH      pbrush;
89     FLONG       flattrs;
90     DWORD       ulUnique;
91 //    DWORD       dwUnknown54;
92 //    DWORD       dwUnknown58;
93 
94     SURFOBJ *psoMask;
95 } EBRUSHOBJ, *PEBRUSHOBJ;
96 
97 /* GDI Brush Attributes */
98 #define BR_NEED_FG_CLR      0x00000001
99 #define BR_NEED_BK_CLR      0x00000002 /* Background color is needed */
100 #define BR_DITHER_OK        0x00000004 /* Allow color dithering */
101 #define BR_IS_SOLID         0x00000010 /* Solid brush */
102 #define BR_IS_HATCH         0x00000020 /* Hatch brush */
103 #define BR_IS_BITMAP        0x00000040 /* DDB pattern brush */
104 #define BR_IS_DIB           0x00000080 /* DIB pattern brush */
105 #define BR_IS_NULL          0x00000100 /* Null/hollow brush */
106 #define BR_IS_GLOBAL        0x00000200 /* Stock objects */
107 #define BR_IS_PEN           0x00000400 /* Pen */
108 #define BR_IS_OLDSTYLEPEN   0x00000800 /* Geometric pen */
109 #define BR_IS_DIBPALCOLORS  0x00001000
110 #define BR_IS_DIBPALINDICES 0x00002000
111 #define BR_IS_DEFAULTSTYLE  0x00004000
112 #define BR_IS_MASKING       0x00008000 /* Pattern bitmap is used as transparent mask (?) */
113 #define BR_IS_INSIDEFRAME   0x00010000
114 #define BR_CACHED_ENGINE    0x00040000
115 #define BR_CACHED_IS_SOLID  0x80000000
116 
117 #define  BRUSH_ShareLockBrush(hBrush) ((PBRUSH)GDIOBJ_ShareLockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
118 #define  BRUSH_ShareUnlockBrush(pBrush) GDIOBJ_vDereferenceObject((POBJ)pBrush)
119 
120 INT
121 FASTCALL
122 BRUSH_GetObject(
123     PBRUSH GdiObject,
124     INT Count,
125     LPLOGBRUSH Buffer);
126 
127 VOID
128 NTAPI
129 BRUSH_vDeleteObject(
130     PVOID pvObject);
131 
132 extern HSURF gahsurfHatch[HS_DDI_MAX];
133 
134 struct _SURFACE;
135 struct _PALETTE;
136 struct _DC;
137 
138 CODE_SEG("INIT")
139 NTSTATUS
140 NTAPI
141 InitBrushImpl(VOID);
142 
143 VOID
144 NTAPI
145 EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, struct _SURFACE *, COLORREF, COLORREF, struct _PALETTE *);
146 
147 VOID
148 NTAPI
149 EBRUSHOBJ_vInitFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, struct _DC *);
150 
151 VOID
152 FASTCALL
153 EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor);
154 
155 VOID
156 NTAPI
157 EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, struct _DC *);
158 
159 BOOL
160 NTAPI
161 EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo, BOOL bCallDriver);
162 
163 VOID
164 NTAPI
165 EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo);
166 
167 PVOID
168 NTAPI
169 EBRUSHOBJ_pvGetEngBrush(EBRUSHOBJ *pebo);
170 
171 SURFOBJ*
172 NTAPI
173 EBRUSHOBJ_psoPattern(EBRUSHOBJ *pebo);
174 
175 #define BRUSHOBJ_psoPattern(pbo) \
176     EBRUSHOBJ_psoPattern(CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject))
177 
178 SURFOBJ*
179 NTAPI
180 EBRUSHOBJ_psoMask(EBRUSHOBJ *pebo);
181 
182 #define BRUSHOBJ_psoMask(pbo) \
183     EBRUSHOBJ_psoMask(CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject))
184 
185 FORCEINLINE
186 ULONG
EBRUSHOBJ_iSetSolidColor(EBRUSHOBJ * pebo,ULONG iSolidColor)187 EBRUSHOBJ_iSetSolidColor(EBRUSHOBJ *pebo, ULONG iSolidColor)
188 {
189     ULONG iOldColor = pebo->BrushObject.iSolidColor;
190     pebo->BrushObject.iSolidColor = iSolidColor;
191     return iOldColor;
192 }
193 
194 BOOL FASTCALL IntGdiSetBrushOwner(PBRUSH,DWORD);
195 BOOL FASTCALL GreSetBrushOwner(HBRUSH,DWORD);
196 
197 HBRUSH APIENTRY
198 IntGdiCreatePatternBrush(
199    HBITMAP hBitmap);
200 
201 HBRUSH APIENTRY
202 IntGdiCreateSolidBrush(
203    COLORREF Color);
204 
205 HBRUSH APIENTRY
206 IntGdiCreateNullBrush(VOID);
207 
208 VOID
209 NTAPI
210 IntGdiSetSolidBrushColor(
211     _In_ HBRUSH hbr,
212     _In_ COLORREF crColor);
213