Pass ROP4 instead of ROP3 to drivers
Modified: trunk/reactos/drivers/video/displays/vga/objects/bitblt.c
Modified: trunk/reactos/drivers/video/displays/vga/objects/bitblt.h
Modified: trunk/reactos/subsys/win32k/dib/dib.c
Modified: trunk/reactos/subsys/win32k/dib/dib.h
Modified: trunk/reactos/subsys/win32k/dib/dib16bpp.c
Modified: trunk/reactos/subsys/win32k/dib/dib1bpp.c
Modified: trunk/reactos/subsys/win32k/dib/dib24bpp.c
Modified: trunk/reactos/subsys/win32k/dib/dib32bpp.c
Modified: trunk/reactos/subsys/win32k/dib/dib4bpp.c
Modified: trunk/reactos/subsys/win32k/dib/dib8bpp.c
Modified: trunk/reactos/subsys/win32k/eng/bitblt.c
Modified: trunk/reactos/subsys/win32k/eng/copybits.c
Modified: trunk/reactos/subsys/win32k/eng/gradient.c
Modified: trunk/reactos/subsys/win32k/eng/mouse.c
Modified: trunk/reactos/subsys/win32k/eng/transblt.c
Modified: trunk/reactos/subsys/win32k/include/inteng.h
Modified: trunk/reactos/subsys/win32k/objects/bitmaps.c
Modified: trunk/reactos/subsys/win32k/objects/brush.c
Modified: trunk/reactos/subsys/win32k/objects/fillshap.c
Modified: trunk/reactos/subsys/win32k/objects/text.c

Modified: trunk/reactos/drivers/video/displays/vga/objects/bitblt.c
--- trunk/reactos/drivers/video/displays/vga/objects/bitblt.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/drivers/video/displays/vga/objects/bitblt.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -188,20 +188,21 @@
     }
 
   /* Punt pattern fills. */
