2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
2002-01-14 01:11:58 +00:00
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
/* GDI surface object */
|
|
|
|
typedef struct _SURFACE
|
|
|
|
{
|
2010-06-05 21:19:41 +00:00
|
|
|
BASEOBJECT BaseObject;
|
2009-01-08 16:33:40 +00:00
|
|
|
|
2010-06-05 21:19:41 +00:00
|
|
|
SURFOBJ SurfObj;
|
|
|
|
//XDCOBJ * pdcoAA;
|
|
|
|
FLONG flags;
|
2012-07-01 13:43:33 +00:00
|
|
|
struct _PALETTE * const ppal; // Use SURFACE_vSetPalette to assign a palette
|
2019-08-16 02:39:26 +00:00
|
|
|
struct _EWNDOBJ *pWinObj;
|
2009-04-14 16:41:48 +00:00
|
|
|
|
2010-06-05 21:19:41 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
HANDLE hSecureUMPD; // if UMPD_SURFACE set
|
|
|
|
HANDLE hMirrorParent;// if MIRROR_SURFACE set
|
|
|
|
HANDLE hDDSurface; // if DIRECTDRAW_SURFACE set
|
|
|
|
};
|
2009-04-14 16:41:48 +00:00
|
|
|
|
2010-06-05 21:19:41 +00:00
|
|
|
SIZEL sizlDim; /* For SetBitmapDimension(), do NOT use
|
2009-01-08 16:33:40 +00:00
|
|
|
to get width/height of bitmap, use
|
|
|
|
bitmap.bmWidth/bitmap.bmHeight for
|
|
|
|
that */
|
2010-04-19 00:56:25 +00:00
|
|
|
|
2010-06-05 21:19:41 +00:00
|
|
|
HDC hdc; // Doc in "Undocumented Windows", page 546, seems to be supported with XP.
|
|
|
|
ULONG cRef;
|
|
|
|
HPALETTE hpalHint;
|
2009-01-08 16:33:40 +00:00
|
|
|
|
2010-06-05 21:19:41 +00:00
|
|
|
/* For device-independent bitmaps: */
|
|
|
|
HANDLE hDIBSection;
|
|
|
|
HANDLE hSecure;
|
|
|
|
DWORD dwOffset;
|
|
|
|
//UINT unk_078;
|
2009-01-09 02:06:39 +00:00
|
|
|
|
2009-04-14 16:41:48 +00:00
|
|
|
/* reactos specific */
|
2010-06-05 21:19:41 +00:00
|
|
|
DWORD biClrImportant;
|
2009-01-08 16:33:40 +00:00
|
|
|
} SURFACE, *PSURFACE;
|
|
|
|
|
2012-07-29 11:20:05 +00:00
|
|
|
/* flags field */
|
|
|
|
enum _SURFACEFLAGS
|
|
|
|
{
|
2010-06-05 21:19:41 +00:00
|
|
|
//#define HOOK_BITBLT 0x00000001
|
|
|
|
//#define HOOK_STRETCHBLT 0x00000002
|
|
|
|
//#define HOOK_PLGBLT 0x00000004
|
|
|
|
//#define HOOK_TEXTOUT 0x00000008
|
|
|
|
//#define HOOK_PAINT 0x00000010
|
|
|
|
//#define HOOK_STROKEPATH 0x00000020
|
|
|
|
//#define HOOK_FILLPATH 0x00000040
|
|
|
|
//#define HOOK_STROKEANDFILLPATH 0x00000080
|
|
|
|
//#define HOOK_LINETO 0x00000100
|
2015-01-26 22:11:34 +00:00
|
|
|
SHAREACCESS_SURFACE = 0x00000200,
|
2010-06-05 21:19:41 +00:00
|
|
|
//#define HOOK_COPYBITS 0x00000400
|
|
|
|
//#define REDIRECTION_SURFACE 0x00000800 // ?
|
|
|
|
//#define HOOK_MOVEPANNING 0x00000800
|
|
|
|
//#define HOOK_SYNCHRONIZE 0x00001000
|
|
|
|
//#define HOOK_STRETCHBLTROP 0x00002000
|
|
|
|
//#define HOOK_SYNCHRONIZEACCESS 0x00004000
|
|
|
|
//#define USE_DEVLOCK_SURFACE 0x00004000
|
|
|
|
//#define HOOK_TRANSPARENTBLT 0x00008000
|
|
|
|
//#define HOOK_ALPHABLEND 0x00010000
|
|
|
|
//#define HOOK_GRADIENTFILL 0x00020000
|
|
|
|
//#if (NTDDI_VERSION < 0x06000000)
|
|
|
|
// #define HOOK_FLAGS 0x0003B5FF
|
|
|
|
//#else
|
|
|
|
// #define HOOK_FLAGS 0x0003B5EF
|
|
|
|
//#endif
|
2012-07-29 11:20:05 +00:00
|
|
|
UMPD_SURFACE = 0x00040000,
|
|
|
|
MIRROR_SURFACE = 0x00080000,
|
|
|
|
DIRECTDRAW_SURFACE = 0x00100000,
|
|
|
|
DRIVER_CREATED_SURFACE = 0x00200000,
|
|
|
|
ENG_CREATE_DEVICE_SURFACE = 0x00400000,
|
|
|
|
DDB_SURFACE = 0x00800000,
|
|
|
|
LAZY_DELETE_SURFACE = 0x01000000,
|
|
|
|
BANDING_SURFACE = 0x02000000,
|
|
|
|
API_BITMAP = 0x04000000,
|
|
|
|
PALETTE_SELECT_SET = 0x08000000,
|
|
|
|
UNREADABLE_SURFACE = 0x10000000,
|
|
|
|
DYNAMIC_MODE_PALETTE = 0x20000000,
|
|
|
|
ABORT_SURFACE = 0x40000000,
|
|
|
|
PDEV_SURFACE = 0x80000000
|
|
|
|
};
|
2010-06-05 21:19:41 +00:00
|
|
|
|
2012-05-01 13:57:18 +00:00
|
|
|
#define BMF_POOLALLOC 0x100
|
2010-06-06 03:12:56 +00:00
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
/* Internal interface */
|
|
|
|
|
[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 SURFACE_AllocSurfaceWithHandle() ((PSURFACE) GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_BITMAP, sizeof(SURFACE)))
|
2009-01-08 16:33:40 +00:00
|
|
|
|
|
|
|
/* NOTE: Use shared locks! */
|
|
|
|
#define SURFACE_ShareLockSurface(hBMObj) \
|
|
|
|
((PSURFACE) GDIOBJ_ShareLockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP))
|
2017-10-23 18:34:02 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
SURFACE_ShareLockByPointer(PSURFACE psurf)
|
|
|
|
{
|
|
|
|
GDIOBJ_vReferenceObjectByPointer(&psurf->BaseObject);
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
#define SURFACE_UnlockSurface(pBMObj) \
|
[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
|
|
|
GDIOBJ_vUnlockObject ((POBJ)pBMObj)
|
2009-01-08 16:33:40 +00:00
|
|
|
#define SURFACE_ShareUnlockSurface(pBMObj) \
|
[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
|
|
|
GDIOBJ_vDereferenceObject ((POBJ)pBMObj)
|
2009-01-08 16:33:40 +00:00
|
|
|
|
2009-03-20 18:02:55 +00:00
|
|
|
#define GDIDEV(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))
|
|
|
|
#define GDIDEVFUNCS(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))->DriverFunctions
|
2004-07-03 13:55:37 +00:00
|
|
|
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
extern UCHAR gajBitsPerFormat[];
|
|
|
|
#define BitsPerFormat(Format) gajBitsPerFormat[Format]
|
2010-09-01 12:04:31 +00:00
|
|
|
|
|
|
|
#define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3)
|
|
|
|
#define WIDTH_BYTES_ALIGN16(cx, bpp) ((((cx) * (bpp) + 15) & ~15) >> 3)
|
|
|
|
|
2012-05-01 12:14:10 +00:00
|
|
|
ULONG
|
|
|
|
FASTCALL
|
|
|
|
BitmapFormat(ULONG cBits, ULONG iCompression);
|
|
|
|
|
2014-05-22 11:45:53 +00:00
|
|
|
VOID
|
2012-05-01 12:14:10 +00:00
|
|
|
NTAPI
|
2014-05-22 11:45:53 +00:00
|
|
|
SURFACE_vCleanup(PVOID ObjectBody);
|
2012-05-01 12:14:10 +00:00
|
|
|
|
|
|
|
PSURFACE
|
|
|
|
NTAPI
|
|
|
|
SURFACE_AllocSurface(
|
|
|
|
_In_ USHORT iType,
|
|
|
|
_In_ ULONG cx,
|
|
|
|
_In_ ULONG cy,
|
|
|
|
_In_ ULONG iFormat,
|
|
|
|
_In_ ULONG fjBitmap,
|
|
|
|
_In_opt_ ULONG cjWidth,
|
2015-03-08 17:25:44 +00:00
|
|
|
_In_opt_ ULONG cjBits,
|
2012-05-01 12:14:10 +00:00
|
|
|
_In_opt_ PVOID pvBits);
|
2012-07-01 13:43:33 +00:00
|
|
|
|
|
|
|
FORCEINLINE
|
2014-05-04 09:45:42 +00:00
|
|
|
VOID
|
2012-07-01 13:43:33 +00:00
|
|
|
SURFACE_vSetPalette(
|
|
|
|
_Inout_ PSURFACE psurf,
|
|
|
|
_In_ PPALETTE ppal)
|
|
|
|
{
|
|
|
|
if (psurf->ppal)
|
|
|
|
GDIOBJ_vDereferenceObject((POBJ)psurf->ppal);
|
|
|
|
if (ppal)
|
|
|
|
GDIOBJ_vReferenceObjectByPointer((POBJ)ppal);
|
|
|
|
*(PVOID*)&psurf->ppal = ppal;
|
|
|
|
}
|
|
|
|
|