[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Wed, 1 Sep 2010 16:52:23 +0000 (16:52 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Wed, 1 Sep 2010 16:52:23 +0000 (16:52 +0000)
  - Use newly introduced macros and get rid of  related functions
  - Ignore alpha channels of solid brush color

svn path=/branches/reactos-yarotows/; revision=48680

subsystems/win32/win32k/eng/bitblt.c
subsystems/win32/win32k/eng/engbrush.c
subsystems/win32/win32k/eng/engmisc.c
subsystems/win32/win32k/eng/mouse.c
subsystems/win32/win32k/include/bitmaps.h
subsystems/win32/win32k/include/dib.h
subsystems/win32/win32k/objects/bitmaps.c
subsystems/win32/win32k/objects/dibobj.c

index 92e9095..876a401 100644 (file)
@@ -158,7 +158,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
 
     // 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, pbo ? pbo->iSolidColor : 0);
+    DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_ColorFill(Dest, DestRect, pbo ? (pbo->iSolidColor &0x00ffffff): 0);
 
     return TRUE;
 }
 
     return TRUE;
 }
index 9418ffc..c61e0e4 100644 (file)
@@ -144,7 +144,7 @@ EngRealizeBrush(
     ULONG lWidth;
 
     /* Calculate width in bytes of the realized brush */
     ULONG lWidth;
 
     /* Calculate width in bytes of the realized brush */
-    lWidth = DIB_GetDIBWidthBytes(psoPattern->sizlBitmap.cx,
+    lWidth = WIDTH_BYTES_ALIGN32(psoPattern->sizlBitmap.cx,
                                   BitsPerFormat(psoDst->iBitmapFormat));
 
     /* Allocate a bitmap */
                                   BitsPerFormat(psoDst->iBitmapFormat));
 
     /* Allocate a bitmap */
index 7265c0d..31ea864 100644 (file)
@@ -64,7 +64,7 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
     /* Allocate a temporary bitmap */
     BitmapSize.cx = DestRect->right - DestRect->left;
     BitmapSize.cy = DestRect->bottom - DestRect->top;
     /* Allocate a temporary bitmap */
     BitmapSize.cx = DestRect->right - DestRect->left;
     BitmapSize.cy = DestRect->bottom - DestRect->top;
-    Width = DIB_GetDIBWidthBytes(BitmapSize.cx, BitsPerFormat(psoDest->iBitmapFormat));
+    Width = WIDTH_BYTES_ALIGN32(BitmapSize.cx, BitsPerFormat(psoDest->iBitmapFormat));
     EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width,
                                                psoDest->iBitmapFormat,
                                                BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
     EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width,
                                                psoDest->iBitmapFormat,
                                                BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
index 02bb965..bda0660 100644 (file)
@@ -334,7 +334,7 @@ EngSetPointerShape(
         rectl.bottom = sizel.cy;
 
         /* Calculate lDelta for our surfaces. */
         rectl.bottom = sizel.cy;
 
         /* Calculate lDelta for our surfaces. */
-        lDelta = DIB_GetDIBWidthBytes(sizel.cx, 
+        lDelta = WIDTH_BYTES_ALIGN32(sizel.cx, 
                                       BitsPerFormat(pso->iBitmapFormat));
 
         /* Create a bitmap for saving the pixels under the cursor. */
                                       BitsPerFormat(pso->iBitmapFormat));
 
         /* Create a bitmap for saving the pixels under the cursor. */
index 8ebcf94..802028d 100644 (file)
@@ -12,7 +12,6 @@ INT     APIENTRY  BITMAP_GetObject(SURFACE * bmp, INT count, LPVOID buffer);
 HBITMAP FASTCALL IntCreateBitmap(IN SIZEL Size, IN LONG Width, IN ULONG Format, IN ULONG Flags, IN PVOID Bits);
 HBITMAP FASTCALL BITMAP_CopyBitmap (HBITMAP  hBitmap);
 UINT    FASTCALL BITMAP_GetRealBitsPixel(UINT nBitsPixel);
 HBITMAP FASTCALL IntCreateBitmap(IN SIZEL Size, IN LONG Width, IN ULONG Format, IN ULONG Flags, IN PVOID Bits);
 HBITMAP FASTCALL BITMAP_CopyBitmap (HBITMAP  hBitmap);
 UINT    FASTCALL BITMAP_GetRealBitsPixel(UINT nBitsPixel);
-INT     FASTCALL BITMAP_GetWidthBytes (INT bmWidth, INT bpp);
 
 HBITMAP
 APIENTRY
 
 HBITMAP
 APIENTRY
index 8b53526..9d5b2b1 100644 (file)
@@ -11,8 +11,6 @@ DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
                        LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size );
 INT APIENTRY
 DIB_GetDIBImageBytes (INT  width, INT height, INT depth);
                        LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size );
 INT APIENTRY
 DIB_GetDIBImageBytes (INT  width, INT height, INT depth);
