Optimze DIB32_bitblt for both DGB=0 and DGB=1
authorMagnus Olsen <magnus@greatlord.com>
Wed, 8 Jun 2005 16:28:41 +0000 (16:28 +0000)
committerMagnus Olsen <magnus@greatlord.com>
Wed, 8 Jun 2005 16:28:41 +0000 (16:28 +0000)
Can not geting it faster with current c code

svn path=/trunk/; revision=15840

reactos/subsys/win32k/dib/dib.c
reactos/subsys/win32k/dib/dib.h
reactos/subsys/win32k/dib/dib16bpp.c
reactos/subsys/win32k/dib/dib1bpp.c
reactos/subsys/win32k/dib/dib24bpp.c
reactos/subsys/win32k/dib/dib32bpp.c
reactos/subsys/win32k/dib/dib4bpp.c
reactos/subsys/win32k/dib/dib8bpp.c
reactos/subsys/win32k/eng/bitblt.c

index 9109a56..4fcc25b 100644 (file)
@@ -35,57 +35,57 @@ DIB_FUNCTIONS DibFunctionsForBitmapFormat[] =
    {
       DIB_1BPP_PutPixel, DIB_1BPP_GetPixel, DIB_1BPP_HLine, DIB_1BPP_VLine,
       DIB_1BPP_BitBlt, DIB_1BPP_BitBltSrcCopy, DIB_1BPP_StretchBlt,
-      DIB_1BPP_TransparentBlt
+      DIB_1BPP_TransparentBlt, DIB_1BPP_ColorFill
    },
    /* BMF_4BPP */
    {
       DIB_4BPP_PutPixel, DIB_4BPP_GetPixel, DIB_4BPP_HLine, DIB_4BPP_VLine,
       DIB_4BPP_BitBlt, DIB_4BPP_BitBltSrcCopy, DIB_4BPP_StretchBlt,
-      DIB_4BPP_TransparentBlt
+      DIB_4BPP_TransparentBlt, DIB_4BPP_ColorFill
    },
    /* BMF_8BPP */
    {
       DIB_8BPP_PutPixel, DIB_8BPP_GetPixel, DIB_8BPP_HLine, DIB_8BPP_VLine,
       DIB_8BPP_BitBlt, DIB_8BPP_BitBltSrcCopy, DIB_8BPP_StretchBlt,
-      DIB_8BPP_TransparentBlt
+      DIB_8BPP_TransparentBlt, DIB_8BPP_ColorFill
    },
    /* BMF_16BPP */
    {
       DIB_16BPP_PutPixel, DIB_16BPP_GetPixel, DIB_16BPP_HLine, DIB_16BPP_VLine,
       DIB_16BPP_BitBlt, DIB_16BPP_BitBltSrcCopy, DIB_16BPP_StretchBlt,
-      DIB_16BPP_TransparentBlt
+      DIB_16BPP_TransparentBlt, DIB_16BPP_ColorFill
    },
    /* BMF_24BPP */
    {
       DIB_24BPP_PutPixel, DIB_24BPP_GetPixel, DIB_24BPP_HLine, DIB_24BPP_VLine,
       DIB_24BPP_BitBlt, DIB_24BPP_BitBltSrcCopy, DIB_24BPP_StretchBlt,
-      DIB_24BPP_TransparentBlt
+      DIB_24BPP_TransparentBlt, DIB_24BPP_ColorFill
    },
    /* BMF_32BPP */
    {
       DIB_32BPP_PutPixel, DIB_32BPP_GetPixel, DIB_32BPP_HLine, DIB_32BPP_VLine,
       DIB_32BPP_BitBlt, DIB_32BPP_BitBltSrcCopy, DIB_32BPP_StretchBlt,
-      DIB_32BPP_TransparentBlt
+      DIB_32BPP_TransparentBlt, DIB_32BPP_ColorFill
    },
    /* BMF_4RLE */
    {
       Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
-      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt
+      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt, Dummy_ColorFill
    },
    /* BMF_8RLE */
    {
       Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
-      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt
+      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt, Dummy_ColorFill
    },
    /* BMF_JPEG */
    {
       Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
-      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt
+      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt, Dummy_ColorFill
    },
    /* BMF_PNG */
    {
       Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
-      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt
+      Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt, Dummy_ColorFill
    }
 };
 
@@ -230,4 +230,10 @@ BOOLEAN Dummy_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
   return FALSE;
 }
 
