diff options
| author | Jay Sorg <jay.sorg@gmail.com> | 2014-03-16 00:09:58 -0700 |
|---|---|---|
| committer | Jay Sorg <jay.sorg@gmail.com> | 2014-03-16 00:09:58 -0700 |
| commit | 8f05bee2389c08dd2abd630941b544425c5ba7f1 (patch) | |
| tree | 09f70fe437d0b1cdb6b315818ccce237196a16a4 /xrdp/xrdp_bitmap.c | |
| parent | da0d0e687aa25beec2f80c247c51a31b148dbf46 (diff) | |
| download | xrdp-proprietary-8f05bee2389c08dd2abd630941b544425c5ba7f1.tar.gz xrdp-proprietary-8f05bee2389c08dd2abd630941b544425c5ba7f1.zip | |
xrdp: add an option to do md5 bitmap hash for bitmap cache
Diffstat (limited to 'xrdp/xrdp_bitmap.c')
| -rw-r--r-- | xrdp/xrdp_bitmap.c | 110 |
1 files changed, 90 insertions, 20 deletions
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 2fe87c4c..49750221 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -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 @@ -815,6 +840,51 @@ xrdp_bitmap_copy_box(struct xrdp_bitmap *self, } /*****************************************************************************/ +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 */ int APP_CC |