-  if ((Rop4 == PATCOPY || Rop4 == PATINVERT) && 
+  if ((GET_OPINDEX_FROM_ROP4(Rop4) == GET_OPINDEX_FROM_ROP3(PATCOPY)
+       || GET_OPINDEX_FROM_ROP4(Rop4) == GET_OPINDEX_FROM_ROP3(PATINVERT)) && 
       Brush->iSolidColor == 0xFFFFFFFF)
     {
       return(FALSE);
     }
 
   /* Get the brush colour. */
-  switch (Rop4)
+  switch (GET_OPINDEX_FROM_ROP4(Rop4))
     {
-    case PATCOPY: SolidColor = Brush->iSolidColor; break;
-    case PATINVERT: SolidColor = Brush->iSolidColor; RasterOp = VGA_XOR; break;
-    case WHITENESS: SolidColor = 0xF; break;
-    case BLACKNESS: SolidColor = 0x0; break;
-    case DSTINVERT: SolidColor = 0xF; RasterOp = VGA_XOR; break;
+    case GET_OPINDEX_FROM_ROP3(PATCOPY): SolidColor = Brush->iSolidColor; break;
+    case GET_OPINDEX_FROM_ROP3(PATINVERT): SolidColor = Brush->iSolidColor; RasterOp = VGA_XOR; break;
+    case GET_OPINDEX_FROM_ROP3(WHITENESS): SolidColor = 0xF; break;
+    case GET_OPINDEX_FROM_ROP3(BLACKNESS): SolidColor = 0x0; break;
+    case GET_OPINDEX_FROM_ROP3(DSTINVERT): SolidColor = 0xF; RasterOp = VGA_XOR; break;
     }
 
   /* Select write mode 3. */
@@ -398,15 +399,15 @@
 
   switch (rop4)
     {
-    case BLACKNESS:
-    case PATCOPY:
-    case WHITENESS:
-    case PATINVERT:
-    case DSTINVERT:
+    case ROP3_TO_ROP4(BLACKNESS):
+    case ROP3_TO_ROP4(PATCOPY):
+    case ROP3_TO_ROP4(WHITENESS):
+    case ROP3_TO_ROP4(PATINVERT):
+    case ROP3_TO_ROP4(DSTINVERT):
       BltRectFunc = VGADDI_BltBrush;
       break;
 
-    case SRCCOPY:
+    case ROP3_TO_ROP4(SRCCOPY):
       if (BMF_4BPP == Source->iBitmapFormat && BMF_4BPP == Dest->iBitmapFormat)
 	{
 	  BltRectFunc = VGADDI_BltSrc;
@@ -417,7 +418,7 @@
 	}
       break;
 
-    case 0xAACC:
+    case R4_MASK:
       BltRectFunc = VGADDI_BltMask;
       break;
 

Modified: trunk/reactos/drivers/video/displays/vga/objects/bitblt.h
--- trunk/reactos/drivers/video/displays/vga/objects/bitblt.h	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/drivers/video/displays/vga/objects/bitblt.h	2005-02-06 18:27:06 UTC (rev 13445)
@@ -20,3 +20,10 @@
 #define BB_TARGET_ONLY   0x0002
 #define BB_SOURCE_COPY   0x0004
 #define BB_PATTERN_COPY  0x0008
+
+#define GET_OPINDEX_FROM_ROP3(Rop3) (((Rop3) >> 16) & 0xff)
+#define GET_OPINDEX_FROM_ROP4(Rop4) ((Rop4) & 0xff)
+#define ROP3_TO_ROP4(Rop3) ((((Rop3) >> 8) & 0xff00) | (((Rop3) >> 16) & 0x00ff))
+#define R3_OPINDEX_SRCCOPY 0xcc
+#define R3_OPINDEX_NOOP 0xaa
+#define R4_MASK ((R3_OPINDEX_NOOP << 8) | R3_OPINDEX_SRCCOPY)

Modified: trunk/reactos/subsys/win32k/dib/dib.c
--- trunk/reactos/subsys/win32k/dib/dib.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -156,25 +156,25 @@
   /* Optimized code for the various named rop codes. */
   switch (Rop)
     {
-    case BLACKNESS:   return(0);
-    case NOTSRCERASE: return(~(Dest | Source));
-    case NOTSRCCOPY:  return(~Source);
-    case SRCERASE:    return((~Dest) & Source);
-    case DSTINVERT:   return(~Dest);
-    case PATINVERT:   return(Dest ^ Pattern);
-    case SRCINVERT:   return(Dest ^ Source);
-    case SRCAND:      return(Dest & Source);
-    case MERGEPAINT:  return(Dest & (~Source));
-    case SRCPAINT:    return(Dest | Source);
-    case MERGECOPY:   return(Source & Pattern);
-    case SRCCOPY:     return(Source);
-    case PATCOPY:     return(Pattern);
-    case PATPAINT:    return(Dest | (~Source) | Pattern);
-    case WHITENESS:   return(0xFFFFFFFF);
+    case ROP3_TO_ROP4(BLACKNESS):   return(0);
+    case ROP3_TO_ROP4(NOTSRCERASE): return(~(Dest | Source));
+    case ROP3_TO_ROP4(NOTSRCCOPY):  return(~Source);
+    case ROP3_TO_ROP4(SRCERASE):    return((~Dest) & Source);
+    case ROP3_TO_ROP4(DSTINVERT):   return(~Dest);
+    case ROP3_TO_ROP4(PATINVERT):   return(Dest ^ Pattern);
+    case ROP3_TO_ROP4(SRCINVERT):   return(Dest ^ Source);
+    case ROP3_TO_ROP4(SRCAND):      return(Dest & Source);
+    case ROP3_TO_ROP4(MERGEPAINT):  return(Dest & (~Source));
+    case ROP3_TO_ROP4(SRCPAINT):    return(Dest | Source);
+    case ROP3_TO_ROP4(MERGECOPY):   return(Source & Pattern);
+    case ROP3_TO_ROP4(SRCCOPY):     return(Source);
+    case ROP3_TO_ROP4(PATCOPY):     return(Pattern);
+    case ROP3_TO_ROP4(PATPAINT):    return(Dest | (~Source) | Pattern);
+    case ROP3_TO_ROP4(WHITENESS):   return(0xFFFFFFFF);
     }
   /* Expand the ROP operation to all four bytes */
-  Rop &= 0x00FF0000;
-  Rop = (Rop << 8) | (Rop) | (Rop >> 8) | (Rop >> 16);
+  Rop &= 0xFF;
+  Rop |= (Rop << 24) | (Rop << 16) | (Rop << 8);
   /* Do the operation on four bits simultaneously. */
   Result = 0;
   for (i = 0; i < 8; i++)

Modified: trunk/reactos/subsys/win32k/dib/dib.h
--- trunk/reactos/subsys/win32k/dib/dib.h	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib.h	2005-02-06 18:27:06 UTC (rev 13445)
@@ -99,9 +99,6 @@
 BOOLEAN DIB_32BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_32BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
 
-#define ROP_USES_SOURCE(Rop4) (((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000))
-#define ROP_USES_PATTERN(Rop4) (((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000))
-
 extern unsigned char notmask[2];
 extern unsigned char altnotmask[2];
 #define MASK1BPP(x) (1<<(7-((x)&7)))

Modified: trunk/reactos/subsys/win32k/dib/dib16bpp.c
--- trunk/reactos/subsys/win32k/dib/dib16bpp.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib16bpp.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -309,8 +309,8 @@
    PULONG DestBits;
    ULONG RoundedRight;
 
-   UsesSource = ROP_USES_SOURCE(BltInfo->Rop4);
-   UsesPattern = ROP_USES_PATTERN(BltInfo->Rop4);  
+   UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+   UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);  
       
    RoundedRight = BltInfo->DestRect.right -
                   ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 0x1);

