Commit in reactos on MAIN
include/win32k/brush.h+126-801.12 -> 1.13
              /pen.h+25-281.8 -> 1.9
lib/user32/windows/defwnd.c+1-31.128 -> 1.129
subsys/win32k/dib/dib16bpp.c+123-571.21 -> 1.22
                 /dib1bpp.c+172-631.16 -> 1.17
                 /dib24bpp.c+96-361.17 -> 1.18
                 /dib32bpp.c+96-331.17 -> 1.18
                 /dib4bpp.c+135-701.23 -> 1.24
                 /dib8bpp.c+121-631.16 -> 1.17
subsys/win32k/eng/bitblt.c+74-341.43 -> 1.44
subsys/win32k/include/object.h-81.21 -> 1.22
subsys/win32k/objects/bitmaps.c+5-51.66 -> 1.67
                     /brush.c+286-3091.32 -> 1.33
                     /dc.c+28-51.125 -> 1.126
                     /fillshap.c+60-371.45 -> 1.46
                     /gdiobj.c+3-31.64 -> 1.65
                     /line.c+33-211.27 -> 1.28
                     /objconv.c+3-311.15 -> 1.16
                     /path.c+2-11.18 -> 1.19
                     /pen.c+93-591.13 -> 1.14
                     /region.c+3-31.46 -> 1.47
                     /text.c+10-61.87 -> 1.88
+1495-955
22 modified files
- Changed the internal brush object to be (almost) Win32k compatible.
- Changed Pen implementation to use brushes internally.
- Added support for pattern brushes.
- Fixed 8bpp StretchBlt.
- Fixed 4bpp to 4bpp non-SRCCOPY blits.
- Fixed 1bpp to 1bpp non-SRCCOPY blits to work when the destination doesn't
  start at exact byte.
- Reenabled 55AA brush for scrollbar.
- Fixed BITMAPOBJ_GetWidthBits to do WORD alignment and not DWORD.

reactos/include/win32k
brush.h 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- brush.h	20 Aug 2003 07:45:01 -0000	1.12
+++ brush.h	5 Apr 2004 21:26:24 -0000	1.13
@@ -3,90 +3,136 @@
 
 #include <win32k/gdiobj.h>
 
-/*  Internal interface  */
+/* Internal interface */
 
 #define NB_HATCH_STYLES  6
 
-#define  BRUSHOBJ_AllocBrush()  \
-  ((HBRUSH) GDIOBJ_AllocObj (sizeof (BRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, NULL))
-#define  BRUSHOBJ_FreeBrush(hBrush)  GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT)
-#define  BRUSHOBJ_LockBrush(hBrush) ((PBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
+/*
+ * The layout of this structure is taken from "Windows Graphics Programming"
+ * book written by Feng Yuan.
+ *
+ * DON'T MODIFY THIS STRUCTURE UNLESS REALLY NEEDED AND EVEN THEN ASK ON
+ * A MAILING LIST FIRST.
+ */
+
+typedef struct
+{
+   ULONG AttrFlags;
+   COLORREF lbColor;
+} BRUSHATTR, *PBRUSHATTR;
+
+typedef struct
+{
+   ULONG ulStyle;
+   HBITMAP hbmPattern;
+   HANDLE hbmClient;
+   ULONG flAttrs;
+
+   ULONG ulBrushUnique;
+   BRUSHATTR *pBrushAttr;
+   BRUSHATTR BrushAttr;
+   ULONG Unknown30;
+   ULONG bCacheGrabbed;
+   COLORREF crBack;
+   COLORREF crFore;
+   ULONG ulPalTime;
+#if 0
+   ULONG ulSurfTime;
+   PVOID ulRealization;
+   ULONG Unknown4C[3];
+#else
+   BRUSHOBJ BrushObject;
+   ULONG Unknown50[2];
+#endif
+   POINT ptPenWidth;
+   ULONG ulPenStyle;
+   DWORD *pStyle;
+   ULONG dwStyleCount;
+   ULONG Unknown6C;
+} GDIBRUSHOBJ, *PGDIBRUSHOBJ;
+
+/* GDI Brush Attributes */
+
+#define GDIBRUSH_NEED_BK_CLR		0x0002 /* Background color is needed */
+#define GDIBRUSH_DITHER_OK		0x0004 /* Allow color dithering */
+#define GDIBRUSH_IS_SOLID		0x0010 /* Solid brush */
+#define GDIBRUSH_IS_HATCH		0x0020 /* Hatch brush */
+#define GDIBRUSH_IS_BITMAP		0x0040 /* DDB pattern brush */
+#define GDIBRUSH_IS_DIB			0x0080 /* DIB pattern brush */ 
+#define GDIBRUSH_IS_NULL		0x0100 /* Null/hollow brush */
+#define GDIBRUSH_IS_GLOBAL		0x0200 /* Stock objects */
+#define GDIBRUSH_IS_PEN			0x0400 /* Pen */
+#define GDIBRUSH_IS_OLDSTYLEPEN		0x0800 /* Geometric pen */
+#define GDIBRUSH_IS_MASKING		0x8000 /* Pattern bitmap is used as transparent mask (?) */
+#define GDIBRUSH_CACHED_IS_SOLID	0x80000000 
+
+#define  BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, NULL))
+#define  BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT)
+#define  BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
 #define  BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
 
-HBRUSH
-STDCALL
-NtGdiCreateBrushIndirect (
-	CONST LOGBRUSH	* lb
-	);
-HBRUSH
-STDCALL
-NtGdiCreateDIBPatternBrush (
-	HGLOBAL	hDIBPacked,
-	UINT	ColorSpec
-	);
-HBRUSH
-STDCALL
-NtGdiCreateDIBPatternBrushPt (
-	CONST VOID	* PackedDIB,
-	UINT		Usage
-	);
-HBRUSH
-STDCALL
-NtGdiCreateHatchBrush (
-	INT		Style,
-	COLORREF	Color
-	);
-HBRUSH
-STDCALL
-NtGdiCreatePatternBrush (
-	HBITMAP	hBitmap
-	);
-HBRUSH
-STDCALL
-NtGdiCreateSolidBrush (
-	COLORREF	Color
-	);
-BOOL
-STDCALL
-NtGdiFixBrushOrgEx (
-	VOID
-	);
-BOOL
-STDCALL
-NtGdiPatBlt (
-	HDC	hDC,
-	INT	XLeft,
-	INT	YLeft,
-	INT	Width,
-	INT	Height,
-	DWORD	ROP
-	);
-BOOL
-STDCALL
+HBRUSH STDCALL
+NtGdiCreateBrushIndirect(
+   CONST LOGBRUSH *LogBrush);
+
+HBRUSH STDCALL
+NtGdiCreateDIBPatternBrush(
+   HGLOBAL hDIBPacked,
+   UINT ColorSpec);
+
+HBRUSH STDCALL
+NtGdiCreateDIBPatternBrushPt(
+   CONST VOID *PackedDIB,
+   UINT Usage);
+
+HBRUSH STDCALL
+NtGdiCreateHatchBrush(
+   INT Style,
+   COLORREF Color);
+
+HBRUSH STDCALL
+NtGdiCreatePatternBrush(
+   HBITMAP hBitmap);
+
+HBRUSH STDCALL
+NtGdiCreateSolidBrush(
+   COLORREF Color);
+
+BOOL STDCALL
+NtGdiFixBrushOrgEx(
+   VOID);
+
+BOOL STDCALL
+NtGdiPatBlt(
+   HDC hDC,
+   INT XLeft,
+   INT YLeft,
+   INT Width,
+   INT Height,
+   DWORD ROP);
+
+BOOL STDCALL
 NtGdiPolyPatBlt(
-	HDC hDC,
-	DWORD dwRop,
-	PPATRECT pRects,
-	int cRects,
-	ULONG Reserved
-	);
-BOOL
-STDCALL
-NtGdiPatBlt (
-	HDC	hDC,
-	INT	XLeft,
-	INT	YLeft,
-	INT	Width,
-	INT	Height,
-	DWORD	ROP
-	);
-BOOL
-STDCALL
-NtGdiSetBrushOrgEx (
-	HDC	hDC,
-	INT	XOrg,
-	INT	YOrg,
-	LPPOINT	Point
-	);
-#endif
+   HDC hDC,
+   DWORD dwRop,
+   PPATRECT pRects,
+   INT cRects,
+   ULONG Reserved);
+
+BOOL STDCALL
+NtGdiPatBlt(
+   HDC hDC,
+   INT XLeft,
+   INT YLeft,
+   INT Width,
+   INT Height,
+   DWORD ROP);
 
+BOOL STDCALL
+NtGdiSetBrushOrgEx(
+   HDC hDC,
+   INT XOrg,
+   INT YOrg,
+   LPPOINT Point);
+
+#endif

reactos/include/win32k
pen.h 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- pen.h	26 Sep 2003 20:58:06 -0000	1.8
+++ pen.h	5 Apr 2004 21:26:24 -0000	1.9
@@ -1,35 +1,32 @@
-
 #ifndef __WIN32K_PEN_H
 #define __WIN32K_PEN_H
 
 #include <win32k/gdiobj.h>
+#include <win32k/brush.h>
 
-/* GDI logical pen object */
-typedef struct
-{
-   LOGPEN logpen;
-   ULONG  iSolidColor;
-} PENOBJ, *PPENOBJ;
-
-/*  Internal interface  */
-
-#define  PENOBJ_AllocPen()  \
-  ((HPEN) GDIOBJ_AllocObj (sizeof (PENOBJ), GDI_OBJECT_TYPE_PEN, NULL))
-#define  PENOBJ_FreePen(hBMObj)  GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT)
-#define  PENOBJ_LockPen(hBMObj) ((PPENOBJ)GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
-#define  PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
-
-HPEN STDCALL NtGdiCreatePen(INT  PenStyle,
-                    INT  Width,
-                    COLORREF  Color);
-
-HPEN STDCALL NtGdiCreatePenIndirect(CONST PLOGPEN  lgpn);
-
-HPEN STDCALL NtGdiExtCreatePen(DWORD  PenStyle,
-                       DWORD  Width,
-                       CONST PLOGBRUSH  lb,
-                       DWORD  StyleCount,
-                       CONST PDWORD  Style);
+/* Internal interface */
 
-#endif
+#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_PEN, NULL))
+#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT)
+#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
+#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
+
+HPEN STDCALL
+NtGdiCreatePen(
+   INT PenStyle,
+   INT Width,
+   COLORREF Color);
+
+HPEN STDCALL
+NtGdiCreatePenIndirect(
+   CONST PLOGPEN LogBrush);
+
+HPEN STDCALL
+NtGdiExtCreatePen(
+   DWORD PenStyle,
+   DWORD Width,
+   CONST PLOGBRUSH LogBrush,
+   DWORD StyleCount,
+   CONST PDWORD Style);
 
+#endif

reactos/lib/user32/windows
defwnd.c 1.128 -> 1.129
diff -u -r1.128 -r1.129
--- defwnd.c	2 Apr 2004 19:00:56 -0000	1.128
+++ defwnd.c	5 Apr 2004 21:26:24 -0000	1.129
@@ -1,4 +1,4 @@
-/* $Id: defwnd.c,v 1.128 2004/04/02 19:00:56 weiden Exp $
+/* $Id: defwnd.c,v 1.129 2004/04/05 21:26:24 navaraf Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -902,7 +902,6 @@
 HBRUSH
 DefWndControlColor(HDC hDC, UINT ctlType)
 {
-#if 0 /* FIXME: Re-enable when pattern brushes are implemented */
   if (CTLCOLOR_SCROLLBAR == ctlType)
     {
       HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
@@ -933,7 +932,6 @@
       UnrealizeObject(hb);
       return hb;
     }
-#endif
 
   SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
 