+BOOLEAN Dummy_ColorFill(SURFOBJ* Dest, RECTL* DestRect, ULONG Color)
+{
+  return FALSE;
+}
+
+
 /* EOF */
index dff7059..220ee26 100644 (file)
@@ -43,6 +43,7 @@ typedef VOID (*PFN_DIB_VLine)(SURFOBJ*,LONG,LONG,LONG,ULONG);
 typedef BOOLEAN (*PFN_DIB_BitBlt)(PBLTINFO);
 typedef BOOLEAN (*PFN_DIB_StretchBlt)(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 typedef BOOLEAN (*PFN_DIB_TransparentBlt)(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+typedef BOOLEAN (*PFN_DIB_ColorFill)(SURFOBJ*, RECTL*, ULONG);
 
 typedef struct
 {
@@ -54,6 +55,7 @@ typedef struct
   PFN_DIB_BitBlt         DIB_BitBltSrcCopy;
   PFN_DIB_StretchBlt     DIB_StretchBlt;
   PFN_DIB_TransparentBlt DIB_TransparentBlt;
+  PFN_DIB_ColorFill      DIB_ColorFill;
 } DIB_FUNCTIONS;
 
 extern DIB_FUNCTIONS DibFunctionsForBitmapFormat[];
@@ -65,6 +67,7 @@ VOID Dummy_VLine(SURFOBJ*,LONG,LONG,LONG,ULONG);
 BOOLEAN Dummy_BitBlt(PBLTINFO);
 BOOLEAN Dummy_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN Dummy_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN Dummy_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 VOID DIB_1BPP_PutPixel(SURFOBJ*,LONG,LONG,ULONG);
 ULONG DIB_1BPP_GetPixel(SURFOBJ*,LONG,LONG);
@@ -74,6 +77,7 @@ BOOLEAN DIB_1BPP_BitBlt(PBLTINFO);
 BOOLEAN DIB_1BPP_BitBltSrcCopy(PBLTINFO);
 BOOLEAN DIB_1BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_1BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN DIB_1BPP_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 VOID DIB_4BPP_PutPixel(SURFOBJ*,LONG,LONG,ULONG);
 ULONG DIB_4BPP_GetPixel(SURFOBJ*,LONG,LONG);
@@ -83,6 +87,7 @@ BOOLEAN DIB_4BPP_BitBlt(PBLTINFO);
 BOOLEAN DIB_4BPP_BitBltSrcCopy(PBLTINFO);
 BOOLEAN DIB_4BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_4BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN DIB_4BPP_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 VOID DIB_8BPP_PutPixel(SURFOBJ*,LONG,LONG,ULONG);
 ULONG DIB_8BPP_GetPixel(SURFOBJ*,LONG,LONG);
@@ -92,6 +97,7 @@ BOOLEAN DIB_8BPP_BitBlt(PBLTINFO);
 BOOLEAN DIB_8BPP_BitBltSrcCopy(PBLTINFO);
 BOOLEAN DIB_8BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_8BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN DIB_8BPP_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 VOID DIB_16BPP_PutPixel(SURFOBJ*,LONG,LONG,ULONG);
 ULONG DIB_16BPP_GetPixel(SURFOBJ*,LONG,LONG);
@@ -101,6 +107,7 @@ BOOLEAN DIB_16BPP_BitBlt(PBLTINFO);
 BOOLEAN DIB_16BPP_BitBltSrcCopy(PBLTINFO);
 BOOLEAN DIB_16BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_16BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN DIB_16BPP_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 VOID DIB_24BPP_PutPixel(SURFOBJ*,LONG,LONG,ULONG);
 ULONG DIB_24BPP_GetPixel(SURFOBJ*,LONG,LONG);
@@ -110,6 +117,7 @@ BOOLEAN DIB_24BPP_BitBlt(PBLTINFO);
 BOOLEAN DIB_24BPP_BitBltSrcCopy(PBLTINFO);
 BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_24BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN DIB_24BPP_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 VOID DIB_32BPP_PutPixel(SURFOBJ*,LONG,LONG,ULONG);
 ULONG DIB_32BPP_GetPixel(SURFOBJ*,LONG,LONG);
@@ -119,17 +127,14 @@ BOOLEAN DIB_32BPP_BitBlt(PBLTINFO);
 BOOLEAN DIB_32BPP_BitBltSrcCopy(PBLTINFO);
 BOOLEAN DIB_32BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
 BOOLEAN DIB_32BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
+BOOLEAN DIB_32BPP_ColorFill(SURFOBJ*, RECTL*, ULONG);
 
 BOOLEAN FASTCALL DIB_32DstInvert(PBLTINFO);
-BOOLEAN FASTCALL DIB32_Srccopy(PBLTINFO);
-BOOLEAN FASTCALL DIB32_ColorFill(PBLTINFO, ULONG);
+
 BOOLEAN FASTCALL DIB32_SrcPaint(PBLTINFO);
 BOOLEAN FASTCALL DIB32_NotSrcErase(PBLTINFO);
 BOOLEAN FASTCALL DIB32_SrcErase(PBLTINFO);
 
-BOOLEAN FASTCALL DIB_32PatCopy(PBLTINFO);
-
-
 extern unsigned char notmask[2];
 extern unsigned char altnotmask[2];
 #define MASK1BPP(x) (1<<(7-((x)&7)))
index ec6a525..0f4f901 100644 (file)
@@ -42,6 +42,7 @@ DIB_16BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
 {
   PDWORD addr = (PDWORD)((PWORD)(SurfObj->pvScan0 + y * SurfObj->lDelta) + x1);
 
 #ifdef _M_IX86
   /* This is about 10% faster than the generic C code below */
   LONG Count = x2 - x1;
@@ -65,7 +66,7 @@ DIB_16BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
 "  jz   .L2\n"
 "  stosw\n"
 ".L2:\n"
-  : /* no output */
+  : // no output */
   : "r"(c), "r"(Count), "D"(addr)
   : "%eax", "%ecx");
 #else /* _M_IX86 */
@@ -88,6 +89,7 @@ DIB_16BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
 #endif /* _M_IX86 */
 }
 
+
 VOID
 DIB_16BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
 {
@@ -423,7 +425,17 @@ DIB_16BPP_BitBlt(PBLTINFO BltInfo)
    return TRUE;
 }
 
-
+/* Optimze for bitBlt */
+BOOLEAN
+DIB_16BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
+{
+  ULONG DestY; 
+       for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+  {
+    DIB_16BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
+  }
+return TRUE;
+}
 /*
 =======================================
  Stretching functions goes below
index 05abf37..026a9f1 100644 (file)
@@ -478,6 +478,20 @@ DIB_1BPP_BitBlt(PBLTINFO BltInfo)
    return TRUE;
 }
 
+/* Optimze for bitBlt */
+BOOLEAN 
+DIB_1BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
+{
+  ULONG DestY; 
+
+        for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+       {                                                       
+               DIB_1BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);                                                     
+       }
+
+return TRUE;
+}
+
 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
 BOOLEAN DIB_1BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
                             RECTL* DestRect, RECTL *SourceRect,