Modified: trunk/reactos/subsys/win32k/dib/dib1bpp.c
--- trunk/reactos/subsys/win32k/dib/dib1bpp.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib1bpp.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -349,8 +349,8 @@
    ULONG RoundedRight;
 /*   BYTE NoBits;*/
 
-   UsesSource = ROP_USES_SOURCE(BltInfo->Rop4);
-   UsesPattern = ROP_USES_PATTERN(BltInfo->Rop4);
+   UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+   UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
 
    RoundedRight = BltInfo->DestRect.right - 
                   ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 31);

Modified: trunk/reactos/subsys/win32k/dib/dib24bpp.c
--- trunk/reactos/subsys/win32k/dib/dib24bpp.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib24bpp.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -244,8 +244,8 @@
    BOOL UsesPattern;
    PBYTE DestBits;
 
-   UsesSource = ROP_USES_SOURCE(BltInfo->Rop4);
-   UsesPattern = ROP_USES_PATTERN(BltInfo->Rop4);
+   UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+   UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
       
    SourceY = BltInfo->SourcePoint.y;
    DestBits = (PBYTE)(

Modified: trunk/reactos/subsys/win32k/dib/dib32bpp.c
--- trunk/reactos/subsys/win32k/dib/dib32bpp.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib32bpp.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -293,8 +293,8 @@
    BOOL UsesPattern;
    PULONG DestBits;
 
-   UsesSource = ROP_USES_SOURCE(BltInfo->Rop4);
-   UsesPattern = ROP_USES_PATTERN(BltInfo->Rop4);
+   UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+   UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
 
    SourceY = BltInfo->SourcePoint.y;
    DestBits = (PULONG)(

Modified: trunk/reactos/subsys/win32k/dib/dib4bpp.c
--- trunk/reactos/subsys/win32k/dib/dib4bpp.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib4bpp.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -251,8 +251,8 @@
       0xFFFFFFFF /* 15 */,
    };
 
-   UsesSource = ROP_USES_SOURCE(BltInfo->Rop4);
-   UsesPattern = ROP_USES_PATTERN(BltInfo->Rop4);
+   UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+   UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
 
    SourceY = BltInfo->SourcePoint.y;
    RoundedRight = BltInfo->DestRect.right -

Modified: trunk/reactos/subsys/win32k/dib/dib8bpp.c
--- trunk/reactos/subsys/win32k/dib/dib8bpp.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/dib/dib8bpp.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -260,8 +260,8 @@
    PULONG DestBits;
    LONG RoundedRight;
 
-   UsesSource = ROP_USES_SOURCE(BltInfo->Rop4);
-   UsesPattern = ROP_USES_PATTERN(BltInfo->Rop4);
+   UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+   UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
 
    SourceY = BltInfo->SourcePoint.y;
    RoundedRight = BltInfo->DestRect.right -

Modified: trunk/reactos/subsys/win32k/eng/bitblt.c
--- trunk/reactos/subsys/win32k/eng/bitblt.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/eng/bitblt.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -213,7 +213,7 @@
    BltInfo.DestRect = *OutputRect;
    BltInfo.SourcePoint = *InputPoint;
 
-   if (Rop4 == SRCCOPY)
+   if (ROP3_TO_ROP4(SRCCOPY) == Rop4)
       return DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
 
    BltInfo.XlatePatternToDest = NULL;
@@ -222,7 +222,7 @@
    BltInfo.Rop4 = Rop4;
 
    /* Pattern brush */
-   if (ROP_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
+   if (ROP4_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
    {
       GdiBrush = CONTAINING_RECORD(Brush, GDIBRUSHINST, BrushObject);
       if((bmPattern = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern)))
@@ -291,9 +291,9 @@
   BOOL               UsesPattern;
   POINTL             AdjustedBrushOrigin;
 
-  UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
-  UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);
-  if (ROP_NOOP == Rop4)
+  UsesSource = ROP4_USES_SOURCE(Rop4);
+  UsesPattern = ROP4_USES_PATTERN(Rop4);
+  if (R4_NOOP == Rop4)
     {
     /* Copy destination onto itself: nop */
     return TRUE;
@@ -392,20 +392,16 @@
     clippingType = ClipRegion->iDComplexity;
   }
 
-  if (0xaacc == Rop4)
+  if (R4_MASK == Rop4)
     {
       BltRectFunc = BltMask;
     }
-  else if (PATCOPY == Rop4)
+  else if (ROP3_TO_ROP4(PATCOPY) == Rop4)
     {
-#if 0
-      BltRectFunc = BltPatCopy;
-#else
       if (Brush->iSolidColor == 0xFFFFFFFF)
         BltRectFunc = CallDibBitBlt;
       else
         BltRectFunc = BltPatCopy;
-#endif
     }
   else
     {
@@ -515,7 +511,7 @@
       InputClippedRect.top = DestRect->bottom;
       InputClippedRect.bottom = DestRect->top;
     }
-  UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+  UsesSource = ROP4_USES_SOURCE(Rop4);
   if (UsesSource)
     {
       if (NULL == SourcePoint || NULL == SourceSurf)
@@ -833,40 +829,41 @@
       
       tMask = Mask->pvScan0 + (SourcePoint->y * Mask->lDelta) + SourcePoint->x;
       for (j = 0; j < dy; j++)
-	{
-	  lMask = tMask;
-	  for (i = 0; i < dx; i++)
-	    {
-	      if (*lMask > 0)
-		{
-			if(*lMask == 0xff)
-			{
-				DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
-					Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
-			}
-			else
-			{
-				Background = DIB_GetSource(Dest, DestRect->left + i, DestRect->top + j, SrcColorTranslation);
+        {
+          lMask = tMask;
+          for (i = 0; i < dx; i++)
+            {
+              if (*lMask > 0)
+                {
+                  if (*lMask == 0xff)
+                    {
+                      DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
+                          Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
+                    }
+                  else
+                    {
+                      Background = DIB_GetSource(Dest, DestRect->left + i, DestRect->top + j,
+                                                 SrcColorTranslation);
 
-				NewColor = 
-				     RGB((*lMask * (r - GetRValue(Background)) >> 8) + GetRValue(Background),
-				         (*lMask * (g - GetGValue(Background)) >> 8) + GetGValue(Background),
-				         (*lMask * (b - GetBValue(Background)) >> 8) + GetBValue(Background));
-				
-				Background = XLATEOBJ_iXlate(ColorTranslation, NewColor);
-				DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
-					Dest, DestRect->left + i, DestRect->top + j, Background);
-			}
-		}
-		  lMask++;
-	    }
-	  tMask += Mask->lDelta;
-	}
+                      NewColor = 
+                          RGB((*lMask * (r - GetRValue(Background)) >> 8) + GetRValue(Background),
+                              (*lMask * (g - GetGValue(Background)) >> 8) + GetGValue(Background),
+                              (*lMask * (b - GetBValue(Background)) >> 8) + GetBValue(Background));
+
+                      Background = XLATEOBJ_iXlate(ColorTranslation, NewColor);
+                      DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
+                        Dest, DestRect->left + i, DestRect->top + j, Background);
+                    }
+                }
+              lMask++;
+            }
+          tMask += Mask->lDelta;
+        }
       return TRUE;
     }
   else
     {
-    return FALSE;
+      return FALSE;
     }
 }
 