reactos/subsys/win32k/dib
dib16bpp.c 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- dib16bpp.c	28 Mar 2004 23:25:48 -0000	1.21
+++ dib16bpp.c	5 Apr 2004 21:26:24 -0000	1.22
@@ -16,15 +16,17 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib16bpp.c,v 1.21 2004/03/28 23:25:48 navaraf Exp $ */
+/* $Id: dib16bpp.c,v 1.22 2004/04/05 21:26:24 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
 #include <math.h>
-#include <win32k/bitmaps.h>
-#include <win32k/debug.h>
 #include <debug.h>
 #include <ddk/winddi.h>
+#include <win32k/bitmaps.h>
+#include <win32k/brush.h>
+#include <win32k/debug.h>
+#include <include/object.h>
 #include "../eng/objects.h"
 #include "dib.h"
 
@@ -279,64 +281,128 @@
 		 PBRUSHOBJ Brush, PPOINTL BrushOrigin,
 		 XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
-  LONG     i, j, sx, sy;
-  ULONG    Dest, Source, Pattern;
-  PULONG   DestBits;
-  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
-  LONG     RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1);
+   ULONG X, Y;
+   ULONG SourceX, SourceY;
+   ULONG Dest, Source, Pattern = 0;
+   PULONG DestBits;
+   BOOL UsesSource;
+   BOOL UsesPattern;
+   LONG RoundedRight;
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
+
+   if (Rop4 == SRCCOPY)
+   {
+      return DIB_16BPP_BitBltSrcCopy(
+         DestSurf,
+         SourceSurf,
+         DestGDI,
+         SourceGDI,
+         DestRect,
+         SourcePoint,
+         ColorTranslation);
+   }
 
-  if (Rop4 == SRCCOPY)
-    {
-      return(DIB_16BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
-    }
-  else
-    {
-      sy = SourcePoint->y;
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+      
+   if (UsesPattern)
+   {
+      if (Brush == NULL)
+      {
+         UsesPattern = FALSE;
+      } else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+      {
+         PBITMAPOBJ PatternBitmap;
 
-      for (j=DestRect->top; j<DestRect->bottom; j++)
+         GdiBrush = CONTAINING_RECORD(
+            Brush,
+            GDIBRUSHOBJ,
+            BrushObject);
+
+         PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+         PatternSurface = BitmapToSurf(PatternBitmap, NULL);
+         BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+         PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+         PatternWidth = PatternObj->sizlBitmap.cx;
+         PatternHeight = PatternObj->sizlBitmap.cy;
+      }
+   }
+
+   RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1);
+   SourceY = SourcePoint->y;
+   DestBits = (PULONG)(
+      DestSurf->pvScan0 +
+      (DestRect->left << 1) +
+      DestRect->top * DestSurf->lDelta);
+
+   for (Y = DestRect->top; Y < DestRect->bottom; Y++)
+   {
+      SourceX = SourcePoint->x;
+      for (X = DestRect->left; X < RoundedRight; X += 2, DestBits++, SourceX += 2)
       {
-        sx = SourcePoint->x;
-	DestBits = (PULONG)(DestSurf->pvScan0 + 2 * DestRect->left + j * DestSurf->lDelta);
-        for (i=DestRect->left; i<RoundedRight; i+=2, DestBits++)
-	  {
-	    Dest = *DestBits;
-	    if (UsesSource)
-	      {
-		Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
-		Source |= DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + 1, sy, ColorTranslation) << 16;
-	      }
-	    if (UsesPattern)
-	      {
-		/* FIXME: No support for pattern brushes. */
-		Pattern = (Brush->iSolidColor & 0xFFFF) |
-                          ((Brush->iSolidColor & 0xFFFF) << 16);
-	      }
-	    *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
-	  }
-	if (i < DestRect->right)
-	  {
-	    Dest = *DestBits;
-	    for (; i < DestRect->right; i++)
-	      {
-		if (UsesSource)
-		  {
-		    Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
-		  }
-		if (UsesPattern)
-		  {
-		    /* FIXME: No support for pattern brushes. */
-		    Pattern = (Brush->iSolidColor & 0xFFFF) |
-                              ((Brush->iSolidColor & 0xFFFF) << 16);
-		  }				
-		DIB_16BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF);
-		Dest >>= 16;
-	      }	 
-	  }
-        sy++;
+         Dest = *DestBits;
+ 
+         if (UsesSource)
+         {
+            Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
+            Source |= DIB_GetSource(SourceSurf, SourceGDI, SourceX + 1, SourceY, ColorTranslation) << 16;
+         }
+
+         if (UsesPattern)
+	 {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+            {
+               Pattern = (DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack);
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + 1) % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 16;
+            }
+            else
+            {
+               Pattern = (Brush->iSolidColor & 0xFFFF) |
+                        ((Brush->iSolidColor & 0xFFFF) << 16);
+            }
+         }
+
+         *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
       }
-    }
-  return TRUE;
+
+      if (X < DestRect->right)
+      {
+         Dest = *((PUSHORT)DestBits);
+
+         if (UsesSource)
+         {
+            Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
+         }
+
+         if (UsesPattern)
+         {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+            else
+               Pattern = Brush->iSolidColor & 0xFFFF;
+         }				
+
+         DIB_16BPP_PutPixel(DestSurf, X, Y, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF);
+         DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+      }
+
+      SourceY++;
+      DestBits = (PULONG)(
+         (ULONG_PTR)DestBits -
+         ((DestRect->right - DestRect->left) << 1) +
+         DestSurf->lDelta);
+   }
+
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+  
+   return TRUE;
 }
 
 

reactos/subsys/win32k/dib
dib1bpp.c 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- dib1bpp.c	28 Mar 2004 23:24:57 -0000	1.16
+++ dib1bpp.c	5 Apr 2004 21:26:24 -0000	1.17
@@ -16,13 +16,15 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib1bpp.c,v 1.16 2004/03/28 23:24:57 navaraf Exp $ */
+/* $Id: dib1bpp.c,v 1.17 2004/04/05 21:26:24 navaraf Exp $ */
 
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
 #include <win32k/bitmaps.h>
+#include <win32k/brush.h>
 #include <win32k/debug.h>
+#include <include/object.h>
 #include <debug.h>
 #include <ddk/winddi.h>
 #include "../eng/objects.h"
@@ -351,68 +353,175 @@
 	PBRUSHOBJ Brush, PPOINTL BrushOrigin,
 	XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
-	LONG     i, j, k, sx, sy;
-	ULONG    Dest, Source, Pattern;
-	PULONG   DestBits;
-	BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-	BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
-	LONG    RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7);
-
-	if (Rop4 == SRCCOPY)
-	{
-		return(DIB_1BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
-	}
-	else
-	{
-		sy = SourcePoint->y;
-
-		for (j=DestRect->top; j<DestRect->bottom; j++)
-		{
-			sx = SourcePoint->x;
-			DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left>>3) + j * DestSurf->lDelta);
-			for (i=DestRect->left; i<RoundedRight; i+=32, DestBits++)
-			{
-				Dest = *DestBits;
-				if (UsesSource)
-				{
-					Source = 0;
-					for (k = 0; k < 8; k++)
-					{
-						Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (7 - k));
-						Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 8, sy, ColorTranslation) << (8 + (7 - k)));
-						Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 16, sy, ColorTranslation) << (16 + (7 - k)));
-						Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 24, sy, ColorTranslation) << (24 + (7 - k)));
-					}
-				}
-				if (UsesPattern)
-				{
-					/* FIXME: No support for pattern brushes. */
-					Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
-				}
-				*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
-			}
-			if (i < DestRect->right)
-			{
-				Dest = *DestBits;
-				for (; i < DestRect->right; i++)
-				{
-					if (UsesSource)
-					{
-						Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
-					}
-					if (UsesPattern)
-					{
-						/* FIXME: No support for pattern brushes. */
-						Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
-					}
-					DIB_1BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
-					Dest >>= 1;
-				}
-			}
-			sy++;
-		}
-	}
-	return TRUE;
+   ULONG X, Y, SourceX, SourceY, k;
+   ULONG Dest, Source, Pattern;
+   PULONG DestBits;
+   BOOL UsesSource;
+   BOOL UsesPattern;
+   LONG RoundedRight;
+   BYTE NoBits;
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
+
+   if (Rop4 == SRCCOPY)
+   {
+      return DIB_1BPP_BitBltSrcCopy(
+         DestSurf,
+         SourceSurf,
+         DestGDI,
+         SourceGDI,
+         DestRect,
+         SourcePoint,
+         ColorTranslation);
+   }
+
+   if (UsesPattern)
+   {
+      if (Brush == NULL)
+      {
+         UsesPattern = FALSE;
+      } else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+      {
+         PBITMAPOBJ PatternBitmap;
+
+         GdiBrush = CONTAINING_RECORD(
+            Brush,
+            GDIBRUSHOBJ,
+            BrushObject);
+
+         PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+         PatternSurface = BitmapToSurf(PatternBitmap, NULL);
+         BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+         PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+         PatternWidth = PatternObj->sizlBitmap.cx;
+         PatternHeight = PatternObj->sizlBitmap.cy;
+      }
+   }
+
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+   RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7);
+   SourceY = SourcePoint->y;
+
+   for (Y = DestRect->top; Y < DestRect->bottom; Y++)
+   {
+      SourceX = SourcePoint->x;
+      DestBits = (PULONG)(
+         DestSurf->pvScan0 +
+         (DestRect->left >> 3) +
+         Y * DestSurf->lDelta);
+
+      X = DestRect->left;
+      if (X & 7)
+      {
+         Dest = *((PBYTE)DestBits);
+         NoBits = 7 - (X & 7);
+
+         if (UsesSource)
+         {
+            Source = 0;
+            for (k = 7 - NoBits; k < NoBits; k++)
+               Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k, SourceY, ColorTranslation) << (7 - k));
+         }
+
+         if (UsesPattern)
+         {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+            {
+               Pattern = 0;
+               for (k = 7 - NoBits; k < NoBits; k++)
+                  Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k) % PatternWidth, Y % PatternHeight) << (7 - k));
+            }
+            else
+            {
+               Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
+            }
+         }
+
+         Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
+         Dest &= ~((1 << (7 - NoBits)) - 1);
+         Dest |= *((PBYTE)DestBits) & ((1 << (7 - NoBits)) - 1);
+         
+         X += NoBits;
+         SourceX += NoBits;
+      }
+
+      for (; X < RoundedRight; X += 32, DestBits++, SourceX++)
+      {
+         Dest = *DestBits;
+
+         if (UsesSource)
+         {
+            Source = 0;
+            for (k = 0; k < 8; k++)
+            {
+               Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k, SourceY, ColorTranslation) << (7 - k));
+               Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k + 8, SourceY, ColorTranslation) << (8 + (7 - k)));
+               Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k + 16, SourceY, ColorTranslation) << (16 + (7 - k)));
+               Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k + 24, SourceY, ColorTranslation) << (24 + (7 - k)));
+            }
+         }
+
+         if (UsesPattern)
+         {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+            {
+               Pattern = 0;
+               for (k = 0; k < 8; k++)
+               {
+                  Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k) % PatternWidth, Y % PatternHeight) << (7 - k));
+                  Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k + 8) % PatternWidth, Y % PatternHeight) << (8 + (7 - k)));
+                  Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k + 16) % PatternWidth, Y % PatternHeight) << (16 + (7 - k)));
+                  Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k + 24) % PatternWidth, Y % PatternHeight) << (24 + (7 - k)));
+               }
+            }
+            else
+            {
+               Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
+            }
+         }
+
+         *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
+      }
+
+      if (X < DestRect->right)
+      {
+//         Dest = *DestBits;
+         for (; X < DestRect->right; X++, SourceX++)
+         {
+//            Dest = *DestBits;
+            Dest = DIB_1BPP_GetPixel(DestSurf, X, Y);
+
+            if (UsesSource)
+            {
+               Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
+            }
+
+            if (UsesPattern)
+            {
+               if (Brush->iSolidColor == 0xFFFFFFFF)
+                  Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight);
+               else
+                  Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
+            }
+
+            DIB_1BPP_PutPixel(DestSurf, X, Y, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
+//            Dest >>= 1;
+         }
+      }
+
+      SourceY++;
+   }
+
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+  
+   return TRUE;
 }
 
 BOOLEAN