index 56b6b25..da2a3ff 100644 (file)
@@ -302,6 +302,20 @@ DIB_24BPP_BitBlt(PBLTINFO BltInfo)
    return TRUE;
 }
 
+/* BitBlt Optimze */
+BOOLEAN 
+DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
+{
+  ULONG DestY; 
+
+        for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+       {                                                       
+               DIB_24BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);                                                    
+       }
+
+return TRUE;
+}
+
 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
 BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
                             RECTL* DestRect, RECTL *SourceRect,
index b080166..aa3881a 100644 (file)
@@ -45,54 +45,46 @@ DIB_32BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
 VOID
 DIB_32BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
 {      
-  LONG cx  = (x2 - x1) ;
-  if (cx>0)
-  {
+  LONG cx  = (x2 - x1) ;  
    PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;  
    PDWORD addr = (PDWORD)byteaddr + x1;
    memset4(addr, c, cx);  
-  }
-  else if (cx<0)
-  {
-   PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;  
-   PDWORD addr = (PDWORD)byteaddr + x2;
-   cx = (x1 - x2) ;
-   memset4(addr, c, cx);  
-  }
+  
+  
   
 }
 #else
 VOID
 DIB_32BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
 {
-       PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;  
-       PDWORD addr = (PDWORD)byteaddr + x1;            
-       LONG cx = x1;
-       while(cx < x2) 
-       {
-               *addr = (DWORD)c;
-               ++addr;
-               ++cx;
-       }         
+  PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;  
+  PDWORD addr = (PDWORD)byteaddr + x1;         
+  LONG cx = x1;
+  while(cx < x2) 
+  {
+    *addr = (DWORD)c;
+    ++addr;
+    ++cx;
+   }     
 }
 #endif
 
 VOID
 DIB_32BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
 {
+
+  
   PBYTE byteaddr = SurfObj->pvScan0 + y1 * SurfObj->lDelta;
   PDWORD addr = (PDWORD)byteaddr + x;
-  LONG lDelta = SurfObj->lDelta >> 2; /* >> 2 == / sizeof(DWORD) */
+  LONG lDelta = SurfObj->lDelta >> 2; // >> 2 == / sizeof(DWORD) 
 
   byteaddr = (PBYTE)addr;
   while(y1++ < y2) 
   {
-       *addr = (DWORD)c;
-       addr += lDelta;
-       }
-   
+    *addr = (DWORD)c;
+    addr += lDelta;
+  } 
+  
 }
 
 BOOLEAN