@@ -918,7 +915,7 @@
     InputRect.bottom = DestRect->bottom - DestRect->top;
     }
 
-  if (! IntEngEnter(&EnterLeaveSource, NULL, &InputRect, TRUE, &Translate, &InputObj))
+  if (! IntEngEnter(&EnterLeaveSource, DestObj, &InputRect, TRUE, &Translate, &InputObj))
     {
     return FALSE;
     }
@@ -1004,7 +1001,8 @@
                            &OutputRect, &InputPoint, MaskOrigin, Brush, &AdjustedBrushOrigin);
       else
         Ret = BltMask(OutputObj, InputObj, Mask, DestColorTranslation,
-                           &OutputRect, &InputPoint, MaskOrigin, Brush, &AdjustedBrushOrigin, 0xAACC);
+                           &OutputRect, &InputPoint, MaskOrigin, Brush, &AdjustedBrushOrigin,
+                           R4_MASK);
       break;
     case DC_RECT:
       // Clip the blt to the clip rectangle
@@ -1020,7 +1018,7 @@
                            &CombinedRect, &Pt, MaskOrigin, Brush, &AdjustedBrushOrigin);
       else
         Ret = BltMask(OutputObj, InputObj, Mask, DestColorTranslation,
-                           &CombinedRect, &Pt, MaskOrigin, Brush, &AdjustedBrushOrigin, 0xAACC);
+                           &CombinedRect, &Pt, MaskOrigin, Brush, &AdjustedBrushOrigin, R4_MASK);
       break;
     case DC_COMPLEX:
       Ret = TRUE;