reactos/subsys/win32k/dib
dib24bpp.c 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- dib24bpp.c	28 Mar 2004 23:25:48 -0000	1.17
+++ dib24bpp.c	5 Apr 2004 21:26:24 -0000	1.18
@@ -16,13 +16,15 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib24bpp.c,v 1.17 2004/03/28 23:25:48 navaraf Exp $ */
+/* $Id: dib24bpp.c,v 1.18 2004/04/05 21:26:24 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
 #include <win32k/bitmaps.h>
+#include <win32k/brush.h>
 #include <win32k/debug.h>
 #include <debug.h>
+#include <include/object.h>
 #include <ddk/winddi.h>
 #include "../eng/objects.h"
 #include "dib.h"
@@ -251,44 +253,102 @@
 		 PBRUSHOBJ Brush, PPOINTL BrushOrigin,
 		 XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
-  LONG     i, j, sx, sy;
-  ULONG    Dest, Source, Pattern;
-  PBYTE    DestBits;
-  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
-
-  if (Rop4 == SRCCOPY)
-    {
-      return(DIB_24BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
-    }
-  else
-    {
-      sy = SourcePoint->y;
+   ULONG X, Y;
+   ULONG SourceX, SourceY;
+   ULONG Dest, Source, Pattern;
+   PBYTE DestBits;
+   BOOL UsesSource;
+   BOOL UsesPattern;
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
+
+   if (Rop4 == SRCCOPY)
+   {
+      return DIB_24BPP_BitBltSrcCopy(
+         DestSurf,
+         SourceSurf,
+         DestGDI,
+         SourceGDI,
+         DestRect,
+         SourcePoint,
+         ColorTranslation);
+   }
+
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+      
+   if (UsesPattern)
+   {
+      if (Brush == NULL)
+      {
+         UsesPattern = FALSE;
+      } else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+      {
+         PBITMAPOBJ PatternBitmap;
 
-      for (j = DestRect->top; j < DestRect->bottom; j++)
+         GdiBrush = CONTAINING_RECORD(
+            Brush,
+            GDIBRUSHOBJ,
+            BrushObject);
+
+         PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+         PatternSurface = BitmapToSurf(PatternBitmap, NULL);
+         BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+         PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+         PatternWidth = PatternObj->sizlBitmap.cx;
+         PatternHeight = PatternObj->sizlBitmap.cy;
+      }
+   }
+
+   SourceY = SourcePoint->y;
+   DestBits = (PBYTE)(
+      DestSurf->pvScan0 +
+      (DestRect->left << 1) + DestRect->left +
+      DestRect->top * DestSurf->lDelta);
+
+   for (Y = DestRect->top; Y < DestRect->bottom; Y++)
+   {
+      SourceX = SourcePoint->x;
+      for (X = DestRect->left; X < DestRect->right; X++, DestBits += 3, SourceX++)
       {
-        sx = SourcePoint->x;
-	DestBits = (PBYTE)(DestSurf->pvScan0 + 3 * DestRect->left + j * DestSurf->lDelta);
-        for (i=DestRect->left; i<DestRect->right; i++, DestBits+=3)
-	  {
-	    Dest = *(PUSHORT)(DestBits) + (*(DestBits + 2) << 16);
-	    if (UsesSource)
-	      {
-		Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation) & 0x00ffffff;
-	      }
-	    if (UsesPattern)
-	      {
-		/* FIXME: No support for pattern brushes. */
-		Pattern = Brush->iSolidColor;
-	      }
-	    Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
-            *(PUSHORT)(DestBits) = Dest & 0xFFFF;
-            *(DestBits + 2) = Dest >> 16;
-	  }
-        sy++;
+         Dest = *((PUSHORT)DestBits) + (*(DestBits + 2) << 16);
+ 
+         if (UsesSource)
+         {
+            Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
+         }
+
+         if (UsesPattern)
+	 {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+            {
+               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+            }
+            else
+            {
+               Pattern = Brush->iSolidColor;
+            }
+         }
+
+         Dest = DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFFFF;
+         *(PUSHORT)(DestBits) = Dest & 0xFFFF;
+         *(DestBits + 2) = Dest >> 16;
       }
-    }
-  return TRUE;
+
+      SourceY++;
+      DestBits -= (DestRect->right - DestRect->left) * 3;
+      DestBits += DestSurf->lDelta;
+   }
+
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+  
+   return TRUE;
 }
 
 BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,

reactos/subsys/win32k/dib
dib32bpp.c 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- dib32bpp.c	4 Apr 2004 16:40:05 -0000	1.17
+++ dib32bpp.c	5 Apr 2004 21:26:24 -0000	1.18
@@ -16,14 +16,16 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib32bpp.c,v 1.17 2004/04/04 16:40:05 gvg Exp $ */
+/* $Id: dib32bpp.c,v 1.18 2004/04/05 21:26:24 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
 #include <win32k/bitmaps.h>
+#include <win32k/brush.h>
 #include <win32k/debug.h>
 #include <debug.h>
 #include <ddk/winddi.h>
+#include <include/object.h>
 #include "../eng/objects.h"
 #include "dib.h"
 
@@ -300,42 +302,103 @@
 		 PBRUSHOBJ Brush, PPOINTL BrushOrigin,
 		 XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
-  LONG     i, j, sx, sy;
-  ULONG    Dest, Source, Pattern;
-  PULONG   DestBits;
-  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+   ULONG X, Y;
+   ULONG SourceX, SourceY;
+   ULONG Dest, Source, Pattern;
+   PULONG DestBits;
+   BOOL UsesSource;
+   BOOL UsesPattern;
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
+
+   if (Rop4 == SRCCOPY)
+   {
+      return DIB_32BPP_BitBltSrcCopy(
+         DestSurf,
+         SourceSurf,
+         DestGDI,
+         SourceGDI,
+         DestRect,
+         SourcePoint,
+         ColorTranslation);
+   }
 
-  if (Rop4 == SRCCOPY)
-    {
-      return(DIB_32BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
-    }
-  else
-    {
-      sy = SourcePoint->y;
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+      
+   if (UsesPattern)
+   {
+      if (Brush == NULL)
+      {
+         UsesPattern = FALSE;
+      } else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+      {
+         PBITMAPOBJ PatternBitmap;
 
-      for (j=DestRect->top; j<DestRect->bottom; j++)
+         GdiBrush = CONTAINING_RECORD(
+            Brush,
+            GDIBRUSHOBJ,
+            BrushObject);
+
+         PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+         PatternSurface = BitmapToSurf(PatternBitmap, NULL);
+         BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+         PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+         PatternWidth = PatternObj->sizlBitmap.cx;
+         PatternHeight = PatternObj->sizlBitmap.cy;
+      }
+   }
+
+   SourceY = SourcePoint->y;
+   DestBits = (PULONG)(
+      DestSurf->pvScan0 +
+      (DestRect->left << 2) +
+      DestRect->top * DestSurf->lDelta);
+
+   for (Y = DestRect->top; Y < DestRect->bottom; Y++)
+   {
+      SourceX = SourcePoint->x;
+
+      for (X = DestRect->left; X < DestRect->right; X++, DestBits++, SourceX++)
       {
-        sx = SourcePoint->x;
-	DestBits = (PULONG)(DestSurf->pvScan0 + 4 * DestRect->left + j * DestSurf->lDelta);
-        for (i=DestRect->left; i<DestRect->right; i++, DestBits++)
-	  {
-	    Dest = *DestBits;
-	    if (UsesSource)
-	      {
-		Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
-	      }
-	    if (UsesPattern)
-	      {
-		/* FIXME: No support for pattern brushes. */
-		Pattern = Brush->iSolidColor;
-	      }
-	    *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
-	  }
-        sy++;
+         Dest = *DestBits;
+ 
+         if (UsesSource)
+         {
+            Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
+         }
+
+         if (UsesPattern)
+	 {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+            {
+               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+            }
+            else
+            {
+               Pattern = Brush->iSolidColor;
+            }
+         }
+
+         *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
       }
-    }
-  return TRUE;
+
+      SourceY++;
+      DestBits = (PULONG)(
+         (ULONG_PTR)DestBits -
+         ((DestRect->right - DestRect->left) << 2) +
+         DestSurf->lDelta);
+   }
+
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+  
+   return TRUE;
 }
 
 /*

reactos/subsys/win32k/dib
dib4bpp.c 1.23 -> 1.24
diff -u -r1.23 -r1.24
--- dib4bpp.c	8 Feb 2004 09:27:39 -0000	1.23
+++ dib4bpp.c	5 Apr 2004 21:26:24 -0000	1.24
@@ -16,13 +16,15 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib4bpp.c,v 1.23 2004/02/08 09:27:39 navaraf Exp $ */
+/* $Id: dib4bpp.c,v 1.24 2004/04/05 21:26:24 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
 #include <win32k/bitmaps.h>
+#include <win32k/brush.h>
 #include <win32k/debug.h>
 #include <debug.h>
+#include <include/object.h>
 #include <ddk/winddi.h>
 #include "../eng/objects.h"
 #include "dib.h"
@@ -30,18 +32,15 @@
 VOID
 DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
 {
-  PBYTE addr = SurfObj->pvScan0;
-
-  addr += (x>>1) + y * SurfObj->lDelta;
-  *addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
+   PBYTE addr = SurfObj->pvScan0 + (x>>1) + y * SurfObj->lDelta;
+   *addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
 }
 
 ULONG
 DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
 {
-  PBYTE addr = SurfObj->pvScan0;
-
-  return (addr[(x>>1) + y * SurfObj->lDelta] >> ((1-(x&1))<<2) ) & 0x0f;
+   PBYTE addr = SurfObj->pvScan0 + (x>>1) + y * SurfObj->lDelta;
+   return (*addr >> ((1-(x&1))<<2)) & 0x0f;
 }
 
 VOID
@@ -141,8 +140,8 @@
 
         for (i=DestRect->left; i<DestRect->right; i++)
         {
-          *DestLine = (*DestLine & notmask[i&1]) |
-            ((XLATEOBJ_iXlate(ColorTranslation, *SourceLine_8BPP)) << ((4 * (1-(i & 1)))));
+          *DestLine = (*DestLine & notmask[f2]) |
+            ((XLATEOBJ_iXlate(ColorTranslation, *SourceLine_8BPP)) << ((4 * (1 - f2))));
           if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; }
           SourceLine_8BPP++;
         }
@@ -165,8 +164,8 @@
         for (i = DestRect->left; i < DestRect->right; i++)
         {
           xColor = *((PWORD) SourceBits);
-          *DestBits = (*DestBits & notmask[i&1]) |
-            ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1)))));
+          *DestBits = (*DestBits & notmask[f2]) |
+            ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2))));
           if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; }
           SourceBits += 2;
         }
@@ -190,8 +189,8 @@
           xColor = (*(SourceLine_24BPP + 2) << 0x10) +
              (*(SourceLine_24BPP + 1) << 0x08) +
              (*(SourceLine_24BPP));
-          *DestLine = (*DestLine & notmask[i&1]) |
-            ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1)))));
+          *DestLine = (*DestLine & notmask[f2]) |
+            ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2))));
           if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; }
           SourceLine_24BPP+=3;
         }
@@ -214,8 +213,8 @@
         for (i = DestRect->left; i < DestRect->right; i++)
         {
           xColor = *((PDWORD) SourceBits);
-          *DestBits = (*DestBits & notmask[i&1]) |
-            ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1)))));
+          *DestBits = (*DestBits & notmask[f2]) |
+            ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2))));
           if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; }
           SourceBits += 4;
         }
@@ -242,9 +241,14 @@
    LONG i, j, sx, sy;
    ULONG Dest, Source, Pattern;
    PULONG DestBits;
-   BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-   BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
-   LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7);
+   BOOL UsesSource;
+   BOOL UsesPattern;
+   LONG RoundedRight;
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
    static const ULONG ExpandSolidColor[16] = 
    {
       0x00000000 /* 0 */,
@@ -267,74 +271,135 @@
 
    if (Rop4 == SRCCOPY)
    {
-      return(DIB_4BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
+      return DIB_4BPP_BitBltSrcCopy(
+         DestSurf,
+         SourceSurf,
+         DestGDI,
+         SourceGDI,
+         DestRect,
+         SourcePoint,
+         ColorTranslation);
    }
-   else
+
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+
+   if (UsesPattern)
    {
-      sy = SourcePoint->y;
+      if (Brush == NULL)
+      {
+         UsesPattern = FALSE;
+      } else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+      {
+         PBITMAPOBJ PatternBitmap;
+
+         GdiBrush = CONTAINING_RECORD(
+            Brush,
+            GDIBRUSHOBJ,
+            BrushObject);
+
+         PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+         PatternSurface = BitmapToSurf(PatternBitmap, NULL);
+         BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+         PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+         PatternWidth = PatternObj->sizlBitmap.cx;
+         PatternHeight = PatternObj->sizlBitmap.cy;
+      }
+   }
+   
+   sy = SourcePoint->y;
+   RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7);
 
-      for (j = DestRect->top; j < DestRect->bottom; j++, sy++)
+   for (j = DestRect->top; j < DestRect->bottom; j++, sy++)
+   {
+      DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left >> 1) + j * DestSurf->lDelta);
+      sx = SourcePoint->x;
+      i = DestRect->left;
+
+      if (i & 0x1)
       {
-         DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left >> 1) + j * DestSurf->lDelta);
-         sx = SourcePoint->x;
+         Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
 
-         /* Process all pixels on the left that aren't DWORD aligned */
-         for (i = DestRect->left; i & 0x7; i++, sx++)
+         if (UsesSource)
          {
-            Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
-            if (UsesSource)
-            {
-               Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
-            }
-            if (UsesPattern)
-            {
-               /* FIXME: No support for pattern brushes. */
-               Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
-            }				
-            DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
-	       }
+            Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
+         }
 
-	       /* Process all DWORD aligned pixels */
-         for (; i < RoundedRight; i += 8, sx += 8, DestBits++)
+         if (UsesPattern)
          {
-            Dest = *DestBits;
-            if (UsesSource)
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+            else
+               Pattern = Brush->iSolidColor & 0xF;
+         }				
+
+         DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
+
+         i++;
+         sx++;
+         DestBits++;
+      }
+
+      for (; i < RoundedRight; i += 8, sx += 8, DestBits++)
+      {
+         Dest = *DestBits;
+         if (UsesSource)
+         {
+            Source =
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 1, sy, ColorTranslation)) | 
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 0, sy, ColorTranslation) << 4) |
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 3, sy, ColorTranslation) << 8) | 
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 2, sy, ColorTranslation) << 12) |
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 5, sy, ColorTranslation) << 16) | 
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 4, sy, ColorTranslation) << 20) |
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 7, sy, ColorTranslation) << 24) | 
+               (DIB_GetSource(SourceSurf, SourceGDI, sx + 6, sy, ColorTranslation) << 28);
+         }
+         if (UsesPattern)
+         {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
             {
-               Source =
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 1, sy, ColorTranslation)) | 
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 0, sy, ColorTranslation) << 4) |
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 3, sy, ColorTranslation) << 8) | 
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 2, sy, ColorTranslation) << 12) |
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 5, sy, ColorTranslation) << 16) | 
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 4, sy, ColorTranslation) << 20) |
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 7, sy, ColorTranslation) << 24) | 
-                  (DIB_GetSource(SourceSurf, SourceGDI, sx + 6, sy, ColorTranslation) << 28);
+               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 1) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 4;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 2) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 8;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 3) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 12;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 4) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 16;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 5) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 20;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 6) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 24;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 7) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 28;
             }
