From b32ea1b77eccdef91016c5f1239d93d51089fc82 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Thu, 24 Nov 2011 15:32:49 -0800 Subject: [PATCH] got fast index and fast glyph working --- include/freerdp/primary.h | 5 +- libfreerdp-cache/glyph.c | 113 +++++++++++++++++++++++++++++++-- libfreerdp-core/capabilities.c | 5 -- libfreerdp-core/orders.c | 56 +++++++--------- 4 files changed, 135 insertions(+), 44 deletions(-) diff --git a/include/freerdp/primary.h b/include/freerdp/primary.h index 5fe370f98..d3b74888d 100644 --- a/include/freerdp/primary.h +++ b/include/freerdp/primary.h @@ -331,7 +331,7 @@ struct _FAST_INDEX_ORDER sint32 x; sint32 y; uint32 cbData; - uint8* data; + uint8 data[256]; }; typedef struct _FAST_INDEX_ORDER FAST_INDEX_ORDER; @@ -353,7 +353,8 @@ struct _FAST_GLYPH_ORDER sint32 x; sint32 y; uint32 cbData; - uint8* data; + uint8 data[256]; + void* glyph_data; }; typedef struct _FAST_GLYPH_ORDER FAST_GLYPH_ORDER; diff --git a/libfreerdp-cache/glyph.c b/libfreerdp-cache/glyph.c index ade5154ac..b2c5f9939 100644 --- a/libfreerdp-cache/glyph.c +++ b/libfreerdp-cache/glyph.c @@ -182,19 +182,123 @@ void update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index) void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fast_index) { + sint32 opLeft, opTop, opRight, opBottom; + sint32 x, y; rdpGlyphCache* glyph_cache; glyph_cache = context->cache->glyph; - fast_index->x = fast_index->bkLeft; + opLeft = fast_index->opLeft; + opTop = fast_index->opTop; + opRight = fast_index->opRight; + opBottom = fast_index->opBottom; + x = fast_index->x; + y = fast_index->y; + + if (opBottom == -32768) + { + uint8 flags = (uint8) (opTop & 0x0F); + + if (flags & 0x01) + opBottom = fast_index->bkBottom; + if (flags & 0x02) + opRight = fast_index->bkRight; + if (flags & 0x04) + opTop = fast_index->bkTop; + if (flags & 0x08) + opLeft = fast_index->bkLeft; + } + + if (opLeft == 0) + opLeft = fast_index->bkLeft; + + if (opRight == 0) + opRight = fast_index->bkRight; + + if (x == -32768) + x = fast_index->bkLeft; + + if (y == -32768) + y = fast_index->bkTop; update_process_glyph_fragments(context, fast_index->data, fast_index->cbData, fast_index->cacheId, fast_index->ulCharInc, fast_index->flAccel, - fast_index->backColor, fast_index->foreColor, fast_index->x, fast_index->y, + fast_index->backColor, fast_index->foreColor, x, y, fast_index->bkLeft, fast_index->bkTop, fast_index->bkRight - fast_index->bkLeft, fast_index->bkBottom - fast_index->bkTop, - fast_index->opLeft, fast_index->opTop, - fast_index->opRight - fast_index->opLeft, fast_index->opBottom - fast_index->opTop); + opLeft, opTop, + opRight - opLeft, opBottom - opTop); +} + +void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph) +{ + sint32 opLeft, opTop, opRight, opBottom; + sint32 x, y; + GLYPH_DATA_V2* glyph_data; + rdpGlyph* glyph; + rdpCache* cache = context->cache; + uint8 text_data[2]; + + opLeft = fast_glyph->opLeft; + opTop = fast_glyph->opTop; + opRight = fast_glyph->opRight; + opBottom = fast_glyph->opBottom; + x = fast_glyph->x; + y = fast_glyph->y; + + if (opBottom == -32768) + { + uint8 flags = (uint8) (opTop & 0x0F); + + if (flags & 0x01) + opBottom = fast_glyph->bkBottom; + if (flags & 0x02) + opRight = fast_glyph->bkRight; + if (flags & 0x04) + opTop = fast_glyph->bkTop; + if (flags & 0x08) + opLeft = fast_glyph->bkLeft; + } + + if (opLeft == 0) + opLeft = fast_glyph->bkLeft; + + if (opRight == 0) + opRight = fast_glyph->bkRight; + + if (x == -32768) + x = fast_glyph->bkLeft; + + if (y == -32768) + y = fast_glyph->bkTop; + + if (fast_glyph->glyph_data != NULL) + { + /* got option font that needs to go into cache */ + glyph_data = (GLYPH_DATA_V2*) (fast_glyph->glyph_data); + 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_New(context, glyph); + glyph_cache_put(cache->glyph, fast_glyph->cacheId, fast_glyph->data[0], glyph); + xfree(fast_glyph->glyph_data); + fast_glyph->glyph_data = NULL; + } + + text_data[0] = fast_glyph->data[0]; + text_data[1] = 0; + + update_process_glyph_fragments(context, text_data, 2, + fast_glyph->cacheId, fast_glyph->ulCharInc, fast_glyph->flAccel, + fast_glyph->backColor, fast_glyph->foreColor, x, y, + fast_glyph->bkLeft, fast_glyph->bkTop, + fast_glyph->bkRight - fast_glyph->bkLeft, fast_glyph->bkBottom - fast_glyph->bkTop, + opLeft, opTop, + opRight - opLeft, opBottom - opTop); } void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph) @@ -316,6 +420,7 @@ void glyph_cache_register_callbacks(rdpUpdate* update) { update->primary->GlyphIndex = update_gdi_glyph_index; update->primary->FastIndex = update_gdi_fast_index; + update->primary->FastGlyph = update_gdi_fast_glyph; update->secondary->CacheGlyph = update_gdi_cache_glyph; update->secondary->CacheGlyphV2 = update_gdi_cache_glyph_v2; } diff --git a/libfreerdp-core/capabilities.c b/libfreerdp-core/capabilities.c index 05a86c707..08d61a91f 100644 --- a/libfreerdp-core/capabilities.c +++ b/libfreerdp-core/capabilities.c @@ -330,11 +330,6 @@ void rdp_write_order_capability_set(STREAM* s, rdpSettings* settings) stream_write_uint16(s, 1); /* maximumOrderLevel (2 bytes) */ stream_write_uint16(s, 0); /* numberFonts (2 bytes) */ stream_write_uint16(s, orderFlags); /* orderFlags (2 bytes) */ - - /* hack jsorg71 */ - settings->order_support[NEG_FAST_INDEX_INDEX] = 0; - settings->order_support[NEG_FAST_GLYPH_INDEX] = 0; - stream_write(s, settings->order_support, 32); /* orderSupport (32 bytes) */ stream_write_uint16(s, 0); /* textFlags (2 bytes) */ stream_write_uint16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ diff --git a/libfreerdp-core/orders.c b/libfreerdp-core/orders.c index 1aa57b4ce..0e9d37563 100644 --- a/libfreerdp-core/orders.c +++ b/libfreerdp-core/orders.c @@ -936,8 +936,6 @@ void update_read_glyph_index_order(STREAM* s, ORDER_INFO* orderInfo, GLYPH_INDEX void update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index) { - fast_index->opaqueRect = false; - if (orderInfo->fieldFlags & ORDER_FIELD_01) stream_read_uint8(s, fast_index->cacheId); @@ -983,45 +981,19 @@ void update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_O if (orderInfo->fieldFlags & ORDER_FIELD_14) update_read_coord(s, &fast_index->y, orderInfo->deltaCoordinates); - if (fast_index->opBottom == -32768) - { - uint8 flags = (uint8) (fast_index->opTop & 0x0F); - - if (flags & 0x01) - fast_index->opBottom = fast_index->bkBottom; - if (flags & 0x02) - fast_index->opRight = fast_index->bkRight; - if (flags & 0x04) - fast_index->opTop = fast_index->bkTop; - if (flags & 0x08) - fast_index->opLeft = fast_index->bkLeft; - } - - if (fast_index->opLeft == 0) - fast_index->opLeft = fast_index->bkLeft; - - if (fast_index->opRight == 0) - fast_index->opRight = fast_index->bkRight; - - if (fast_index->x == -32768) - fast_index->x = fast_index->bkLeft; - - if (fast_index->y == -32768) - fast_index->y = fast_index->bkTop; - - if ((fast_index->opRight > fast_index->opLeft) && (fast_index->opBottom > fast_index->opTop)) - fast_index->opaqueRect = true; - if (orderInfo->fieldFlags & ORDER_FIELD_15) { stream_read_uint8(s, fast_index->cbData); - stream_get_mark(s, fast_index->data); + memcpy(fast_index->data, s->p, fast_index->cbData); stream_seek(s, fast_index->cbData); } } void update_read_fast_glyph_order(STREAM* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph) { + GLYPH_DATA_V2* glyph; + uint8* phold; + if (orderInfo->fieldFlags & ORDER_FIELD_01) stream_read_uint8(s, fast_glyph->cacheId); @@ -1070,7 +1042,25 @@ void update_read_fast_glyph_order(STREAM* s, ORDER_INFO* orderInfo, FAST_GLYPH_O if (orderInfo->fieldFlags & ORDER_FIELD_15) { stream_read_uint8(s, fast_glyph->cbData); - stream_seek(s, fast_glyph->cbData); + memcpy(fast_glyph->data, s->p, fast_glyph->cbData); + phold = s->p; + stream_seek(s, 1); + if ((fast_glyph->cbData > 1) && (fast_glyph->glyph_data == NULL)) + { + /* parse optional glyph data */ + glyph = (GLYPH_DATA_V2*) xmalloc(sizeof(GLYPH_DATA_V2)); + glyph->cacheIndex = fast_glyph->data[0]; + 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); + glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; + glyph->cb += glyph->cb % 4; + glyph->aj = (uint8*) xmalloc(glyph->cb); + stream_read(s, glyph->aj, glyph->cb); + fast_glyph->glyph_data = glyph; + } + s->p = phold + fast_glyph->cbData; } }