xfreerdp: fix bitmap updates after refactoring
This commit is contained in:
parent
dbdbea9285
commit
657fd998e5
@ -170,7 +170,7 @@ void wf_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
|
|||||||
|
|
||||||
for (i = 0; i < bitmap->number; i++)
|
for (i = 0; i < bitmap->number; i++)
|
||||||
{
|
{
|
||||||
bmp = &bitmap->bitmaps[i];
|
bmp = &bitmap->rectangles[i];
|
||||||
|
|
||||||
wf_bmp = wf_image_new(wfi, bmp->width, bmp->height, wfi->srcBpp, bmp->dstData);
|
wf_bmp = wf_image_new(wfi, bmp->width, bmp->height, wfi->srcBpp, bmp->dstData);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
|
|||||||
XImage* image;
|
XImage* image;
|
||||||
xfInfo* xfi = ((xfContext*) context)->xfi;
|
xfInfo* xfi = ((xfContext*) context)->xfi;
|
||||||
|
|
||||||
|
XSetFunction(xfi->display, xfi->gc, GXcopy);
|
||||||
pixmap = XCreatePixmap(xfi->display, xfi->drawable, bitmap->width, bitmap->height, xfi->depth);
|
pixmap = XCreatePixmap(xfi->display, xfi->drawable, bitmap->width, bitmap->height, xfi->depth);
|
||||||
|
|
||||||
if (bitmap->data != NULL)
|
if (bitmap->data != NULL)
|
||||||
@ -44,17 +45,24 @@ void xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
|
|||||||
data = freerdp_image_convert(bitmap->data, NULL,
|
data = freerdp_image_convert(bitmap->data, NULL,
|
||||||
bitmap->width, bitmap->height, bitmap->bpp, xfi->bpp, xfi->clrconv);
|
bitmap->width, bitmap->height, bitmap->bpp, xfi->bpp, xfi->clrconv);
|
||||||
|
|
||||||
image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
|
if (bitmap->ephemeral != True)
|
||||||
|
{
|
||||||
|
image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
|
||||||
ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, xfi->scanline_pad, 0);
|
ZPixmap, 0, (char*) data, bitmap->width, bitmap->height, xfi->scanline_pad, 0);
|
||||||
|
|
||||||
XPutImage(xfi->display, pixmap, xfi->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
|
XPutImage(xfi->display, pixmap, xfi->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
|
||||||
|
XFree(image);
|
||||||
|
|
||||||
if (data != bitmap->data)
|
if (data != bitmap->data)
|
||||||
xfree(data);
|
xfree(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bitmap->data = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((xfBitmap*) bitmap)->pixmap = pixmap;
|
((xfBitmap*) bitmap)->pixmap = pixmap;
|
||||||
((xfBitmap*) bitmap)->image = image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
||||||
@ -65,17 +73,32 @@ void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
|||||||
XFreePixmap(xfi->display, ((xfBitmap*) bitmap)->pixmap);
|
XFreePixmap(xfi->display, ((xfBitmap*) bitmap)->pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap, int x, int y)
|
void xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
|
||||||
{
|
{
|
||||||
|
XImage* image;
|
||||||
|
int width, height;
|
||||||
xfInfo* xfi = ((xfContext*) context)->xfi;
|
xfInfo* xfi = ((xfContext*) context)->xfi;
|
||||||
|
|
||||||
|
width = bitmap->right - bitmap->left + 1;
|
||||||
|
height = bitmap->bottom - bitmap->top + 1;
|
||||||
|
|
||||||
|
XSetFunction(xfi->display, xfi->gc, GXcopy);
|
||||||
|
|
||||||
|
image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
|
||||||
|
ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfi->scanline_pad, 0);
|
||||||
|
|
||||||
XPutImage(xfi->display, xfi->primary, xfi->gc,
|
XPutImage(xfi->display, xfi->primary, xfi->gc,
|
||||||
((xfBitmap*) bitmap)->image, 0, 0, x, y, bitmap->width, bitmap->height);
|
image, 0, 0, bitmap->left, bitmap->top, width, height);
|
||||||
|
|
||||||
|
XFree(image);
|
||||||
|
|
||||||
if (xfi->remote_app != True)
|
if (xfi->remote_app != True)
|
||||||
XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, bitmap->width, bitmap->height, x, y);
|
{
|
||||||
|
XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc,
|
||||||
|
bitmap->left, bitmap->top, width, height, bitmap->left, bitmap->top);
|
||||||
|
}
|
||||||
|
|
||||||
gdi_InvalidateRegion(xfi->hdc, x, y, bitmap->width, bitmap->height);
|
gdi_InvalidateRegion(xfi->hdc, bitmap->left, bitmap->top, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||||
@ -94,8 +117,7 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
|||||||
{
|
{
|
||||||
boolean status;
|
boolean status;
|
||||||
|
|
||||||
status = bitmap_decompress(data, bitmap->data,
|
status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp);
|
||||||
width, height, length, bpp, bpp);
|
|
||||||
|
|
||||||
if (status != True)
|
if (status != True)
|
||||||
{
|
{
|
||||||
@ -104,11 +126,9 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
freerdp_image_flip(data, data, width, height, bpp);
|
freerdp_image_flip(data, bitmap->data, width, height, bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap->width = width;
|
|
||||||
bitmap->height = height;
|
|
||||||
bitmap->compressed = False;
|
bitmap->compressed = False;
|
||||||
bitmap->length = size;
|
bitmap->length = size;
|
||||||
bitmap->bpp = bpp;
|
bitmap->bpp = bpp;
|
||||||
|
@ -55,7 +55,6 @@ struct xf_bitmap
|
|||||||
{
|
{
|
||||||
rdpBitmap bitmap;
|
rdpBitmap bitmap;
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
XImage* image;
|
|
||||||
};
|
};
|
||||||
typedef struct xf_bitmap xfBitmap;
|
typedef struct xf_bitmap xfBitmap;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ typedef struct rdp_pointer rdpPointer;
|
|||||||
|
|
||||||
typedef void (*pBitmap_New)(rdpContext* context, rdpBitmap* bitmap);
|
typedef void (*pBitmap_New)(rdpContext* context, rdpBitmap* bitmap);
|
||||||
typedef void (*pBitmap_Free)(rdpContext* context, rdpBitmap* bitmap);
|
typedef void (*pBitmap_Free)(rdpContext* context, rdpBitmap* bitmap);
|
||||||
typedef void (*pBitmap_Paint)(rdpContext* context, rdpBitmap* bitmap, int x, int y);
|
typedef void (*pBitmap_Paint)(rdpContext* context, rdpBitmap* bitmap);
|
||||||
typedef void (*pBitmap_Decompress)(rdpContext* context, rdpBitmap* bitmap,
|
typedef void (*pBitmap_Decompress)(rdpContext* context, rdpBitmap* bitmap,
|
||||||
uint8* data, int width, int height, int bpp, int length, boolean compressed);
|
uint8* data, int width, int height, int bpp, int length, boolean compressed);
|
||||||
typedef void (*pBitmap_SetSurface)(rdpContext* context, rdpBitmap* bitmap, boolean primary);
|
typedef void (*pBitmap_SetSurface)(rdpContext* context, rdpBitmap* bitmap, boolean primary);
|
||||||
@ -51,6 +51,7 @@ struct rdp_bitmap
|
|||||||
uint16 top;
|
uint16 top;
|
||||||
uint16 right;
|
uint16 right;
|
||||||
uint16 bottom;
|
uint16 bottom;
|
||||||
|
|
||||||
uint16 width;
|
uint16 width;
|
||||||
uint16 height;
|
uint16 height;
|
||||||
uint16 bpp;
|
uint16 bpp;
|
||||||
@ -59,6 +60,7 @@ struct rdp_bitmap
|
|||||||
uint8* data;
|
uint8* data;
|
||||||
|
|
||||||
boolean compressed;
|
boolean compressed;
|
||||||
|
boolean ephemeral;
|
||||||
};
|
};
|
||||||
|
|
||||||
FREERDP_API rdpBitmap* Bitmap_Alloc(rdpContext* context);
|
FREERDP_API rdpBitmap* Bitmap_Alloc(rdpContext* context);
|
||||||
@ -67,6 +69,9 @@ FREERDP_API void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap);
|
|||||||
FREERDP_API void Bitmap_Register(rdpContext* context, rdpBitmap* bitmap);
|
FREERDP_API void Bitmap_Register(rdpContext* context, rdpBitmap* bitmap);
|
||||||
FREERDP_API void Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
FREERDP_API void Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||||
uint8* data, int width, int height, int bpp, int length, boolean compressed);
|
uint8* data, int width, int height, int bpp, int length, boolean compressed);
|
||||||
|
FREERDP_API void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap,
|
||||||
|
uint16 left, uint16 top, uint16 right, uint16 bottom);
|
||||||
|
FREERDP_API void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, uint16 width, uint16 height);
|
||||||
FREERDP_API void Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, boolean primary);
|
FREERDP_API void Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, boolean primary);
|
||||||
|
|
||||||
/* Pointer Class */
|
/* Pointer Class */
|
||||||
|
@ -91,7 +91,7 @@ struct _BITMAP_UPDATE
|
|||||||
{
|
{
|
||||||
uint16 count;
|
uint16 count;
|
||||||
uint16 number;
|
uint16 number;
|
||||||
BITMAP_DATA* bitmaps;
|
BITMAP_DATA* rectangles;
|
||||||
};
|
};
|
||||||
typedef struct _BITMAP_UPDATE BITMAP_UPDATE;
|
typedef struct _BITMAP_UPDATE BITMAP_UPDATE;
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ void update_gdi_cache_bitmap(rdpUpdate* update, CACHE_BITMAP_V2_ORDER* cache_bit
|
|||||||
|
|
||||||
bitmap = Bitmap_Alloc(update->context);
|
bitmap = Bitmap_Alloc(update->context);
|
||||||
|
|
||||||
|
Bitmap_SetDimensions(update->context, bitmap, cache_bitmap->bitmapWidth, cache_bitmap->bitmapHeight);
|
||||||
|
|
||||||
bitmap->Decompress(update->context, bitmap,
|
bitmap->Decompress(update->context, bitmap,
|
||||||
cache_bitmap->bitmapDataStream, cache_bitmap->bitmapWidth, cache_bitmap->bitmapHeight,
|
cache_bitmap->bitmapDataStream, cache_bitmap->bitmapWidth, cache_bitmap->bitmapHeight,
|
||||||
cache_bitmap->bitmapBpp, cache_bitmap->bitmapLength, cache_bitmap->compressed);
|
cache_bitmap->bitmapBpp, cache_bitmap->bitmapLength, cache_bitmap->compressed);
|
||||||
@ -81,13 +83,25 @@ void update_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap_update)
|
|||||||
rdpCache* cache = update->context->cache;
|
rdpCache* cache = update->context->cache;
|
||||||
|
|
||||||
if (cache->bitmap->bitmap == NULL)
|
if (cache->bitmap->bitmap == NULL)
|
||||||
|
{
|
||||||
cache->bitmap->bitmap = Bitmap_Alloc(update->context);
|
cache->bitmap->bitmap = Bitmap_Alloc(update->context);
|
||||||
|
cache->bitmap->bitmap->ephemeral = True;
|
||||||
|
}
|
||||||
|
|
||||||
bitmap = cache->bitmap->bitmap;
|
bitmap = cache->bitmap->bitmap;
|
||||||
|
|
||||||
for (i = 0; i < bitmap_update->number; i++)
|
for (i = 0; i < bitmap_update->number; i++)
|
||||||
{
|
{
|
||||||
bitmap_data = &bitmap_update->bitmaps[i];
|
bitmap_data = &bitmap_update->rectangles[i];
|
||||||
|
|
||||||
|
bitmap->bpp = bitmap_data->bitsPerPixel;
|
||||||
|
bitmap->length = bitmap_data->bitmapLength;
|
||||||
|
|
||||||
|
Bitmap_SetRectangle(update->context, bitmap,
|
||||||
|
bitmap_data->destLeft, bitmap_data->destTop,
|
||||||
|
bitmap_data->destRight, bitmap_data->destBottom);
|
||||||
|
|
||||||
|
Bitmap_SetDimensions(update->context, bitmap, bitmap_data->width, bitmap_data->height);
|
||||||
|
|
||||||
bitmap->Decompress(update->context, bitmap,
|
bitmap->Decompress(update->context, bitmap,
|
||||||
bitmap_data->bitmapDataStream, bitmap_data->width, bitmap_data->height,
|
bitmap_data->bitmapDataStream, bitmap_data->width, bitmap_data->height,
|
||||||
@ -95,7 +109,7 @@ void update_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap_update)
|
|||||||
|
|
||||||
bitmap->New(update->context, bitmap);
|
bitmap->New(update->context, bitmap);
|
||||||
|
|
||||||
bitmap->Paint(update->context, bitmap, bitmap_data->destLeft, bitmap_data->destTop);
|
bitmap->Paint(update->context, bitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ rdpBitmap* Bitmap_Alloc(rdpContext* context)
|
|||||||
if (bitmap != NULL)
|
if (bitmap != NULL)
|
||||||
{
|
{
|
||||||
memcpy(bitmap, context->graphics->Bitmap_Prototype, sizeof(rdpBitmap));
|
memcpy(bitmap, context->graphics->Bitmap_Prototype, sizeof(rdpBitmap));
|
||||||
|
bitmap->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
@ -55,15 +56,18 @@ void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap, int x, int y)
|
void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap, uint16 left, uint16 top, uint16 right, uint16 bottom)
|
||||||
{
|
{
|
||||||
bitmap->Paint(context, bitmap, x, y);
|
bitmap->left = left;
|
||||||
|
bitmap->top = top;
|
||||||
|
bitmap->right = right;
|
||||||
|
bitmap->bottom = bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, uint16 width, uint16 height)
|
||||||
uint8* data, int width, int height, int bpp, int length, boolean compressed)
|
|
||||||
{
|
{
|
||||||
bitmap->Decompress(context, bitmap, data, width, height, bpp, length, compressed);
|
bitmap->width = width;
|
||||||
|
bitmap->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static method */
|
/* static method */
|
||||||
|
@ -46,8 +46,6 @@ void update_recv_orders(rdpUpdate* update, STREAM* s)
|
|||||||
|
|
||||||
void update_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data)
|
void update_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data)
|
||||||
{
|
{
|
||||||
uint16 bytesPerPixel;
|
|
||||||
|
|
||||||
stream_read_uint16(s, bitmap_data->destLeft);
|
stream_read_uint16(s, bitmap_data->destLeft);
|
||||||
stream_read_uint16(s, bitmap_data->destTop);
|
stream_read_uint16(s, bitmap_data->destTop);
|
||||||
stream_read_uint16(s, bitmap_data->destRight);
|
stream_read_uint16(s, bitmap_data->destRight);
|
||||||
@ -58,8 +56,6 @@ void update_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data)
|
|||||||
stream_read_uint16(s, bitmap_data->flags);
|
stream_read_uint16(s, bitmap_data->flags);
|
||||||
stream_read_uint16(s, bitmap_data->bitmapLength);
|
stream_read_uint16(s, bitmap_data->bitmapLength);
|
||||||
|
|
||||||
bytesPerPixel = (bitmap_data->bitsPerPixel + 7) / 8;
|
|
||||||
|
|
||||||
if (bitmap_data->flags & BITMAP_COMPRESSION)
|
if (bitmap_data->flags & BITMAP_COMPRESSION)
|
||||||
{
|
{
|
||||||
uint16 cbCompMainBodySize;
|
uint16 cbCompMainBodySize;
|
||||||
@ -96,10 +92,10 @@ void update_read_bitmap(rdpUpdate* update, STREAM* s, BITMAP_UPDATE* bitmap_upda
|
|||||||
|
|
||||||
count = bitmap_update->number * 2;
|
count = bitmap_update->number * 2;
|
||||||
|
|
||||||
bitmap_update->bitmaps = (BITMAP_DATA*) xrealloc(bitmap_update->bitmaps,
|
bitmap_update->rectangles = (BITMAP_DATA*) xrealloc(bitmap_update->rectangles,
|
||||||
sizeof(BITMAP_DATA) * count);
|
sizeof(BITMAP_DATA) * count);
|
||||||
|
|
||||||
memset(&bitmap_update->bitmaps[bitmap_update->count], 0,
|
memset(&bitmap_update->rectangles[bitmap_update->count], 0,
|
||||||
sizeof(BITMAP_DATA) * (count - bitmap_update->count));
|
sizeof(BITMAP_DATA) * (count - bitmap_update->count));
|
||||||
|
|
||||||
bitmap_update->count = count;
|
bitmap_update->count = count;
|
||||||
@ -108,7 +104,7 @@ void update_read_bitmap(rdpUpdate* update, STREAM* s, BITMAP_UPDATE* bitmap_upda
|
|||||||
/* rectangles */
|
/* rectangles */
|
||||||
for (i = 0; i < bitmap_update->number; i++)
|
for (i = 0; i < bitmap_update->number; i++)
|
||||||
{
|
{
|
||||||
update_read_bitmap_data(s, &bitmap_update->bitmaps[i]);
|
update_read_bitmap_data(s, &bitmap_update->rectangles[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +402,7 @@ rdpUpdate* update_new(rdpRdp* rdp)
|
|||||||
if (update != NULL)
|
if (update != NULL)
|
||||||
{
|
{
|
||||||
update->bitmap_update.count = 64;
|
update->bitmap_update.count = 64;
|
||||||
update->bitmap_update.bitmaps = (BITMAP_DATA*) xzalloc(sizeof(BITMAP_DATA) * update->bitmap_update.count);
|
update->bitmap_update.rectangles = (BITMAP_DATA*) xzalloc(sizeof(BITMAP_DATA) * update->bitmap_update.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return update;
|
return update;
|
||||||
@ -416,7 +412,7 @@ void update_free(rdpUpdate* update)
|
|||||||
{
|
{
|
||||||
if (update != NULL)
|
if (update != NULL)
|
||||||
{
|
{
|
||||||
xfree(update->bitmap_update.bitmaps);
|
xfree(update->bitmap_update.rectangles);
|
||||||
xfree(update);
|
xfree(update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,16 @@ void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap, int x, int y)
|
void gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
|
||||||
{
|
{
|
||||||
|
int width, height;
|
||||||
gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
|
gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
|
||||||
|
|
||||||
gdi_BitBlt(context->gdi->primary->hdc, x, y,
|
width = bitmap->right - bitmap->left + 1;
|
||||||
bitmap->width, bitmap->height,
|
height = bitmap->bottom - bitmap->top + 1;
|
||||||
gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
|
|
||||||
|
gdi_BitBlt(context->gdi->primary->hdc, bitmap->left, bitmap->top,
|
||||||
|
width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||||
|
Loading…
Reference in New Issue
Block a user