Commit in reactos/subsys/win32k/dib on MAIN
dib16bpp.c+21-181.25 -> 1.26
dib1bpp.c+28-291.19 -> 1.20
dib24bpp.c+17-101.21 -> 1.22
dib32bpp.c+19-151.21 -> 1.22
dib4bpp.c+28-241.25 -> 1.26
dib8bpp.c+23-211.19 -> 1.20
+136-117
6 modified files
1. fixed crash in 1bpp blt code that was caused by an uninitialized variable. 
2. speed improvements for patterned brushes

reactos/subsys/win32k/dib
dib16bpp.c 1.25 -> 1.26
diff -u -r1.25 -r1.26
--- dib16bpp.c	6 Apr 2004 23:05:36 -0000	1.25
+++ dib16bpp.c	7 Apr 2004 10:19:34 -0000	1.26
@@ -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: dib16bpp.c,v 1.25 2004/04/06 23:05:36 weiden Exp $ */
+/* $Id: dib16bpp.c,v 1.26 2004/04/07 10:19:34 weiden Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -283,11 +283,11 @@
 {
    ULONG X, Y;
    ULONG SourceX, SourceY;
-   ULONG wd, Dest, Source, Pattern = 0;
+   ULONG wd, Dest, Source, Pattern = 0, PatternY;
    PULONG DestBits;
    BOOL UsesSource;
-   BOOL UsesPattern;
-   LONG RoundedRight;
+   BOOL UsesPattern, CalcPattern;
+   ULONG RoundedRight;
    /* Pattern brushes */
    PGDIBRUSHOBJ GdiBrush;
    HBITMAP PatternSurface = NULL;
@@ -309,11 +309,11 @@
    UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
    UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
       
-   if (UsesPattern)
+   if ((CalcPattern = UsesPattern))
    {
       if (Brush == NULL)
       {
-         UsesPattern = FALSE;
+         UsesPattern = CalcPattern = FALSE;
       } else
       if (Brush->iSolidColor == 0xFFFFFFFF)
       {
@@ -331,6 +331,13 @@
          PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
          PatternWidth = PatternObj->sizlBitmap.cx;
          PatternHeight = PatternObj->sizlBitmap.cy;
+         CalcPattern = TRUE;
+      }
+      else
+      {
+         CalcPattern = FALSE;
+         Pattern = (Brush->iSolidColor & 0xFFFF) |
+                    ((Brush->iSolidColor & 0xFFFF) << 16);
       }
    }
    
@@ -345,6 +352,10 @@
    for (Y = DestRect->top; Y < DestRect->bottom; Y++)
    {
       SourceX = SourcePoint->x;
+      
+      if(CalcPattern)
+        PatternY = Y % PatternHeight;
+      
       for (X = DestRect->left; X < RoundedRight; X += 2, DestBits++, SourceX += 2)
       {
          Dest = *DestBits;
@@ -355,18 +366,10 @@
             Source |= DIB_GetSource(SourceSurf, SourceGDI, SourceX + 1, SourceY, ColorTranslation) << 16;
          }
 
-         if (UsesPattern)
+         if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
 	 {
-            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);
-            }
+            Pattern = (DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack);
+            Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + 1) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 16;
          }
 
          *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
@@ -384,7 +387,7 @@
          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 % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
             else
                Pattern = Brush->iSolidColor & 0xFFFF;
          }				

reactos/subsys/win32k/dib
dib1bpp.c 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- dib1bpp.c	6 Apr 2004 21:19:44 -0000	1.19
+++ dib1bpp.c	7 Apr 2004 10:19:34 -0000	1.20
@@ -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: dib1bpp.c,v 1.19 2004/04/06 21:19:44 navaraf Exp $ */
+/* $Id: dib1bpp.c,v 1.20 2004/04/07 10:19:34 weiden Exp $ */
 
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -354,11 +354,11 @@
 	XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
    ULONG X, Y, SourceX, SourceY, k;
-   ULONG Dest, Source, Pattern;
+   ULONG Dest, Source, Pattern = 0;
    PULONG DestBits;
    BOOL UsesSource;
-   BOOL UsesPattern;
-   LONG RoundedRight;
+   BOOL UsesPattern, CalcPattern;
+   ULONG RoundedRight;
    BYTE NoBits;
    /* Pattern brushes */
    PGDIBRUSHOBJ GdiBrush;
