From a1b8dfd79f1c07f550165d2fdd3cddb953ee2c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 9 Nov 2011 12:16:09 -0500 Subject: [PATCH] libfreerdp-cache: got glyph drawing partially working --- client/X11/xf_gdi.c | 159 +----------------------------- client/X11/xf_graphics.c | 96 +++++++++++++++--- client/X11/xfreerdp.h | 7 ++ include/freerdp/cache/glyph.h | 2 +- libfreerdp-cache/glyph.c | 98 ++++++++++++------- libfreerdp-core/capabilities.c | 2 - libfreerdp-core/orders.c | 172 --------------------------------- libfreerdp-gdi/gdi.c | 153 +---------------------------- libfreerdp-gdi/graphics.c | 51 ++++++---- 9 files changed, 185 insertions(+), 555 deletions(-) diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 15e0bb508..cba98e8d2 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -613,166 +613,11 @@ void xf_gdi_mem3blt(rdpUpdate* update, MEM3BLT_ORDER* mem3blt) } -void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) -{ -#if 0 - int i, j; - int x, y; - int w, h; - Pixmap bmp; - Pixmap* bmps; - uint32 fgcolor; - uint32 bgcolor; - GLYPH_DATA* glyph; - GLYPH_DATA** glyphs; - GLYPH_FRAGMENT* fragment; - xfInfo* xfi = ((xfContext*) update->context)->xfi; - rdpCache* cache = update->context->cache; - - 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, bgcolor); - XSetBackground(xfi->display, xfi->gc, fgcolor); - - if (fast_index->opaqueRect) - { - XSetFillStyle(xfi->display, xfi->gc, FillSolid); - - x = fast_index->opLeft; - y = fast_index->opTop; - w = fast_index->opRight - fast_index->opLeft + 1; - h = fast_index->opBottom - fast_index->opTop + 1; - - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, x, y, w, h); - - if (xfi->drawing == xfi->primary) - { - if (xfi->remote_app != True) - { - XFillRectangle(xfi->display, xfi->drawable, xfi->gc, x, y, w, h); - } - - gdi_InvalidateRegion(xfi->hdc, x, y, w, h); - } - } - - x = fast_index->bkLeft; - y = fast_index->y; - - XSetFillStyle(xfi->display, xfi->gc, FillStippled); - - for (i = 0; i < fast_index->nfragments; i++) - { - fragment = &fast_index->fragments[i]; - - if (fragment->operation == GLYPH_FRAGMENT_USE) - { - fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(cache->glyph, - fragment->index, &fragment->nindices, (void**) &bmps); - - glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices); - - for (j = 0; j < fragment->nindices; j++) - { - glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]); - } - } - else - { - bmps = (Pixmap*) xmalloc(sizeof(Pixmap*) * fragment->nindices); - glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices); - - for (j = 0; j < fragment->nindices; j++) - { - glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]); - } - } - - for (j = 0; j < fragment->nindices; j++) - { - bmp = bmps[j]; - glyph = glyphs[j]; - - XSetStipple(xfi->display, xfi->gc, bmp); - XSetTSOrigin(xfi->display, xfi->gc, glyph->x + x, glyph->y + y); - XFillRectangle(xfi->display, xfi->drawing, xfi->gc, glyph->x + x, glyph->y + y, glyph->cx, glyph->cy); - XSetStipple(xfi->display, xfi->gc, xfi->bitmap_mono); - - if ((j + 1) < fragment->nindices) - { - if (!(fast_index->flAccel & SO_CHAR_INC_EQUAL_BM_BASE)) - { - if (fast_index->flAccel & SO_VERTICAL) - { - y += fragment->indices[j + 1].delta; - } - else - { - x += fragment->indices[j + 1].delta; - } - } - else - { - x += glyph->cx; - } - } - } - - if (fragment->operation == GLYPH_FRAGMENT_ADD) - { - glyph_fragment_put(cache->glyph, fragment->index, - fragment->nindices, (void*) fragment->indices, (void*) bmps); - } - } - - if (xfi->drawing == xfi->primary) - { - if (xfi->remote_app != True) - { - XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, - fast_index->bkLeft, fast_index->bkTop, - fast_index->bkRight - fast_index->bkLeft + 1, - fast_index->bkBottom - fast_index->bkTop + 1, - fast_index->bkLeft, fast_index->bkTop); - } - - gdi_InvalidateRegion(xfi->hdc, fast_index->bkLeft, fast_index->bkTop, - fast_index->bkRight - fast_index->bkLeft + 1, - fast_index->bkBottom - fast_index->bkTop + 1); - } -#endif -} - void xf_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table) { } -#if 0 -void xf_gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph) -{ - int i; - Pixmap bitmap; - GLYPH_DATA* glyph; - xfInfo* xfi = ((xfContext*) update->context)->xfi; - rdpCache* cache = update->context->cache; - - for (i = 0; i < cache_glyph->cGlyphs; i++) - { - glyph = cache_glyph->glyphData[i]; - bitmap = xf_glyph_new(xfi, glyph->cx, glyph->cy, glyph->aj); - glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph->cacheIndex, glyph, (void*) bitmap); - } -} - -void xf_gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_v2) -{ - -} -#endif - void xf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command) { int i, tx, ty; @@ -916,7 +761,7 @@ void xf_gdi_register_update_callbacks(rdpUpdate* update) update->Mem3Blt = xf_gdi_mem3blt; update->SaveBitmap = NULL; update->GlyphIndex = NULL; - update->FastIndex = xf_gdi_fast_index; + update->FastIndex = NULL; update->FastGlyph = NULL; update->PolygonSC = NULL; update->PolygonCB = NULL; @@ -924,8 +769,6 @@ void xf_gdi_register_update_callbacks(rdpUpdate* update) update->EllipseCB = NULL; update->CacheColorTable = xf_gdi_cache_color_table; - //update->CacheGlyph = xf_gdi_cache_glyph; - //update->CacheGlyphV2 = xf_gdi_cache_glyph_v2; update->SurfaceBits = xf_gdi_surface_bits; } diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index b517c8e05..265ef4733 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -195,28 +195,92 @@ void xf_Pointer_Set(rdpContext* context, rdpPointer* pointer) XDefineCursor(xfi->display, xfi->window->handle, ((xfPointer*) pointer)->cursor); } +/* Glyph Class */ + +void xf_Glyph_New(rdpContext* context, rdpGlyph* glyph) +{ + xfInfo* xfi; + int scanline; + XImage* image; + xfGlyph* xf_glyph; + + xf_glyph = (xfGlyph*) glyph; + xfi = ((xfContext*) context)->xfi; + + scanline = (glyph->cx + 7) / 8; + + xf_glyph->pixmap = XCreatePixmap(xfi->display, xfi->drawable, glyph->cx, glyph->cy, 1); + + image = XCreateImage(xfi->display, xfi->visual, 1, + ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline); + + image->byte_order = MSBFirst; + image->bitmap_bit_order = MSBFirst; + + XInitImage(image); + XPutImage(xfi->display, xf_glyph->pixmap, xfi->gc_mono, image, 0, 0, 0, 0, glyph->cx, glyph->cy); + XFree(image); +} + +void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph) +{ + +} + +void xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y) +{ + +} + +void xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor) +{ + +} + +void xf_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor) +{ + +} + /* Graphics Module */ void xf_register_graphics(rdpGraphics* graphics) { - rdpBitmap bitmap; - rdpPointer pointer; + rdpBitmap* bitmap; + rdpPointer* pointer; + rdpGlyph* glyph; - memset(&bitmap, 0, sizeof(rdpBitmap)); - bitmap.size = sizeof(xfBitmap); + bitmap = xnew(rdpBitmap); + bitmap->size = sizeof(xfBitmap); - bitmap.New = xf_Bitmap_New; - bitmap.Free = xf_Bitmap_Free; - bitmap.Paint = xf_Bitmap_Paint; - bitmap.Decompress = xf_Bitmap_Decompress; - bitmap.SetSurface = xf_Bitmap_SetSurface; + bitmap->New = xf_Bitmap_New; + bitmap->Free = xf_Bitmap_Free; + bitmap->Paint = xf_Bitmap_Paint; + bitmap->Decompress = xf_Bitmap_Decompress; + bitmap->SetSurface = xf_Bitmap_SetSurface; - memset(&pointer, 0, sizeof(rdpPointer)); - pointer.size = sizeof(xfPointer); - pointer.New = xf_Pointer_New; - pointer.Free = xf_Pointer_Free; - pointer.Set = xf_Pointer_Set; + graphics_register_bitmap(graphics, bitmap); + xfree(bitmap); - graphics_register_bitmap(graphics, &bitmap); - graphics_register_pointer(graphics, &pointer); + pointer = xnew(rdpPointer); + pointer->size = sizeof(xfPointer); + + pointer->New = xf_Pointer_New; + pointer->Free = xf_Pointer_Free; + pointer->Set = xf_Pointer_Set; + + graphics_register_pointer(graphics, pointer); + xfree(pointer); + + glyph = xnew(rdpGlyph); + glyph->size = sizeof(xfGlyph); + + glyph->New = xf_Glyph_New; + glyph->Free = xf_Glyph_Free; + glyph->Draw = xf_Glyph_Draw; + glyph->BeginDraw = xf_Glyph_BeginDraw; + glyph->EndDraw = xf_Glyph_EndDraw; + + graphics_register_glyph(graphics, glyph); + xfree(glyph); } diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 7d7178bea..b3c2f04e4 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -56,6 +56,13 @@ struct xf_bitmap }; typedef struct xf_bitmap xfBitmap; +struct xf_glyph +{ + rdpGlyph glyph; + Pixmap pixmap; +}; +typedef struct xf_glyph xfGlyph; + struct xf_context { rdpContext _p; diff --git a/include/freerdp/cache/glyph.h b/include/freerdp/cache/glyph.h index fd3603464..36a6df732 100644 --- a/include/freerdp/cache/glyph.h +++ b/include/freerdp/cache/glyph.h @@ -41,7 +41,7 @@ struct _GLYPH_CACHE struct _FRAGMENT_CACHE_ENTRY { - void* entry; + void* fragment; uint16 size; }; diff --git a/libfreerdp-cache/glyph.c b/libfreerdp-cache/glyph.c index a092e26ef..a0c7d53be 100644 --- a/libfreerdp-cache/glyph.c +++ b/libfreerdp-cache/glyph.c @@ -24,46 +24,55 @@ #include void update_process_glyph(rdpUpdate* update, uint8* data, int* index, - int* x, int* y, uint8 cacheId, boolean delta, boolean vertical) + int* x, int* y, uint8 cacheId, uint8 ulCharInc, uint8 flAccel) { int offset; rdpGlyph* glyph; + uint8 cacheIndex; rdpGraphics* graphics; rdpGlyphCache* glyph_cache; graphics = update->context->graphics; glyph_cache = update->context->cache->glyph; - glyph = glyph_cache_get(glyph_cache, cacheId, data[(*index)++]); + cacheIndex = data[(*index)++]; - if (glyph != NULL) + if (cacheIndex == 0xFF) { - Glyph_Draw(update->context, glyph, *x, *y); + (*index)++; + return; } - offset = data[(*index)++]; + glyph = glyph_cache_get(glyph_cache, cacheId, cacheIndex); - if (offset & 0x80) + if ((ulCharInc == 0) && (!(flAccel & SO_CHAR_INC_EQUAL_BM_BASE))) { - offset = data[*index + 1] | (data[*index + 2] << 8); - *index += 2; - } + offset = data[*index]; - if (delta) - { - if (vertical) + if (offset & 0x80) + { + offset = data[*index + 1] | (data[*index + 2] << 8); + (*index)++; + (*index)++; + } + + if (flAccel & SO_VERTICAL) *y += offset; else *x += offset; } - else + + if (glyph != NULL) { - *x += glyph->cx; + Glyph_Draw(update->context, glyph, glyph->x + *x, glyph->y + *y); + + if (flAccel & SO_CHAR_INC_EQUAL_BM_BASE) + *x += glyph->cx; } } void update_process_glyph_fragments(rdpUpdate* update, uint8* data, uint8 length, - uint8 cacheId, boolean delta, boolean vertical, uint32 bgcolor, uint32 fgcolor, int x, int y, + uint8 cacheId, uint8 ulCharInc, uint8 flAccel, uint32 bgcolor, uint32 fgcolor, int x, int y, int bkX, int bkY, int bkWidth, int bkHeight, int opX, int opY, int opWidth, int opHeight) { int n; @@ -86,9 +95,11 @@ void update_process_glyph_fragments(rdpUpdate* update, uint8* data, uint8 length { case GLYPH_FRAGMENT_USE: + printf("GLYPH_FRAGMENT_USE\n"); + if (index + 2 > length) { - /* at least two bytes need to follow */ + /* at least one byte need to follow */ index = length = 0; break; } @@ -96,13 +107,24 @@ void update_process_glyph_fragments(rdpUpdate* update, uint8* data, uint8 length id = data[index + 1]; fragments = (uint8*) glyph_cache_fragment_get(glyph_cache, id, &size); - n = 0; - - do + if (fragments != NULL) { - update_process_glyph(update, fragments, &n, &x, &y, cacheId, delta, vertical); + n = 0; + + if ((ulCharInc == 0) && (!(flAccel & SO_CHAR_INC_EQUAL_BM_BASE))) + { + if (flAccel & SO_VERTICAL) + y += data[index + 2]; + else + x += data[index + 2]; + } + + do + { + update_process_glyph(update, fragments, &n, &x, &y, cacheId, ulCharInc, flAccel); + } + while (n < size); } - while (n < size); index += (index + 2 < length) ? 3 : 2; length -= index; @@ -113,16 +135,21 @@ void update_process_glyph_fragments(rdpUpdate* update, uint8* data, uint8 length case GLYPH_FRAGMENT_ADD: + printf("GLYPH_FRAGMENT_ADD\n"); + if (index + 3 > length) { - /* at least three bytes need to follow */ + /* at least two bytes need to follow */ index = length = 0; break; } id = data[index + 1]; size = data[index + 2]; - glyph_cache_fragment_put(glyph_cache, id, size, data); + + fragments = (uint8*) xmalloc(size); + memcpy(fragments, data, size); + glyph_cache_fragment_put(glyph_cache, id, size, fragments); index += 3; length -= index; @@ -132,7 +159,10 @@ void update_process_glyph_fragments(rdpUpdate* update, uint8* data, uint8 length break; default: - update_process_glyph(update, data, &index, &x, &y, cacheId, delta, vertical); + printf("GLYPH_FRAGMENT_NOP\n"); + + update_process_glyph(update, data, &index, &x, &y, cacheId, ulCharInc, flAccel); + index++; break; } } @@ -150,20 +180,14 @@ void update_gdi_glyph_index(rdpUpdate* update, GLYPH_INDEX_ORDER* glyph_index) void update_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) { - boolean delta = False; - boolean vertical = False; rdpGlyphCache* glyph_cache; glyph_cache = update->context->cache->glyph; - if ((fast_index->ulCharInc == 0) && !(fast_index->flAccel & SO_CHAR_INC_EQUAL_BM_BASE)) - delta = True; - - if (fast_index->flAccel & SO_VERTICAL) - vertical = True; + fast_index->x = fast_index->bkLeft; update_process_glyph_fragments(update, fast_index->data, fast_index->cbData, - fast_index->cacheId, delta, vertical, + fast_index->cacheId, fast_index->ulCharInc, fast_index->flAccel, fast_index->backColor, fast_index->foreColor, fast_index->x, fast_index->y, fast_index->bkLeft, fast_index->bkTop, fast_index->bkRight - fast_index->bkLeft, fast_index->bkBottom - fast_index->bkTop, @@ -252,17 +276,17 @@ void glyph_cache_put(rdpGlyphCache* glyph_cache, uint8 id, uint16 index, rdpGlyp void* glyph_cache_fragment_get(rdpGlyphCache* glyph_cache, uint8 index, uint8* size) { - void* entry; + void* fragment; - entry = glyph_cache->fragCache.entries[index].entry; + fragment = glyph_cache->fragCache.entries[index].fragment; *size = glyph_cache->fragCache.entries[index].size; - return entry; + return fragment; } -void glyph_cache_fragment_put(rdpGlyphCache* glyph_cache, uint8 index, uint8 size, void* entry) +void glyph_cache_fragment_put(rdpGlyphCache* glyph_cache, uint8 index, uint8 size, void* fragment) { - glyph_cache->fragCache.entries[index].entry = entry; + glyph_cache->fragCache.entries[index].fragment = fragment; glyph_cache->fragCache.entries[index].size = size; } diff --git a/libfreerdp-core/capabilities.c b/libfreerdp-core/capabilities.c index 4c9393db7..059dc62f5 100644 --- a/libfreerdp-core/capabilities.c +++ b/libfreerdp-core/capabilities.c @@ -232,8 +232,6 @@ void rdp_write_bitmap_capability_set(STREAM* s, rdpSettings* settings) desktopResizeFlag = settings->desktop_resize; - printf("desktop width:%d height:%d\n", settings->width, settings->height); - stream_write_uint16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ stream_write_uint16(s, 1); /* receive1BitPerPixel (2 bytes) */ stream_write_uint16(s, 1); /* receive4BitsPerPixel (2 bytes) */ diff --git a/libfreerdp-core/orders.c b/libfreerdp-core/orders.c index eeda85939..6f2cf23e6 100644 --- a/libfreerdp-core/orders.c +++ b/libfreerdp-core/orders.c @@ -422,178 +422,6 @@ INLINE void update_read_delta_points(STREAM* s, DELTA_POINT* points, int number, } } -INLINE uint16 update_read_glyph_fragments(STREAM* s, GLYPH_FRAGMENT** fragments, boolean delta, uint8 size) -{ - int index; - uint8 byte; - uint16 count; - uint8** offsets; - uint16* lengths; - uint8* operations; - uint8* array_mark; - uint8* stream_end; - uint8* stream_start; - GLYPH_FRAGMENT* fragment; - - count = 0; - fragment = NULL; - *fragments = NULL; - array_mark = NULL; - stream_end = s->p + size; - stream_get_mark(s, stream_start); - offsets = (uint8**) xmalloc(sizeof(uint8*) * size / 2); - lengths = (uint16*) xmalloc(sizeof(uint16) * size / 2); - operations = (uint8*) xmalloc(size / 2); - - while (s->p < stream_end) - { - stream_read_uint8(s, byte); - - if (byte == GLYPH_FRAGMENT_USE) - { - if (array_mark != NULL) - { - offsets[count] = array_mark; - lengths[count] = array_mark - ((count < 1) ? stream_start : offsets[count - 1]); - operations[count] = GLYPH_FRAGMENT_NOP; - array_mark = NULL; - count++; - } - - offsets[count] = (s->p - 1); - stream_seek_uint8(s); - - if (delta) - update_seek_glyph_delta(s); - - lengths[count] = (s->p - offsets[count]); - operations[count] = GLYPH_FRAGMENT_USE; - count++; - } - else if (byte == GLYPH_FRAGMENT_ADD) - { - stream_seek_uint8(s); - stream_read_uint8(s, byte); - - if ((s->p - (byte + 3)) != array_mark) - { - offsets[count] = array_mark; - lengths[count] = (s->p - (byte + 3)) - array_mark; - array_mark = NULL; - count++; - } - - offsets[count] = (s->p - (byte + 3)); - lengths[count] = (s->p - offsets[count]); - operations[count] = GLYPH_FRAGMENT_ADD; - array_mark = NULL; - count++; - } - else - { - if (array_mark == NULL) - array_mark = (s->p - 1); - - if (delta) - update_seek_glyph_delta(s); - } - } - - if (array_mark != NULL) - { - lengths[count] = array_mark - ((count < 1) ? stream_start : offsets[count - 1]); - - if (lengths[count] > 1) - { - offsets[count] = array_mark; - operations[count] = GLYPH_FRAGMENT_NOP; - array_mark = NULL; - count++; - } - } - - index = 0; - stream_set_mark(s, stream_start); - *fragments = (GLYPH_FRAGMENT*) xmalloc(sizeof(GLYPH_FRAGMENT) * count); - - for (index = 0; index < count; index++) - { - fragment = &(*fragments[index]); - stream_set_mark(s, offsets[index]); - - if (operations[index] == GLYPH_FRAGMENT_USE) - { - stream_seek_uint8(s); - fragment->operation = GLYPH_FRAGMENT_USE; - stream_read_uint8(s, fragment->index); - } - else if (operations[index] == GLYPH_FRAGMENT_ADD) - { - uint16 icount; - fragment->operation = GLYPH_FRAGMENT_ADD; - - fragment->nindices = 0; - icount = (lengths[index] - 3) / ((delta) ? 2 : 1); - fragment->indices = (GLYPH_FRAGMENT_INDEX*) xmalloc(icount * sizeof(GLYPH_FRAGMENT_INDEX)); - - while (s->p < (offsets[index] + (lengths[index] - 3))) - { - if ((fragment->nindices + 1) > icount) - { - fragment->indices = (GLYPH_FRAGMENT_INDEX*) xrealloc(fragment->indices, - ++icount * sizeof(GLYPH_FRAGMENT_INDEX)); - } - - stream_read_uint8(s, fragment->indices[fragment->nindices].index); - - if (delta) - update_read_glyph_delta(s, &fragment->indices[fragment->nindices].delta); - else - fragment->indices[fragment->nindices].delta = 0; - - fragment->nindices++; - } - - stream_seek_uint8(s); - stream_read_uint8(s, fragment->index); - stream_read_uint8(s, fragment->size); - } - else - { - uint16 icount; - fragment->operation = GLYPH_FRAGMENT_NOP; - - fragment->nindices = 0; - icount = lengths[index] / ((delta) ? 2 : 1); - fragment->indices = (GLYPH_FRAGMENT_INDEX*) xmalloc(icount * sizeof(GLYPH_FRAGMENT_INDEX)); - - while (s->p < (offsets[index] + lengths[index])) - { - if ((fragment->nindices + 1) > icount) - { - fragment->indices = (GLYPH_FRAGMENT_INDEX*) xrealloc(fragment->indices, - ++icount * sizeof(GLYPH_FRAGMENT_INDEX)); - } - - stream_read_uint8(s, fragment->indices[fragment->nindices].index); - - if (delta) - update_read_glyph_delta(s, &fragment->indices[fragment->nindices].delta); - else - fragment->indices[fragment->nindices].delta = 0; - - fragment->nindices++; - } - } - } - - xfree(offsets); - xfree(lengths); - xfree(operations); - - return count; -} - /* Primary Drawing Orders */ void update_read_dstblt_order(STREAM* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt) diff --git a/libfreerdp-gdi/gdi.c b/libfreerdp-gdi/gdi.c index 36884d3cd..9e8175b70 100644 --- a/libfreerdp-gdi/gdi.c +++ b/libfreerdp-gdi/gdi.c @@ -625,161 +625,12 @@ void gdi_mem3blt(rdpUpdate* update, MEM3BLT_ORDER* mem3blt) } -void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) -{ -#if 0 - int i, j; - int x, y; - GDI_RECT rect; - uint32 bgcolor; - uint32 fgcolor; - HGDI_BRUSH brush; - gdiBitmap* bmp; - gdiBitmap** bmps; - GLYPH_DATA* glyph; - GLYPH_DATA** glyphs; - GLYPH_FRAGMENT* fragment; - rdpGdi* gdi = update->context->gdi; - rdpCache* cache = update->context->cache; - - x = fast_index->bkLeft; - y = fast_index->y; - - 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++) - { - fragment = &fast_index->fragments[i]; - - if (fragment->operation == GLYPH_FRAGMENT_USE) - { - fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(cache->glyph, - fragment->index, &fragment->nindices, (void**) &bmps); - - glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices); - - for (j = 0; j < fragment->nindices; j++) - { - glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]); - } - } - else - { - bmps = (gdiBitmap**) xmalloc(sizeof(gdiBitmap*) * fragment->nindices); - glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices); - - for (j = 0; j < fragment->nindices; j++) - { - glyphs[j] = glyph_get(cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]); - } - } - - for (j = 0; j < fragment->nindices; j++) - { - bmp = bmps[j]; - glyph = glyphs[j]; - - if (bmp == NULL || glyph == NULL) - continue; - - gdi_BitBlt(gdi->drawing->hdc, glyph->x + x, glyph->y + y, bmp->bitmap->width, - bmp->bitmap->height, bmp->hdc, 0, 0, GDI_DSPDxax); - - if ((j + 1) < fragment->nindices) - { - if (!(fast_index->flAccel & SO_CHAR_INC_EQUAL_BM_BASE)) - { - if (fast_index->flAccel & SO_VERTICAL) - { - y += fragment->indices[j + 1].delta; - } - else - { - x += fragment->indices[j + 1].delta; - } - } - else - { - x += glyph->cx; - } - } - } - - if (fragment->operation == GLYPH_FRAGMENT_ADD) - { - glyph_fragment_put(cache->glyph, fragment->index, - fragment->nindices, (void*) fragment->indices, (void*) bmps); - } - } - - gdi_SetTextColor(gdi->drawing->hdc, gdi->textColor); - gdi_DeleteObject((HGDIOBJECT) brush); -#endif -} - void gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table) { rdpCache* cache = update->context->cache; color_table_put(cache->color_table, cache_color_table->cacheIndex, (void*) cache_color_table->colorTable); } -#if 0 -void gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph) -{ - int i; - GLYPH_DATA* glyph; - gdiBitmap* gdi_bmp; - rdpGdi* gdi = update->context->gdi; - rdpCache* cache = update->context->cache; - - for (i = 0; i < cache_glyph->cGlyphs; i++) - { - glyph = cache_glyph->glyphData[i]; - gdi_bmp = gdi_glyph_new(gdi, glyph); - glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph->cacheIndex, glyph, (void*) gdi_bmp); - } -} - -void gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_v2) -{ - int i; - uint8* extra; - GLYPH_DATA_V2* glyph; - gdiBitmap* gdi_bmp; - rdpCache* cache = update->context->cache; - - for (i = 0; i < cache_glyph_v2->cGlyphs; i++) - { - glyph = cache_glyph_v2->glyphData[i]; - gdi_bmp = (gdiBitmap*) malloc(sizeof(gdiBitmap)); - - gdi_bmp->hdc = gdi_GetDC(); - gdi_bmp->hdc->bytesPerPixel = 1; - gdi_bmp->hdc->bitsPerPixel = 1; - - extra = freerdp_glyph_convert(glyph->cx, glyph->cy, glyph->aj); - gdi_bmp->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, 1, extra); - gdi_bmp->bitmap->bytesPerPixel = 1; - gdi_bmp->bitmap->bitsPerPixel = 1; - - gdi_SelectObject(gdi_bmp->hdc, (HGDIOBJECT) gdi_bmp->bitmap); - gdi_bmp->org_bitmap = NULL; - - glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph->cacheIndex, glyph, (void*) gdi_bmp); - } -} -#endif - int tilenum = 0; void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command) @@ -919,7 +770,7 @@ void gdi_register_update_callbacks(rdpUpdate* update) update->Mem3Blt = gdi_mem3blt; update->SaveBitmap = NULL; update->GlyphIndex = NULL; - update->FastIndex = gdi_fast_index; + update->FastIndex = NULL; update->FastGlyph = NULL; update->PolygonSC = NULL; update->PolygonCB = NULL; @@ -927,8 +778,6 @@ void gdi_register_update_callbacks(rdpUpdate* update) update->EllipseCB = NULL; update->CacheColorTable = gdi_cache_color_table; - //update->CacheGlyph = gdi_cache_glyph; - //update->CacheGlyphV2 = gdi_cache_glyph_v2; update->SurfaceBits = gdi_surface_bits; } diff --git a/libfreerdp-gdi/graphics.c b/libfreerdp-gdi/graphics.c index ec0d2ba75..66bfa3090 100644 --- a/libfreerdp-gdi/graphics.c +++ b/libfreerdp-gdi/graphics.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,8 @@ #include "graphics.h" +/* Bitmap Class */ + HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int width, int height, int bpp, uint8* data) { uint8* bmpData; @@ -129,6 +132,8 @@ void gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, boolean prima gdi->drawing = (gdiBitmap*) bitmap; } +/* Glyph Class */ + void gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph) { uint8* data; @@ -171,7 +176,10 @@ void gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y) gdi_glyph = (gdiGlyph*) glyph; - gdi_BitBlt(gdi->drawing->hdc, glyph->x + x, glyph->y + y, gdi_glyph->bitmap->width, + printf("Glyph_Draw: x:%d y:%d w:%d h:%d\n", x, y, + gdi_glyph->bitmap->width, gdi_glyph->bitmap->height); + + gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width, gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax); } @@ -181,8 +189,10 @@ void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; + bgcolor = freerdp_color_convert(bgcolor, gdi->srcBpp, 32, gdi->clrconv); fgcolor = freerdp_color_convert(fgcolor, gdi->srcBpp, 32, gdi->clrconv); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); + gdi_SetNullClipRgn(gdi->drawing->hdc); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); @@ -194,32 +204,39 @@ void gdi_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, { rdpGdi* gdi = context->gdi; + bgcolor = freerdp_color_convert(bgcolor, gdi->srcBpp, 32, gdi->clrconv); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); } +/* Graphics Module */ + void gdi_register_graphics(rdpGraphics* graphics) { - rdpBitmap bitmap; - rdpGlyph glyph; + rdpBitmap* bitmap; + rdpGlyph* glyph; - bitmap.size = sizeof(gdiBitmap); + bitmap = xnew(rdpBitmap); + bitmap->size = sizeof(gdiBitmap); - bitmap.New = gdi_Bitmap_New; - bitmap.Free = gdi_Bitmap_Free; - bitmap.Paint = gdi_Bitmap_Paint; - bitmap.Decompress = gdi_Bitmap_Decompress; - bitmap.SetSurface = gdi_Bitmap_SetSurface; + bitmap->New = gdi_Bitmap_New; + bitmap->Free = gdi_Bitmap_Free; + bitmap->Paint = gdi_Bitmap_Paint; + bitmap->Decompress = gdi_Bitmap_Decompress; + bitmap->SetSurface = gdi_Bitmap_SetSurface; - graphics_register_bitmap(graphics, &bitmap); + graphics_register_bitmap(graphics, bitmap); + xfree(bitmap); - glyph.size = sizeof(gdiGlyph); + glyph = xnew(rdpGlyph); + glyph->size = sizeof(gdiGlyph); - glyph.New = gdi_Glyph_New; - glyph.Free = gdi_Glyph_Free; - glyph.Draw = gdi_Glyph_Draw; - glyph.BeginDraw = gdi_Glyph_BeginDraw; - glyph.EndDraw = gdi_Glyph_EndDraw; + glyph->New = gdi_Glyph_New; + glyph->Free = gdi_Glyph_Free; + glyph->Draw = gdi_Glyph_Draw; + glyph->BeginDraw = gdi_Glyph_BeginDraw; + glyph->EndDraw = gdi_Glyph_EndDraw; - graphics_register_glyph(graphics, &glyph); + graphics_register_glyph(graphics, glyph); + xfree(glyph); }