Restored handling of ephemeral, fixed allocation of buffer in bitmap new.

This commit is contained in:
Michael Jumper 2012-02-08 15:09:12 -08:00
parent 1bb82d68f8
commit 72497211d9
3 changed files with 41 additions and 35 deletions

View File

@ -133,12 +133,12 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) {
primary->MemBlt = guac_rdp_gdi_memblt; primary->MemBlt = guac_rdp_gdi_memblt;
primary->OpaqueRect = guac_rdp_gdi_opaquerect; primary->OpaqueRect = guac_rdp_gdi_opaquerect;
/*pointer_cache_register_callbacks(instance->update);*/ pointer_cache_register_callbacks(instance->update);
glyph_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); bitmap_cache_register_callbacks(instance->update);
/*offscreen_cache_register_callbacks(instance->update);*/ offscreen_cache_register_callbacks(instance->update);
/*palette_cache_register_callbacks(instance->update);*/ palette_cache_register_callbacks(instance->update);
/* Init channels (pre-connect) */ /* Init channels (pre-connect) */
if (freerdp_channels_pre_connect(channels, instance)) { if (freerdp_channels_pre_connect(channels, instance)) {

View File

@ -57,6 +57,12 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {
guac_client* client = ((rdp_freerdp_context*) context)->client; guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_socket* socket = client->socket; 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 */ /* Convert image data if present */
if (bitmap->data != NULL) { if (bitmap->data != NULL) {
@ -66,30 +72,24 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {
context->instance->settings->color_depth, context->instance->settings->color_depth,
32, ((rdp_freerdp_context*) context)->clrconv); 32, ((rdp_freerdp_context*) context)->clrconv);
/* If not ephemeral, send to client */ /* 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);
/* 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) { if (!bitmap->ephemeral) {
/* Allocate buffer */
guac_layer* buffer = guac_client_alloc_buffer(client);
/* 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);
/* Send surface to buffer */
guac_protocol_send_png(socket, GUAC_COMP_SRC, buffer, 0, 0, surface);
/* Free surface */
cairo_surface_destroy(surface);
/* Free image data if actually alloated */ /* Free image data if actually alloated */
if (image_buffer != bitmap->data) if (image_buffer != bitmap->data)
free(image_buffer); free(image_buffer);
/* Store buffer reference in bitmap */
((guac_rdp_bitmap*) bitmap)->layer = buffer;
} }
/* Otherwise, store converted image in bitmap, free any existing */ /* 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 */ /* Store converted image in bitmap */
bitmap->data = image_buffer; 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_client* client = ((rdp_freerdp_context*) context)->client;
guac_socket* socket = client->socket; guac_socket* socket = client->socket;
/* If not ephemeral, copy image data from buffer to visible layer */ guac_protocol_send_copy(socket,
if (!bitmap->ephemeral) ((guac_rdp_bitmap*) bitmap)->layer,
guac_protocol_send_copy(socket, 0, 0, bitmap->width, bitmap->height,
((guac_rdp_bitmap*) bitmap)->layer, GUAC_COMP_OVER,
0, 0, bitmap->width, bitmap->height, GUAC_DEFAULT_LAYER, bitmap->left, bitmap->top);
GUAC_COMP_OVER,
GUAC_DEFAULT_LAYER, bitmap->left, bitmap->top);
/* Otherwise, buffer apparently should not be drawn ... */
} }
@ -145,6 +138,7 @@ void guac_rdp_bitmap_setsurface(rdpContext* context, rdpBitmap* bitmap, boolean
else else
((rdp_guac_client_data*) client->data)->current_surface ((rdp_guac_client_data*) client->data)->current_surface
= ((guac_rdp_bitmap*) bitmap)->layer; = ((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) { void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, uint8* data, int width, int height, int bpp, int length, boolean compressed) {

View File

@ -40,6 +40,7 @@
#include <guacamole/client.h> #include <guacamole/client.h>
#include "client.h" #include "client.h"
#include "rdp_bitmap.h"
void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) { void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) {
guac_client* client = ((rdp_freerdp_context*) context)->client; 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) { void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) {
guac_client* client = ((rdp_freerdp_context*) context)->client; 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) { void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) {