@@ -378,11 +378,14 @@
          ColorTranslation);
    }
 
-   if (UsesPattern)
+   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+
+   if ((CalcPattern = UsesPattern))
    {
       if (Brush == NULL)
       {
-         UsesPattern = FALSE;
+         UsesPattern = CalcPattern = FALSE;
       } else
       if (Brush->iSolidColor == 0xFFFFFFFF)
       {
@@ -400,22 +403,32 @@
          PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
          PatternWidth = PatternObj->sizlBitmap.cx;
          PatternHeight = PatternObj->sizlBitmap.cy;
+         
+         CalcPattern = TRUE;
+      }
+      else
+      {
+         CalcPattern = FALSE;
+         Pattern = Brush->iSolidColor;
       }
    }
 
-   UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-   UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
    RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x31);
    SourceY = SourcePoint->y;
-
+   
    for (Y = DestRect->top; Y < DestRect->bottom; Y++)
    {
+      ULONG PatternY;
+      
       SourceX = SourcePoint->x;
       DestBits = (PULONG)(
          DestSurf->pvScan0 +
          (DestRect->left >> 3) +
          Y * DestSurf->lDelta);
 
+      if(CalcPattern)
+        PatternY = Y % PatternHeight;
+
       X = DestRect->left;
       if (X & 31)
       {
@@ -431,18 +444,11 @@
                Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k, SourceY, ColorTranslation) << (31 - k));
          }
 
-         if (UsesPattern)
+         if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
          {
-            if (Brush->iSolidColor == 0xFFFFFFFF)
-            {
-               Pattern = 0;
-               for (k = 31 - NoBits; k < NoBits; k++)
-                  Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k) % PatternWidth, Y % PatternHeight) << (31 - k));
-            }
-            else
-            {
-               Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
-            }
+            Pattern = 0;
+            for (k = 31 - NoBits; k < NoBits; k++)
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k) % PatternWidth, PatternY) << (31 - k));
          }
 
          Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
@@ -484,10 +490,6 @@
                   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);	    
@@ -506,12 +508,9 @@
                Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
             }
 
-            if (UsesPattern)
+            if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
             {
-               if (Brush->iSolidColor == 0xFFFFFFFF)
-                  Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight);
-               else
-                  Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
+               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight);
             }
 
             DIB_1BPP_PutPixel(DestSurf, X, Y, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);

reactos/subsys/win32k/dib
dib24bpp.c 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- dib24bpp.c	6 Apr 2004 23:05:36 -0000	1.21
+++ dib24bpp.c	7 Apr 2004 10:19:34 -0000	1.22
@@ -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: dib24bpp.c,v 1.21 2004/04/06 23:05:36 weiden Exp $ */
+/* $Id: dib24bpp.c,v 1.22 2004/04/07 10:19:34 weiden Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -255,10 +255,10 @@
 {
    ULONG X, Y;
    ULONG SourceX, SourceY;
-   ULONG Dest, Source, Pattern;
+   ULONG Dest, Source, Pattern = 0, PatternY;
    PBYTE DestBits;
    BOOL UsesSource;
-   BOOL UsesPattern;
+   BOOL UsesPattern, CalcPattern;
    /* Pattern brushes */
    PGDIBRUSHOBJ GdiBrush;
    HBITMAP PatternSurface = NULL;
@@ -280,11 +280,11 @@
    UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
    UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
       
-   if (UsesPattern)
+   if ((CalcPattern = UsesPattern))
    {
       if (Brush == NULL)
       {
-         UsesPattern = FALSE;
+         UsesPattern = CalcPattern = FALSE;
       } else
       if (Brush->iSolidColor == 0xFFFFFFFF)
       {
@@ -302,6 +302,13 @@
          PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
          PatternWidth = PatternObj->sizlBitmap.cx;
          PatternHeight = PatternObj->sizlBitmap.cy;
+         
+         CalcPattern = TRUE;
+      }
+      else
+      {
+         CalcPattern = FALSE;
+         Pattern = Brush->iSolidColor;
       }
    }
 