@@ -1058,7 +1056,7 @@
 	                           &CombinedRect, &Pt, MaskOrigin, Brush, &AdjustedBrushOrigin) && Ret;
               else
                 Ret = BltMask(OutputObj, InputObj, Mask, DestColorTranslation,
-                                   &CombinedRect, &Pt, MaskOrigin, Brush, &AdjustedBrushOrigin, 0xAACC) && Ret;
+                                   &CombinedRect, &Pt, MaskOrigin, Brush, &AdjustedBrushOrigin, R4_MASK) && Ret;
 	    }
 	}
       while(EnumMore);
@@ -1069,26 +1067,20 @@
   IntEngLeave(&EnterLeaveDest);
   IntEngLeave(&EnterLeaveSource);
 
-  /* Dummy BitBlt to let driver know that something has changed.
-     0x00AA0029 is the Rop for D (no-op) */
-  /* FIXME: Remove the typecast! */
-  IntEngBitBlt((BITMAPOBJ*)DestObj, NULL, (BITMAPOBJ*)Mask, ClipRegion, DestColorTranslation,
-               DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, ROP_NOOP);
-
   return Ret;
 }
 
 BOOL STDCALL
 IntEngMaskBlt(SURFOBJ *DestObj,
-             SURFOBJ *Mask,
-             CLIPOBJ *ClipRegion,
-             XLATEOBJ *DestColorTranslation,
-             XLATEOBJ *SourceColorTranslation,
-             RECTL *DestRect,
-             POINTL *SourcePoint,
-             POINTL *MaskOrigin,
-             BRUSHOBJ *Brush,
-             POINTL *BrushOrigin)
+              SURFOBJ *Mask,
+              CLIPOBJ *ClipRegion,
+              XLATEOBJ *DestColorTranslation,
+              XLATEOBJ *SourceColorTranslation,
+              RECTL *DestRect,
+              POINTL *SourcePoint,
+              POINTL *MaskOrigin,
+              BRUSHOBJ *Brush,
+              POINTL *BrushOrigin)
 {
   BOOLEAN ret;
   RECTL OutputRect;
@@ -1123,9 +1115,21 @@
   MouseSafetyOnDrawStart(DestObj, OutputRect.left, OutputRect.top,
                          OutputRect.right, OutputRect.bottom);
 
+  /* Dummy BitBlt to let driver know that it should flush its changes.
+     This should really be done using a call to DrvSynchronizeSurface,
+     but the VMware driver doesn't hook that call. */
+  /* FIXME: Remove the typecast! */
+  IntEngBitBlt((BITMAPOBJ*)DestObj, NULL, (BITMAPOBJ*)Mask, ClipRegion, DestColorTranslation,
+               DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, R4_NOOP);
+
   ret = EngMaskBitBlt(DestObj, Mask, ClipRegion, DestColorTranslation, SourceColorTranslation,
                       &OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin);
 
+  /* Dummy BitBlt to let driver know that something has changed. */
+  /* FIXME: Remove the typecast! */
+  IntEngBitBlt((BITMAPOBJ*)DestObj, NULL, (BITMAPOBJ*)Mask, ClipRegion, DestColorTranslation,
+               DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, R4_NOOP);
+
   MouseSafetyOnDrawEnd(DestObj);
 
   return ret;

Modified: trunk/reactos/subsys/win32k/eng/copybits.c
--- trunk/reactos/subsys/win32k/eng/copybits.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/eng/copybits.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -98,7 +98,7 @@
     /* FIXME: Remove the typecast! */
     ret = IntEngBitBlt((BITMAPOBJ*)Dest, (BITMAPOBJ*)Source,
                        NULL, Clip, ColorTranslation, DestRect, SourcePoint,
-                       NULL, NULL, NULL, 0);
+                       NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
 
     MouseSafetyOnDrawEnd(Dest);
     MouseSafetyOnDrawEnd(Source);

Modified: trunk/reactos/subsys/win32k/eng/gradient.c
--- trunk/reactos/subsys/win32k/eng/gradient.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/eng/gradient.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -541,7 +541,7 @@
 	  pco->rclBounds.top, 
       pco->rclBounds.right,
 	  pco->rclBounds.bottom);
