xrdp: add an option to do md5 bitmap hash for bitmap cache

ulab-next
Jay Sorg 10 years ago
parent da0d0e687a
commit 8f05bee238

@ -207,6 +207,8 @@ xrdp_bitmap_copy_box(struct xrdp_bitmap* self,
struct xrdp_bitmap* dest,
int x, int y, int cx, int cy);
int APP_CC
xrdp_bitmap_hash_crc(struct xrdp_bitmap *self);
int APP_CC
xrdp_bitmap_copy_box_with_crc(struct xrdp_bitmap* self,
struct xrdp_bitmap* dest,
int x, int y, int cx, int cy);

@ -729,11 +729,17 @@ xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
struct xrdp_bitmap *dest,
int x, int y, int cx, int cy)
{
int i = 0;
int j = 0;
int destx = 0;
int desty = 0;
int pixel = 0;
int i;
int destx;
int desty;
int incs;
int incd;
tui8 *s8;
tui8 *d8;
tui16 *s16;
tui16 *d16;
tui32 *s32;
tui32 *d32;
if (self == 0)
{
@ -775,35 +781,54 @@ xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
if (self->bpp == 24)
{
s32 = ((tui32 *)(self->data)) + (self->width * y + x);
d32 = ((tui32 *)(dest->data)) + (dest->width * desty + destx);
incs = self->width - cx;
incd = dest->width - cx;
for (i = 0; i < cy; i++)
{
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL32(self->data, j + x, i + y, self->width);
SETPIXEL32(dest->data, j + destx, i + desty, dest->width, pixel);
}
g_memcpy(d32, s32, cx * 4);
s32 += cx;
d32 += cx;
s32 += incs;
d32 += incd;
}
}
else if (self->bpp == 15 || self->bpp == 16)
{
s16 = ((tui16 *)(self->data)) + (self->width * y + x);
d16 = ((tui16 *)(dest->data)) + (dest->width * desty + destx);
incs = self->width - cx;
incd = dest->width - cx;
for (i = 0; i < cy; i++)
{
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL16(self->data, j + x, i + y, self->width);
SETPIXEL16(dest->data, j + destx, i + desty, dest->width, pixel);
}
g_memcpy(d16, s16, cx * 2);
s16 += cx;
d16 += cx;
s16 += incs;
d16 += incd;
}
}
else if (self->bpp == 8)
{
s8 = ((tui8 *)(self->data)) + (self->width * y + x);
d8 = ((tui8 *)(dest->data)) + (dest->width * desty + destx);
incs = self->width - cx;
incd = dest->width - cx;
for (i = 0; i < cy; i++)
{
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL8(self->data, j + x, i + y, self->width);
SETPIXEL8(dest->data, j + destx, i + desty, dest->width, pixel);
}
g_memcpy(d8, s8, cx);
s8 += cx;
d8 += cx;
s8 += incs;
d8 += incd;
}
}
else
@ -814,6 +839,51 @@ xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
return 0;
}
/*****************************************************************************/
int APP_CC
xrdp_bitmap_hash_crc(struct xrdp_bitmap *self)
{
void *hash;
int bytes;
int crc;
int index;
char hash_data[16];
if (self->bpp == 24)
{
bytes = self->width * self->height * 4;
}
else if (self->bpp == 15 || self->bpp == 16)
{
bytes = self->width * self->height * 2;
}
else if (self->bpp == 8)
{
bytes = self->width * self->height;
}
else
{
return 1;
}
hash = ssl_md5_info_create();
ssl_md5_transform(hash, self->data, bytes);
ssl_md5_complete(hash, hash_data);
ssl_md5_info_delete(hash);
CRC_START(crc);
CRC_PASS(self->width, crc);
CRC_PASS(self->width >> 8, crc);
CRC_PASS(self->height, crc);
CRC_PASS(self->height >> 8, crc);
for (index = 0; index < 16; index++)
{
CRC_PASS(hash_data[index], crc);
}
CRC_END(crc);
self->crc32 = crc;
self->crc16 = self->crc32 & 0xffff;
return 0;
}
/*****************************************************************************/
/* copy part of self at x, y to 0, 0 in dest */
/* returns error */

@ -850,7 +850,12 @@ xrdp_painter_copy(struct xrdp_painter *self,
w = MIN(64, ((srcx + cx) - i));
h = MIN(64, ((srcy + cy) - j));
b = xrdp_bitmap_create(w, h, src->bpp, 0, self->wm);
#if 1
xrdp_bitmap_copy_box_with_crc(src, b, i, j, w, h);
#else
xrdp_bitmap_copy_box(src, b, i, j, w, h);
xrdp_bitmap_hash_crc(b);
#endif
bitmap_id = xrdp_cache_add_bitmap(self->wm->cache, b, self->wm->hints);
cache_id = HIWORD(bitmap_id);
cache_idx = LOWORD(bitmap_id);

Loading…
Cancel
Save