Author: fireball
Date: Wed Aug 5 14:35:19 2009
New Revision: 42405
URL:
http://svn.reactos.org/svn/reactos?rev=42405&view=rev
Log:
- Remove unused code from GreCreateBitmap.
- If GreCreateBitmap is called with 0 bytewidth, calculate it automatically.
- Fix GreCreatePen pattern brush creation, and free up pattern bitmap in GreFreeBrush.
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c [iso-8859-1] Wed Aug
5 14:35:19 2009
@@ -70,8 +70,9 @@
pBrush->flAttrs = bOldStylePen? GDIBRUSH_IS_OLDSTYLEPEN : GDIBRUSH_IS_PEN;
- /* Initialize default pattern bitmap size */
- szPatSize.cx = 1; szPatSize.cy = 1;
+ /* Initialize default pattern bitmap size (24x1) */
+ szPatSize.cx = 24;
+ szPatSize.cy = 1;
// If dwPenStyle is PS_COSMETIC, the width must be set to 1.
if ( !(bOldStylePen) && ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC)
&& ( dwWidth != 1) )
@@ -99,7 +100,7 @@
case PS_ALTERNATE:
pBrush->flAttrs |= GDIBRUSH_IS_BITMAP;
- pBrush->hbmPattern = GreCreateBitmap(szPatSize, 1, BMF_24BPP, BMF_NOZEROINIT,
NULL);
+ pBrush->hbmPattern = GreCreateBitmap(szPatSize, 0, BMF_1BPP, BMF_NOZEROINIT,
NULL);
pPattern = SURFACE_Lock(pBrush->hbmPattern);
GreSetBitmapBits(pPattern, sizeof(PatternDashDotDot), (PVOID)PatternAlternate);
SURFACE_Unlock(pPattern);
@@ -107,7 +108,7 @@
case PS_DOT:
pBrush->flAttrs |= GDIBRUSH_IS_BITMAP;
- pBrush->hbmPattern = GreCreateBitmap(szPatSize, 1, BMF_24BPP, BMF_NOZEROINIT,
NULL);
+ pBrush->hbmPattern = GreCreateBitmap(szPatSize, 0, BMF_1BPP, BMF_NOZEROINIT,
NULL);
pPattern = SURFACE_Lock(pBrush->hbmPattern);
GreSetBitmapBits(pPattern, sizeof(PatternDashDotDot), (PVOID)PatternDot);
SURFACE_Unlock(pPattern);
@@ -115,7 +116,7 @@
case PS_DASH:
pBrush->flAttrs |= GDIBRUSH_IS_BITMAP;
- pBrush->hbmPattern = GreCreateBitmap(szPatSize, 1, BMF_24BPP, BMF_NOZEROINIT,
NULL);
+ pBrush->hbmPattern = GreCreateBitmap(szPatSize, 0, BMF_1BPP, BMF_NOZEROINIT,
NULL);
pPattern = SURFACE_Lock(pBrush->hbmPattern);
GreSetBitmapBits(pPattern, sizeof(PatternDashDotDot), (PVOID)PatternDash);
SURFACE_Unlock(pPattern);
@@ -123,7 +124,7 @@
case PS_DASHDOT:
pBrush->flAttrs |= GDIBRUSH_IS_BITMAP;
- pBrush->hbmPattern = GreCreateBitmap(szPatSize, 1, BMF_24BPP, BMF_NOZEROINIT,
NULL);
+ pBrush->hbmPattern = GreCreateBitmap(szPatSize, 0, BMF_1BPP, BMF_NOZEROINIT,
NULL);
pPattern = SURFACE_Lock(pBrush->hbmPattern);
GreSetBitmapBits(pPattern, sizeof(PatternDashDotDot), (PVOID)PatternDashDot);
SURFACE_Unlock(pPattern);
@@ -131,7 +132,7 @@
case PS_DASHDOTDOT:
pBrush->flAttrs |= GDIBRUSH_IS_BITMAP;
- pBrush->hbmPattern = GreCreateBitmap(szPatSize, 1, BMF_24BPP, BMF_NOZEROINIT,
NULL);
+ pBrush->hbmPattern = GreCreateBitmap(szPatSize, 0, BMF_1BPP, BMF_NOZEROINIT,
NULL);
pPattern = SURFACE_Lock(pBrush->hbmPattern);
GreSetBitmapBits(pPattern, sizeof(PatternDashDotDot), (PVOID)PatternDashDotDot);
SURFACE_Unlock(pPattern);
@@ -223,7 +224,11 @@
NTAPI
GreFreeBrush(PBRUSHGDI pBrush)
{
- /* Just free the memory */
+ /* Free the pattern bitmap if any */
+ if (pBrush->hbmPattern)
+ GreDeleteBitmap(pBrush->hbmPattern);
+
+ /* Free the memory */
EngFreeMem(pBrush);
}
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 5
14:35:19 2009
@@ -160,20 +160,13 @@
pSurfObj->iType = STYPE_BITMAP;
pSurfObj->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
+ /* Calculate byte width automatically if it was not provided */
+ if (Width == 0)
+ Width = BITMAP_GetWidthBytes(Size.cx, BitsPerFormat(Format));
+
pSurfObj->lDelta = abs(Width);
pSurfObj->cjBits = pSurfObj->lDelta * Size.cy;
-#if 0
- if (!Bits)
- {
- DPRINT1("Bitmaps without Bits aren't supported yet!\n");
-
- /* Cleanup and exit */
- free_gdi_handle(hSurface);
- ExFreePool(pSurface);
- return 0;
- }
-#endif
if (!Bits)
{
/* Allocate memory for bitmap bits */