-  if((psoDest->iType != STYPE_BITMAP) && (pboDest->flHooks & HOOK_GRADIENTFILL))
+  if(pboDest->flHooks & HOOK_GRADIENTFILL)
   {
     Ret = GDIDEVFUNCS(psoDest).GradientFill(
       psoDest, pco, pxlo, pVertex, nVertex, pMesh, nMesh, 
@@ -551,19 +551,6 @@
   }
   Ret = EngGradientFill(psoDest, pco, pxlo, pVertex, nVertex, pMesh, nMesh, prclExtents, 
                         pptlDitherOrg, ulMode);
-  if(Ret)
-  {
-    /* Dummy BitBlt to let driver know that something has changed.
-       0x00AA0029 is the Rop for D (no-op) */
-    if(pboDest->flHooks & HOOK_BITBLT)
-    {
-      GDIDEVFUNCS(psoDest).BitBlt(
-                      psoDest, NULL, NULL, pco, pxlo,
-                      prclExtents, pptlDitherOrg, NULL, NULL, NULL, ROP_NOOP);
-      MouseSafetyOnDrawEnd(psoDest);
-      return TRUE;
-    }
-  }
   MouseSafetyOnDrawEnd(psoDest);
   return Ret;
 }

Modified: trunk/reactos/subsys/win32k/eng/mouse.c
--- trunk/reactos/subsys/win32k/eng/mouse.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/eng/mouse.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -178,7 +178,7 @@
         if((MaskSurface = EngLockSurface(pgp->MaskSurface)))
         {
           EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
-                    &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, SRCCOPY);
+                    &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
           EngUnlockSurface(MaskSurface);
         }
         EngUnlockSurface(SaveSurface);
