Author: fireball
Date: Wed Aug 12 20:02:42 2009
New Revision: 42636
URL:
http://svn.reactos.org/svn/reactos?rev=42636&view=rev
Log:
- Add cleanup routine for SURFACE object. Now SURFACE frees all memory except bits if they
were allocated (TODO).
- Implement surface's bits locking/unlock (same concept as in trunk).
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c [iso-8859-1] Wed Aug
12 20:02:42 2009
@@ -19,9 +19,11 @@
IN LONG y,
IN RECTL *prcl)
{
- SURFACE_LockBitmapBits(pso);
+ SURFACE *pSurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
+
+ SURFACE_LockBitmapBits(pSurf);
GDIDEVFUNCS(pso).MovePointer(pso, x, y, prcl);
- SURFACE_UnlockBitmapBits(pso);
+ SURFACE_UnlockBitmapBits(pSurf);
}
@@ -41,10 +43,11 @@
ULONG ulResult = SPS_DECLINE;
PFN_DrvSetPointerShape pfnSetPointerShape;
PPDEVOBJ ppdev = &PrimarySurface;
+ SURFACE *pSurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
pfnSetPointerShape = GDIDEVFUNCS(pso).SetPointerShape;
- SURFACE_LockBitmapBits(pso);
+ SURFACE_LockBitmapBits(pSurf);
if (pfnSetPointerShape)
{
ulResult = pfnSetPointerShape(pso,
@@ -82,7 +85,7 @@
ppdev->pfnMovePointer = EngMovePointer;
}
- SURFACE_UnlockBitmapBits(pso);
+ SURFACE_UnlockBitmapBits(pSurf);
return ulResult;
}
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c [iso-8859-1] Wed Aug 12
20:02:42 2009
@@ -51,7 +51,7 @@
{0, 0, 0, NULL}, /* 02 reserved entry
*/
{0, 0, 0, NULL}, /* 03 reserved entry
*/
{0, 0, 0, NULL}, /* 04 reserved entry
*/
- {0, sizeof(SURFACE), TAG_SURFOBJ, GDI_CleanupDummy}, /* 05 SURFACE */
+ {0, sizeof(SURFACE), TAG_SURFOBJ, SURFACE_Cleanup}, /* 05 SURFACE */
{0, 0, 0, NULL}, /* 06 reserved entry
*/
{0, 0, 0, NULL}, /* 07 reserved entry
*/
{0, sizeof(PALETTE), TAG_PALETTE, GDI_CleanupDummy}, /* 08 PAL */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1] Wed Aug 12
20:02:42 2009
@@ -197,6 +197,21 @@
/* Set the format */
pSurfObj->iBitmapFormat = Format;
+ /* Initialize bits lock */
+ pSurface->pBitsLock = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(FAST_MUTEX),
+ TAG_SURFOBJ);
+
+ if (!pSurface->pBitsLock)
+ {
+ /* Cleanup and return */
+ if (!Bits) EngFreeMem(pSurfObj->pvBits);
+ GDIOBJ_FreeObjByHandle(hSurface, GDI_OBJECT_TYPE_BITMAP);
+ return 0;
+ }
+
+ ExInitializeFastMutex(pSurface->pBitsLock);
+
/* Unlock the surface */
SURFACE_Unlock(pSurface);
@@ -209,6 +224,25 @@
{
GDIOBJ_FreeObjByHandle(hBitmap, GDI_OBJECT_TYPE_BITMAP);
}
+
+BOOL APIENTRY
+SURFACE_Cleanup(PVOID ObjectBody)
+{
+ PSURFACE pSurf = (PSURFACE)ObjectBody;
+
+ /* TODO: Free bits memory */
+ //if (pSurf->SurfObj.fl
+
+ /* Delete DIB palette if it exists */
+ if (pSurf->hDIBPalette)
+ GDIOBJ_FreeObjByHandle(pSurf->hDIBPalette, GDI_OBJECT_TYPE_PALETTE);
+
+ /* Free bitslock storage */
+ ExFreePoolWithTag(pSurf->pBitsLock, TAG_SURFOBJ);
+
+ return TRUE;
+}
+
LONG FASTCALL
GreGetBitmapBits(PSURFACE pSurf, ULONG ulBytes, PVOID pBits)
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1] Wed
Aug 12 20:02:42 2009
@@ -10,6 +10,7 @@
FLONG flHooks;
HPALETTE hDIBPalette;
+ PFAST_MUTEX pBitsLock; /* grab this lock before accessing actual bits in the bitmap
*/
} SURFACE, *PSURFACE;
HBITMAP
@@ -31,6 +32,9 @@
INT FASTCALL
BITMAP_GetWidthBytes(INT bmWidth, INT bpp);
+BOOL APIENTRY
+SURFACE_Cleanup(PVOID ObjectBody);
+
#define GDIDEVFUNCS(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))->DriverFunctions
#define SURFACE_Lock(hBMObj) \
@@ -42,7 +46,7 @@
#define SURFACE_ShareUnlock(pBMObj) \
GDIOBJ_ShareUnlockObjByPtr ((PBASEOBJECT)pBMObj)
-#define SURFACE_LockBitmapBits(x)
-#define SURFACE_UnlockBitmapBits(x)
+#define SURFACE_LockBitmapBits(pBMObj)
ExEnterCriticalRegionAndAcquireFastMutexUnsafe((pBMObj)->pBitsLock)
+#define SURFACE_UnlockBitmapBits(pBMObj)
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion((pBMObj)->pBitsLock)
#endif