@@ -315,236 +307,241 @@ DIB_32BPP_BitBltSrcCopy(PBLTINFO BltInfo)
 BOOLEAN
 DIB_32BPP_BitBlt(PBLTINFO BltInfo)
 {
-   ULONG DestX, DestY;
-   ULONG SourceX, SourceY;
-   ULONG PatternY = 0;
-   ULONG Dest, Source = 0, Pattern = 0;
-   BOOL UsesSource;
-   BOOL UsesPattern;
-   PULONG DestBits;
-
-   switch (BltInfo->Rop4)
-       {
-
-                case  ROP4_BLACKNESS:  
-                        //return(0x00000000);  
-                        return DIB32_ColorFill(BltInfo, 0x00000000);
-                break;
-
-                case ROP4_WHITENESS:   
-                        //return(0xFFFFFFFF);
-                         return DIB32_ColorFill(BltInfo, 0xFFFFFFFF);
-                break;
-
-               case  ROP4_SRCCOPY:     
-                         // return(Source);
-              return DIB32_Srccopy(BltInfo); 
-               break;  
-        
-               case ROP4_DSTINVERT:
-                        // return(~Dest);
-                        return DIB_32DstInvert(BltInfo);
-               break;  
-
-               case  ROP4_SRCPAINT:    
-                        // return(Dest | Source);      
-                    return DIB32_SrcPaint(BltInfo);
-               break;
-
-               case ROP4_NOTSRCERASE:  
-                        return DIB32_NotSrcErase(BltInfo);
-        break; 
-               case ROP4_SRCERASE:  
-                        return DIB32_SrcErase(BltInfo);
-        break; 
-
-                case  ROP4_PATCOPY:     
-                        // return(Pattern);
-                        return DIB_32PatCopy(BltInfo);
-                break;
+  ULONG DestX, DestY;
+  ULONG SourceX, SourceY;
+  ULONG PatternY = 0, PatternX = 0, orgPatternX = 0;
+  ULONG Source = 0, Pattern = 0;
+  BOOL UsesSource;
+  BOOL UsesPattern;
+  PULONG DestBits;
+  ULONG Delta;
+
+  switch (BltInfo->Rop4)
+  {  
+    case ROP4_DSTINVERT:               
+         return DIB_32DstInvert(BltInfo);
+    break;     
+
+    case  ROP4_SRCPAINT:       
+           return DIB32_SrcPaint(BltInfo);
+    break;
+
+    case ROP4_NOTSRCERASE:  
+         return DIB32_NotSrcErase(BltInfo);
+    break; 
+
+    case ROP4_SRCERASE:  
+         return DIB32_SrcErase(BltInfo);
+    break; 
                                
-               default:
-               break;
-         }     
+    default:
+    break;
+   }   
 
    UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
    UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
 
    SourceY = BltInfo->SourcePoint.y;
-   DestBits = (PULONG)(
-      BltInfo->DestSurface->pvScan0 +
-      (BltInfo->DestRect.left << 2) +
-      BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
+   DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+                       BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
 
-   if (UsesPattern)
+   Delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) << 2); 
+          
+   if ((UsesSource) && (BltInfo->PatternSurface))
    {
-      if (BltInfo->PatternSurface)
+      if (UsesPattern)
       {
-         PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
-                    BltInfo->PatternSurface->sizlBitmap.cy;
+      PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
+                   BltInfo->PatternSurface->sizlBitmap.cy;
       }
-      else
+
+      orgPatternX = (BltInfo->DestRect.left + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx;
+       
+
+      for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
       {
-         Pattern = BltInfo->Brush->iSolidColor;
-      }
-   }
+        SourceX = BltInfo->SourcePoint.x;
 
-   for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
-   {
-      SourceX = BltInfo->SourcePoint.x;
+        PatternX = orgPatternX;
+
+        for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++, SourceX++)
+        {
+         
+          Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
+        
+          Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);
+          
+          *DestBits = DIB_DoRop(BltInfo->Rop4, *DestBits, Source, Pattern);
+
+          PatternX++;
+          PatternX %= BltInfo->PatternSurface->sizlBitmap.cx;
 
-      for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++, SourceX++)
+          }
+
+        SourceY++;
+        
+        PatternY++;
+        PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+        
+        DestBits = (PULONG)((ULONG_PTR)DestBits + Delta);
+      }
+    }
+       
+    else if ((UsesSource) && (!BltInfo->PatternSurface))
+    {
+      if (UsesPattern)
       {
-         Dest = *DestBits;
+        Pattern = BltInfo->Brush->iSolidColor;
+      }
 
-         if (UsesSource)
-         {
-            Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
-         }
+      for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
+      {
+        SourceX = BltInfo->SourcePoint.x;        
 
-         if (BltInfo->PatternSurface)
-        {
-            Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
+        for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++, SourceX++)
+        {                 
+          Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
+                
+          *DestBits = DIB_DoRop(BltInfo->Rop4, *DestBits, Source, Pattern);
          }
 
-         *DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
+        SourceY++;        
+        DestBits = (PULONG)((ULONG_PTR)DestBits + Delta);
       }
+    }
 
