From: Michael Jumper Date: Wed, 8 Feb 2012 23:09:12 +0000 (-0800) Subject: Restored handling of ephemeral, fixed allocation of buffer in bitmap new. X-Git-Url: http://git.alex.org.uk Restored handling of ephemeral, fixed allocation of buffer in bitmap new. --- diff --git a/src/client.c b/src/client.c index 798c488..89294e1 100644 --- a/src/client.c +++ b/src/client.c @@ -133,12 +133,12 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) { primary->MemBlt = guac_rdp_gdi_memblt; primary->OpaqueRect = guac_rdp_gdi_opaquerect; - /*pointer_cache_register_callbacks(instance->update);*/ + pointer_cache_register_callbacks(instance->update); glyph_cache_register_callbacks(instance->update); - /*brush_cache_register_callbacks(instance->update);*/ + brush_cache_register_callbacks(instance->update); bitmap_cache_register_callbacks(instance->update); - /*offscreen_cache_register_callbacks(instance->update);*/ - /*palette_cache_register_callbacks(instance->update);*/ + offscreen_cache_register_callbacks(instance->update); + palette_cache_register_callbacks(instance->update); /* Init channels (pre-connect) */ if (freerdp_channels_pre_connect(channels, instance)) { diff --git a/src/rdp_bitmap.c b/src/rdp_bitmap.c index 315ef36..ac5eb69 100644 --- a/src/rdp_bitmap.c +++ b/src/rdp_bitmap.c @@ -57,6 +57,12 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) { guac_client* client = ((rdp_freerdp_context*) context)->client; guac_socket* socket = client->socket; + /* Allocate buffer */ + guac_layer* buffer = guac_client_alloc_buffer(client); + + /* Store buffer reference in bitmap */ + ((guac_rdp_bitmap*) bitmap)->layer = buffer; + /* Convert image data if present */ if (bitmap->data != NULL) { @@ -66,30 +72,24 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) { context->instance->settings->color_depth, 32, ((rdp_freerdp_context*) context)->clrconv); - /* If not ephemeral, send to client */ - if (!bitmap->ephemeral) { + /* Create surface from image data */ + cairo_surface_t* surface = cairo_image_surface_create_for_data( + bitmap->data, CAIRO_FORMAT_RGB24, + bitmap->width, bitmap->height, 4*bitmap->width); - /* Allocate buffer */ - guac_layer* buffer = guac_client_alloc_buffer(client); + /* Send surface to buffer */ + guac_protocol_send_png(socket, GUAC_COMP_SRC, buffer, 0, 0, surface); - /* Create surface from image data */ - cairo_surface_t* surface = cairo_image_surface_create_for_data( - bitmap->data, CAIRO_FORMAT_RGB24, - bitmap->width, bitmap->height, 4*bitmap->width); + /* Free surface */ + cairo_surface_destroy(surface); - /* Send surface to buffer */ - guac_protocol_send_png(socket, GUAC_COMP_SRC, buffer, 0, 0, surface); - - /* Free surface */ - cairo_surface_destroy(surface); + /* If ephemeral, just free image data */ + if (!bitmap->ephemeral) { /* Free image data if actually alloated */ if (image_buffer != bitmap->data) free(image_buffer); - /* Store buffer reference in bitmap */ - ((guac_rdp_bitmap*) bitmap)->layer = buffer; - } /* Otherwise, store converted image in bitmap, free any existing */ @@ -102,9 +102,6 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) { /* Store converted image in bitmap */ bitmap->data = image_buffer; - /* Not stored in a layer */ - ((guac_rdp_bitmap*) bitmap)->layer = NULL; - } } @@ -116,15 +113,11 @@ void guac_rdp_bitmap_paint(rdpContext* context, rdpBitmap* bitmap) { guac_client* client = ((rdp_freerdp_context*) context)->client; guac_socket* socket = client->socket; - /* If not ephemeral, copy image data from buffer to visible layer */ - if (!bitmap->ephemeral) - guac_protocol_send_copy(socket, - ((guac_rdp_bitmap*) bitmap)->layer, - 0, 0, bitmap->width, bitmap->height, - GUAC_COMP_OVER, - GUAC_DEFAULT_LAYER, bitmap->left, bitmap->top); - - /* Otherwise, buffer apparently should not be drawn ... */ + guac_protocol_send_copy(socket, + ((guac_rdp_bitmap*) bitmap)->layer, + 0, 0, bitmap->width, bitmap->height, + GUAC_COMP_OVER, + GUAC_DEFAULT_LAYER, bitmap->left, bitmap->top); } @@ -145,6 +138,7 @@ void guac_rdp_bitmap_setsurface(rdpContext* context, rdpBitmap* bitmap, boolean else ((rdp_guac_client_data*) client->data)->current_surface = ((guac_rdp_bitmap*) bitmap)->layer; + } void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, uint8* data, int width, int height, int bpp, int length, boolean compressed) { diff --git a/src/rdp_gdi.c b/src/rdp_gdi.c index ac6507b..8ea0daa 100644 --- a/src/rdp_gdi.c +++ b/src/rdp_gdi.c @@ -40,6 +40,7 @@ #include #include "client.h" +#include "rdp_bitmap.h" void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) { guac_client* client = ((rdp_freerdp_context*) context)->client; @@ -57,8 +58,19 @@ void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) { } void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { + guac_client* client = ((rdp_freerdp_context*) context)->client; - guac_client_log_info(client, "guac_rdp_gdi_memblt()"); + const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface; + guac_socket* socket = client->socket; + guac_rdp_bitmap* bitmap = (guac_rdp_bitmap*) memblt->bitmap; + + if (bitmap->layer != NULL) + guac_protocol_send_copy(socket, + bitmap->layer, + memblt->nXSrc, memblt->nYSrc, memblt->nWidth, memblt->nHeight, + GUAC_COMP_OVER, + current_layer, memblt->nLeftRect, memblt->nTopRect); + } void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) {