-            if (UsesPattern)
+            else
             {
-               /* FIXME: No support for pattern brushes. */
                Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
             }
-            *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
          }
+         *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
+      }
 
-         /* Process the rest of pixel on the line */
-         for (; i < DestRect->right; i++, sx++)
+      /* Process the rest of pixel on the line */
+      for (; i < DestRect->right; i++, sx++)
+      {
+         Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
+         if (UsesSource)
          {
-            Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
-            if (UsesSource)
-            {
-               Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
-            }
-            if (UsesPattern)
-            {
-               /* FIXME: No support for pattern brushes. */
-               Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
-            }				
-            DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
-         }	 
-      }
+            Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
+         }
+         if (UsesPattern)
+         {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+            else
+               Pattern = Brush->iSolidColor & 0xF;
+         }				
+         DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
+      }	 
    }
+
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+
    return TRUE;
 }
 

reactos/subsys/win32k/dib
dib8bpp.c 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- dib8bpp.c	28 Mar 2004 23:25:48 -0000	1.16
+++ dib8bpp.c	5 Apr 2004 21:26:24 -0000	1.17
@@ -16,13 +16,15 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib8bpp.c,v 1.16 2004/03/28 23:25:48 navaraf Exp $ */
+/* $Id: dib8bpp.c,v 1.17 2004/04/05 21:26:24 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
 #include <win32k/bitmaps.h>
+#include <win32k/brush.h>
 #include <win32k/debug.h>
 #include <debug.h>
+#include <include/object.h>
 #include <ddk/winddi.h>
 #include "../eng/objects.h"
 #include "dib.h"
@@ -274,71 +276,127 @@
 		 PBRUSHOBJ Brush, PPOINTL BrushOrigin,
 		 XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
-  LONG     i, j, k, sx, sy;
-  ULONG    Dest, Source, Pattern;
-  PULONG   DestBits;
-  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
-  LONG     RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x3);
+   LONG i, j, k, sx, sy;
+   ULONG Dest, Source, Pattern;
+   PULONG DestBits;
+   BOOL UsesSource;
+   BOOL UsesPattern;
+   LONG RoundedRight;
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
+
+   if (Rop4 == SRCCOPY)
+   {
+      return DIB_8BPP_BitBltSrcCopy(
+         DestSurf,
+         SourceSurf,
+         DestGDI,
+         SourceGDI,
+         DestRect,
+         SourcePoint,
+         ColorTranslation);
+   }
+
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+
+   if (UsesPattern)
+   {
+      if (Brush == NULL)
+      {
+         UsesPattern = FALSE;
+      } else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+      {
+         PBITMAPOBJ PatternBitmap;
 
-  if (Rop4 == SRCCOPY)
-    {
-      return(DIB_8BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
-    }
-  else
-    {
-      sy = SourcePoint->y;
+         GdiBrush = CONTAINING_RECORD(
+            Brush,
+            GDIBRUSHOBJ,
+            BrushObject);
+
+         PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+         PatternSurface = BitmapToSurf(PatternBitmap, NULL);
+         BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+         PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+         PatternWidth = PatternObj->sizlBitmap.cx;
+         PatternHeight = PatternObj->sizlBitmap.cy;
+      }
+   }
+   
+   RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x3);
+   sy = SourcePoint->y;
 
-      for (j=DestRect->top; j<DestRect->bottom; j++)
+   for (j = DestRect->top; j < DestRect->bottom; j++)
+   {
+      sx = SourcePoint->x;
+      DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta);
+
+      for (i = DestRect->left; i < RoundedRight; i += 4, DestBits++)
       {
-        sx = SourcePoint->x;
-	DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta);
-        for (i=DestRect->left; i<RoundedRight; i+=4, DestBits++)
-	  {
-	    Dest = *DestBits;
-	    if (UsesSource)
-	      {
-		Source = 0;
-		for (k = 0; k < 4; k++)
-		  {
-		    Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8));
-		  }
-	      }
-	    if (UsesPattern)
-	      {
-		/* FIXME: No support for pattern brushes. */
-		Pattern = (Brush->iSolidColor & 0xFF) |
-                          ((Brush->iSolidColor & 0xFF) << 8) |
-                          ((Brush->iSolidColor & 0xFF) << 16) |
-                          ((Brush->iSolidColor & 0xFF) << 24);
-	      }
-	    *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
-	  }
-	if (i < DestRect->right)
-	  {
-	    Dest = *DestBits;
-	    for (; i < DestRect->right; i++)
-	      {
-		if (UsesSource)
-		  {
-		    Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
-		  }
-		if (UsesPattern)
-		  {
-		    /* FIXME: No support for pattern brushes. */
-		    Pattern = (Brush->iSolidColor & 0xFF) |
-                              ((Brush->iSolidColor & 0xFF) << 8) |
-                              ((Brush->iSolidColor & 0xFF) << 16) |
-                              ((Brush->iSolidColor & 0xFF) << 24);
-		  }				
-		DIB_8BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF);
-		Dest >>= 8;
-	      }	 
-	  }
-        sy++;
+         Dest = *DestBits;
+
+         if (UsesSource)
+         {
+            Source = 0;
+            for (k = 0; k < 4; k++)
+               Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8));
+         }
+
+         if (UsesPattern)
+         {
+            if (Brush->iSolidColor == 0xFFFFFFFF)
+            {
+               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 1) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 8;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 2) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 16;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 3) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 24;
+            }
+            else
+            {
+               Pattern = (Brush->iSolidColor & 0xFF) |
+                        ((Brush->iSolidColor & 0xFF) << 8) |
+                        ((Brush->iSolidColor & 0xFF) << 16) |
+                        ((Brush->iSolidColor & 0xFF) << 24);
+            }
+         }
+         *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
       }
-    }
-  return TRUE;
+
+      if (i < DestRect->right)
+      {
+         Dest = *DestBits;
+         for (; i < DestRect->right; i++)
+         {
+            if (UsesSource)
+	    {
+               Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
+            }
+
+            if (UsesPattern)
+            {
+               if (Brush->iSolidColor == 0xFFFFFFFF)
+                  Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
+               else
+                  Pattern = Brush->iSolidColor & 0xFF;
+            }
+
+            DIB_8BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF);
+            Dest >>= 8;
+         }
+      }
+
+      sy++;
+   }
+
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+
+   return TRUE;
 }
 
 /*
@@ -393,7 +451,7 @@
                   int TgtWidth, int TgtHeight, int srcPitch, int dstPitch)
 {
   int NumPixels = TgtHeight;
-  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) >> 1; //(SrcHeight / TgtHeight) * SrcWidth;
+  int IntPart = ((SrcHeight / TgtHeight) * srcPitch); //(SrcHeight / TgtHeight) * SrcWidth;
   int FractPart = SrcHeight % TgtHeight;
   int Mid = TgtHeight >> 1;
   int E = 0;

reactos/subsys/win32k/eng
bitblt.c 1.43 -> 1.44
diff -u -r1.43 -r1.44
--- bitblt.c	22 Mar 2004 14:58:56 -0000	1.43
+++ bitblt.c	5 Apr 2004 21:26:24 -0000	1.44
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: bitblt.c,v 1.43 2004/03/22 14:58:56 weiden Exp $
+/* $Id: bitblt.c,v 1.44 2004/04/05 21:26:24 navaraf Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -109,41 +109,74 @@
 	POINTL* BrushPoint,
 	ROP4 Rop4)
 {
-  LONG i, j, dx, dy, c8;
-  BYTE *tMask, *lMask;
-  static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+   LONG i, j, dx, dy, c8;
+   BYTE *tMask, *lMask;
+   static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+   /* Pattern brushes */
+   PGDIBRUSHOBJ GdiBrush;
+   HBITMAP PatternSurface = NULL;
+   PSURFOBJ PatternObj;
+   ULONG PatternWidth, PatternHeight;
   
-  dx = DestRect->right  - DestRect->left;
-  dy = DestRect->bottom - DestRect->top;
+   if (Mask == NULL)
+   {
+      return FALSE;
+   }
+
+   dx = DestRect->right  - DestRect->left;
+   dy = DestRect->bottom - DestRect->top;
+
+   if (Brush->iSolidColor == 0xFFFFFFFF)
+   {
+      PBITMAPOBJ PatternBitmap;
+
+      GdiBrush = CONTAINING_RECORD(
+         Brush,
+         GDIBRUSHOBJ,
+         BrushObject);
+
+      PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
+      PatternSurface = BitmapToSurf(PatternBitmap, Dest->hdev);
+      BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
+
+      PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
+      PatternWidth = PatternObj->sizlBitmap.cx;
+      PatternHeight = PatternObj->sizlBitmap.cy;
+   }
+
+   tMask = Mask->pvScan0 + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3);
+   for (j = 0; j < dy; j++)
+   {
+      lMask = tMask;
+      c8 = SourcePoint->x & 0x07;
+      for (i = 0; i < dx; i++)
+      {
+         if (0 != (*lMask & maskbit[c8]))
+         {
+            if (PatternSurface == NULL)
+            {
+               DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
+            }
+            else
+            {
+               DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j,
+                  DIB_1BPP_GetPixel(PatternObj, (DestRect->left + i) % PatternWidth, (DestRect->top + j) % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack);
+            }
+         }
+         c8++;
+         if (8 == c8)
+         {
+            lMask++;
+            c8 = 0;
+         }
+      }
+      tMask += Mask->lDelta;
+   }
 
-  if (Mask != NULL)
-    {
-      tMask = Mask->pvBits + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3);
-      for (j = 0; j < dy; j++)
-	{
-	  lMask = tMask;
-	  c8 = SourcePoint->x & 0x07;
-	  for (i = 0; i < dx; i++)
-	    {
-	      if (0 != (*lMask & maskbit[c8]))
-		{
-		  DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
-		}
-	      c8++;
-	      if (8 == c8)
-		{
-		  lMask++;
-		  c8=0;
-		}
-	    }
-	  tMask += Mask->lDelta;
-	}
-      return TRUE;
-    }
-  else
-    {
-    return FALSE;
-    }
+   if (PatternSurface != NULL)
+      EngDeleteSurface(PatternSurface);
+
+   return TRUE;
 }
 
 static BOOLEAN STDCALL
@@ -345,7 +378,14 @@
     }
   else if (PATCOPY == Rop4)
     {
+#if 0
       BltRectFunc = BltPatCopy;
+#else
+      if (Brush->iSolidColor == 0xFFFFFFFF)
+        BltRectFunc = CallDibBitBlt;
+      else
+        BltRectFunc = BltPatCopy;
+#endif
     }
   else
     {

reactos/subsys/win32k/include
object.h 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- object.h	24 Feb 2004 13:27:02 -0000	1.21
+++ object.h	5 Apr 2004 21:26:25 -0000	1.22
@@ -132,14 +132,6 @@
 
 /* objects/objconv.c */
 
-BRUSHOBJ*
-FASTCALL
-PenToBrushObj(BRUSHOBJ *brush, PENOBJ *pen);
-
-BRUSHOBJ*
-FASTCALL
-HPenToBrushObj ( BRUSHOBJ *brush, HPEN hpen );
-
 HBITMAP
 FASTCALL
 BitmapToSurf ( PBITMAPOBJ BitmapObj, HDEV GDIDevice );

reactos/subsys/win32k/objects
bitmaps.c 1.66 -> 1.67
diff -u -r1.66 -r1.67
--- bitmaps.c	3 Apr 2004 21:25:20 -0000	1.66
+++ bitmaps.c	5 Apr 2004 21:26:25 -0000	1.67
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: bitmaps.c,v 1.66 2004/04/03 21:25:20 weiden Exp $ */
+/* $Id: bitmaps.c,v 1.67 2004/04/05 21:26:25 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -62,7 +62,7 @@
 	PXLATEOBJ XlateObj = NULL;
 	HPALETTE SourcePalette, DestPalette;
 	ULONG SourceMode, DestMode;
-	PBRUSHOBJ BrushObj;
+	PGDIBRUSHOBJ BrushObj;
 	BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
 	BOOL UsesPattern = TRUE;//((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
 	HPALETTE Mono = NULL;
@@ -244,7 +244,7 @@
 
 	/* Perform the bitblt operation */
 	Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, DCDest->CombinedClip, XlateObj,
-		&DestRect, &SourcePoint, NULL, BrushObj, NULL, ROP);
+		&DestRect, &SourcePoint, NULL, &BrushObj->BrushObject, NULL, ROP);
 
 	EngDeleteXlate(XlateObj);
 	if (NULL != Mono)