-      SourceY++;
-      if (BltInfo->PatternSurface)
+    else if ((!UsesSource) && (BltInfo->PatternSurface))
+    {
+      if (UsesPattern)
       {
-         PatternY++;
-         PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+       PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
+                   BltInfo->PatternSurface->sizlBitmap.cy;
       }
-      DestBits = (PULONG)(
-         (ULONG_PTR)DestBits -
-         ((BltInfo->DestRect.right - BltInfo->DestRect.left) << 2) +
-         BltInfo->DestSurface->lDelta);
-   }
 
-   return TRUE;
-}
+      orgPatternX = (BltInfo->DestRect.left + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx;
+      for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
+      {       
 
-/* optimze functions for bitblt */
+        PatternX = orgPatternX;
 
-BOOLEAN
-FASTCALL
-DIB_32PatCopy(PBLTINFO BltInfo)   
-{
-       ULONG delta;
-       ULONG DestX, DestY, PatternY;    
-       PULONG DestBits;         
+        for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++)
+        {
+          
+          Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);
+          *DestBits = DIB_DoRop(BltInfo->Rop4, *DestBits, 0, Pattern);
 
-    if (!BltInfo->PatternSurface)
-       {       
-               return DIB32_ColorFill(BltInfo, XLATEOBJ_iXlate(BltInfo->XlatePatternToDest, BltInfo->Brush->iSolidColor));
-       }
+          PatternX++;
+          PatternX %= BltInfo->PatternSurface->sizlBitmap.cx;
+         }
+                
+        PatternY++;
+        PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+        
+        DestBits = (PULONG)((ULONG_PTR)DestBits + Delta);
+      }
+    }
+    else if ((!UsesSource) && (!BltInfo->PatternSurface))
+    {
 
+      if (UsesPattern)
+      {
+        Pattern = BltInfo->Brush->iSolidColor;
+      }
 
-       DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
-                                          BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
+      for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
+      {
 
-       delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2);
-   
-       PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) % BltInfo->PatternSurface->sizlBitmap.cy;
-   
-   for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
-   {
+        for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++)
+        {                  
+          *DestBits = DIB_DoRop(BltInfo->Rop4, *DestBits, 0, Pattern);
+        }
 
-      for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++)
-      {       
-       *DestBits = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);                  
+        DestBits = (PULONG)((ULONG_PTR)DestBits + Delta);
       }
-      
-      PatternY++;
-      PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;      
-
-      DestBits = (PULONG)((ULONG_PTR)DestBits + delta);        
-   }
+    }
 
-   
    return TRUE;
 }
 
+/* optimze functions for bitblt */
+
 BOOLEAN
 FASTCALL
 DIB_32DstInvert(PBLTINFO BltInfo)   
 {
-                       ULONG DestX, DestY;             
-                       PULONG DestBits;
+  ULONG DestX, DestY;          
+  PULONG DestBits;
 
-                       ULONG bottom = BltInfo->DestRect.bottom;
-                       ULONG right  = BltInfo->DestRect.right; 
-                       ULONG delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2)  ;
+  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);
+  DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+                      BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
                                                                                                
-                       for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
-                       {                                                                                       
-                               for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++)
-                               {
-                                                                               
-                                       *DestBits = ~*DestBits ;
-                               }
+  for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
+  {                                                                                    
+    for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++)
+    {
+      *DestBits = ~*DestBits ;
+    }
                                
