Author: tkreuzer Date: Wed Sep 1 12:04:31 2010 New Revision: 48675
URL: http://svn.reactos.org/svn/reactos?rev=48675&view=rev Log: Add macros WIDTH_BYTES_ALIGN16/32
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- 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] Wed Sep 1 12:04:31 2010 @@ -200,17 +200,16 @@ cBitsPixel = gajBitsPerFormat[pso->iBitmapFormat];
/* Is a width in bytes given? */ - if (!ulWidth) - { - /* Calculate width from the bitmap width in pixels */ - ulWidth = DIB_GetDIBWidthBytes(psurf->SurfObj.sizlBitmap.cx, cBitsPixel); + if (ulWidth) + { + /* Align the width (Windows compatibility, drivers expect that) */ + ulWidth = WIDTH_BYTES_ALIGN32((ulWidth << 3) / cBitsPixel, cBitsPixel); } else { - /* Align the width (windows compatibility, drivers expect that) */ - ulWidth = ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 31) & ~31) >> 3; + /* Calculate width from the bitmap width in pixels */ + ulWidth = WIDTH_BYTES_ALIGN32(pso->sizlBitmap.cx, cBitsPixel); } -
/* Calculate the bitmap size in bytes */ pso->cjBits = ulWidth * pso->sizlBitmap.cy;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h [iso-8859-1] Wed Sep 1 12:04:31 2010 @@ -128,3 +128,7 @@ ULONG FASTCALL BitmapFormat (WORD Bits, DWORD Compression); extern UCHAR gajBitsPerFormat[]; #define BitsPerFormat(Format) gajBitsPerFormat[Format] + +#define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3) +#define WIDTH_BYTES_ALIGN16(cx, bpp) ((((cx) * (bpp) + 15) & ~15) >> 3) +