From f7928c2574b465f507fb8c025e83fdfff0a8157b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 8 Feb 2012 12:32:27 -0800 Subject: [PATCH] Non-static clrconv, handle palette updates. --- protocols/rdp/include/client.h | 3 +-- protocols/rdp/include/rdp_gdi.h | 1 + protocols/rdp/src/client.c | 19 +++++++++++-------- protocols/rdp/src/rdp_bitmap.c | 10 ++++++++-- protocols/rdp/src/rdp_gdi.c | 9 ++++++++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/protocols/rdp/include/client.h b/protocols/rdp/include/client.h index 6bdcd108..c24f7825 100644 --- a/protocols/rdp/include/client.h +++ b/protocols/rdp/include/client.h @@ -70,10 +70,9 @@ typedef struct rdp_freerdp_context { rdpContext _p; guac_client* client; + CLRCONV* clrconv; } rdp_freerdp_context; -extern CLRCONV guac_rdp_clrconv; - #endif diff --git a/protocols/rdp/include/rdp_gdi.h b/protocols/rdp/include/rdp_gdi.h index 3bd633be..b4df003b 100644 --- a/protocols/rdp/include/rdp_gdi.h +++ b/protocols/rdp/include/rdp_gdi.h @@ -45,5 +45,6 @@ void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt); void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt); void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt); void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect); +void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette); #endif diff --git a/protocols/rdp/src/client.c b/protocols/rdp/src/client.c index c9e23a36..d8ca3a3b 100644 --- a/protocols/rdp/src/client.c +++ b/protocols/rdp/src/client.c @@ -72,13 +72,6 @@ const char* GUAC_CLIENT_ARGS[] = { NULL }; -CLRCONV guac_rdp_clrconv = { - .alpha = 1, - .invert = 0, - .rgb555 = 0, - .palette = NULL -}; - boolean rdp_freerdp_pre_connect(freerdp* instance) { rdpContext* context = instance->context; @@ -88,6 +81,15 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) { rdpGlyph* glyph; rdpPointer* pointer; rdpPrimaryUpdate* primary; + CLRCONV* clrconv; + + /* Init color conversion structure */ + clrconv = xnew(CLRCONV); + clrconv->alpha = 1; + clrconv->invert = 0; + clrconv->rgb555 = 0; + clrconv->palette = xnew(rdpPalette); + ((rdp_freerdp_context*) context)->clrconv = clrconv; /* Init FreeRDP cache */ instance->context->cache = cache_new(instance->settings); @@ -121,8 +123,9 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) { graphics_register_pointer(context->graphics, pointer); /* Set up GDI */ - primary = instance->update->primary; + instance->update->Palette = guac_rdp_gdi_palette_update; + primary = instance->update->primary; primary->DstBlt = guac_rdp_gdi_dstblt; primary->PatBlt = guac_rdp_gdi_patblt; primary->ScrBlt = guac_rdp_gdi_scrblt; diff --git a/protocols/rdp/src/rdp_bitmap.c b/protocols/rdp/src/rdp_bitmap.c index c9798b92..315ef36c 100644 --- a/protocols/rdp/src/rdp_bitmap.c +++ b/protocols/rdp/src/rdp_bitmap.c @@ -64,7 +64,7 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) { unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL, bitmap->width, bitmap->height, context->instance->settings->color_depth, - 32, (HCLRCONV) &guac_rdp_clrconv); + 32, ((rdp_freerdp_context*) context)->clrconv); /* If not ephemeral, send to client */ if (!bitmap->ephemeral) { @@ -102,6 +102,9 @@ 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; + } } @@ -127,7 +130,10 @@ void guac_rdp_bitmap_paint(rdpContext* context, rdpBitmap* bitmap) { void guac_rdp_bitmap_free(rdpContext* context, rdpBitmap* bitmap) { guac_client* client = ((rdp_freerdp_context*) context)->client; - guac_client_free_buffer(client, ((guac_rdp_bitmap*) bitmap)->layer); + + /* Free layer, if any */ + if (((guac_rdp_bitmap*) bitmap)->layer != NULL) + guac_client_free_buffer(client, ((guac_rdp_bitmap*) bitmap)->layer); } void guac_rdp_bitmap_setsurface(rdpContext* context, rdpBitmap* bitmap, boolean primary) { diff --git a/protocols/rdp/src/rdp_gdi.c b/protocols/rdp/src/rdp_gdi.c index 9c8884f0..ff792119 100644 --- a/protocols/rdp/src/rdp_gdi.c +++ b/protocols/rdp/src/rdp_gdi.c @@ -65,7 +65,8 @@ void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect guac_client* client = ((rdp_freerdp_context*) context)->client; uint32 color = freerdp_color_convert(opaque_rect->color, - context->instance->settings->color_depth, 32, &guac_rdp_clrconv); + context->instance->settings->color_depth, 32, + ((rdp_freerdp_context*) context)->clrconv); const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface; @@ -80,4 +81,10 @@ void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect } +void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) { + CLRCONV* clrconv = ((rdp_freerdp_context*) context)->clrconv; + clrconv->palette->count = palette->number; + clrconv->palette->entries = palette->entries; + +}