-                        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);                              
-                        }
+    DestBits = (PULONG)((ULONG_PTR)DestBits + delta);                          
+  }
                
     
-    /* Return TRUE */
-    return TRUE;
+  /* Return TRUE */
+  return TRUE;
 }
 
 BOOLEAN 
 FASTCALL 
 DIB32_SrcErase(PBLTINFO BltInfo)
 {
-       BOOLEAN status = FALSE;
+  BOOLEAN status = FALSE;
        
-       switch (BltInfo->SourceSurface->iBitmapFormat)
-       {                          
-               case BMF_1BPP:
-               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; 
-                       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);
+  switch (BltInfo->SourceSurface->iBitmapFormat)
+  {                       
+    case BMF_1BPP:
+    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; 
+      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_GetSource(BltInfo->SourceSurface,  SourceX, 
-                                               SourceY, BltInfo->XlateSourceToDest));
-                               }
+      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_GetSource(BltInfo->SourceSurface,  SourceX, 
+          SourceY, BltInfo->XlateSourceToDest));
+        }
                                
-                        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);                               
-                        SourceY++;      
-                        }
-               
-               }
-               status = TRUE;
-           break;                      
+        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);                               
+        SourceY++;      
+       }               
+     }
+     status = TRUE;
+     break;                    
 
 
-               default:
-               break;
-       }
+     default:
+     break;
+          }
 
  return status;
 }
@@ -553,50 +550,49 @@ BOOLEAN
 FASTCALL 
 DIB32_NotSrcErase(PBLTINFO BltInfo)
 {
-       BOOLEAN status = FALSE;
+  BOOLEAN status = FALSE;
        
-       switch (BltInfo->SourceSurface->iBitmapFormat)
-       {                          
-               case BMF_1BPP:
-               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; 
-                       ULONG delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2)  ;
-
-                       DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+  switch (BltInfo->SourceSurface->iBitmapFormat)
+  {                       
+    case BMF_1BPP:
+    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; 
+      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_GetSource(BltInfo->SourceSurface,  SourceX, 
-                                               SourceY, BltInfo->XlateSourceToDest));
-                               }
+      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_GetSource(BltInfo->SourceSurface,  SourceX, 
+                     SourceY, BltInfo->XlateSourceToDest));
+        }
                                
-                        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);                               
-                        SourceY++;      
-                        }
+      DestBits = (PULONG)((ULONG_PTR)DestBits + delta);                                 
+      SourceY++;        
+      }
                
-               }
-               status = TRUE;
-           break;                      
-
+    }
+    status = TRUE;
+    break;                     
 
-               default:
-               break;
-       }
+    default:
+    break;
+    }
 
  return status;
 }
@@ -605,214 +601,107 @@ BOOLEAN
 FASTCALL 
 DIB32_SrcPaint(PBLTINFO BltInfo)
 {
-       BOOLEAN status = FALSE;
-
-       // return(Source);
-       switch (BltInfo->SourceSurface->iBitmapFormat)
-       {                          
-               case BMF_1BPP:
-               case BMF_4BPP:                                          
-               case BMF_16BPP:
-               case BMF_24BPP:                         
-               {
-                       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;
+  BOOLEAN status = FALSE;
+       
+  switch (BltInfo->SourceSurface->iBitmapFormat)
+  {                       
+    case BMF_1BPP:
+    case BMF_4BPP:                                             
+    case BMF_16BPP:
+    case BMF_24BPP:                            
+    {
+      ULONG DestX, DestY;
+      ULONG SourceX, SourceY;
+      PULONG DestBits;
 
-                       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_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;
+      ULONG bottom = BltInfo->DestRect.bottom;
+      ULONG right  = BltInfo->DestRect.right; 
+      ULONG delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2)  ;
 
-                       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)(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_GetSource(BltInfo->SourceSurface,  SourceX, 
+                        SourceY, BltInfo->XlateSourceToDest));
+        }
                                
-                        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);      
-                        SourceY++;      
-                        }
+        DestBits = (PULONG)((ULONG_PTR)DestBits + delta);      
+        SourceY++;      
+        }
                
-               }
-               status = TRUE;
-           break;
+      }
+      status = TRUE;
+      break;                   
 
