From 6f2575c0769986cd204fb5e2313599470da79146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 20 Sep 2011 15:30:52 -0400 Subject: [PATCH] libfreerdp-core: improving parsing if fast index order --- client/X11/xf_gdi.c | 14 ++++++-------- libfreerdp-core/orders.c | 37 ++++++++++++++++--------------------- libfreerdp-gdi/gdi.c | 18 +++++++++++++++--- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index fd948edbf..1ba07b6c8 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -531,8 +531,8 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) int x, y; Pixmap bmp; Pixmap* bmps; - uint32 fg_color; - uint32 bg_color; + uint32 fgcolor; + uint32 bgcolor; GLYPH_DATA* glyph; GLYPH_DATA** glyphs; GLYPH_FRAGMENT* fragment; @@ -541,14 +541,13 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) x = fast_index->bkLeft; y = fast_index->y; - fg_color = freerdp_color_convert(fast_index->foreColor, 32, xfi->bpp, xfi->clrconv); - bg_color = freerdp_color_convert(fast_index->backColor, 32, xfi->bpp, xfi->clrconv); + fgcolor = freerdp_color_convert(fast_index->foreColor, xfi->srcBpp, 32, xfi->clrconv); + bgcolor = freerdp_color_convert(fast_index->backColor, xfi->srcBpp, 32, xfi->clrconv); XSetFunction(xfi->display, xfi->gc, GXcopy); - XSetForeground(xfi->display, xfi->gc, bg_color); - XSetBackground(xfi->display, xfi->gc, fg_color); + XSetForeground(xfi->display, xfi->gc, bgcolor); + XSetBackground(xfi->display, xfi->gc, fgcolor); -#if 0 if (fast_index->opaqueRect) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); @@ -562,7 +561,6 @@ void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) fast_index->opRight - fast_index->opLeft + 1, fast_index->opBottom - fast_index->opTop + 1); } } -#endif XSetFillStyle(xfi->display, xfi->gc, FillStippled); diff --git a/libfreerdp-core/orders.c b/libfreerdp-core/orders.c index 6b99f3057..e441aab4f 100644 --- a/libfreerdp-core/orders.c +++ b/libfreerdp-core/orders.c @@ -1131,10 +1131,7 @@ void update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_O update_read_coord(s, &fast_index->bkBottom, orderInfo->deltaCoordinates); if (orderInfo->fieldFlags & ORDER_FIELD_09) - { update_read_coord(s, &fast_index->opLeft, orderInfo->deltaCoordinates); - fast_index->opaqueRect = True; - } if (orderInfo->fieldFlags & ORDER_FIELD_10) update_read_coord(s, &fast_index->opTop, orderInfo->deltaCoordinates); @@ -1151,30 +1148,25 @@ 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->opRight == 0) - fast_index->opRight = fast_index->bkRight; - if (fast_index->opBottom == -32768) { - if ((fast_index->opTop & 0x0F) == 0x0F) - { - fast_index->opLeft = fast_index->bkLeft; - fast_index->opTop = fast_index->bkTop; + 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; - fast_index->opBottom = fast_index->bkBottom; - fast_index->opaqueRect = True; - } - else if ((fast_index->opTop & 0x0F) == 0x0D) - { - fast_index->opLeft = fast_index->bkLeft; + if (flags & 0x04) fast_index->opTop = fast_index->bkTop; - fast_index->opBottom = fast_index->bkBottom; - fast_index->opaqueRect = True; - } + if (flags & 0x08) + fast_index->opLeft = fast_index->bkLeft; } - if (fast_index->opRight - fast_index->opLeft > 1) - fast_index->opaqueRect = True; + 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; @@ -1182,6 +1174,9 @@ void update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_O 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) { uint8* mark; diff --git a/libfreerdp-gdi/gdi.c b/libfreerdp-gdi/gdi.c index 22f0e6b8d..203793957 100644 --- a/libfreerdp-gdi/gdi.c +++ b/libfreerdp-gdi/gdi.c @@ -677,7 +677,10 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) { int i, j; int x, y; - uint32 color; + GDI_RECT rect; + uint32 bgcolor; + uint32 fgcolor; + HGDI_BRUSH brush; GDI_IMAGE* bmp; GDI_IMAGE** bmps; GLYPH_DATA* glyph; @@ -688,9 +691,17 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) x = fast_index->bkLeft; y = fast_index->y; - color = freerdp_color_convert(fast_index->backColor, gdi->srcBpp, 32, gdi->clrconv); - gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, color); + bgcolor = freerdp_color_convert(fast_index->backColor, gdi->srcBpp, 32, gdi->clrconv); + fgcolor = freerdp_color_convert(fast_index->foreColor, gdi->srcBpp, 32, gdi->clrconv); + gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); gdi_SetNullClipRgn(gdi->drawing->hdc); + brush = gdi_CreateSolidBrush(fgcolor); + + if (fast_index->opaqueRect) + { + gdi_SetRect(&rect, fast_index->opLeft, fast_index->opTop, fast_index->opRight, fast_index->opBottom); + gdi_FillRect(gdi->drawing->hdc, &rect, brush); + } for (i = 0; i < fast_index->nfragments; i++) { @@ -758,6 +769,7 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) } gdi_SetTextColor(gdi->drawing->hdc, gdi->textColor); + gdi_DeleteObject((HGDIOBJECT) brush); } void gdi_create_offscreen_bitmap(rdpUpdate* update, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)