-INT FASTCALL
-DIB_GetDIBWidthBytes (INT width, INT depth);
 HPALETTE FASTCALL
 DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi);
 
 HPALETTE FASTCALL
 DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi);
 
index 442a810..f8e0313 100644 (file)
@@ -55,7 +55,7 @@ UnsafeSetBitmapBits(
     pjDst = psurf->SurfObj.pvScan0;
     pjSrc = pvBits;
     lDeltaDst = psurf->SurfObj.lDelta;
     pjDst = psurf->SurfObj.pvScan0;
     pjSrc = pvBits;
     lDeltaDst = psurf->SurfObj.lDelta;
-    lDeltaSrc = BITMAP_GetWidthBytes(nWidth, cBitsPixel);
+    lDeltaSrc = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel);
 
     while (nHeight--)
     {
 
     while (nHeight--)
     {
@@ -186,7 +186,7 @@ NtGdiCreateBitmap(
     }
 
     /* Make sure that cjBits will not overflow */
     }
 
     /* Make sure that cjBits will not overflow */
-    cjWidthBytes = BITMAP_GetWidthBytes(nWidth, cBitsPixel);
+    cjWidthBytes = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel);
     if ((ULONGLONG)cjWidthBytes * nHeight >= 0x100000000ULL)
     {
         DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
     if ((ULONGLONG)cjWidthBytes * nHeight >= 0x100000000ULL)
     {
         DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
@@ -581,7 +581,7 @@ UnsafeGetBitmapBits(
     pjSrc = psurf->SurfObj.pvScan0;
     pjDst = pvBits;
     lDeltaSrc = psurf->SurfObj.lDelta;
     pjSrc = psurf->SurfObj.pvScan0;
     pjDst = pvBits;
     lDeltaSrc = psurf->SurfObj.lDelta;
-    lDeltaDst = BITMAP_GetWidthBytes(nWidth, cBitsPixel);
+    lDeltaDst = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel);
 
     while (nHeight--)
     {
 
     while (nHeight--)
     {
@@ -613,7 +613,7 @@ NtGdiGetBitmapBits(
         return 0;
     }
 
         return 0;
     }
 
-    bmSize = BITMAP_GetWidthBytes(psurf->SurfObj.sizlBitmap.cx,
+    bmSize = WIDTH_BYTES_ALIGN16(psurf->SurfObj.sizlBitmap.cx,
              BitsPerFormat(psurf->SurfObj.iBitmapFormat)) *
              abs(psurf->SurfObj.sizlBitmap.cy);
 
              BitsPerFormat(psurf->SurfObj.iBitmapFormat)) *
              abs(psurf->SurfObj.sizlBitmap.cy);
 
@@ -858,40 +858,6 @@ BITMAP_GetRealBitsPixel(UINT nBitsPixel)
     return 0;
 }
 
     return 0;
 }
 
-INT FASTCALL
-BITMAP_GetWidthBytes(INT bmWidth, INT bpp)
-{
-#if 0
-    switch (bpp)
-    {
-    case 1:
-        return 2 * ((bmWidth+15) >> 4);
-
-    case 24:
-        bmWidth *= 3; /* fall through */
-    case 8:
-        return bmWidth + (bmWidth & 1);
-
-    case 32:
-        return bmWidth * 4;
-
-    case 16:
-    case 15:
-        return bmWidth * 2;
-
-    case 4:
-        return 2 * ((bmWidth+3) >> 2);
-
-    default:
-        DPRINT ("stub");
-    }
-
-    return -1;
-#endif
-
-    return ((bmWidth * bpp + 15) & ~15) >> 3;
-}
-
 HBITMAP FASTCALL
 BITMAP_CopyBitmap(HBITMAP hBitmap)
 {
 HBITMAP FASTCALL
 BITMAP_CopyBitmap(HBITMAP hBitmap)
 {
@@ -963,7 +929,7 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
     pBitmap->bmHeight = psurf->SurfObj.sizlBitmap.cy;
     pBitmap->bmPlanes = 1;
     pBitmap->bmBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
     pBitmap->bmHeight = psurf->SurfObj.sizlBitmap.cy;
     pBitmap->bmPlanes = 1;
     pBitmap->bmBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
-       pBitmap->bmWidthBytes = BITMAP_GetWidthBytes(pBitmap->bmWidth, pBitmap->bmBitsPixel);
+       pBitmap->bmWidthBytes = WIDTH_BYTES_ALIGN16(pBitmap->bmWidth, pBitmap->bmBitsPixel);
 
     /* Check for DIB section */
     if (psurf->hSecure)
 
     /* Check for DIB section */
     if (psurf->hSecure)
@@ -971,7 +937,7 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
         /* Set bmBits in this case */
         pBitmap->bmBits = psurf->SurfObj.pvBits;
                /* DIBs data are 32 bits aligned */
         /* Set bmBits in this case */
         pBitmap->bmBits = psurf->SurfObj.pvBits;
                /* DIBs data are 32 bits aligned */
-               pBitmap->bmWidthBytes = DIB_GetDIBWidthBytes(pBitmap->bmWidth, pBitmap->bmBitsPixel);
+               pBitmap->bmWidthBytes = WIDTH_BYTES_ALIGN32(pBitmap->bmWidth, pBitmap->bmBitsPixel);
 
         if (Count >= sizeof(DIBSECTION))
         {
 
         if (Count >= sizeof(DIBSECTION))
         {
index 9ed3214..e2bab28 100644 (file)
@@ -480,7 +480,7 @@ NtGdiSetDIBitsToDeviceInternal(
     SourceSize.cx = bmi->bmiHeader.biWidth;
     SourceSize.cy = ScanLines;
 
     SourceSize.cx = bmi->bmiHeader.biWidth;
     SourceSize.cy = ScanLines;
 
-    DIBWidth = DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount);
+    DIBWidth = WIDTH_BYTES_ALIGN32(SourceSize.cx, bmi->bmiHeader.biBitCount);
 
     hSourceBitmap = EngCreateBitmap(SourceSize,
                                     DIBWidth,
 
     hSourceBitmap = EngCreateBitmap(SourceSize,
                                     DIBWidth,
@@ -1390,7 +1390,7 @@ DIB_CreateDIBSection(
     bm.bmType = 0;
     bm.bmWidth = bi->biWidth;
     bm.bmHeight = effHeight;
     bm.bmType = 0;
     bm.bmWidth = bi->biWidth;
     bm.bmHeight = effHeight;
-    bm.bmWidthBytes = ovr_pitch ? ovr_pitch : (ULONG) DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount);
+    bm.bmWidthBytes = ovr_pitch ? ovr_pitch : WIDTH_BYTES_ALIGN32(bm.bmWidth, bi->biBitCount);
 
     bm.bmPlanes = bi->biPlanes;
     bm.bmBitsPixel = bi->biBitCount;
 
     bm.bmPlanes = bi->biPlanes;
     bm.bmBitsPixel = bi->biBitCount;
@@ -1602,18 +1602,6 @@ DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
     return -1;
 }
 
     return -1;
 }
 
-/***********************************************************************
- *           DIB_GetDIBWidthBytes
- *
- * Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
- * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/struc/src/str01.htm
- * 11/16/1999 (RJJ) lifted from wine
- */
-INT FASTCALL DIB_GetDIBWidthBytes(INT width, INT depth)
-{
-    return ((width * depth + 31) & ~31) >> 3;
-}
-
 /***********************************************************************
  *           DIB_GetDIBImageBytes
  *
 /***********************************************************************
  *           DIB_GetDIBImageBytes
  *
@@ -1623,7 +1611,7 @@ INT FASTCALL DIB_GetDIBWidthBytes(INT width, INT depth)
 
 INT APIENTRY DIB_GetDIBImageBytes(INT  width, INT height, INT depth)
 {
 
 INT APIENTRY DIB_GetDIBImageBytes(INT  width, INT height, INT depth)
 {
-    return DIB_GetDIBWidthBytes(width, depth) * (height < 0 ? -height : height);
+    return WIDTH_BYTES_ALIGN32(width, depth) * (height < 0 ? -height : height);
 }
 
 /***********************************************************************
 }
 
 /***********************************************************************