@@ -314,6 +321,10 @@
    for (Y = DestRect->top; Y < DestRect->bottom; Y++)
    {
       SourceX = SourcePoint->x;
+      
+      if(CalcPattern)
+        PatternY = Y % PatternHeight;
+      
       for (X = DestRect->left; X < DestRect->right; X++, DestBits += 3, SourceX++)
       {
          Dest = *((PUSHORT)DestBits) + (*(DestBits + 2) << 16);
@@ -327,11 +338,7 @@
 	 {
             if (Brush->iSolidColor == 0xFFFFFFFF)
             {
-               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
-            }
-            else
-            {
-               Pattern = Brush->iSolidColor;
+               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
             }
          }
 

reactos/subsys/win32k/dib
dib32bpp.c 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- dib32bpp.c	6 Apr 2004 23:05:36 -0000	1.21
+++ dib32bpp.c	7 Apr 2004 10:19:34 -0000	1.22
@@ -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: dib32bpp.c,v 1.21 2004/04/06 23:05:36 weiden Exp $ */
+/* $Id: dib32bpp.c,v 1.22 2004/04/07 10:19:34 weiden Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -304,10 +304,10 @@
 {
    ULONG X, Y;
    ULONG SourceX, SourceY;
-   ULONG Dest, Source, Pattern, wd;
+   ULONG Dest, Source, Pattern = 0, wd;
    PULONG DestBits;
    BOOL UsesSource;
-   BOOL UsesPattern;
+   BOOL UsesPattern, CalcPattern;
    /* Pattern brushes */
    PGDIBRUSHOBJ GdiBrush;
    HBITMAP PatternSurface = NULL;
@@ -329,11 +329,11 @@
    UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
    UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
       
-   if (UsesPattern)
+   if ((CalcPattern = UsesPattern))
    {
       if (Brush == NULL)
       {
-         UsesPattern = FALSE;
+         UsesPattern = CalcPattern = FALSE;
       } else
       if (Brush->iSolidColor == 0xFFFFFFFF)
       {
@@ -351,6 +351,13 @@
          PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
          PatternWidth = PatternObj->sizlBitmap.cx;
          PatternHeight = PatternObj->sizlBitmap.cy;
+         
+         CalcPattern = TRUE;
+      }
+      else
+      {
+         CalcPattern = FALSE;
+         Pattern = Brush->iSolidColor;
       }
    }
 
@@ -363,8 +370,12 @@
    
    for (Y = DestRect->top; Y < DestRect->bottom; Y++)
    {
+      ULONG PatternY;
       SourceX = SourcePoint->x;
-
+      
+      if(CalcPattern)
+        PatternY = Y % PatternHeight;
+      
       for (X = DestRect->left; X < DestRect->right; X++, DestBits++, SourceX++)
       {
          Dest = *DestBits;
@@ -374,16 +385,9 @@
             Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation);
          }
 
-         if (UsesPattern)
+         if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
 	 {
-            if (Brush->iSolidColor == 0xFFFFFFFF)
-            {
-               Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
-            }
-            else
-            {
-               Pattern = Brush->iSolidColor;
-            }
+            Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
          }
 
          *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);

reactos/subsys/win32k/dib
dib4bpp.c 1.25 -> 1.26
diff -u -r1.25 -r1.26
--- dib4bpp.c	6 Apr 2004 17:54:32 -0000	1.25
+++ dib4bpp.c	7 Apr 2004 10:19:34 -0000	1.26
@@ -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: dib4bpp.c,v 1.25 2004/04/06 17:54:32 weiden Exp $ */
+/* $Id: dib4bpp.c,v 1.26 2004/04/07 10:19:34 weiden Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -239,10 +239,10 @@
 		XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
    LONG i, j, sx, sy;
-   ULONG Dest, Source, Pattern;
+   ULONG Dest, Source, Pattern = 0, PatternY;
    PULONG DestBits;
    BOOL UsesSource;
-   BOOL UsesPattern;
+   BOOL UsesPattern, CalcPattern;
    LONG RoundedRight;
    /* Pattern brushes */
    PGDIBRUSHOBJ GdiBrush;
@@ -284,11 +284,11 @@
    UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
    UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
 
-   if (UsesPattern)
+   if ((CalcPattern = UsesPattern))
    {
       if (Brush == NULL)
       {
-         UsesPattern = FALSE;
+         UsesPattern = CalcPattern = FALSE;
       } else
       if (Brush->iSolidColor == 0xFFFFFFFF)
       {
@@ -306,6 +306,12 @@
          PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
          PatternWidth = PatternObj->sizlBitmap.cx;
          PatternHeight = PatternObj->sizlBitmap.cy;
+         CalcPattern = TRUE;
+      }
+      else
+      {
+         CalcPattern = FALSE;
+         Pattern = Brush->iSolidColor & 0xF;
       }
    }
    
@@ -318,6 +324,9 @@
       sx = SourcePoint->x;
       i = DestRect->left;
 
+      if(CalcPattern)
+        PatternY = j % PatternHeight;
+
       if (i & 0x1)
       {
          Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
@@ -327,12 +336,9 @@
             Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
          }
 
-         if (UsesPattern)
+         if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
          {
-            if (Brush->iSolidColor == 0xFFFFFFFF)
-               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
-            else
-               Pattern = Brush->iSolidColor & 0xF;
+            Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
          }				
 
          DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
@@ -361,18 +367,19 @@
          {
             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) << 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;
+               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 1) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 4;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 2) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 8;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 3) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 12;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 4) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 16;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 5) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 20;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 6) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 24;
+               Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 7) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 28;
             }
             else
             {
-               Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
+               *DestBits = DIB_DoRop(Rop4, Dest, Source, ExpandSolidColor[Brush->iSolidColor & 0xF]);
+               continue;
             }
          }
          *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
