Author: jgardou
Date: Mon Aug  2 01:41:16 2010
New Revision: 48408
URL: 
http://svn.reactos.org/svn/reactos?rev=48408&view=rev
Log:
[WIN32K]
  - Apply a better fix for correctly report 16 bits alignment for DDBs, and keep them 32
bits aligned as it should be.
  - Reapply Pigglesworth patch, which was correct since mine was not.
Dedicated to tkreuzer, PigglesWorth and lassy, the three guys still on IRC to watch my
commits at 3:30 AM.
Modified:
    branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
    branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
    branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] Mon Aug
2 01:41:16 2010
@@ -202,17 +202,13 @@
     /* Is a width in bytes given? */
     if (!ulWidth)
     {
-               /* Align the width (windows compatibility) */
-               if(psurf->flags & DDB_SURFACE)
-               {
-                       /* DDB are 16 bits aligned */
-                       ulWidth = BITMAP_GetWidthBytes(pso->sizlBitmap.cx, cBitsPixel);
-               }
-               else
-               {
-                       /* Others are 32 bits aligned */
-                       ulWidth = DIB_GetDIBWidthBytes(pso->sizlBitmap.cx, cBitsPixel);
-               }
+        /* Calculate width from the bitmap width in pixels */
+        ulWidth = DIB_GetDIBWidthBytes(psurf->SurfObj.sizlBitmap.cx, cBitsPixel);
+    }
+       else
+       {
+               /* Align the width (windows compatibility, drivers expect that) */
+       ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 31) & ~31) >> 3;
        }
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Mon
Aug  2 01:41:16 2010
@@ -949,15 +949,17 @@
     pBitmap->bmType = 0;
     pBitmap->bmWidth = psurf->SurfObj.sizlBitmap.cx;
     pBitmap->bmHeight = psurf->SurfObj.sizlBitmap.cy;
-    pBitmap->bmWidthBytes = abs(psurf->SurfObj.lDelta);
     pBitmap->bmPlanes = 1;
     pBitmap->bmBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
+       pBitmap->bmWidthBytes = BITMAP_GetWidthBytes(pBitmap->bmWidth,
pBitmap->bmBitsPixel);
     /* Check for DIB section */
     if (psurf->hSecure)
     {
         /* Set bmBits in this case */
         pBitmap->bmBits = psurf->SurfObj.pvBits;
+               /* DIBs data are 32 bits aligned */
+               pBitmap->bmWidthBytes = DIB_GetDIBWidthBytes(pBitmap->bmWidth,
pBitmap->bmBitsPixel);
         if (Count >= sizeof(DIBSECTION))
         {
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c [iso-8859-1] Mon Aug
2 01:41:16 2010
@@ -25,7 +25,7 @@
   RGN_ATTR Attr[GDIOBJATTRFREE];
 } GDI_OBJ_ATTR_ENTRY, *PGDI_OBJ_ATTR_ENTRY;
-static const USHORT HatchBrushes[NB_HATCH_STYLES][8] =
+static const ULONG HatchBrushes[NB_HATCH_STYLES][8] =
 {
     {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF}, /* HS_HORIZONTAL */
     {0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7}, /* HS_VERTICAL   */