@@ -1099,7 +1099,7 @@
 	PXLATEOBJ XlateObj = NULL;
 	HPALETTE SourcePalette, DestPalette;
 	ULONG SourceMode, DestMode;
-	PBRUSHOBJ BrushObj;
+	PGDIBRUSHOBJ BrushObj;
 	BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
 	BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
 
@@ -1307,7 +1307,7 @@
 	return -1;
 #endif
 
-	return ((bmWidth * bpp + 31) & ~31) >> 3;
+	return ((bmWidth * bpp + 15) & ~15) >> 3;
 }
 
 HBITMAP FASTCALL

reactos/subsys/win32k/objects
brush.c 1.32 -> 1.33
diff -u -r1.32 -r1.33
--- brush.c	19 Feb 2004 21:12:10 -0000	1.32
+++ brush.c	5 Apr 2004 21:26:25 -0000	1.33
@@ -1,400 +1,377 @@
 /*
- *  ReactOS W32 Subsystem
- *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ * ReactOS Win32 Subsystem
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+ * Copyright (C) 1998 - 2004 ReactOS Team
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id: brush.c,v 1.32 2004/02/19 21:12:10 weiden Exp $
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: brush.c,v 1.33 2004/04/05 21:26:25 navaraf Exp $
  */
 
-
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <ddk/ntddk.h>
 #include <win32k/bitmaps.h>
 #include <win32k/brush.h>
 #include <internal/safe.h>
-//#include <win32k/debug.h>
 #include <include/object.h>
 #include <include/inteng.h>
 #include <include/error.h>
 #include <include/tags.h>
-
 #define NDEBUG
 #include <win32k/debug1.h>
 
 HBRUSH FASTCALL
-IntGdiCreateBrushIndirect(PLOGBRUSH lb)
+IntGdiCreateBrushIndirect(PLOGBRUSH LogBrush)
 {
-  PBRUSHOBJ brushPtr;
-  HBRUSH    hBrush;
+   PGDIBRUSHOBJ BrushObject;
+   HBRUSH hBrush;
   
-  hBrush = BRUSHOBJ_AllocBrush();
-  if (hBrush == NULL)
-  {
-    return 0;
-  }
-
-  brushPtr = BRUSHOBJ_LockBrush (hBrush);
-/* FIXME: Occurs! FiN */
-/*  ASSERT( brushPtr ); *///I want to know if this ever occurs
-
-  if( brushPtr ){
-  	brushPtr->iSolidColor = lb->lbColor;
-  	brushPtr->logbrush.lbStyle = lb->lbStyle;
-  	brushPtr->logbrush.lbColor = lb->lbColor;
-  	brushPtr->logbrush.lbHatch = lb->lbHatch;
-
-  	BRUSHOBJ_UnlockBrush( hBrush );
-  	return  hBrush;
-  }
-  return NULL;
-}
+   hBrush = BRUSHOBJ_AllocBrush();
+   if (hBrush == NULL)
+   {
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      return NULL;
+   }
+
+   BrushObject = BRUSHOBJ_LockBrush(hBrush);
+
+   switch (LogBrush->lbStyle)
+   {
+      case BS_NULL:
+         BrushObject->flAttrs = GDIBRUSH_IS_NULL;
+         break;
+      
+      /* FIXME */
+      case BS_HATCHED:
+
+      case BS_SOLID:
+         BrushObject->flAttrs = GDIBRUSH_IS_SOLID;
+         BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
+         BrushObject->BrushObject.iSolidColor = BrushObject->BrushAttr.lbColor;
+         /* FIXME: Fill in the rest of fields!!! */
+         break;
+
+      case BS_PATTERN:
+         BrushObject->flAttrs = GDIBRUSH_IS_BITMAP;
+         BrushObject->hbmPattern = BITMAPOBJ_CopyBitmap((HBITMAP)LogBrush->lbHatch);
+         BrushObject->BrushObject.iSolidColor = 0xFFFFFFFF;
+         /* FIXME: Fill in the rest of fields!!! */
+         break;
+
+      default:
+         DPRINT1("Brush Style: %d\n", LogBrush->lbStyle);
+         UNIMPLEMENTED;
+   }
 
-HBRUSH FASTCALL
-IntGdiCreateDIBPatternBrush(HGLOBAL  hDIBPacked,
-                            UINT  ColorSpec)
-{
-  return NULL;
-#if 0
-  LOGBRUSH  logbrush;
-  PBITMAPINFO  info, newInfo;
-  INT  size;
-
-  DPRINT("%04x\n", hbitmap );
-
-  logbrush.lbStyle = BS_DIBPATTERN;
-  logbrush.lbColor = coloruse;
-  logbrush.lbHatch = 0;
-
-  /* Make a copy of the bitmap */
-  if (!(info = (BITMAPINFO *)GlobalLock( hbitmap )))
-  {
-    return 0;
-  }
-
-
-  if (info->bmiHeader.biCompression) size = info->bmiHeader.biSizeImage;
-  else
-    size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount);
-  size += DIB_BitmapInfoSize(info, coloruse);
-
-  if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
-  {
-    GlobalUnlock16( hbitmap );
-    return 0;
-  }
-  newInfo = (BITMAPINFO *) GlobalLock16((HGLOBAL16)logbrush.lbHatch);
-  memcpy(newInfo, info, size);
-  GlobalUnlock16((HGLOBAL16)logbrush.lbHatch);
-  GlobalUnlock(hbitmap);
-  return IntGdiCreateBrushIndirect(&logbrush);
-#endif
-}
-
-HBRUSH FASTCALL
-IntGdiCreateDIBPatternBrushPt(CONST VOID  *PackedDIB,
-                              UINT  Usage)
-{
-  INT  size;
-  LOGBRUSH  logbrush;
-  PBITMAPINFO  info;
-  PBITMAPINFO  newInfo;
-
-  info = (BITMAPINFO *) PackedDIB;
-  if (info == NULL)
-  {
-    return 0;
-  }
-  DPRINT ("%p %ldx%ld %dbpp\n",
-          info,
-          info->bmiHeader.biWidth,
-          info->bmiHeader.biHeight,
-          info->bmiHeader.biBitCount);
-
-  logbrush.lbStyle = BS_DIBPATTERN;
-  logbrush.lbColor = Usage;
-  logbrush.lbHatch = 0;
-
-  /* Make a copy of the bitmap */
-
-  if (info->bmiHeader.biCompression)
-  {
-    size = info->bmiHeader.biSizeImage;
-  }
-  else
-    {
-    size = DIB_GetDIBImageBytes (info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount);
-  }
-  size += DIB_BitmapInfoSize (info, Usage);
-
-  logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GDI_OBJECT_TYPE_DONTCARE, NULL);
-  if (logbrush.lbHatch == 0)
-  {
-    return 0;
-  }
-  newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE);
-  ASSERT(newInfo);
-  memcpy(newInfo, info, size);
-  GDIOBJ_UnlockObj((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE);
-
-  return  IntGdiCreateBrushIndirect (&logbrush);
+   BRUSHOBJ_UnlockBrush(hBrush);
+   return hBrush;
 }
 
 BOOL FASTCALL
-IntPatBlt(DC *dc,
-          INT  XLeft,
-          INT  YLeft,
-          INT  Width,
-          INT  Height,
-          DWORD  ROP,
-          PBRUSHOBJ BrushObj)
-{
-  RECT DestRect;
-  PSURFOBJ SurfObj;
-  BOOL ret;
-
-  SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
-  if (NULL == SurfObj)
-    {
+IntPatBlt(
+   PDC dc,
+   INT XLeft,
+   INT YLeft,
+   INT Width,
+   INT Height,
+   DWORD ROP,
+   PGDIBRUSHOBJ BrushObj)
+{
+   RECT DestRect;
+   PSURFOBJ SurfObj;
+   BOOL ret;
+
+   SurfObj = (SURFOBJ *)AccessUserObject((ULONG)dc->Surface);
+   if (SurfObj == NULL)
+   {
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       return FALSE;
-    }
+   }
 
-  assert(BrushObj);
-  if (BrushObj->logbrush.lbStyle != BS_NULL)
-    {
+   ASSERT(BrushObj);
+   if (!(BrushObj->flAttrs & GDIBRUSH_IS_NULL))
+   {
       if (Width > 0)
-	{
-	  DestRect.left = XLeft + dc->w.DCOrgX;
-	  DestRect.right = XLeft + Width + dc->w.DCOrgX;
-	}
+      {
+         DestRect.left = XLeft + dc->w.DCOrgX;
+         DestRect.right = XLeft + Width + dc->w.DCOrgX;
+      }
       else
-	{
-	  DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX;
-	  DestRect.right = XLeft + dc->w.DCOrgX + 1;
-	}
+      {
+         DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX;
+         DestRect.right = XLeft + dc->w.DCOrgX + 1;
+      }
+
       if (Height > 0)
-	{
-	  DestRect.top = YLeft + dc->w.DCOrgY;
-	  DestRect.bottom = YLeft + Height + dc->w.DCOrgY;
-	}
+      {
+         DestRect.top = YLeft + dc->w.DCOrgY;
+         DestRect.bottom = YLeft + Height + dc->w.DCOrgY;
+      }
       else
-	{
-	  DestRect.top = YLeft + Height + dc->w.DCOrgY + 1;
-	  DestRect.bottom = YLeft + dc->w.DCOrgY + 1;
-	}
-      ret = IntEngBitBlt(SurfObj,
-		         NULL,
-		         NULL,
-		         dc->CombinedClip,
-		         NULL,
-		         &DestRect,
-		         NULL,
-		         NULL,
-		         BrushObj,
-		         NULL,
-		         ROP);
-    }
+      {
+         DestRect.top = YLeft + Height + dc->w.DCOrgY + 1;
+         DestRect.bottom = YLeft + dc->w.DCOrgY + 1;
+      }
+
+      ret = IntEngBitBlt(
+         SurfObj,
+         NULL,
+         NULL,
+         dc->CombinedClip,
+         NULL,
+         &DestRect,
+         NULL,
+         NULL,
+         &BrushObj->BrushObject,
+         NULL,
+         ROP);
+   }
 
-  return ret;
+   return ret;
 }
 
 BOOL FASTCALL
-IntGdiPolyPatBlt(HDC hDC,
-                 DWORD dwRop,
-                 PPATRECT pRects,
-                 int cRects,
-                 ULONG Reserved)
-{
-	int i;
-	PPATRECT r;
-	PBRUSHOBJ BrushObj;
-	DC *dc;
+IntGdiPolyPatBlt(
+   HDC hDC,
+   DWORD dwRop,
+   PPATRECT pRects,
+   int cRects,
+   ULONG Reserved)
+{
+   int i;
+   PPATRECT r;
+   PGDIBRUSHOBJ BrushObj;
+   DC *dc;
 	
-    dc = DC_LockDc(hDC);
-	if (dc == NULL)
-	{
-		SetLastWin32Error(ERROR_INVALID_HANDLE);
-		return(FALSE);
-	}
+   dc = DC_LockDc(hDC);
+   if (dc == NULL)
+   {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      return FALSE;
+   }
 	
-	for (r = pRects, i = 0; i < cRects; i++)
-	{
-		BrushObj = BRUSHOBJ_LockBrush(r->hBrush);
-		IntPatBlt(dc,r->r.left,r->r.top,r->r.right,r->r.bottom,dwRop,BrushObj);
-		BRUSHOBJ_UnlockBrush(r->hBrush);
-		r++;
-	}
-	DC_UnlockDc( hDC );
+   for (r = pRects, i = 0; i < cRects; i++)
+   {
+      BrushObj = BRUSHOBJ_LockBrush(r->hBrush);
+      IntPatBlt(
+         dc,
+         r->r.left,
+         r->r.top,
+         r->r.right,
+         r->r.bottom,
+         dwRop,
+         BrushObj);
+      BRUSHOBJ_UnlockBrush(r->hBrush);
+      r++;
+   }
+
+   DC_UnlockDc( hDC );
 	
-	return(TRUE);
+   return TRUE;
 }
 
-/******************************************************************************/
+/* PUBLIC FUNCTIONS ***********************************************************/
 
-HBRUSH STDCALL NtGdiCreateBrushIndirect(CONST LOGBRUSH  *lb)
+HBRUSH STDCALL
+NtGdiCreateBrushIndirect(CONST LOGBRUSH *LogBrush)
 {
-  LOGBRUSH  Safelb;
-  NTSTATUS  Status;
+   LOGBRUSH SafeLogBrush;
+   NTSTATUS Status;
   
-  Status = MmCopyFromCaller(&Safelb, lb, sizeof(LOGBRUSH));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return 0;
-  }
+   Status = MmCopyFromCaller(&SafeLogBrush, LogBrush, sizeof(LOGBRUSH));
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return 0;
+   }
   
-  return IntGdiCreateBrushIndirect(&Safelb);
+   return IntGdiCreateBrushIndirect(&SafeLogBrush);
 }
 
