sorry revert to 15772
Modified: trunk/reactos/subsys/win32k/dib/dib32bpp.c

Modified: trunk/reactos/subsys/win32k/dib/dib32bpp.c
--- trunk/reactos/subsys/win32k/dib/dib32bpp.c	2005-06-04 17:47:53 UTC (rev 15776)
+++ trunk/reactos/subsys/win32k/dib/dib32bpp.c	2005-06-04 18:43:39 UTC (rev 15777)
@@ -20,6 +20,9 @@
 #include <w32k.h>
 
 
+#include <w32k.h>
+
+
 VOID
 DIB_32BPP_PutPixel(SURFOBJ *SurfObj, LONG x, LONG y, ULONG c)
 {
@@ -402,36 +405,38 @@
 FASTCALL
 DIB_32DstInvert(PBLTINFO BltInfo)   
 {
-	ULONG SourceX, SourceY;
-	ULONG right  = BltInfo->DestRect.right; 
     PULONG DestBits;
-	ULONG top  = BltInfo->DestRect.top; 
-	ULONG left = BltInfo->DestRect.left;
-	ULONG DestX;
-	ULONG DestY = BltInfo->DestRect.bottom - top;
-	ULONG delta = BltInfo->DestSurface->lDelta - (DestX << 2);
+    ULONG top  = BltInfo->DestRect.top; 
+    ULONG left = BltInfo->DestRect.left;
+    ULONG DestX = BltInfo->DestRect.right - left;
+    ULONG DestY = BltInfo->DestRect.bottom - top;
+    ULONG delta = BltInfo->DestSurface->lDelta - (DestX << 2);
 
-	/* Calculate the Initial Destination */
-	DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (left  << 2) +
+    /* Calculate the Initial Destination */
+    DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (left  << 2) +
                         top * BltInfo->DestSurface->lDelta);
-									
-	SourceY =  BltInfo->SourcePoint.y;
-	while (DestY>0)
-	{							
-		SourceX = BltInfo->SourcePoint.x;	
 
-
-		
-		for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++, SourceX++)
-		{
-			*DestBits = ~*DestBits;
-		}	
-
-		DestBits = (PULONG)((ULONG_PTR)DestBits + delta);	
-		SourceY++;	
-		DestY--;
-	 }
-
+    while (DestY > 0)
+    {      
+        while (DestX > 0)
+        {
+            /* Invert bits */
+            *DestBits =~ *DestBits;
+            
+            /* Update Position */
+            DestBits++;
+            
+            /* Decrease distance to do */
+            DestX--;
+        }
+      
+        /* Update position */
+        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);
+        
+        /* Decrease distance to do */
+        DestY--;
+    }
+    
     /* Return TRUE */
     return TRUE;
 }
@@ -448,42 +453,69 @@
 		case BMF_4BPP:						
 		case BMF_16BPP:
 		case BMF_24BPP:				
-		case BMF_32BPP:	
 		{
+			ULONG DestX, DestY;
 			ULONG SourceX, SourceY;
+			PULONG DestBits;
+
+			ULONG bottom = BltInfo->DestRect.bottom;
 			ULONG right  = BltInfo->DestRect.right; 
-            PULONG DestBits;
-			ULONG top  = BltInfo->DestRect.top; 
-			ULONG left = BltInfo->DestRect.left;
-			ULONG DestX;
-			ULONG DestY = BltInfo->DestRect.bottom - top;
-			ULONG delta = BltInfo->DestSurface->lDelta - (DestX << 2);
+			ULONG delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2)  ;
 
-			/* Calculate the Initial Destination */
-			DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (left  << 2) +
-                        top * BltInfo->DestSurface->lDelta);
+			DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+                                BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
 									
 			SourceY =  BltInfo->SourcePoint.y;
