[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Mon, 2 Aug 2010 01:41:16 +0000 (01:41 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Mon, 2 Aug 2010 01:41:16 +0000 (01:41 +0000)
  - 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.

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

subsystems/win32/win32k/eng/surface.c
subsystems/win32/win32k/objects/bitmaps.c
subsystems/win32/win32k/objects/brush.c

index 3229bb2..b1ac89f 100644 (file)
@@ -202,17 +202,13 @@ SURFACE_bSetBitmapBits(
     /* 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;
        }
 
 
index f5036a9..5d324d9 100644 (file)
@@ -949,15 +949,17 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
     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))
         {
index 2704538..d1f8175 100644 (file)
@@ -25,7 +25,7 @@ typedef struct _GDI_OBJ_ATTR_ENTRY
   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   */