@@ -231,7 +231,7 @@
          DestSurface->sizlBitmap.cy - pt.y);
 
       EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
-                &DestRect, &SrcPoint, NULL, NULL, NULL, SRCCOPY);
+                &DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
       EngUnlockSurface(SaveSurface);
    }
 
@@ -265,17 +265,17 @@
            if((ColorSurf = EngLockSurface(pgp->ColorSurface)))
            {
              EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, pgp->XlateObject,
-                       &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, 0xAACC);
+                       &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, R4_MASK);
              EngUnlockSurface(ColorSurf);
            }
         }
         else
         {
            EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
-                     &DestRect, &SrcPoint, NULL, NULL, NULL, SRCAND);
+                     &DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCAND));
            SrcPoint.y += pgp->Size.cy;
            EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
-                     &DestRect, &SrcPoint, NULL, NULL, NULL, SRCINVERT);
+                     &DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCINVERT));
         }
         EngUnlockSurface(MaskSurf);
       }

Modified: trunk/reactos/subsys/win32k/eng/transblt.c
--- trunk/reactos/subsys/win32k/eng/transblt.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/eng/transblt.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -270,18 +270,6 @@
                             &OutputRect, SourceRect, iTransColor, Reserved);
   }
   
-  if(Ret)
-  {
-    /* Dummy BitBlt to let driver know that something has changed.
-       0x00AA0029 is the Rop for D (no-op) */
-    if (DestObj->flHooks & HOOK_BITBLT)
-    {
-      GDIDEVFUNCS(DestSurf).BitBlt(
-                          DestSurf, NULL, NULL, Clip, ColorTranslation,
-                          &OutputRect, NULL, NULL, NULL, NULL, ROP_NOOP);
-    }
-  }
-  
   MouseSafetyOnDrawEnd(DestSurf);
   if(SourceSurf != DestSurf)
   {

Modified: trunk/reactos/subsys/win32k/include/inteng.h
--- trunk/reactos/subsys/win32k/include/inteng.h	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/include/inteng.h	2005-02-06 18:27:06 UTC (rev 13445)
@@ -18,8 +18,18 @@
   ULONG Width;
 } SPAN, *PSPAN;
 
-#define ROP_NOOP	0x00AA0029
+#define R3_OPINDEX_SRCCOPY 0xcc
+#define R3_OPINDEX_NOOP 0xaa
+#define R4_NOOP ((R3_OPINDEX_NOOP << 8) | R3_OPINDEX_NOOP)
+#define R4_MASK ((R3_OPINDEX_NOOP << 8) | R3_OPINDEX_SRCCOPY)
 
+#define ROP2_TO_MIX(Rop2) (((Rop2) << 8) | (Rop2))
+#define ROP3_USES_SOURCE(Rop3) ((((Rop3) & 0xCC0000) >> 2) != ((Rop3) & 0x330000))
+#define ROP4_USES_SOURCE(Rop4) (((((Rop4) & 0xCC) >> 2) != ((Rop4) & 0x33)) || ((((Rop4) & 0xCC00) >> 2) != ((Rop4) & 0x3300)))
+#define ROP3_USES_PATTERN(Rop3) ((((Rop3) & 0xF00000) >> 4) != ((Rop3) & 0x0F0000))
+#define ROP4_USES_PATTERN(Rop4) (((((Rop4) & 0xF0) >> 4) != ((Rop4) & 0x0F)) || ((((Rop4) & 0xF000) >> 4) != ((Rop4) & 0x0F00)))
+#define ROP3_TO_ROP4(Rop3) ((((Rop3) >> 8) & 0xff00) | (((Rop3) >> 16) & 0x00ff))
+
 /* Definitions of IntEngXxx functions */
 
 #define IntEngLockProcessDriverObjs(W32Process) \