-HBRUSH STDCALL NtGdiCreateDIBPatternBrush(HGLOBAL  hDIBPacked,
-                                  UINT  ColorSpec)
+HBRUSH STDCALL
+NtGdiCreateDIBPatternBrush(HGLOBAL hDIBPacked, UINT ColorSpec)
 {
-  /* IntGdiCreateDIBPatternBrush() */
-  UNIMPLEMENTED;
+   UNIMPLEMENTED;
+   return 0;
 }
 
-HBRUSH STDCALL NtGdiCreateDIBPatternBrushPt(CONST VOID  *PackedDIB,
-                                    UINT  Usage)
+HBRUSH STDCALL
+NtGdiCreateDIBPatternBrushPt(CONST VOID *PackedDIB, UINT Usage)
 {
-  /* FIXME - copy PackedDIB memory first! */
-  return IntGdiCreateDIBPatternBrushPt(PackedDIB, Usage);
+   UNIMPLEMENTED;
+   return 0;
 }
 
-HBRUSH STDCALL NtGdiCreateHatchBrush(INT  Style,
-                             COLORREF  Color)
+HBRUSH STDCALL
+NtGdiCreateHatchBrush(INT Style, COLORREF Color)
 {
-  LOGBRUSH  logbrush;
+   LOGBRUSH LogBrush;
 
-  DPRINT("%d %06lx\n", Style, Color);
+   if (Style < 0 || Style >= NB_HATCH_STYLES)
+      return 0;
 
-  if (Style < 0 || Style >= NB_HATCH_STYLES)
-  {
-    return 0;
-  }
-  logbrush.lbStyle = BS_HATCHED;
-  logbrush.lbColor = Color;
-  logbrush.lbHatch = Style;
+   LogBrush.lbStyle = BS_HATCHED;
+   LogBrush.lbColor = Color;
+   LogBrush.lbHatch = Style;
 
-  return  IntGdiCreateBrushIndirect (&logbrush);
+   return IntGdiCreateBrushIndirect(&LogBrush);
 }
 
-HBRUSH STDCALL NtGdiCreatePatternBrush(HBITMAP  hBitmap)
+HBRUSH STDCALL
+NtGdiCreatePatternBrush(HBITMAP hBitmap)
 {
-  LOGBRUSH  logbrush = { BS_PATTERN, 0, 0 };
+   LOGBRUSH LogBrush;
+
+   LogBrush.lbStyle = BS_PATTERN;
+   LogBrush.lbColor = 0;
+   LogBrush.lbHatch = (ULONG)hBitmap;
 
-  DPRINT ("%04x\n", hBitmap);
-  logbrush.lbHatch = (INT) BITMAPOBJ_CopyBitmap (hBitmap);
-  if(!logbrush.lbHatch)
-  {
-    return 0;
-  }
-  else
-  {
-    return IntGdiCreateBrushIndirect( &logbrush );
-  }
+   return IntGdiCreateBrushIndirect(&LogBrush);
 }
 
-HBRUSH STDCALL NtGdiCreateSolidBrush(COLORREF  Color)
+HBRUSH STDCALL
+NtGdiCreateSolidBrush(COLORREF Color)
 {
-  LOGBRUSH logbrush;
+   LOGBRUSH LogBrush;
 
-  logbrush.lbStyle = BS_SOLID;
-  logbrush.lbColor = Color;
-  logbrush.lbHatch = 0;
+   LogBrush.lbStyle = BS_SOLID;
+   LogBrush.lbColor = Color;
+   LogBrush.lbHatch = 0;
 
-  return IntGdiCreateBrushIndirect(&logbrush);
+   return IntGdiCreateBrushIndirect(&LogBrush);
 }
 
-BOOL STDCALL NtGdiFixBrushOrgEx(VOID)
+BOOL STDCALL
+NtGdiFixBrushOrgEx(VOID)
 {
-  return FALSE;
+   return FALSE;
 }
 
-BOOL STDCALL NtGdiPolyPatBlt(HDC hDC,
-			DWORD dwRop,
-			PPATRECT pRects,
-			int cRects,
-			ULONG Reserved)
+/*
+ * NtGdiSetBrushOrgEx
+ *
+ * The NtGdiSetBrushOrgEx function sets the brush origin that GDI assigns to
+ * the next brush an application selects into the specified device context. 
+ *
+ * Status
+ *    @implemented
+ */
+
+BOOL STDCALL
+NtGdiSetBrushOrgEx(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point)
 {
-	PPATRECT rb;
-	NTSTATUS Status;
-	BOOL Ret;
+   PDC dc = DC_LockDc(hDC);
+   if (dc == NULL)
+   {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      return FALSE;
+   }
+
+   if (Point != NULL)
+   {
+      POINT SafePoint;
+      SafePoint.x = dc->w.brushOrgX;
+      SafePoint.y = dc->w.brushOrgY;
+      MmCopyToCaller(Point, &SafePoint, sizeof(POINT));
+   }
+
+   dc->w.brushOrgX = XOrg;
+   dc->w.brushOrgY = YOrg;
+   DC_UnlockDc(hDC);
+
+   return TRUE;
+}
+
+BOOL STDCALL
+NtGdiPolyPatBlt(
+   HDC hDC,
+   DWORD dwRop,
+   PPATRECT pRects,
+   INT cRects,
+   ULONG Reserved)
+{
+   PPATRECT rb;
+   NTSTATUS Status;
+   BOOL Ret;
     
-	if(cRects > 0)
-	{
-	  rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, TAG_PATBLT);
-	  if(!rb)
-	  {
-	    SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-	    return FALSE;
-	  }
+   if (cRects > 0)
+   {
+      rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, TAG_PATBLT);
+      if (!rb)
+      {
+         SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+         return FALSE;
+      }
       Status = MmCopyFromCaller(rb, pRects, sizeof(PATRECT) * cRects);
-      if(!NT_SUCCESS(Status))
+      if (!NT_SUCCESS(Status))
       {
-        ExFreePool(rb);
-        SetLastNtError(Status);
-        return FALSE;
+         ExFreePool(rb);
+         SetLastNtError(Status);
+         return FALSE;
       }
-    }
+   }
     
-    Ret = IntGdiPolyPatBlt(hDC, dwRop, pRects, cRects, Reserved);
+   Ret = IntGdiPolyPatBlt(hDC, dwRop, pRects, cRects, Reserved);
 	
-	if(cRects > 0)
-	  ExFreePool(rb);
-	return Ret;
-}
-
-BOOL STDCALL NtGdiPatBlt(HDC  hDC,
-			INT  XLeft,
-			INT  YLeft,
-			INT  Width,
-			INT  Height,
-			DWORD  ROP)
-{
-  PBRUSHOBJ BrushObj;
-  DC *dc = DC_LockDc(hDC);
-  BOOL ret;
+   if (cRects > 0)
+      ExFreePool(rb);
+
+   return Ret;
+}
+
+BOOL STDCALL
+NtGdiPatBlt(
+   HDC hDC,
+   INT XLeft,
+   INT YLeft,
+   INT Width,
+   INT Height,
+   DWORD ROP)
+{
+   PGDIBRUSHOBJ BrushObj;
+   DC *dc = DC_LockDc(hDC);
+   BOOL ret;
 
-  if (NULL == dc)
-    {
+   if (dc == NULL)
+   {
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       return FALSE;
-    }
+   }
 
-  BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
-  if (NULL == BrushObj)
-    {
+   BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+   if (BrushObj == NULL)
+   {
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       DC_UnlockDc(hDC);
       return FALSE;
-    }
+   }
 
-  ret = IntPatBlt(dc,XLeft,YLeft,Width,Height,ROP,BrushObj);
+   ret = IntPatBlt(
+      dc,
+      XLeft,
+      YLeft,
+      Width,
+      Height,
+      ROP,
+      BrushObj);
 
-  BRUSHOBJ_UnlockBrush(dc->w.hBrush);
-  DC_UnlockDc(hDC);
-  return ret;
-}
+   BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+   DC_UnlockDc(hDC);
 
-BOOL STDCALL NtGdiSetBrushOrgEx(HDC  hDC,
-                        INT  XOrg,
-                        INT  YOrg,
-                        LPPOINT  Point)
-{
-  UNIMPLEMENTED;
+   return ret;
 }
+
 /* EOF */

reactos/subsys/win32k/objects
dc.c 1.125 -> 1.126
diff -u -r1.125 -r1.126
--- dc.c	23 Mar 2004 19:46:50 -0000	1.125
+++ dc.c	5 Apr 2004 21:26:25 -0000	1.126
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dc.c,v 1.125 2004/03/23 19:46:50 gvg Exp $
+/* $Id: dc.c,v 1.126 2004/04/05 21:26:25 navaraf Exp $
  *
  * DC.C - Device context functions
  *
@@ -995,13 +995,16 @@
 {
   COLORREF oldColor;
   PDC  dc = DC_LockDc(hDC);
+  HBRUSH hBrush;
 
   if ( !dc )
     return 0x80000000;
 
   oldColor = dc->w.backgroundColor;
   dc->w.backgroundColor = color;
+  hBrush = dc->w.hBrush;
   DC_UnlockDc ( hDC );
+  NtGdiSelectObject(hDC, hBrush);
   return oldColor;
 }
 
@@ -1702,8 +1705,8 @@
   HGDIOBJ objOrg = NULL; // default to failure
   BITMAPOBJ *pb;
   PDC dc;
-  PPENOBJ pen;
-  PBRUSHOBJ brush;
+  PGDIBRUSHOBJ pen;
+  PGDIBRUSHOBJ brush;
   PXLATEOBJ XlateObj;
   PPALGDI PalGDI;
   DWORD objectType;
@@ -1740,7 +1743,17 @@
               pen = PENOBJ_LockPen((HPEN) hGDIObj);
               if (NULL != pen)
                 {
-                  pen->iSolidColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor);
+                  if (pen->flAttrs & GDIBRUSH_IS_SOLID)
+                    {
+                      pen->BrushObject.iSolidColor = 
+                        XLATEOBJ_iXlate(XlateObj, pen->BrushAttr.lbColor);
+                    }
+                  else
+                    {
+                      pen->BrushObject.iSolidColor = 0xFFFFFFFF;
+                    }
+                  pen->crBack = XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor);
+                  pen->crFore = XLATEOBJ_iXlate(XlateObj, dc->w.textColor);
                   PENOBJ_UnlockPen((HPEN) hGDIObj);
                   objOrg = (HGDIOBJ)dc->w.hPen;
                   dc->w.hPen = hGDIObj;
@@ -1776,7 +1789,17 @@
               brush = BRUSHOBJ_LockBrush((HBRUSH) hGDIObj);
               if (NULL != brush)
                 {
-                  brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->logbrush.lbColor);
+                  if (brush->flAttrs & GDIBRUSH_IS_SOLID)
+                    {
+                      brush->BrushObject.iSolidColor = 
+                        XLATEOBJ_iXlate(XlateObj, brush->BrushAttr.lbColor);
+                    }
+                  else
+                    {
+                      brush->BrushObject.iSolidColor = 0xFFFFFFFF;
+                    }
+                  brush->crBack = XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor);
+                  brush->crFore = XLATEOBJ_iXlate(XlateObj, dc->w.textColor);
                   BRUSHOBJ_UnlockBrush((HBRUSH) hGDIObj);
                   objOrg = (HGDIOBJ)dc->w.hBrush;
                   dc->w.hBrush = (HBRUSH) hGDIObj;

reactos/subsys/win32k/objects
fillshap.c 1.45 -> 1.46
diff -u -r1.45 -r1.46
--- fillshap.c	27 Mar 2004 00:35:02 -0000	1.45
+++ fillshap.c	5 Apr 2004 21:26:25 -0000	1.46
@@ -16,11 +16,12 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: fillshap.c,v 1.45 2004/03/27 00:35:02 weiden Exp $ */
+/* $Id: fillshap.c,v 1.46 2004/04/05 21:26:25 navaraf Exp $ */
 
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <ddk/ntddk.h>
+#include <ddk/winddi.h>
 #include <win32k/fillshap.h>
 #include <win32k/brush.h>
 #include <win32k/dc.h>
@@ -46,7 +47,7 @@
 #define PUTPIXEL(x,y,brushObj)      \
   ret = ret && IntEngLineTo(SurfObj,  \
        dc->CombinedClip,              \
-       brushObj,                      \
+       &brushObj->BrushObject,        \
        x, y, (x)+1, y,                \
        &RectBounds,                   \
        dc->w.ROPmode);
@@ -54,7 +55,7 @@
 #define PUTLINE(x1,y1,x2,y2,brushObj)  \
   ret = ret && IntEngLineTo(SurfObj,  \
        dc->CombinedClip,              \
-       brushObj,                      \
+       &brushObj->BrushObject,        \
        x1, y1, x2, y2,                \
        &RectBounds,                   \
        dc->w.ROPmode);