@@ -386,12 +393,9 @@
          {
             Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
          }
-         if (UsesPattern)
+         if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
          {
-            if (Brush->iSolidColor == 0xFFFFFFFF)
-               Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
-            else
-               Pattern = Brush->iSolidColor & 0xF;
+            Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack;
          }				
          DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
       }	 

reactos/subsys/win32k/dib
dib8bpp.c 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- dib8bpp.c	6 Apr 2004 23:05:36 -0000	1.19
+++ dib8bpp.c	7 Apr 2004 10:19:34 -0000	1.20
@@ -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: dib8bpp.c,v 1.19 2004/04/06 23:05:36 weiden Exp $ */
+/* $Id: dib8bpp.c,v 1.20 2004/04/07 10:19:34 weiden Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -277,10 +277,10 @@
 		 XLATEOBJ *ColorTranslation, ULONG Rop4)
 {
    LONG i, j, k, sx, sy;
-   ULONG Dest, Source, Pattern;
+   ULONG Dest, Source, Pattern = 0, PatternY;
    PULONG DestBits;
    BOOL UsesSource;
-   BOOL UsesPattern;
+   BOOL UsesPattern, CalcPattern;
    LONG RoundedRight;
    /* Pattern brushes */
    PGDIBRUSHOBJ GdiBrush;
@@ -303,11 +303,11 @@
    UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
    UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
 
-   if (UsesPattern)
+   if ((CalcPattern = UsesPattern))
    {
       if (Brush == NULL)
       {
-         UsesPattern = FALSE;
+         UsesPattern = CalcPattern = FALSE;
       } else
       if (Brush->iSolidColor == 0xFFFFFFFF)
       {
@@ -325,6 +325,15 @@
          PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
          PatternWidth = PatternObj->sizlBitmap.cx;
          PatternHeight = PatternObj->sizlBitmap.cy;
+         CalcPattern = TRUE;
+      }
+      else
+      {
+         CalcPattern = FALSE;
+         Pattern = (Brush->iSolidColor & 0xFF) |
+                    ((Brush->iSolidColor & 0xFF) << 8) |
+                    ((Brush->iSolidColor & 0xFF) << 16) |
+                    ((Brush->iSolidColor & 0xFF) << 24);
       }
    }
    
@@ -336,6 +345,9 @@
       sx = SourcePoint->x;
       DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta);
 
+      if(CalcPattern)
+        PatternY = j % PatternHeight;
+
       for (i = DestRect->left; i < RoundedRight; i += 4, DestBits++)
       {
          Dest = *DestBits;
@@ -347,22 +359,12 @@
                Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8));
          }
 
-         if (UsesPattern)
+         if (UsesPattern && (Brush->iSolidColor == 0xFFFFFFFF))
          {
-            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);
-            }
+            Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
+            Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 1) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 8;
+            Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 2) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 16;
+            Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 3) % PatternWidth, PatternY) ? GdiBrush->crFore : GdiBrush->crBack) << 24;
          }
          *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);	    
       }
@@ -380,7 +382,7 @@
             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 % PatternWidth,PatternY) ? GdiBrush->crFore : GdiBrush->crBack;
                else
                   Pattern = Brush->iSolidColor & 0xFF;
             }
CVSspam 0.2.8