if ((nWidth % 4) != 0)
{
- nXSrc -= (nWidth % 4);
- nWidth += (nWidth % 4);
+ nWidth += (4 - (nWidth % 4));
}
if ((nHeight % 4) != 0)
{
- nYSrc -= (nHeight % 4);
- nHeight += (nHeight % 4);
+ nHeight += (4 - (nHeight % 4));
}
for (yIdx = 0; yIdx < rows; yIdx++)
#include "shadow.h"
#include "shadow_surface.h"
-
+#define ALIGN_SCREEN_SIZE(size, align) ((size + align - 1) & (~(align - 1)))
rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, int x, int y, int width, int height)
{
rdpShadowSurface* surface;
surface->y = y;
surface->width = width;
surface->height = height;
- surface->scanline = (surface->width + (surface->width % 4)) * 4;
+ surface->scanline = ALIGN_SCREEN_SIZE(surface->width, 4) * 4;
- surface->data = (BYTE*) calloc(1, surface->scanline * surface->height);
+ surface->data = (BYTE*) calloc(1, surface->scanline * ALIGN_SCREEN_SIZE(surface->height, 4));
if (!surface->data)
{
free (surface);
BOOL shadow_surface_resize(rdpShadowSurface *surface, int x, int y, int width, int height)
{
BYTE* buffer = NULL;
- int scanline = (width + (width % 4)) * 4;
+ int scanline = ALIGN_SCREEN_SIZE(width, 4) * 4;
if (!surface)
return FALSE;
return TRUE;
}
- buffer = (BYTE*) realloc(surface->data, scanline * height);
+ buffer = (BYTE*) realloc(surface->data, scanline * ALIGN_SCREEN_SIZE(height, 4));
if (buffer)
{
surface->x = x;