@@ -65,7 +66,7 @@
               int    Count)
 {
   SURFOBJ *SurfObj;
-  BRUSHOBJ PenBrushObj, *FillBrushObj;
+  PGDIBRUSHOBJ PenBrushObj, FillBrushObj;
   BOOL ret = FALSE; // default to failure
   PRECTL RectBounds;
   RECTL DestRect;
@@ -113,16 +114,16 @@
 	/* Now fill the polygon with the current brush. */
 	FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
 	ASSERT(FillBrushObj);
-	if ( FillBrushObj->logbrush.lbStyle != BS_NULL )
-	  ret = FillPolygon ( dc, SurfObj, FillBrushObj, dc->w.ROPmode, UnsafePoints, Count, DestRect );
+	if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
+	  ret = FillPolygon ( dc, SurfObj, &FillBrushObj->BrushObject, dc->w.ROPmode, UnsafePoints, Count, DestRect );
 	BRUSHOBJ_UnlockBrush(dc->w.hBrush);
 #endif
 
-	/* make BRUSHOBJ from current pen. */
-	HPenToBrushObj ( &PenBrushObj, dc->w.hPen );
+	/* get BRUSHOBJ from current pen. */
+	PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
 
 	// Draw the Polygon Edges with the current pen ( if not a NULL pen )
-	if ( PenBrushObj.logbrush.lbStyle != BS_NULL )
+	if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
 	{
 	  for ( CurrentPoint = 0; CurrentPoint < Count; ++CurrentPoint )
 	  {
@@ -141,7 +142,7 @@
 	    //DPRINT("Polygon Making line from (%d,%d) to (%d,%d)\n", From.x, From.y, To.x, To.y );
 	    ret = IntEngLineTo(SurfObj,
 			       dc->CombinedClip,
-			       &PenBrushObj,
+			       &PenBrushObj->BrushObject,
 			       From.x,
 			       From.y,
 			       To.x,
@@ -160,6 +161,7 @@
 #endif
       }
 
+      PENOBJ_UnlockPen( dc->w.hPen );
       RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
   
   return ret;
@@ -239,8 +241,7 @@
    int CenterX, CenterY;
    int RadiusX, RadiusY;
    int Temp;
-   BRUSHOBJ PenBrush;
-   PBRUSHOBJ FillBrush;
+   PGDIBRUSHOBJ FillBrush, PenBrush;
    PSURFOBJ SurfObj;
    RECTL RectBounds;
    PDC dc;
@@ -275,8 +276,16 @@
       return FALSE;
    }
 
+   PenBrush = PENOBJ_LockPen(dc->w.hPen);
+   if (NULL == PenBrush)
+   {
+      PENOBJ_UnlockPen(dc->w.hPen);
+      DC_UnlockDc(hDC);
+      SetLastWin32Error(ERROR_INTERNAL_ERROR);
+      return FALSE;
+   }
+
    SurfObj = (PSURFOBJ)AccessUserObject((ULONG)dc->Surface);
-   HPenToBrushObj(&PenBrush, dc->w.hPen);
 
    nLeftRect += dc->w.DCOrgX;
    nRightRect += dc->w.DCOrgX - 1;
@@ -370,32 +379,33 @@
 
       if (Cond1)
       {
-         PUTPIXEL(CenterX + C, CenterY + B, &PenBrush);
+         PUTPIXEL(CenterX + C, CenterY + B, PenBrush);
          if (C)
-            PUTPIXEL(CenterX - C, CenterY + B, &PenBrush);
+            PUTPIXEL(CenterX - C, CenterY + B, PenBrush);
          if (B)
          {
-            PUTPIXEL(CenterX + C, CenterY - B, &PenBrush);
+            PUTPIXEL(CenterX + C, CenterY - B, PenBrush);
             if (C)
-               PUTPIXEL(CenterX - C, CenterY - B, &PenBrush);
+               PUTPIXEL(CenterX - C, CenterY - B, PenBrush);
          }
       }
 
       if (Cond2)
       {
-         PUTPIXEL(CenterX + D, CenterY + A, &PenBrush);
+         PUTPIXEL(CenterX + D, CenterY + A, PenBrush);
          if (D)
-            PUTPIXEL(CenterX - D, CenterY + A, &PenBrush);
+            PUTPIXEL(CenterX - D, CenterY + A, PenBrush);
          if (A)
          {
-            PUTPIXEL(CenterX + D, CenterY - A, &PenBrush);
+            PUTPIXEL(CenterX + D, CenterY - A, PenBrush);
             if (D)
-               PUTPIXEL(CenterX - D, CenterY - A, &PenBrush);
+               PUTPIXEL(CenterX - D, CenterY - A, PenBrush);
          }
       }
    } while (B > A);
 
    BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+   PENOBJ_UnlockPen(dc->w.hPen);
    DC_UnlockDc(hDC);
 
    return ret;
@@ -945,7 +955,7 @@
 	     int BottomRect)
 {
   SURFOBJ   *SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
-  BRUSHOBJ   PenBrushObj, *FillBrushObj;
+  PGDIBRUSHOBJ PenBrushObj, FillBrushObj;
   BOOL       ret = FALSE; // default to failure
   RECTL      DestRect;
 
@@ -971,7 +981,7 @@
 
     if ( FillBrushObj )
     {
-      if ( FillBrushObj->logbrush.lbStyle != BS_NULL )
+      if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
       {
 	ret = IntEngBitBlt(SurfObj,
                            NULL,
@@ -981,7 +991,7 @@
                            &DestRect,
                            NULL,
                            NULL,
-                           FillBrushObj,
+                           &FillBrushObj->BrushObject,
                            NULL,
                            PATCOPY);
       }
@@ -989,43 +999,50 @@
 
     BRUSHOBJ_UnlockBrush(dc->w.hBrush);
 
-    /* make BRUSHOBJ from current pen. */
-    HPenToBrushObj ( &PenBrushObj, dc->w.hPen );
+    /* get BRUSHOBJ from current pen. */
+    PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+    if (PenBrushObj == NULL)
+    {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      return FALSE;
+    }
 
     // Draw the rectangle with the current pen
 
     ret = TRUE; // change default to success
 
-    if ( PenBrushObj.logbrush.lbStyle != BS_NULL )
+    if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
     {
       ret = ret && IntEngLineTo(SurfObj,
 			 dc->CombinedClip,
-			 &PenBrushObj,
+			 &PenBrushObj->BrushObject,
 			 LeftRect, TopRect, RightRect, TopRect,
 			 &DestRect, // Bounding rectangle
 			 dc->w.ROPmode); // MIX
 
       ret = ret && IntEngLineTo(SurfObj,
 			 dc->CombinedClip,
-			 &PenBrushObj,
+			 &PenBrushObj->BrushObject,
 			 RightRect, TopRect, RightRect, BottomRect,
 			 &DestRect, // Bounding rectangle
 			 dc->w.ROPmode); // MIX
 
       ret = ret && IntEngLineTo(SurfObj,
 			 dc->CombinedClip,
-			 &PenBrushObj,
+			 &PenBrushObj->BrushObject,
 			 RightRect, BottomRect, LeftRect, BottomRect,
 			 &DestRect, // Bounding rectangle
 			 dc->w.ROPmode); // MIX
 
       ret = ret && IntEngLineTo(SurfObj,
 			 dc->CombinedClip,
-			 &PenBrushObj,
+			 &PenBrushObj->BrushObject,
 			 LeftRect, BottomRect, LeftRect, TopRect,
 			 &DestRect, // Bounding rectangle
 			 dc->w.ROPmode); // MIX */
     }
+
+    PENOBJ_UnlockPen(dc->w.hPen);
   }
 
   /* Move current position in DC?
@@ -1071,7 +1088,7 @@
 	int  yCurveDiameter)
 {
   SURFOBJ   *SurfObj;
-  BRUSHOBJ   PenBrush, *PenBrushObj, *FillBrushObj;
+  PGDIBRUSHOBJ   PenBrushObj, FillBrushObj;
   RECTL      RectBounds;
   int i, col, row, width, height, x1, x1start, x2, x2start, y1, y2;
   int xradius, yradius;
@@ -1106,14 +1123,19 @@
 
   FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
   ASSERT(FillBrushObj);
-  if ( FillBrushObj->logbrush.lbStyle == BS_NULL )
+  if (FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)
+  {
+    BRUSHOBJ_UnlockBrush(dc->w.hBrush);
     FillBrushObj = NULL; // make null brush check simpler...
+  }
 
-  HPenToBrushObj ( &PenBrush, dc->w.hPen );
-  if ( PenBrush.logbrush.lbStyle != BS_NULL )
-    PenBrushObj = &PenBrush;
-  else
+  PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+  ASSERT(PenBrushObj);
+  if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)
+  {
+    PENOBJ_UnlockPen(dc->w.hPen);
     PenBrushObj = NULL;
+  }
 
   right--;
   bottom--;
@@ -1292,6 +1314,7 @@
     PUTLINE ( left,  y2,     left,  y1,     PenBrushObj );
   }
 
+  PENOBJ_UnlockPen(dc->w.hPen);
   BRUSHOBJ_UnlockBrush(dc->w.hBrush);
 
   return ret;

reactos/subsys/win32k/objects
gdiobj.c 1.64 -> 1.65
diff -u -r1.64 -r1.65
--- gdiobj.c	3 Apr 2004 20:33:39 -0000	1.64
+++ gdiobj.c	5 Apr 2004 21:26:25 -0000	1.65
@@ -19,7 +19,7 @@
 /*
  * GDIOBJ.C - GDI object manipulation routines
  *
- * $Id: gdiobj.c,v 1.64 2004/04/03 20:33:39 gvg Exp $
+ * $Id: gdiobj.c,v 1.65 2004/04/05 21:26:25 navaraf Exp $
  *
  */
 
@@ -110,8 +110,8 @@
   {GDI_OBJECT_TYPE_BITMAP,      sizeof(BITMAPOBJ)},
   {GDI_OBJECT_TYPE_DC,          sizeof(DC)},
   {GDI_OBJECT_TYPE_PALETTE,     sizeof(PALGDI)},
-  {GDI_OBJECT_TYPE_BRUSH,       sizeof(BRUSHOBJ)},
-  {GDI_OBJECT_TYPE_PEN,         sizeof(PENOBJ)},
+  {GDI_OBJECT_TYPE_BRUSH,       sizeof(GDIBRUSHOBJ)},
+  {GDI_OBJECT_TYPE_PEN,         sizeof(GDIBRUSHOBJ)},
   {GDI_OBJECT_TYPE_FONT,        sizeof(TEXTOBJ)},
   {GDI_OBJECT_TYPE_DCE,         sizeof(DCE)},
 /*

reactos/subsys/win32k/objects
line.c 1.27 -> 1.28
diff -u -r1.27 -r1.28
--- line.c	19 Feb 2004 21:12:10 -0000	1.27
+++ line.c	5 Apr 2004 21:26:25 -0000	1.28
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: line.c,v 1.27 2004/02/19 21:12:10 weiden Exp $ */
+/* $Id: line.c,v 1.28 2004/04/05 21:26:25 navaraf Exp $ */
 
 // Some code from the WINE project source (www.winehq.com)
 
@@ -71,7 +71,7 @@
 {
   SURFOBJ *SurfObj;
   BOOL     Ret;
-  BRUSHOBJ PenBrushObj;
+  PGDIBRUSHOBJ PenBrushObj;
   RECT     Bounds;
 
   SurfObj = (SURFOBJ*)AccessUserObject ( (ULONG)dc->Surface );
@@ -119,16 +119,22 @@
       Bounds.top += dc->w.DCOrgY;
       Bounds.bottom += dc->w.DCOrgY;
 
-      /* make BRUSHOBJ from current pen. */
-      HPenToBrushObj ( &PenBrushObj, dc->w.hPen );
+      /* get BRUSHOBJ from current pen. */
+      PenBrushObj = PENOBJ_LockPen( dc->w.hPen );
+      ASSERT(PenBrushObj);
 
-      Ret = IntEngLineTo(SurfObj,
-                         dc->CombinedClip,
-                         &PenBrushObj,
-                         dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
-                         dc->w.DCOrgX + XEnd,           dc->w.DCOrgY + YEnd,
-                         &Bounds,
-                         dc->w.ROPmode);
+      if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
+      {
+        Ret = IntEngLineTo(SurfObj,
+                           dc->CombinedClip,
+                           &PenBrushObj->BrushObject,
+                           dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
+                           dc->w.DCOrgX + XEnd,           dc->w.DCOrgY + YEnd,
+                           &Bounds,
+                           dc->w.ROPmode);
+      }
+
+      PENOBJ_UnlockPen( dc->w.hPen );
     }
 
   if (Ret)
@@ -209,7 +215,7 @@
   BOOL         ret = FALSE; // default to failure
   LONG         i;
   PROSRGNDATA  reg;
-  BRUSHOBJ     PenBrushObj;
+  PGDIBRUSHOBJ PenBrushObj;
   POINT       *pts;
 
   SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
@@ -236,16 +242,22 @@
 	pts[i].y += dc->w.DCOrgY;
       }
 