@@ -32,7 +42,6 @@
 IntEngCleanupDriverObjs(struct _EPROCESS *Process,
                         PW32PROCESS Win32Process);
 
-#define ROP2_TO_MIX(Rop2) (((Rop2) << 8) | (Rop2))
 BOOL STDCALL
 IntEngLineTo(BITMAPOBJ *Surface,
              CLIPOBJ *Clip,

Modified: trunk/reactos/subsys/win32k/objects/bitmaps.c
--- trunk/reactos/subsys/win32k/objects/bitmaps.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/objects/bitmaps.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -49,8 +49,8 @@
 	HPALETTE SourcePalette = 0, DestPalette = 0;
 	PGDIBRUSHOBJ BrushObj;
 	GDIBRUSHINST BrushInst;
-	BOOL UsesSource = ROP_USES_SOURCE(ROP);
-	BOOL UsesPattern = ROP_USES_PATTERN(ROP);
+	BOOL UsesSource = ROP3_USES_SOURCE(ROP);
+	BOOL UsesPattern = ROP3_USES_PATTERN(ROP);
 
 	DCDest = DC_LockDc(hDCDest);
 	if (NULL == DCDest)
@@ -201,7 +201,8 @@
 
 	/* Perform the bitblt operation */
 	Status = IntEngBitBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip, XlateObj,
-		&DestRect, &SourcePoint, NULL, BrushObj ? &BrushInst.BrushObject : NULL, &BrushOrigin, ROP);
+	                      &DestRect, &SourcePoint, NULL, BrushObj ? &BrushInst.BrushObject : NULL,
+	                      &BrushOrigin, ROP3_TO_ROP4(ROP));
 
 	if (UsesSource && XlateObj != NULL)
 		EngDeleteXlate(XlateObj);

Modified: trunk/reactos/subsys/win32k/objects/brush.c
--- trunk/reactos/subsys/win32k/objects/brush.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/objects/brush.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -239,7 +239,7 @@
          NULL,
          &BrushInst.BrushObject,
          &BrushOrigin,
-         ROP);
+         ROP3_TO_ROP4(ROP));
    }
 
    BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);

Modified: trunk/reactos/subsys/win32k/objects/fillshap.c
--- trunk/reactos/subsys/win32k/objects/fillshap.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/objects/fillshap.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -979,7 +979,7 @@
                            NULL,
                            &FillBrushInst.BrushObject,
                            NULL,
-                           PATCOPY);
+                           ROP3_TO_ROP4(PATCOPY));
       }
     }
 

Modified: trunk/reactos/subsys/win32k/objects/text.c
--- trunk/reactos/subsys/win32k/objects/text.c	2005-02-06 18:24:31 UTC (rev 13444)
+++ trunk/reactos/subsys/win32k/objects/text.c	2005-02-06 18:27:06 UTC (rev 13445)
@@ -1636,7 +1636,7 @@
          &SourcePoint,
          &BrushBgInst.BrushObject,
          &BrushOrigin,
-         PATCOPY);
+         ROP3_TO_ROP4(PATCOPY));
       fuOptions &= ~ETO_OPAQUE;
    }
    else
@@ -1854,7 +1854,7 @@
             &SourcePoint,
             &BrushBgInst.BrushObject,
             &BrushOrigin,
-            PATCOPY);
+            ROP3_TO_ROP4(PATCOPY));
          BackgroundLeft = DestRect.right;
       }