-			while (DestY>0)
+
+			for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
 			{							
 				SourceX = BltInfo->SourcePoint.x;
-
-				for (DestX = left; DestX < right; DestX++, DestBits++, SourceX++)
+				for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++, SourceX++)
 				{
 										
-					*DestBits |= DIB_GetSource(BltInfo->SourceSurface,  SourceX, 
-                                               SourceY, BltInfo->XlateSourceToDest);					
+					*DestBits = (*DestBits | DIB_GetSource(BltInfo->SourceSurface,  SourceX, 
+                                               SourceY, BltInfo->XlateSourceToDest));
 				}
+				
+			 DestBits = (PULONG)((ULONG_PTR)DestBits + delta);	
+			 SourceY++;	 
+			 }
+		
+		}
+		status = TRUE;
+	    break;			
 
+        case BMF_32BPP:
+		{
+			ULONG DestX, DestY;
+			ULONG SourceX, SourceY;			
+			PULONG DestBits;
 
+			ULONG bottom = BltInfo->DestRect.bottom;
+			ULONG right  = BltInfo->DestRect.right; 
+			ULONG delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2)  ;
+
+			DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+                                BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
+									
+			SourceY =  BltInfo->SourcePoint.y;
+
+			for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
+			{
+							
+				SourceX = BltInfo->SourcePoint.x;
+				for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++, SourceX++)
+				{										
+					*DestBits = (*DestBits | DIB_32BPP_GetPixel(BltInfo->SourceSurface,  SourceX, SourceY));
+				}
+				
 			 DestBits = (PULONG)((ULONG_PTR)DestBits + delta);	
-			 SourceY++;	
-			 DestY--;
+			 SourceY++;	 
 			 }
-		 
+		
 		}
 		status = TRUE;
-	    break;			
+	    break;
 
 		default:
 		break;
@@ -491,7 +523,6 @@
 
  return status;
 }
-
 BOOLEAN
 DIB32_Srccopy(PBLTINFO BltInfo)
 {
@@ -505,34 +536,35 @@
 		case BMF_16BPP:
 		case BMF_24BPP:
 		{
-			ULONG SourceX, SourceY;
+			ULONG DestX, DestY;
+			ULONG SourceX, SourceY;			
+			PULONG DestBits;
+
+			ULONG bottom = BltInfo->DestRect.bottom;
 			ULONG right  = BltInfo->DestRect.right; 
-            PULONG DestBits;
-			ULONG top  = BltInfo->DestRect.top; 
-			ULONG left = BltInfo->DestRect.left;
-			ULONG DestX;
-			ULONG DestY = BltInfo->DestRect.bottom - top;
-			ULONG delta = BltInfo->DestSurface->lDelta - (DestX << 2);
+			ULONG delta  = ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) + BltInfo->DestSurface->lDelta;
 
-			/* Calculate the Initial Destination */
-			DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (left  << 2) +
-                        top * BltInfo->DestSurface->lDelta);
+			DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+                                BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
 									
 			SourceY =  BltInfo->SourcePoint.y;
-			while (DestY>0)
-			{							
-				SourceX = BltInfo->SourcePoint.x;				
-				for (DestX = left; DestX < right; DestX++, DestBits++, SourceX++)
+
+			for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
+			{
+							
+				SourceX = BltInfo->SourcePoint.x;
+				for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++, SourceX++)
 				{
-										
+					if (SourceX > BltInfo->SourceSurface->sizlBitmap.cx) break;	
+					
 					*DestBits = DIB_GetSource(BltInfo->SourceSurface,  SourceX, 
-                                               SourceY, BltInfo->XlateSourceToDest);					
+                                               SourceY, BltInfo->XlateSourceToDest);
 				}
-
-			 DestBits = (PULONG)((ULONG_PTR)DestBits + delta);	
-			 SourceY++;	
-			 DestY--;
-			 }			 
+				
+			 DestBits = (PULONG)((ULONG_PTR)DestBits - delta);	
+			 SourceY++;
+			 }
+			 
 		}
 		status = TRUE;
 	    break;