Author: fireball
Date: Wed Aug 12 22:27:16 2009
New Revision: 42639
URL:
http://svn.reactos.org/svn/reactos?rev=42639&view=rev
Log:
- Fix an epic typo in GreCreateBitmap which inverted bottomdown bitmaps and kept topdown
as they were. As a result a hack in EngCreateBitmap goes away.
- Add a internal surface flags field to SURFACE structure, and add the one and only flag
for now - SRF_BITSALLOCD, which means that the bitmap's bits are allocated by GRE.
- Free up GRE allocated bitmap's bits in the cleanup routine. Leaks--;
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.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/eng/engsurf.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.c [iso-8859-1] Wed Aug 12
22:27:16 2009
@@ -23,9 +23,6 @@
IN PVOID Bits)
{
HBITMAP hNewBitmap;
-
- /* HACK: Why?! */
- Flags ^= BMF_TOPDOWN;
/* Call the internal routine */
hNewBitmap = GreCreateBitmap(Size, Width, Format, Flags, Bits);
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
22:27:16 2009
@@ -171,14 +171,17 @@
{
/* Allocate memory for bitmap bits */
pSurfObj->pvBits = EngAllocMem(0 != (Flags & BMF_NOZEROINIT) ? 0 :
FL_ZERO_MEMORY,
- pSurfObj->cjBits, TAG_DIB);
-
+ pSurfObj->cjBits,
+ TAG_DIB);
if (!pSurfObj->pvBits)
{
/* Cleanup and exit */
GDIOBJ_FreeObjByHandle(hSurface, GDI_OBJECT_TYPE_BITMAP);
return 0;
}
+
+ /* Indicate we allocated memory ourselves */
+ pSurface->ulFlags |= SRF_BITSALLOCD;
}
else
{
@@ -187,8 +190,8 @@
pSurfObj->pvScan0 = pSurfObj->pvBits;
- /* Override the 0th scanline if it's topdown */
- if (Flags & BMF_TOPDOWN)
+ /* Override the 0th scanline if it's not topdown */
+ if (!(Flags & BMF_TOPDOWN))
{
pSurfObj->pvScan0 = (PVOID)((ULONG_PTR)pSurfObj->pvBits +
pSurfObj->cjBits - pSurfObj->lDelta);
pSurfObj->lDelta = -pSurfObj->lDelta;
@@ -205,7 +208,8 @@
if (!pSurface->pBitsLock)
{
/* Cleanup and return */
- if (!Bits) EngFreeMem(pSurfObj->pvBits);
+ if (!Bits && (pSurface->ulFlags & SRF_BITSALLOCD))
+ EngFreeMem(pSurfObj->pvBits);
GDIOBJ_FreeObjByHandle(hSurface, GDI_OBJECT_TYPE_BITMAP);
return 0;
}
@@ -230,8 +234,9 @@
{
PSURFACE pSurf = (PSURFACE)ObjectBody;
- /* TODO: Free bits memory */
- //if (pSurf->SurfObj.fl
+ /* Free bits memory */
+ if (pSurf->SurfObj.pvBits && (pSurf->ulFlags & SRF_BITSALLOCD))
+ EngFreeMem(pSurf->SurfObj.pvBits);
/* Delete DIB palette if it exists */
if (pSurf->hDIBPalette)
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 22:27:16 2009
@@ -1,6 +1,7 @@
#ifndef __WIN32K_BITMAP_H
#define __WIN32K_BITMAP_H
+#define SRF_BITSALLOCD 0x01 /* GRE allocated memory for bits itself */
typedef struct _SURFACE
{
@@ -11,6 +12,7 @@
HPALETTE hDIBPalette;
PFAST_MUTEX pBitsLock; /* grab this lock before accessing actual bits in the bitmap
*/
+ ULONG ulFlags; /* implementation specific flags */
} SURFACE, *PSURFACE;
HBITMAP