Author: fireball
Date: Thu Aug 13 19:29:50 2009
New Revision: 42656
URL:
http://svn.reactos.org/svn/reactos?rev=42656&view=rev
Log:
- Implement hatched brushes support.
- Convert brush's pattern bitmap handle to a kernel GDI handle.
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c
branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Thu Aug 13
19:29:50 2009
@@ -260,9 +260,8 @@
break;
case BS_HATCHED:
- DPRINT1("BS_HATCHED\n" );
- //GreCreateHatchedBrush();
- UNIMPLEMENTED;
+ DPRINT("BS_HATCHED\n" );
+ pDC->pFillBrush = GreCreateHatchedBrush(pLogBrush->lbHatch,
pLogBrush->lbColor);
break;
case BS_PATTERN:
@@ -273,6 +272,7 @@
DPRINT1("Trying to select an unknown bitmap %x to the DC %x!\n",
pLogBrush->lbHatch, physDev);
break;
}
+ GDIOBJ_SetOwnership(hBmpKern, NULL);
pDC->pFillBrush = GreCreatePatternBrush(hBmpKern);
break;
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] Thu Aug
13 19:29:50 2009
@@ -11,6 +11,17 @@
#include <win32k.h>
#define NDEBUG
#include <debug.h>
+
+
+static const USHORT HatchBrushes[NB_HATCH_STYLES][8] =
+{
+ {0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00}, /* HS_HORIZONTAL */
+ {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, /* HS_VERTICAL */
+ {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, /* HS_FDIAGONAL */
+ {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, /* HS_BDIAGONAL */
+ {0x08, 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08}, /* HS_CROSS */
+ {0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81} /* HS_DIAGCROSS */
+};
/* PUBLIC FUNCTIONS **********************************************************/
@@ -220,13 +231,50 @@
return pBrush;
}
+PBRUSHGDI
+NTAPI
+GreCreateHatchedBrush(INT iHatchStyle, COLORREF crColor)
+{
+ PBRUSHGDI pBrush;
+ SIZEL szPatSize;
+ PSURFACE pPattern;
+
+ /* Make sure hatch style is in range */
+ if (iHatchStyle < 0 || iHatchStyle >= NB_HATCH_STYLES)
+ return NULL;
+
+ /* Allocate memory for the object */
+ pBrush = EngAllocMem(FL_ZERO_MEMORY, sizeof(BRUSHGDI), TAG_BRUSHOBJ);
+ if (!pBrush) return NULL;
+
+ /* Set HATCH flag */
+ pBrush->flAttrs |= GDIBRUSH_IS_HATCH;
+
+ /* Create and set pattern bitmap */
+ szPatSize.cx = 8; szPatSize.cy = 8;
+ pBrush->hbmPattern = GreCreateBitmap(szPatSize, 0, BMF_1BPP, BMF_NOZEROINIT,
NULL);
+ GDIOBJ_SetOwnership(pBrush->hbmPattern, NULL);
+ pPattern = SURFACE_Lock(pBrush->hbmPattern);
+ GreSetBitmapBits(pPattern, 8, (PVOID)HatchBrushes[iHatchStyle]);
+ SURFACE_Unlock(pPattern);
+
+ /* Set color to the reserved value */
+ pBrush->BrushObj.iSolidColor = crColor & 0xFFFFFF;
+
+ /* Return newly created brush */
+ return pBrush;
+}
+
VOID
NTAPI
GreFreeBrush(PBRUSHGDI pBrush)
{
/* Free the pattern bitmap if any */
if (pBrush->hbmPattern)
+ {
+ GDIOBJ_SetOwnership(pBrush->hbmPattern, PsGetCurrentProcess());
GreDeleteBitmap(pBrush->hbmPattern);
+ }
/* Free the memory */
EngFreeMem(pBrush);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h [iso-8859-1] Thu
Aug 13 19:29:50 2009
@@ -20,6 +20,9 @@
#define GDIBRUSH_IS_INSIDEFRAME 0x00010000
#define GDIBRUSH_CACHED_ENGINE 0x00040000
#define GDIBRUSH_CACHED_IS_SOLID 0x80000000
+
+/* Total amount of hatch brush styles */
+#define NB_HATCH_STYLES 6
/* BRUSHGDI is a handleless GDI object */
typedef struct _BRUSHGDI
@@ -50,6 +53,9 @@
IN BOOL bOldStylePen);
PBRUSHGDI NTAPI
+GreCreateHatchedBrush(INT iHatchStyle, COLORREF crColor);
+
+PBRUSHGDI NTAPI
GreCreateSolidBrush(COLORREF crColor);
PBRUSHGDI NTAPI