From db331d64f7ba36f39aa5b927bd8ae03b095bcc78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 3 Feb 2013 12:41:59 -0500 Subject: [PATCH] libfreerdp-core: fix message queue ids, fix async glyph messages --- include/freerdp/primary.h | 26 +++++++++++++++++++++++++- include/freerdp/secondary.h | 29 +++-------------------------- libfreerdp/cache/glyph.c | 25 ++++++++++++++----------- libfreerdp/core/message.h | 6 +++--- libfreerdp/core/orders.c | 20 ++++++++++++-------- libfreerdp/crypto/base64.c | 1 + libfreerdp/primitives/prim_colors.c | 8 +++----- 7 files changed, 61 insertions(+), 54 deletions(-) diff --git a/include/freerdp/primary.h b/include/freerdp/primary.h index 2e370ae..add5a4b 100644 --- a/include/freerdp/primary.h +++ b/include/freerdp/primary.h @@ -22,6 +22,30 @@ #include +struct _GLYPH_DATA +{ + UINT32 cacheIndex; + INT32 x; + INT32 y; + UINT32 cx; + UINT32 cy; + UINT32 cb; + BYTE* aj; +}; +typedef struct _GLYPH_DATA GLYPH_DATA; + +struct _GLYPH_DATA_V2 +{ + UINT32 cacheIndex; + INT32 x; + INT32 y; + UINT32 cx; + UINT32 cy; + UINT32 cb; + BYTE* aj; +}; +typedef struct _GLYPH_DATA_V2 GLYPH_DATA_V2; + #define BACKMODE_TRANSPARENT 0x0001 #define BACKMODE_OPAQUE 0x0002 @@ -357,7 +381,7 @@ struct _FAST_GLYPH_ORDER INT32 y; UINT32 cbData; BYTE data[256]; - void* glyph_data; + GLYPH_DATA_V2 glyphData; }; typedef struct _FAST_GLYPH_ORDER FAST_GLYPH_ORDER; diff --git a/include/freerdp/secondary.h b/include/freerdp/secondary.h index bb5e68f..16c4c63 100644 --- a/include/freerdp/secondary.h +++ b/include/freerdp/secondary.h @@ -21,6 +21,7 @@ #define FREERDP_UPDATE_SECONDARY_H #include +#include #define GLYPH_FRAGMENT_NOP 0x00 #define GLYPH_FRAGMENT_USE 0xFE @@ -131,45 +132,21 @@ struct _CACHE_COLOR_TABLE_ORDER }; typedef struct _CACHE_COLOR_TABLE_ORDER CACHE_COLOR_TABLE_ORDER; -struct _GLYPH_DATA -{ - UINT32 cacheIndex; - INT32 x; - INT32 y; - UINT32 cx; - UINT32 cy; - UINT32 cb; - BYTE* aj; -}; -typedef struct _GLYPH_DATA GLYPH_DATA; - struct _CACHE_GLYPH_ORDER { UINT32 cacheId; UINT32 cGlyphs; - GLYPH_DATA glyphData[255]; + GLYPH_DATA glyphData[256]; BYTE* unicodeCharacters; }; typedef struct _CACHE_GLYPH_ORDER CACHE_GLYPH_ORDER; -struct _GLYPH_DATA_V2 -{ - UINT32 cacheIndex; - INT32 x; - INT32 y; - UINT32 cx; - UINT32 cy; - UINT32 cb; - BYTE* aj; -}; -typedef struct _GLYPH_DATA_V2 GLYPH_DATA_V2; - struct _CACHE_GLYPH_V2_ORDER { UINT32 cacheId; UINT32 flags; UINT32 cGlyphs; - GLYPH_DATA_V2 glyphData[255]; + GLYPH_DATA_V2 glyphData[256]; BYTE* unicodeCharacters; }; typedef struct _CACHE_GLYPH_V2_ORDER CACHE_GLYPH_V2_ORDER; diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 59336e6..7b56ed2 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -173,6 +173,7 @@ void update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index) rdpGlyphCache* glyph_cache; glyph_cache = context->cache->glyph; + update_process_glyph_fragments(context, glyph_index->data, glyph_index->cbData, glyph_index->cacheId, glyph_index->ulCharInc, glyph_index->flAccel, glyph_index->backColor, glyph_index->foreColor, glyph_index->x, glyph_index->y, @@ -184,8 +185,9 @@ void update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index) void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fast_index) { - INT32 opLeft, opTop, opRight, opBottom; INT32 x, y; + INT32 opLeft, opTop; + INT32 opRight, opBottom; rdpGlyphCache* glyph_cache; glyph_cache = context->cache->glyph; @@ -234,12 +236,13 @@ void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fast_index) void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph) { - INT32 opLeft, opTop, opRight, opBottom; INT32 x, y; - GLYPH_DATA_V2* glyph_data; rdpGlyph* glyph; - rdpCache* cache = context->cache; BYTE text_data[2]; + INT32 opLeft, opTop; + INT32 opRight, opBottom; + GLYPH_DATA_V2* glyph_data; + rdpCache* cache = context->cache; opLeft = fast_glyph->opLeft; opTop = fast_glyph->opTop; @@ -274,21 +277,21 @@ void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph) if (y == -32768) y = fast_glyph->bkTop; - if (fast_glyph->glyph_data != NULL) + if (fast_glyph->cbData > 1) { /* got option font that needs to go into cache */ - glyph_data = (GLYPH_DATA_V2*) (fast_glyph->glyph_data); + glyph_data = &fast_glyph->glyphData; + glyph = Glyph_Alloc(context); glyph->x = glyph_data->x; glyph->y = glyph_data->y; glyph->cx = glyph_data->cx; glyph->cy = glyph_data->cy; - glyph->aj = glyph_data->aj; glyph->cb = glyph_data->cb; + glyph->aj = glyph_data->aj; Glyph_New(context, glyph); + glyph_cache_put(cache->glyph, fast_glyph->cacheId, fast_glyph->data[0], glyph); - free(fast_glyph->glyph_data); - fast_glyph->glyph_data = NULL; } text_data[0] = fast_glyph->data[0]; @@ -320,8 +323,8 @@ void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph) glyph->y = glyph_data->y; glyph->cx = glyph_data->cx; glyph->cy = glyph_data->cy; - glyph->aj = glyph_data->aj; glyph->cb = glyph_data->cb; + glyph->aj = glyph_data->aj; Glyph_New(context, glyph); glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph_data->cacheIndex, glyph); @@ -345,8 +348,8 @@ void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_ glyph->y = glyph_data->y; glyph->cx = glyph_data->cx; glyph->cy = glyph_data->cy; - glyph->aj = glyph_data->aj; glyph->cb = glyph_data->cb; + glyph->aj = glyph_data->aj; Glyph_New(context, glyph); glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph_data->cacheIndex, glyph); diff --git a/libfreerdp/core/message.h b/libfreerdp/core/message.h index 2a292a8..9b776b1 100644 --- a/libfreerdp/core/message.h +++ b/libfreerdp/core/message.h @@ -22,11 +22,11 @@ #include -#define GetMessageType(_id) (_id & 0xF) -#define GetMessageClass(_id) ((_id >> 8) & 0xF) +#define GetMessageType(_id) (_id & 0xFF) +#define GetMessageClass(_id) ((_id >> 16) & 0xFF) #define MakeMessageId(_class, _type) \ - (((_class ##_Class) << 8) | (_class ## _ ## _type)) + (((_class ##_Class) << 16) | (_class ## _ ## _type)) /* Update */ diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 5cc4df7..bf705e3 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -909,8 +909,6 @@ BOOL update_read_glyph_index_order(STREAM* s, ORDER_INFO* orderInfo, GLYPH_INDEX return TRUE; } - - BOOL update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index) { ORDER_FIELD_BYTE(1, fast_index->cacheId); @@ -942,12 +940,10 @@ BOOL update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_O return TRUE; } - - BOOL update_read_fast_glyph_order(STREAM* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph) { - GLYPH_DATA_V2* glyph; BYTE* phold; + GLYPH_DATA_V2* glyph; ORDER_FIELD_BYTE(1, fast_glyph->cacheId); ORDER_FIELD_2BYTE(2, fast_glyph->ulCharInc, fast_glyph->flAccel); @@ -968,32 +964,40 @@ BOOL update_read_fast_glyph_order(STREAM* s, ORDER_INFO* orderInfo, FAST_GLYPH_O { if (stream_get_left(s) < 1) return FALSE; + stream_read_BYTE(s, fast_glyph->cbData); + if (stream_get_left(s) < fast_glyph->cbData) return FALSE; + memcpy(fast_glyph->data, s->p, fast_glyph->cbData); phold = s->p; if (!stream_skip(s, 1)) return FALSE; - if ((fast_glyph->cbData > 1) && (fast_glyph->glyph_data == NULL)) + + if (fast_glyph->cbData > 1) { /* parse optional glyph data */ - glyph = (GLYPH_DATA_V2*) malloc(sizeof(GLYPH_DATA_V2)); + glyph = &fast_glyph->glyphData; glyph->cacheIndex = fast_glyph->data[0]; + if (!update_read_2byte_signed(s, &glyph->x) || !update_read_2byte_signed(s, &glyph->y) || !update_read_2byte_unsigned(s, &glyph->cx) || !update_read_2byte_unsigned(s, &glyph->cy)) return FALSE; + glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; + if (stream_get_left(s) < glyph->cb) return FALSE; + glyph->aj = (BYTE*) malloc(glyph->cb); stream_read(s, glyph->aj, glyph->cb); - fast_glyph->glyph_data = glyph; } + s->p = phold + fast_glyph->cbData; } return TRUE; diff --git a/libfreerdp/crypto/base64.c b/libfreerdp/crypto/base64.c index 82f7b4c..f7050fe 100644 --- a/libfreerdp/crypto/base64.c +++ b/libfreerdp/crypto/base64.c @@ -104,6 +104,7 @@ static void* base64_decode(BYTE* s, int length, int* data_len) if (length % 4) return NULL; + n[0] = n[1] = n[2] = n[3] = 0; q = data = (BYTE*) malloc(length / 4 * 3); for (p = (char*) s; *p; ) diff --git a/libfreerdp/primitives/prim_colors.c b/libfreerdp/primitives/prim_colors.c index 331cd4c..e6e7a18 100644 --- a/libfreerdp/primitives/prim_colors.c +++ b/libfreerdp/primitives/prim_colors.c @@ -714,13 +714,12 @@ PRIM_STATIC pstatus_t neon_yCbCrToRGB_16s16s_P3P3( */ /* ------------------------------------------------------------------------- */ -void primitives_init_colors( - const primitives_hints_t *hints, - primitives_t *prims) +void primitives_init_colors(const primitives_hints_t* hints, primitives_t* prims) { prims->RGBToRGB_16s8u_P3AC4R = general_RGBToRGB_16s8u_P3AC4R; prims->yCbCrToRGB_16s16s_P3P3 = general_yCbCrToRGB_16s16s_P3P3; prims->RGBToYCbCr_16s16s_P3P3 = general_RGBToYCbCr_16s16s_P3P3; + #if defined(WITH_SSE2) if (hints->x86_flags & PRIM_X86_SSE2_AVAILABLE) { @@ -737,8 +736,7 @@ void primitives_init_colors( } /* ------------------------------------------------------------------------- */ -void primitives_deinit_colors( - primitives_t *prims) +void primitives_deinit_colors(primitives_t* prims) { /* Nothing to do. */ } -- 2.7.4