Evgeniy Boltik <bstsoft AT narod DOT ru>
authorMatthias Kupfer <mkupfer@reactos.org>
Wed, 4 Mar 2009 16:25:22 +0000 (16:25 +0000)
committerMatthias Kupfer <mkupfer@reactos.org>
Wed, 4 Mar 2009 16:25:22 +0000 (16:25 +0000)
- Fix if param Brush == NULL.
- See issue #4220 for details.

svn path=/trunk/; revision=39870

reactos/subsystems/win32/win32k/dib/dib1bpp.c
reactos/subsystems/win32/win32k/dib/dib24bpp.c
reactos/subsystems/win32/win32k/dib/dib4bpp.c
reactos/subsystems/win32/win32k/eng/bitblt.c
reactos/tools/gendib/gendib.c

index 5093e5c..11316b4 100644 (file)
@@ -369,7 +369,8 @@ DIB_1BPP_BitBlt(PBLTINFO BltInfo)
       else
       {
          /* FIXME: Shouldn't it be expanded? */
-         Pattern = BltInfo->Brush->iSolidColor;
+         if (BltInfo->Brush)
+            Pattern = BltInfo->Brush->iSolidColor;
       }
    }
 
index d3c60d4..a574004 100644 (file)
@@ -263,7 +263,8 @@ DIB_24BPP_BitBlt(PBLTINFO BltInfo)
       }
       else
       {
-         Pattern = BltInfo->Brush->iSolidColor;
+         if (BltInfo->Brush)
+            Pattern = BltInfo->Brush->iSolidColor;
       }
    }
 
index 7e9b81d..420648f 100644 (file)
@@ -271,7 +271,8 @@ DIB_4BPP_BitBlt(PBLTINFO BltInfo)
       }
       else
       {
-         Pattern = ExpandSolidColor[BltInfo->Brush->iSolidColor];
+         if (BltInfo->Brush)
+           Pattern = ExpandSolidColor[BltInfo->Brush->iSolidColor];
       }
    }
 
index 4e711b3..0e487af 100644 (file)
@@ -106,7 +106,7 @@ BltMask(SURFOBJ* Dest,
     dx = DestRect->right  - DestRect->left;
     dy = DestRect->bottom - DestRect->top;
 
-    if (Brush->iSolidColor == 0xFFFFFFFF)
+    if (Brush && Brush->iSolidColor == 0xFFFFFFFF)
     {
         GdiBrush = CONTAINING_RECORD(
                        Brush,
@@ -140,13 +140,13 @@ BltMask(SURFOBJ* Dest,
                 if (psurfPattern == NULL)
                 {
                     DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
-                        Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
+                        Dest, DestRect->left + i, DestRect->top + j, Brush ? Brush->iSolidColor : 0);
                 }
                 else
                 {
                     DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
                         Dest, DestRect->left + i, DestRect->top + j,
-                        DIB_GetSource(psoPattern, (DestRect->left + i) % PatternWidth, PatternY, GdiBrush->XlateObject));
+                        DIB_GetSource(psoPattern, (DestRect->left + i) % PatternWidth, PatternY, GdiBrush ? GdiBrush->XlateObject : NULL));
                 }
             }
             c8++;
@@ -180,7 +180,7 @@ BltPatCopy(SURFOBJ* Dest,
     // These functions are assigned if we're working with a DIB
     // The assigned functions depend on the bitsPerPixel of the DIB
 
-    DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_ColorFill(Dest, DestRect, Brush->iSolidColor);
+    DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_ColorFill(Dest, DestRect, Brush ? Brush->iSolidColor : 0);
 
     return TRUE;
 }
@@ -218,7 +218,7 @@ CallDibBitBlt(SURFOBJ* OutputObj,
     BltInfo.Rop4 = Rop4;
 
     /* Pattern brush */
-    if (ROP4_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
+    if (ROP4_USES_PATTERN(Rop4) && Brush && Brush->iSolidColor == 0xFFFFFFFF)
     {
         GdiBrush = CONTAINING_RECORD(Brush, GDIBRUSHINST, BrushObject);
         if ((psurfPattern = SURFACE_LockSurface(GdiBrush->GdiBrushObject->hbmPattern)))
@@ -488,7 +488,7 @@ EngBitBlt(SURFOBJ *DestObj,
     }
     else if (ROP3_TO_ROP4(PATCOPY) == Rop4)
     {
-        if (Brush->iSolidColor == 0xFFFFFFFF)
+        if (Brush && Brush->iSolidColor == 0xFFFFFFFF)
             BltRectFunc = CallDibBitBlt;
         else
             BltRectFunc = BltPatCopy;
@@ -1547,7 +1547,7 @@ AlphaBltMask(SURFOBJ* psoDest,
 
     if (Mask != NULL)
     {
-        BrushColor = XLATEOBJ_iXlate(SrcColorTranslation, Brush->iSolidColor);
+        BrushColor = XLATEOBJ_iXlate(SrcColorTranslation, Brush ? Brush->iSolidColor : 0);
         r = (int)GetRValue(BrushColor);
         g = (int)GetGValue(BrushColor);
         b = (int)GetBValue(BrushColor);
@@ -1563,7 +1563,7 @@ AlphaBltMask(SURFOBJ* psoDest,
                     if (*lMask == 0xff)
                     {
                         DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_PutPixel(
-                            psoDest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
+                            psoDest, DestRect->left + i, DestRect->top + j, Brush ? Brush->iSolidColor : 0);
                     }
                     else
                     {
index fe594dc..73c6678 100644 (file)
@@ -877,6 +877,12 @@ CreatePrimitive(FILE *Out, unsigned Bpp, PROPINFO RopInfo)
             {
               if (0 == Partial)
                 {
+                  Output(Out, "if (!BltInfo->Brush)\n");
+                  Output(Out, "{\n");
+                  Output(Out, "Pattern = 0;\n");
+                  Output(Out, "}\n");
+                  Output(Out, "else\n");
+                  Output(Out, "{\n");
                   Output(Out, "Pattern = BltInfo->Brush->iSolidColor");
                 }
               else
@@ -887,6 +893,7 @@ CreatePrimitive(FILE *Out, unsigned Bpp, PROPINFO RopInfo)
               if (32 / Bpp <= Partial + 1)
                 {
                   Output(Out, ";\n");
+                  Output(Out, "}\n");
                 }
               else
                 {