-      /* make BRUSHOBJ from current pen. */
-      HPenToBrushObj ( &PenBrushObj, dc->w.hPen );
+      /* get BRUSHOBJ from current pen. */
+      PenBrushObj = PENOBJ_LockPen( dc->w.hPen );
+      ASSERT(PenBrushObj);
+
+      if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
+      {
+        //get IntEngPolyline to do the drawing.
+        ret = IntEngPolyline(SurfObj,
+  			   dc->CombinedClip,
+  			   &PenBrushObj->BrushObject,
+  			   pts,
+  			   Count,
+  			   dc->w.ROPmode);
+      }
 
-      //get IntEngPolyline to do the drawing.
-      ret = IntEngPolyline(SurfObj,
-			   dc->CombinedClip,
-			   &PenBrushObj,
-			   pts,
-			   Count,
-			   dc->w.ROPmode);
+      PENOBJ_UnlockPen( dc->w.hPen );
     }
 
     ExFreePool ( pts );

reactos/subsys/win32k/objects
objconv.c 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- objconv.c	1 Feb 2004 15:45:41 -0000	1.15
+++ objconv.c	5 Apr 2004 21:26:25 -0000	1.16
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: objconv.c,v 1.15 2004/02/01 15:45:41 gvg Exp $ */
+/* $Id: objconv.c,v 1.16 2004/04/05 21:26:25 navaraf Exp $ */
 
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -38,35 +38,6 @@
 //#define NDEBUG
 #include <win32k/debug1.h>
 
-
-BRUSHOBJ*
-FASTCALL
-PenToBrushObj ( BRUSHOBJ *brush, PENOBJ *pen )
-{
-  ASSERT ( pen );
-  ASSERT ( brush );
-  memset ( brush, 0, sizeof(BRUSHOBJ) );
-  if ( pen->logpen.lopnStyle == PS_NULL )
-    brush->logbrush.lbStyle = BS_NULL;
-  else
-    brush->iSolidColor = pen->iSolidColor;
-  return brush;
-}
-
-BRUSHOBJ*
-FASTCALL
-HPenToBrushObj ( BRUSHOBJ *brush, HPEN hpen )
-{
-  PENOBJ *pen;
-  ASSERT ( hpen );
-  ASSERT ( brush );
-  pen = PENOBJ_LockPen(hpen);
-  ASSERT ( pen );
-  PenToBrushObj ( brush, pen );
-  PENOBJ_UnlockPen(hpen);
-  return brush;
-}
-
 HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice)
 {
   HBITMAP BitmapHandle;
@@ -87,11 +58,12 @@
                                    BitmapFormat(BitmapObj->bitmap.bmBitsPixel, BI_RGB),
                                    0, BitmapObj->bitmap.bmBits);
     }
-  if (NULL != BitmapHandle)
+  if (NULL != BitmapHandle && NULL != GDIDevice)
     {
       EngAssociateSurface(BitmapHandle, GDIDevice, 0);
     }
 
   return BitmapHandle;
 }
+
 /* EOF */

reactos/subsys/win32k/objects
path.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- path.c	19 Feb 2004 21:12:10 -0000	1.18
+++ path.c	5 Apr 2004 21:26:25 -0000	1.19
@@ -16,10 +16,11 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: path.c,v 1.18 2004/02/19 21:12:10 weiden Exp $ */
+/* $Id: path.c,v 1.19 2004/04/05 21:26:25 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <ddk/ntddk.h>
+#include <ddk/winddi.h>
 #include <win32k/brush.h>
 #include <win32k/dc.h>
 #include <win32k/path.h>

reactos/subsys/win32k/objects
pen.c 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- pen.c	12 Dec 2003 15:47:37 -0000	1.13
+++ pen.c	5 Apr 2004 21:26:25 -0000	1.14
@@ -1,95 +1,129 @@
 /*
- *  ReactOS W32 Subsystem
- *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ * ReactOS Win32 Subsystem
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+ * Copyright (C) 1998 - 2004 ReactOS Team
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: pen.c,v 1.14 2004/04/05 21:26:25 navaraf Exp $
  */
-/* $Id: pen.c,v 1.13 2003/12/12 15:47:37 weiden Exp $ */
+
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <ddk/ntddk.h>
+#include <ddk/winddi.h>
 #include <win32k/pen.h>
+#include <win32k/bitmaps.h>
 #include <include/error.h>
 #include <internal/safe.h>
-
 #define NDEBUG
 #include <win32k/debug1.h>
 
+/* PRIVATE FUNCTIONS **********************************************************/
+
 HPEN FASTCALL
-IntGdiCreatePenIndirect(PLOGPEN lgpn)
+IntGdiCreatePenIndirect(PLOGPEN LogPen)
 {
-  HPEN hpen;
-  PPENOBJ penPtr;
+   HPEN hPen;
+   PGDIBRUSHOBJ PenObject;
+   static const WORD wPatternAlternate[] = {0x5555};
   
-  if (lgpn->lopnStyle > PS_INSIDEFRAME) return 0;
-
-  hpen = PENOBJ_AllocPen();
-  if (!hpen) return 0;
+   if (LogPen->lopnStyle > PS_INSIDEFRAME)
+      return 0;
 
-  penPtr   = PENOBJ_LockPen( hpen );
-  ASSERT( penPtr );
+   hPen = PENOBJ_AllocPen();
+   if (!hPen)
+   {
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      DPRINT("Can't allocate pen\n");
+      return 0;
+   }
+
+   PenObject = PENOBJ_LockPen(hPen);  
+   PenObject->ptPenWidth = LogPen->lopnWidth;
+   PenObject->ulPenStyle = LogPen->lopnStyle;
+   PenObject->BrushAttr.lbColor = LogPen->lopnColor;
+   PenObject->BrushObject.iSolidColor = LogPen->lopnColor;
+   PenObject->flAttrs = GDIBRUSH_IS_OLDSTYLEPEN;
+   switch (LogPen->lopnStyle)
+   {
+      case PS_NULL:
+         PenObject->flAttrs |= GDIBRUSH_IS_NULL;
+         break;
+
+      case PS_SOLID:
+         PenObject->flAttrs |= GDIBRUSH_IS_SOLID;
+         break;
+
+      case PS_ALTERNATE:
+         PenObject->flAttrs |= GDIBRUSH_IS_BITMAP;
+         PenObject->hbmPattern = NtGdiCreateBitmap(8, 1, 1, 1, wPatternAlternate);
+         break;
+
+      default:
+         UNIMPLEMENTED;
+   }
 
-  penPtr->logpen.lopnStyle = lgpn->lopnStyle;
-  penPtr->logpen.lopnWidth = lgpn->lopnWidth;
-  penPtr->logpen.lopnColor = lgpn->lopnColor;
-  PENOBJ_UnlockPen( hpen );
+   PENOBJ_UnlockPen(hPen);
   
-  return hpen;
+   return hPen;
 }
 
-/******************************************************************************/
+/* PUBLIC FUNCTIONS ***********************************************************/
 
-HPEN
-STDCALL
-NtGdiCreatePen(INT PenStyle, INT Width, COLORREF Color)
+HPEN STDCALL
+NtGdiCreatePen(
+   INT PenStyle,
+   INT Width,
+   COLORREF Color)
 {
-  LOGPEN logpen;
+  LOGPEN LogPen;
 
-  logpen.lopnStyle = PenStyle;
-  logpen.lopnWidth.x = Width;
-  logpen.lopnWidth.y = 0;
-  logpen.lopnColor = Color;
+  LogPen.lopnStyle = PenStyle;
+  LogPen.lopnWidth.x = Width;
+  LogPen.lopnWidth.y = 0;
+  LogPen.lopnColor = Color;
 
-  return IntGdiCreatePenIndirect(&logpen);
+  return IntGdiCreatePenIndirect(&LogPen);
 }
 
-HPEN
-STDCALL
-NtGdiCreatePenIndirect(CONST PLOGPEN lgpn)
+HPEN STDCALL
+NtGdiCreatePenIndirect(CONST PLOGPEN LogPen)
 {
-  LOGPEN   Safelgpn;
-  NTSTATUS Status;
+   LOGPEN SafeLogPen;
+   NTSTATUS Status;
   
-  Status = MmCopyFromCaller(&Safelgpn, lgpn, sizeof(LOGPEN));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return 0;
-  }
+   Status = MmCopyFromCaller(&SafeLogPen, LogPen, sizeof(LOGPEN));
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return 0;
+   }
   
-  return IntGdiCreatePenIndirect(&Safelgpn);
+   return IntGdiCreatePenIndirect(&SafeLogPen);
 }
 
-HPEN
-STDCALL
-NtGdiExtCreatePen(DWORD  PenStyle,
-                       DWORD  Width,
-                       CONST PLOGBRUSH  lb,
-                       DWORD  StyleCount,
-                       CONST PDWORD  Style)
+HPEN STDCALL
+NtGdiExtCreatePen(
+   DWORD PenStyle,
+   DWORD Width,
+   CONST PLOGBRUSH LogBrush,
+   DWORD StyleCount,
+   CONST PDWORD Style)
 {
-  UNIMPLEMENTED;
+   UNIMPLEMENTED;
 }
+
 /* EOF */

reactos/subsys/win32k/objects
region.c 1.46 -> 1.47
diff -u -r1.46 -r1.47
--- region.c	3 Apr 2004 20:36:56 -0000	1.46
+++ region.c	5 Apr 2004 21:26:25 -0000	1.47
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: region.c,v 1.46 2004/04/03 20:36:56 gvg Exp $ */
+/* $Id: region.c,v 1.47 2004/04/05 21:26:25 navaraf Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <ddk/ntddk.h>
@@ -2005,7 +2005,7 @@
   PROSRGNDATA visrgn;
   CLIPOBJ* ClipRegion;
   BOOL bRet = FALSE;
-  PBRUSHOBJ pBrush;
+  PGDIBRUSHOBJ pBrush;
   POINTL BrushOrigin;
   SURFOBJ	*SurfObj;
 
@@ -2048,7 +2048,7 @@
 
   bRet = IntEngPaint(SurfObj,
 	 ClipRegion,
-	 pBrush,
+	 &pBrush->BrushObject,
 	 &BrushOrigin,
 	 0xFFFF);//FIXME:don't know what to put here
 

reactos/subsys/win32k/objects
text.c 1.87 -> 1.88
diff -u -r1.87 -r1.88
--- text.c	4 Apr 2004 15:28:43 -0000	1.87
+++ text.c	5 Apr 2004 21:26:25 -0000	1.88
@@ -22,12 +22,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: text.c,v 1.87 2004/04/04 15:28:43 gvg Exp $ */
+/* $Id: text.c,v 1.88 2004/04/05 21:26:25 navaraf Exp $ */
 
 
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <ddk/ntddk.h>
+#include <ddk/winddi.h>
 #include <napi/win32.h>
 #include <internal/safe.h>
 #include <win32k/brush.h>
@@ -1493,9 +1494,9 @@
    RECTL DestRect, MaskRect;
    POINTL SourcePoint, BrushOrigin;
    HBRUSH hBrushFg = NULL;
-   PBRUSHOBJ BrushFg = NULL;
+   PGDIBRUSHOBJ BrushFg = NULL;
    HBRUSH hBrushBg = NULL;
-   PBRUSHOBJ BrushBg = NULL;
+   PGDIBRUSHOBJ BrushBg = NULL;
    HBITMAP HSourceGlyph;
    PSURFOBJ SourceGlyphSurf;
    SIZEL bitSize;
@@ -1638,7 +1639,7 @@
          &DestRect,
          &SourcePoint,
          &SourcePoint,
-         BrushBg,
+         &BrushBg->BrushObject,
          &BrushOrigin,
          PATCOPY);
       fuOptions &= ~ETO_OPAQUE;
@@ -1799,7 +1800,7 @@
             &DestRect,
             &SourcePoint,
             &SourcePoint,
-            BrushBg,
+            &BrushBg->BrushObject,
             &BrushOrigin,
             PATCOPY);
          BackgroundLeft = DestRect.right;
@@ -1838,7 +1839,7 @@
          &DestRect,
          &SourcePoint,
          (PPOINTL)&MaskRect,
-         BrushFg,
+         &BrushFg->BrushObject,
          &BrushOrigin);
 
       EngDeleteSurface(HSourceGlyph);
@@ -2578,6 +2579,7 @@
 {
   COLORREF  oldColor;
   PDC  dc = DC_LockDc(hDC);
+  HBRUSH hBrush;
 
   if (!dc)
   {
@@ -2586,7 +2588,9 @@
 
   oldColor = dc->w.textColor;
   dc->w.textColor = color;
+  hBrush = dc->w.hBrush;
   DC_UnlockDc( hDC );
+  NtGdiSelectObject(hDC, hBrush);
   return  oldColor;
 }
 
CVSspam 0.2.8