-               default:
-               break;
-       }
+      case BMF_32BPP:
+      {
+        ULONG DestX, DestY;
+        ULONG SourceX, SourceY;                        
+        PULONG DestBits;
 
- return status;
-}
+        ULONG bottom = BltInfo->DestRect.bottom;
+        ULONG right  = BltInfo->DestRect.right; 
+        ULONG delta  = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2)  ;
 
-BOOLEAN 
-FASTCALL 
-DIB32_Srccopy(PBLTINFO BltInfo)
-{
-       BOOLEAN status = FALSE;
-
-       // return(Source);
-       switch (BltInfo->SourceSurface->iBitmapFormat)
-       {                          
-               case BMF_1BPP:
-               case BMF_4BPP:                                          
-               case BMF_16BPP:
-               case BMF_24BPP:
-               {
-                       ULONG DestX, DestY;
-                       ULONG SourceX, SourceY;                 
-                       PULONG DestBits;
-
-                       ULONG bottom = BltInfo->DestRect.bottom;
-                       ULONG right  = BltInfo->DestRect.right; 
-                       ULONG delta  = ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) + BltInfo->DestSurface->lDelta;
-
-                        DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 +
-                      (BltInfo->DestRect.left << 2) +
-                       BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
+        DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
+                            BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
                                                                        
-                       SourceY =  BltInfo->SourcePoint.y;
+        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++)
-                               {
-                                       if (SourceX > BltInfo->SourceSurface->sizlBitmap.cx) break;     
-                                       
-                                       *DestBits = DIB_GetSource(BltInfo->SourceSurface,  SourceX, 
-                                               SourceY, BltInfo->XlateSourceToDest);
-                               }
+        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++;
-                        }
-                        
-               }
-               status = TRUE;
-           break;                                                      
-
-               case BMF_32BPP:
-               {
-                        INT Destdelta;
-                        INT Sourcedelta;
-                        register PBYTE Destaddr;
-                        register PBYTE Srcaddr;
-                        LONG  DesmaxX, DesmaxY; 
-                        LONG  SrcmaxX, SrcmaxY;
-                                       
-                        SrcmaxX = BltInfo->SourceSurface->sizlBitmap.cx - BltInfo->SourcePoint.x;
-                        SrcmaxY = BltInfo->SourceSurface->sizlBitmap.cy - BltInfo->SourcePoint.y;
-                                       
-                        DesmaxX = BltInfo->DestRect.right - BltInfo->DestRect.left;
-                        DesmaxY = BltInfo->DestRect.bottom - BltInfo->DestRect.top;
-                                       
-                       if (DesmaxX > SrcmaxX ) DesmaxX = SrcmaxX;
-                       if (DesmaxY > SrcmaxY ) DesmaxY = SrcmaxY;
-                                       
-                       Destdelta = BltInfo->DestSurface->lDelta;
-                       Sourcedelta = BltInfo->SourceSurface->lDelta;
-                       Destaddr = BltInfo->DestSurface->pvScan0 + BltInfo->DestRect.top * Destdelta + (BltInfo->DestRect.left<<2);
-                       Srcaddr = BltInfo->SourceSurface->pvScan0 + BltInfo->SourcePoint.y * Sourcedelta + (BltInfo->SourcePoint.x<<2);
-                       DesmaxX *= 4;
-                       if (DesmaxY > 0)
-                       {
-                               do
-                               {
-                                       RtlCopyMemory(Destaddr, Srcaddr, DesmaxX);
-                                       Destaddr += Destdelta;
-                                       Srcaddr += Sourcedelta;
-                               }
-                               while (--DesmaxY);
-                       }
-                       status = TRUE;  
-                       break;
-                       }
+          DestBits = (PULONG)((ULONG_PTR)DestBits + delta);    
+          SourceY++;    
+         }
+               
+       }
+       status = TRUE;
+       break;
 
-               default:
-               break;
-           }
+       default:
+       break;
+       }
 
-return status;
+ return status;
 }
 
 BOOLEAN 
