GUAC-852: Store raw ARGB32 palette internally, for future use in conversions.
This commit is contained in:
parent
3171da9e09
commit
7449543461
@ -192,6 +192,11 @@ typedef struct rdp_freerdp_context {
|
||||
*/
|
||||
CLRCONV* clrconv;
|
||||
|
||||
/**
|
||||
* The current color palette, as received from the RDP server.
|
||||
*/
|
||||
UINT32 palette[256];
|
||||
|
||||
} rdp_freerdp_context;
|
||||
|
||||
#endif
|
||||
|
@ -192,12 +192,14 @@ static void bitmap_decompress(rdpContext* context,
|
||||
|
||||
rdpCodecs* codecs = context->codecs;
|
||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
|
||||
/* Decode as interleaved if less than 32 bits per pixel */
|
||||
if (srcBpp < 32) {
|
||||
freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED);
|
||||
interleaved_decompress(codecs->interleaved, srcData, size, srcBpp,
|
||||
&dstData, PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, NULL);
|
||||
&dstData, PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height,
|
||||
(BYTE*) palette);
|
||||
}
|
||||
|
||||
/* Otherwise, decode as planar */
|
||||
@ -218,6 +220,7 @@ void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* d
|
||||
int width, int height, int bpp, int length, BOOL compressed, int codec_id) {
|
||||
#endif
|
||||
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
int size = width * height * 4;
|
||||
|
||||
bitmap->data = (UINT8*) _aligned_malloc(size, 16);
|
||||
@ -228,7 +231,7 @@ void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* d
|
||||
freerdp_image_copy(
|
||||
bitmap->data, PIXEL_FORMAT_XRGB32, -1, 0, 0,
|
||||
width, height, data, gdi_get_pixel_format(bpp, TRUE), -1, 0, 0,
|
||||
NULL);
|
||||
(BYTE*) palette);
|
||||
|
||||
bitmap->compressed = FALSE;
|
||||
bitmap->length = size;
|
||||
|
@ -320,11 +320,11 @@ void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect
|
||||
|
||||
/* Get client data */
|
||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||
rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
|
||||
UINT32 color = freerdp_color_convert_var(opaque_rect->color,
|
||||
client_data->settings.color_depth, 32,
|
||||
((rdp_freerdp_context*) context)->clrconv);
|
||||
UINT32 color = freerdp_convert_gdi_order_color(opaque_rect->color,
|
||||
guac_rdp_get_depth(context->instance),
|
||||
PIXEL_FORMAT_ARGB32, (BYTE*) palette);
|
||||
|
||||
guac_common_surface* current_surface = ((rdp_guac_client_data*) client->data)->current_surface;
|
||||
|
||||
@ -340,18 +340,58 @@ void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect
|
||||
|
||||
}
|
||||
|
||||
void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) {
|
||||
/**
|
||||
* Updates the palette within a FreeRDP CLRCONV object using the new palette
|
||||
* entries provided by an RDP palette update.
|
||||
*/
|
||||
static void guac_rdp_update_clrconv(CLRCONV* clrconv,
|
||||
PALETTE_UPDATE* palette) {
|
||||
|
||||
CLRCONV* clrconv = ((rdp_freerdp_context*) context)->clrconv;
|
||||
clrconv->palette->count = palette->number;
|
||||
#ifdef LEGACY_RDPPALETTE
|
||||
clrconv->palette->entries = palette->entries;
|
||||
#else
|
||||
memcpy(clrconv->palette->entries, palette->entries, sizeof(palette->entries));
|
||||
memcpy(clrconv->palette->entries, palette->entries,
|
||||
sizeof(palette->entries));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a raw ARGB32 palette using the new palette entries provided by an
|
||||
* RDP palette update.
|
||||
*/
|
||||
static void guac_rdp_update_palette(UINT32* guac_palette,
|
||||
PALETTE_UPDATE* palette) {
|
||||
|
||||
PALETTE_ENTRY* entry = palette->entries;
|
||||
int i;
|
||||
|
||||
/* Copy each palette entry as ARGB32 */
|
||||
for (i=0; i < palette->number; i++) {
|
||||
|
||||
*guac_palette = 0xFF000000
|
||||
| (entry->red << 16)
|
||||
| (entry->green << 8)
|
||||
| entry->blue;
|
||||
|
||||
guac_palette++;
|
||||
entry++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) {
|
||||
|
||||
CLRCONV* clrconv = ((rdp_freerdp_context*) context)->clrconv;
|
||||
UINT32* guac_palette = ((rdp_freerdp_context*) context)->palette;
|
||||
|
||||
/* Update internal palette representations */
|
||||
guac_rdp_update_clrconv(clrconv, palette);
|
||||
guac_rdp_update_palette(guac_palette, palette);
|
||||
|
||||
}
|
||||
|
||||
void guac_rdp_gdi_set_bounds(rdpContext* context, rdpBounds* bounds) {
|
||||
|
||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||
|
@ -128,6 +128,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
|
||||
int x, int y, int width, int height, UINT32 fgcolor, UINT32 bgcolor) {
|
||||
|
||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
rdp_guac_client_data* guac_client_data =
|
||||
(rdp_guac_client_data*) client->data;
|
||||
|
||||
@ -137,7 +138,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
|
||||
/* Convert background color */
|
||||
bgcolor = freerdp_convert_gdi_order_color(bgcolor,
|
||||
guac_rdp_get_depth(context->instance),
|
||||
PIXEL_FORMAT_ARGB32, NULL);
|
||||
PIXEL_FORMAT_ARGB32, (BYTE*) palette);
|
||||
|
||||
guac_common_surface_rect(guac_client_data->current_surface, x, y, width, height,
|
||||
(bgcolor & 0xFF0000) >> 16,
|
||||
@ -150,7 +151,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
|
||||
guac_client_data->glyph_color =
|
||||
freerdp_convert_gdi_order_color(fgcolor,
|
||||
guac_rdp_get_depth(context->instance),
|
||||
PIXEL_FORMAT_ARGB32, NULL);
|
||||
PIXEL_FORMAT_ARGB32, (BYTE*) palette);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user