reactos/win32ss/gdi/ntgdi/brush.h

209 lines
5.1 KiB
C
Raw Normal View History

#pragma once
/* Internal interface */
#define NB_HATCH_STYLES 6
/*
* The layout of this structure is taken from "Windows Graphics Programming"
* book written by Feng Yuan.
*
* DON'T MODIFY THIS STRUCTURE UNLESS REALLY NEEDED AND EVEN THEN ASK ON
* A MAILING LIST FIRST.
*/
typedef struct _BRUSHBODY
{
ULONG iHatch; // This is not the brush style, but the hatch style!
HBITMAP hbmPattern;
HBITMAP hbmClient;
ULONG flAttrs;
ULONG ulBrushUnique;
BRUSH_ATTR *pBrushAttr; // Pointer to the currently active brush attribute
BRUSH_ATTR BrushAttr; // Internal brush attribute for global brushes
POINT ptOrigin;
ULONG bCacheGrabbed;
COLORREF crBack;
COLORREF crFore;
ULONG ulPalTime;
ULONG ulSurfTime;
PVOID pvRBrush;
HDEV hdev;
//DWORD unk054;
/* The following members are for PENs only */
LONG lWidth;
FLOATOBJ eWidth;
ULONG ulPenStyle;
DWORD *pStyle;
ULONG dwStyleCount;
BYTE jJoin; // 0x06c Join styles for geometric wide lines
BYTE jEndCap; // end cap style for a geometric wide line
//WORD unk06e; // 0x06e
INT iBrushStyle; // 0x070
//PREGION prgn; // 0x074
//DWORD unk078; // 0x078
//DWORD unk07c; // 0x07c
ULONG ulStyleSize;
LIST_ENTRY ListHead; // 0x080
} BRUSHBODY;
#ifndef __cplusplus
typedef struct _BRUSH
{
/* Header for all gdi objects in the handle table.
Do not (re)move this. */
BASEOBJECT BaseObject;
BRUSHBODY;
} BRUSH, *PBRUSH;
#else
class BRUSH;
typedef class BRUSH *PBRUSH;
#endif
typedef struct _EBRUSHOBJ
{
BRUSHOBJ BrushObject;
COLORREF crRealize;
ULONG ulRGBColor;
PVOID pengbrush;
ULONG ulSurfPalTime;
ULONG ulDCPalTime;
COLORREF crCurrentText;
COLORREF crCurrentBack;
COLORADJUSTMENT *pca;
// DWORD dwUnknown2c;
// DWORD dwUnknown30;
SURFACE * psurfTrg;
XLATEOBJ rewrite. The new XLATEOBJ is not allocated from paged pool anymore, but instead allocated on the stack and Initialized. Only when we habe more than a color table with more than 6 entries, we need to allocate an additional buffer. The new interface: EXLATEOBJ_vInitialize is the main init function. It takes a source and destination palette and back and fore colors for monochome surfaces. EXLATEOBJ_vInitXlateFromDCs takes the source and dest DC and is for color translation between 2 surfaces represented by 2 DCs. EXLATEOBJ_vInitBrushXlate initializes an XLATEOBJ for a pattern brush. Finally EXLATEOBJ_vCleanup needs to be called when the XLATEOBJ is not needed anymore. Implement individual iXlate functions for certain cases and store a function pointer in the EXLATEOBJ structure for quick access. Change the usage of the PALETTE.Mode member to be a flag instead of an enum, add usage of PAL_MONOCHOME, PAL_RGB16_555 and PAL_RGB16_565. Add gpalMono, which *should* be used as palette for 1bpp DDBs. Currently there's a hack in the XLATEOBJ init code, to hack around the fact that this is missing. Fix the Hatch brush patterns, as they were inverted. Implement PALETTE_ulGetNearestBitFieldsIndex and PALETTE_ulGetNearestIndex. Get rid of the XLATEOBJ for the mouse pointer instead realize the pointer before usage. Get rid of logicalToSystem PALETTE member. NtGdiGetDIBitsInternal: Don't create a DIBBrush from the BITMAPINFO, when pvBits is NULL, as the function might be uninitualized. This fixes a crash of gdi_regtest. The whole function is quite ugly and needs to be rewritten (like probably the rest of the DIB code). This fixes the problem of artifacts in the selected desktop icons and some color problems. svn path=/trunk/; revision=42391
2009-08-04 20:37:10 +00:00
struct _PALETTE * ppalSurf;
struct _PALETTE * ppalDC;
struct _PALETTE * ppalDIB;
// DWORD dwUnknown44;
PBRUSH pbrush;
FLONG flattrs;
DWORD ulUnique;
// DWORD dwUnknown54;
// DWORD dwUnknown58;
SURFOBJ *psoMask;
} EBRUSHOBJ, *PEBRUSHOBJ;
/* GDI Brush Attributes */
#define BR_NEED_FG_CLR 0x00000001
#define BR_NEED_BK_CLR 0x00000002 /* Background color is needed */
#define BR_DITHER_OK 0x00000004 /* Allow color dithering */
#define BR_IS_SOLID 0x00000010 /* Solid brush */
#define BR_IS_HATCH 0x00000020 /* Hatch brush */
#define BR_IS_BITMAP 0x00000040 /* DDB pattern brush */
#define BR_IS_DIB 0x00000080 /* DIB pattern brush */
#define BR_IS_NULL 0x00000100 /* Null/hollow brush */
#define BR_IS_GLOBAL 0x00000200 /* Stock objects */
#define BR_IS_PEN 0x00000400 /* Pen */
#define BR_IS_OLDSTYLEPEN 0x00000800 /* Geometric pen */
#define BR_IS_DIBPALCOLORS 0x00001000
#define BR_IS_DIBPALINDICES 0x00002000
#define BR_IS_DEFAULTSTYLE 0x00004000
#define BR_IS_MASKING 0x00008000 /* Pattern bitmap is used as transparent mask (?) */
#define BR_IS_INSIDEFRAME 0x00010000
#define BR_CACHED_ENGINE 0x00040000
#define BR_CACHED_IS_SOLID 0x80000000
#define BRUSH_ShareLockBrush(hBrush) ((PBRUSH)GDIOBJ_ShareLockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
[WIN32K] Rewrite of the GDI handle manager - The old handle manager used a completely retarded spinlock in combination with KeDelayExecutionThread() for both exclusive and shared locks. This is probably the most uneffective algorithm possible. It was also duplicating code everywhere and it was a overall mess It is now replaced with a lock-free reference counter for shared locks and a pushlock for exclusive locks. -> Better performance and scalability. - Allocate user mode object attributes from the new gdi pool. This way, we don't need any caching, since the pool serves as a cache. Its also much faster and uses much less memory. - Allow object allocations of different size, instead of fixed size from a table. This way a single allocation can take care of actual needs. - Allow allcoating objects without a handle and insert them into the handle table later - Properly synchronize the process GDIHandleCount. Now gdiview and taskmanager show the correct number of gdi handles. - Implement a new event tracking system, that is capable of tracking all reverences and locks of objects and pool allocations to help track possible leaks - Make sure that all objects of a process are deleted in cleanup - Make sure all usermode memory allocations are freed, when cleaning up the process pool. - Make sure that each object type is using the correct type of lock (either shared or exclusive, not a mixture) - Fix some object / reference leaks - Lots of inferface improvements - Use global variables for certain things instead of members in the mapped gdi handle table - Make IntSysCreateRectpRgn create a region without a handle - Fix detection od source and mask use in GreStretchBltMask - Use GDIOBJ_bLockMultipleObjects in NtGdiCombineRegion to avoid possible deadlocks - Fix NtGdiAbortPath to reset DCPATH_ACTIVE flag in the dc and only bail out on error, instead of always - Replace DC_AllocateDcAttr and DC_AllocDcAttr with DC_bAllocDcAttr using the new user mode pool - Remove DCU_SyncDcAttrtoUser and DCU_SynchDcAttrtoUser. Those functions were unused and didn't do anything useful anyway, - Replace IntGdiSetDCOwnerEx and DC_SetOwnership with GreSetDCOwner, remove unused NoSetBrush parameter - Replace GDIOBJ_bValidateHandle and IsObjectDead with GreIsHandleValid - Chage GDIOBJ_bLockMultipleObjects: pass object type, return a BOOL, whether all objects could be locked, cleanup on failure svn path=/trunk/; revision=51470
2011-04-28 08:26:46 +00:00
#define BRUSH_ShareUnlockBrush(pBrush) GDIOBJ_vDereferenceObject((POBJ)pBrush)
INT
FASTCALL
BRUSH_GetObject(
PBRUSH GdiObject,
INT Count,
LPLOGBRUSH Buffer);
VOID
NTAPI
BRUSH_vDeleteObject(
PVOID pvObject);
extern HSURF gahsurfHatch[HS_DDI_MAX];
struct _SURFACE;
struct _PALETTE;
struct _DC;
INIT_FUNCTION
NTSTATUS
NTAPI
InitBrushImpl(VOID);
VOID
NTAPI
EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, struct _SURFACE *, COLORREF, COLORREF, struct _PALETTE *);
VOID
NTAPI
EBRUSHOBJ_vInitFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, struct _DC *);
VOID
FASTCALL
EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor);
VOID
NTAPI
EBRUSHOBJ_vUpdateFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, struct _DC *);
BOOL
NTAPI
EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo, BOOL bCallDriver);
VOID
NTAPI
EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo);
PVOID
NTAPI
EBRUSHOBJ_pvGetEngBrush(EBRUSHOBJ *pebo);
SURFOBJ*
NTAPI
EBRUSHOBJ_psoPattern(EBRUSHOBJ *pebo);
#define BRUSHOBJ_psoPattern(pbo) \
EBRUSHOBJ_psoPattern(CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject))
SURFOBJ*
NTAPI
EBRUSHOBJ_psoMask(EBRUSHOBJ *pebo);
#define BRUSHOBJ_psoMask(pbo) \
EBRUSHOBJ_psoMask(CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject))
FORCEINLINE
ULONG
EBRUSHOBJ_iSetSolidColor(EBRUSHOBJ *pebo, ULONG iSolidColor)
{
ULONG iOldColor = pebo->BrushObject.iSolidColor;
pebo->BrushObject.iSolidColor = iSolidColor;
return iOldColor;
}
BOOL FASTCALL IntGdiSetBrushOwner(PBRUSH,DWORD);
BOOL FASTCALL GreSetBrushOwner(HBRUSH,DWORD);
HBRUSH APIENTRY
IntGdiCreatePatternBrush(
HBITMAP hBitmap);
HBRUSH APIENTRY
IntGdiCreateSolidBrush(
COLORREF Color);
HBRUSH APIENTRY
IntGdiCreateNullBrush(VOID);
VOID
NTAPI
IntGdiSetSolidBrushColor(
_In_ HBRUSH hbr,
_In_ COLORREF crColor);