libfreerdp-core: fix async updates with palettes

This commit is contained in:
Marc-André Moreau 2013-02-03 16:19:25 -05:00
parent 4d804018e0
commit e18a0b807f
8 changed files with 19 additions and 23 deletions

View File

@ -279,8 +279,7 @@ Pixmap xf_glyph_new(xfInfo* xfi, int width, int height, BYTE* data)
void xf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
{
xfInfo* xfi = ((xfContext*) context)->xfi;
xfi->clrconv->palette->count = palette->number;
xfi->clrconv->palette->entries = palette->entries;
CopyMemory(xfi->clrconv->palette, palette, sizeof(rdpPalette));
}
void xf_gdi_set_bounds(rdpContext* context, rdpBounds* bounds)

View File

@ -128,7 +128,7 @@ struct _CACHE_COLOR_TABLE_ORDER
{
UINT32 cacheIndex;
UINT32 numberColors;
UINT32* colorTable;
UINT32 colorTable[256];
};
typedef struct _CACHE_COLOR_TABLE_ORDER CACHE_COLOR_TABLE_ORDER;

View File

@ -90,7 +90,7 @@ typedef struct _PALETTE_UPDATE PALETTE_UPDATE;
struct rdp_palette
{
UINT32 count;
PALETTE_ENTRY* entries;
PALETTE_ENTRY entries[256];
};
typedef struct rdp_palette rdpPalette;

View File

@ -25,14 +25,17 @@
#include <winpr/crt.h>
#include <freerdp/utils/stream.h>
#include <freerdp/cache/palette.h>
void update_gdi_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cache_color_table)
{
UINT32* colorTable;
rdpCache* cache = context->cache;
palette_cache_put(cache->palette, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable);
colorTable = (UINT32*) malloc(sizeof(UINT32) * 256);
CopyMemory(colorTable, cache_color_table->colorTable, sizeof(UINT32) * 256);
palette_cache_put(cache->palette, cache_color_table->cacheIndex, (void*) colorTable);
}
void* palette_cache_get(rdpPaletteCache* palette_cache, UINT32 index)
@ -98,4 +101,3 @@ void palette_cache_free(rdpPaletteCache* palette_cache)
free(palette_cache);
}
}

View File

@ -487,9 +487,6 @@ static void message_CacheColorTable(rdpContext* context, CACHE_COLOR_TABLE_ORDER
wParam = (CACHE_COLOR_TABLE_ORDER*) malloc(sizeof(CACHE_COLOR_TABLE_ORDER));
CopyMemory(wParam, cacheColorTableOrder, sizeof(CACHE_COLOR_TABLE_ORDER));
wParam->colorTable = (UINT32*) malloc(sizeof(UINT32) * wParam->numberColors);
CopyMemory(wParam->colorTable, cacheColorTableOrder->colorTable, wParam->numberColors);
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheColorTable), (void*) wParam, NULL);
}
@ -1194,8 +1191,6 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
IFCALL(update->CacheColorTable, msg->context, (CACHE_COLOR_TABLE_ORDER*) msg->wParam);
{
CACHE_COLOR_TABLE_ORDER* wParam = (CACHE_COLOR_TABLE_ORDER*) msg->wParam;
free(wParam->colorTable);
free(wParam);
}
break;

View File

@ -1243,25 +1243,26 @@ BOOL update_read_cache_color_table_order(STREAM* s, CACHE_COLOR_TABLE_ORDER* cac
if (stream_get_left(s) < 3)
return FALSE;
stream_read_BYTE(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */
stream_read_UINT16(s, cache_color_table_order->numberColors); /* numberColors (2 bytes) */
if (cache_color_table_order->numberColors != 256)
{
/* This field MUST be set to 256 */
return FALSE;
}
if (stream_get_left(s) < cache_color_table_order->numberColors * 4)
return FALSE;
colorTable = cache_color_table_order->colorTable;
if (colorTable == NULL)
colorTable = (UINT32*) malloc(cache_color_table_order->numberColors * 4);
else
colorTable = (UINT32*) realloc(colorTable, cache_color_table_order->numberColors * 4);
colorTable = (UINT32*) &cache_color_table_order->colorTable;
for (i = 0; i < (int) cache_color_table_order->numberColors; i++)
{
update_read_color_quad(s, &colorTable[i]);
}
cache_color_table_order->colorTable = colorTable;
return TRUE;
}

View File

@ -439,8 +439,7 @@ void gdi_bitmap_free_ex(gdiBitmap* bitmap)
void gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
{
rdpGdi* gdi = context->gdi;
gdi->clrconv->palette->count = palette->number;
gdi->clrconv->palette->entries = palette->entries;
CopyMemory(gdi->clrconv->palette, palette, sizeof(rdpPalette));
}
void gdi_set_bounds(rdpContext* context, rdpBounds* bounds)