19 #include <freerdp/config.h>
23 #include "shadow_surface.h"
24 #define ALIGN_SCREEN_SIZE(size, align) \
25 ((((size) % (align)) != 0) ? ((size) + (align) - ((size) % (align))) : (size))
27 rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, UINT16 x, UINT16 y, UINT32 width,
30 rdpShadowSurface* surface = NULL;
31 surface = (rdpShadowSurface*)calloc(1,
sizeof(rdpShadowSurface));
36 surface->server = server;
39 surface->width = width;
40 surface->height = height;
41 surface->scanline = ALIGN_SCREEN_SIZE(surface->width, 32) * 4;
42 surface->format = PIXEL_FORMAT_BGRX32;
43 surface->data = (BYTE*)calloc(ALIGN_SCREEN_SIZE(surface->height, 32), surface->scanline);
51 if (!InitializeCriticalSectionAndSpinCount(&(surface->lock), 4000))
58 region16_init(&(surface->invalidRegion));
62 void shadow_surface_free(rdpShadowSurface* surface)
68 DeleteCriticalSection(&(surface->lock));
69 region16_uninit(&(surface->invalidRegion));
73 BOOL shadow_surface_resize(rdpShadowSurface* surface, UINT16 x, UINT16 y, UINT32 width,
77 UINT32 scanline = ALIGN_SCREEN_SIZE(width, 4) * 4;
82 if ((width == surface->width) && (height == surface->height))
90 buffer = (BYTE*)realloc(surface->data, 1ull * scanline * ALIGN_SCREEN_SIZE(height, 4ull));
96 surface->width = width;
97 surface->height = height;
98 surface->scanline = scanline;
99 surface->data = buffer;