-FASTCALL 
-DIB32_ColorFill(PBLTINFO BltInfo, ULONG color)
+DIB_32BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
 {                       
-       ULONG DestY;    
+  ULONG DestY; 
 
 #ifdef _M_IX86   
-       ULONG SourceX;
-
-       if (BltInfo->DestRect.left!=0)
-       {
-               SourceX = (BltInfo->DestRect.right - BltInfo->DestRect.left) -1;
-               for (DestY=BltInfo->DestRect.bottom-1;DestY>=BltInfo->DestRect.top;DestY--)
-               {                                                       
-                       memset4( (PDWORD) (BltInfo->DestSurface->pvScan0 + DestY * 
-                                                          BltInfo->DestSurface->lDelta + 
-                                                          BltInfo->DestRect.left),  color, SourceX);                                    
-               }
-                       
-    } else {                                            
-               SourceX = ((BltInfo->DestRect.bottom - BltInfo->DestRect.top) * BltInfo->DestRect.right) -1;
-
-               memset4(BltInfo->DestSurface->pvScan0 + BltInfo->DestRect.top * 
-                           BltInfo->DestSurface->lDelta, color, SourceX);  
-                          
-                       }
-#else                  
-       ULONG SourceY;
+  ULONG width;
+  PULONG pos;
+  ULONG delta = DestSurface->lDelta;
+  
+  width = (DestRect->right - DestRect->left) ;
+  pos =  (PULONG) (DestSurface->pvScan0 + DestRect->top * delta + (DestRect->left<<2));
+  
+  for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+  {                                                    
+    memset4( ((PDWORD)(pos)),  color, width);                                           
+    pos =(PULONG)((ULONG_PTR)pos + delta);      
+  }
 
-       for (DestY=BltInfo->DestRect.bottom-1;DestY>=BltInfo->DestRect.top;DestY--)
-       {                                                       
-               DIB_32BPP_HLine(BltInfo->DestSurface, BltInfo->DestRect.left, BltInfo->DestRect.right, DestY, color);                                                   
-       }
+#else                          
+       for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+  {
+    DIB_32BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
+  }
 #endif
 
        return TRUE;
@@ -1033,22 +922,22 @@ BOOLEAN DIB_32BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
    BOOLEAN DesIsBiggerY=FALSE;
       
    DPRINT("DIB_32BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
-     BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
-     DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
+            BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right, 
+            SourceRect->bottom, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
 
-   SrcSizeY = SourceRect->bottom;
-   SrcSizeX = SourceRect->right;
+    SrcSizeY = SourceRect->bottom;
+    SrcSizeX = SourceRect->right;
   
-   DesSizeY = DestRect->bottom;
-   DesSizeX = DestRect->right; 
+    DesSizeY = DestRect->bottom;
+    DesSizeX = DestRect->right; 
 
-   zoomX = DesSizeX / SrcSizeX;
-   if (zoomX==0) zoomX=1;
+    zoomX = DesSizeX / SrcSizeX;
+    if (zoomX==0) zoomX=1;
     
-   zoomY = DesSizeY / SrcSizeY;
-   if (zoomY==0) zoomY=1;
+    zoomY = DesSizeY / SrcSizeY;
+    if (zoomY==0) zoomY=1;
 
-   if (DesSizeY>SrcSizeY)
+    if (DesSizeY>SrcSizeY)
       DesIsBiggerY = TRUE;  
 
     switch(SourceSurf->iBitmapFormat)
index a52979c..e915592 100644 (file)
@@ -356,6 +356,20 @@ DIB_4BPP_BitBlt(PBLTINFO BltInfo)
    return TRUE;
 }
 
+/* BitBlt Optimze */
+BOOLEAN 
+DIB_4BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
+{
+  ULONG DestY; 
+
+        for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+       {                                                       
+               DIB_4BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);                                                     
+       }
+
+return TRUE;
+}
+
 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
 BOOLEAN DIB_4BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
                             RECTL* DestRect, RECTL *SourceRect,
index 4413bc7..d1fb1db 100644 (file)
@@ -345,6 +345,18 @@ DIB_8BPP_BitBlt(PBLTINFO BltInfo)
    return TRUE;
 }
 
+/* Optimze BitBlt */
+BOOLEAN 
+DIB_8BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
+{                       
+  ULONG DestY;                 
+       for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+  {
+    DIB_32BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
+  }
+       
+       return TRUE;
+}
 /*
 =======================================
  Stretching functions goes below
index e5b054d..dbd8ea9 100644 (file)
@@ -174,15 +174,8 @@ BltPatCopy(SURFOBJ* Dest,
 {
   // These functions are assigned if we're working with a DIB
   // The assigned functions depend on the bitsPerPixel of the DIB
-  LONG y;
-  ULONG LineWidth;
 
-  LineWidth  = DestRect->right - DestRect->left;
-  for (y = DestRect->top; y < DestRect->bottom; y++)
-  {
-    DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_HLine(
-      Dest, DestRect->left, DestRect->right, y,  Brush->iSolidColor);
-  }
+  DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_ColorFill(Dest, DestRect, Brush->iSolidColor);
 
   return TRUE;
 }