From: Armin Novak Date: Wed, 20 Jul 2016 08:06:45 +0000 (+0200) Subject: Bug fixes. X-Git-Tag: 2.0.0-beta1+android10~160^2~162 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f90966da6d5b135d2c1b70ca66c09b29e641426;p=platform%2Fupstream%2Ffreerdp.git Bug fixes. --- diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index 0258309..7bcb393 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -135,6 +135,10 @@ static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, UINT32 SrcFormat; UINT32 bytesPerPixel; xfContext* xfc = (xfContext*) context; + + if (!Bitmap_SetDimensions(bitmap, width, height)) + return FALSE; + bytesPerPixel = (bpp + 7) / 8; size = width * height * 4; bitmap->data = (BYTE*) _aligned_malloc(size, 16); @@ -153,7 +157,7 @@ static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, if (!interleaved_decompress(context->codecs->interleaved, pSrcData, SrcSize, width, height, bpp, pDstData, xfc->format, - 0, 0, 0, width, height, + 0, 0, 0, bitmap->width, bitmap->height, &context->gdi->palette)) return FALSE; } @@ -161,7 +165,7 @@ static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, { if (!planar_decompress(context->codecs->planar, pSrcData, SrcSize, width, height, - pDstData, xfc->format, 0, 0, 0, width, height, TRUE)) + pDstData, xfc->format, 0, 0, 0, bitmap->width, bitmap->height, TRUE)) return FALSE; } } @@ -375,6 +379,8 @@ static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph) XFreePixmap(xfc->display, ((xfGlyph*) glyph)->pixmap); xf_unlock_x11(xfc, FALSE); + free(glyph->aj); + free(glyph); } static BOOL xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x, diff --git a/include/freerdp/graphics.h b/include/freerdp/graphics.h index 14c2774..2d74554 100644 --- a/include/freerdp/graphics.h +++ b/include/freerdp/graphics.h @@ -145,7 +145,8 @@ struct rdp_glyph UINT32 paddingB[32 - 22]; /* 22 */ }; -FREERDP_API rdpGlyph* Glyph_Alloc(rdpContext* context); +FREERDP_API rdpGlyph* Glyph_Alloc(rdpContext* context, INT32 x, INT32 y, + UINT32 cx, UINT32 cy, UINT32 cb, const BYTE* aj); /* Graphics Module */ diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index 143d982..9583a69 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -108,13 +108,6 @@ static BOOL update_gdi_cache_bitmap(rdpContext* context, if (!bitmap) return FALSE; - if (!Bitmap_SetDimensions(bitmap, cacheBitmap->bitmapWidth, - cacheBitmap->bitmapHeight)) - { - bitmap->Free(context, bitmap); - return FALSE; - } - if (!bitmap->Decompress(context, bitmap, cacheBitmap->bitmapDataStream, cacheBitmap->bitmapWidth, cacheBitmap->bitmapHeight, @@ -155,9 +148,6 @@ static BOOL update_gdi_cache_bitmap_v2(rdpContext* context, if (!bitmap) return FALSE; - Bitmap_SetDimensions(bitmap, cacheBitmapV2->bitmapWidth, - cacheBitmapV2->bitmapHeight); - if (!cacheBitmapV2->bitmapBpp) cacheBitmapV2->bitmapBpp = settings->ColorDepth; @@ -205,14 +195,12 @@ static BOOL update_gdi_cache_bitmap_v3(rdpContext* context, if (!bitmap) return FALSE; - Bitmap_SetDimensions(bitmap, bitmapData->width, bitmapData->height); - if (!cacheBitmapV3->bpp) cacheBitmapV3->bpp = settings->ColorDepth; compressed = (bitmapData->codecID != RDP_CODEC_ID_NONE); bitmap->Decompress(context, bitmap, - bitmapData->data, bitmap->width, bitmap->height, + bitmapData->data, bitmapData->width, bitmapData->height, bitmapData->bpp, bitmapData->length, compressed, bitmapData->codecID); @@ -256,16 +244,14 @@ static BOOL update_gdi_bitmap_update(rdpContext* context, Bitmap_SetRectangle(bitmap, bitmapData->destLeft, bitmapData->destTop, bitmapData->destRight, bitmapData->destBottom); - Bitmap_SetDimensions(bitmap, bitmapData->width, bitmapData->height); - bitmap->Decompress(context, bitmap, - bitmapData->bitmapDataStream, bitmapData->width, bitmapData->height, - bitmapData->bitsPerPixel, bitmapData->bitmapLength, - bitmapData->compressed, RDP_CODEC_ID_NONE); if (reused) bitmap->Free(context, bitmap); - reused = TRUE; + bitmap->Decompress(context, bitmap, + bitmapData->bitmapDataStream, bitmapData->width, bitmapData->height, + bitmapData->bitsPerPixel, bitmapData->bitmapLength, + bitmapData->compressed, RDP_CODEC_ID_NONE); if (!bitmap->New(context, bitmap)) return FALSE; diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 4fc9dee..a3b9464 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -389,32 +389,12 @@ static BOOL update_gdi_fast_glyph(rdpContext* context, if (!glyphData) return FALSE; - glyph = Glyph_Alloc(context); + glyph = Glyph_Alloc(context, x, y, glyphData->cx, glyphData->cy, + glyphData->cb, glyphData->aj); if (!glyph) return FALSE; - glyph->x = x; - glyph->y = y; - glyph->cx = glyphData->cx; - glyph->cy = glyphData->cy; - glyph->cb = glyphData->cb; - glyph->aj = malloc(glyphData->cb); - - if (!glyph->aj) - { - IFCALL(glyph->Free, context, glyph); - return FALSE; - } - - CopyMemory(glyph->aj, glyphData->aj, glyph->cb); - - if (!glyph->New(context, glyph)) - { - IFCALL(glyph->Free, context, glyph); - return FALSE; - } - glyph_cache_put(cache->glyph, fastGlyph->cacheId, fastGlyph->data[0], glyph); } @@ -449,22 +429,14 @@ static BOOL update_gdi_cache_glyph(rdpContext* context, if (!glyph_data) return FALSE; - if (!(glyph = Glyph_Alloc(context))) + if (!(glyph = Glyph_Alloc(context, glyph_data->x, + glyph_data->y, + glyph_data->cx, + glyph_data->cy, + glyph_data->cb, + glyph_data->aj))) return FALSE; - glyph->x = glyph_data->x; - glyph->y = glyph_data->y; - glyph->cx = glyph_data->cx; - glyph->cy = glyph_data->cy; - glyph->cb = glyph_data->cb; - glyph->aj = glyph_data->aj; - - if (!glyph->New(context, glyph)) - { - glyph->Free(context, glyph); - return FALSE; - } - glyph_cache_put(cache->glyph, cacheGlyph->cacheId, glyph_data->cacheIndex, glyph); } @@ -491,24 +463,16 @@ static BOOL update_gdi_cache_glyph_v2(rdpContext* context, if (!glyphData) return FALSE; - glyph = Glyph_Alloc(context); + glyph = Glyph_Alloc(context, glyphData->x, + glyphData->y, + glyphData->cx, + glyphData->cy, + glyphData->cb, + glyphData->aj); if (!glyph) return FALSE; - glyph->x = glyphData->x; - glyph->y = glyphData->y; - glyph->cx = glyphData->cx; - glyph->cy = glyphData->cy; - glyph->cb = glyphData->cb; - glyph->aj = glyphData->aj; - - if (!glyph->New(context, glyph)) - { - glyph->Free(context, glyph); - return FALSE; - } - glyph_cache_put(cache->glyph, cacheGlyphV2->cacheId, glyphData->cacheIndex, glyph); } @@ -564,7 +528,7 @@ BOOL glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, prevGlyph = glyphCache->glyphCache[id].entries[index]; if (prevGlyph) - glyph->Free(glyphCache->context, prevGlyph); + prevGlyph->Free(glyphCache->context, prevGlyph); glyphCache->glyphCache[id].entries[index] = glyph; return TRUE; diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index 7577771..c1f26b0 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -43,7 +43,7 @@ static BOOL freerdp_bitmap_planar_delta_encode_planes( BYTE* outPlanes[4]); static INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, - UINT32 nDstWidth, UINT32 nDstHeight) + UINT32 nWidth, UINT32 nHeight) { UINT32 x, y; int cRawBytes; diff --git a/libfreerdp/core/graphics.c b/libfreerdp/core/graphics.c index 05a2281..56eb4c2 100644 --- a/libfreerdp/core/graphics.c +++ b/libfreerdp/core/graphics.c @@ -154,7 +154,8 @@ void graphics_register_pointer(rdpGraphics* graphics, rdpPointer* pointer) /* Glyph Class */ -rdpGlyph* Glyph_Alloc(rdpContext* context) +rdpGlyph* Glyph_Alloc(rdpContext* context, INT32 x, INT32 y, + UINT32 cx, UINT32 cy, UINT32 cb, const BYTE* aj) { rdpGlyph* glyph; rdpGraphics* graphics; @@ -173,6 +174,28 @@ rdpGlyph* Glyph_Alloc(rdpContext* context) return NULL; *glyph = *graphics->Glyph_Prototype; + glyph->cb = cb; + glyph->cx = cx; + glyph->cy = cy; + glyph->x = x; + glyph->y = y; + glyph->aj = malloc(glyph->cb); + + if (!glyph->aj) + { + free(glyph); + return NULL; + } + + CopyMemory(glyph->aj, aj, cb); + + if (!glyph->New(context, glyph)) + { + free(glyph->aj); + free(glyph); + return NULL; + } + return glyph; } diff --git a/libfreerdp/gdi/bitmap.c b/libfreerdp/gdi/bitmap.c index ffd00fd..1b70868 100644 --- a/libfreerdp/gdi/bitmap.c +++ b/libfreerdp/gdi/bitmap.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "brush.h" #include "clipping.h" @@ -183,13 +184,10 @@ static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (!hDstBmp || !hSrcBmp) return FALSE; - if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, - nXDest, nYDest, nWidth, nHeight, - hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline, - nXSrc, nYSrc, palette)) - return FALSE; - - return TRUE; + return freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline, + nXDest, nYDest, nWidth, nHeight, + hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline, + nXSrc, nYSrc, palette); } static BOOL BitBlt_NOTSRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, @@ -249,7 +247,7 @@ static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 color; colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, palette); - color = colorA & ~colorB; + color = ~colorA & colorB; WriteColor(dstp, hdcDest->format, color); } } @@ -279,11 +277,11 @@ static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { UINT32 color; - UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - colorA = ConvertColor(colorA, hdcSrc->format, + UINT32 colorA = ReadColor(dstp, hdcDest->format); + UINT32 colorB = ReadColor(srcp, hdcSrc->format); + colorB = ConvertColor(colorB, hdcSrc->format, hdcDest->format, palette); - color = ~colorA & ~colorB; + color = ~(colorA | colorB); WriteColor(dstp, hdcDest->format, color); } } @@ -313,9 +311,9 @@ static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { UINT32 color; - UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - colorA = ConvertColor(colorA, hdcSrc->format, + UINT32 colorA = ReadColor(dstp, hdcDest->format); + UINT32 colorB = ReadColor(srcp, hdcSrc->format); + colorB = ConvertColor(colorB, hdcSrc->format, hdcDest->format, palette); color = colorA ^ colorB; WriteColor(dstp, hdcDest->format, color); @@ -347,9 +345,9 @@ static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { UINT32 color; - UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - colorA = ConvertColor(colorA, hdcSrc->format, + UINT32 colorA = ReadColor(dstp, hdcDest->format); + UINT32 colorB = ReadColor(srcp, hdcSrc->format); + colorB = ConvertColor(colorB, hdcSrc->format, hdcDest->format, palette); color = colorA & colorB; WriteColor(dstp, hdcDest->format, color); @@ -399,13 +397,12 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette) { UINT32 x, y; - UINT32 color; + UINT32 colorC; if (!hdcDest || !hdcSrc) return FALSE; - /* D = (D ^ S) & (P ^ D) */ - color = hdcDest->textColor; + colorC = hdcDest->textColor; for (y = 0; y < nHeight; y++) { @@ -419,11 +416,15 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { UINT32 dstColor; - UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - colorA = ConvertColor(colorA, hdcSrc->format, + UINT32 tmp1, tmp2; + UINT32 colorA = ReadColor(dstp, hdcDest->format); + UINT32 colorB = ReadColor(srcp, hdcSrc->format); + colorB = ConvertColor(colorB, hdcSrc->format, hdcDest->format, palette); - dstColor = (colorB ^ colorA) & (color & colorB); + tmp1 = colorA ^ colorB; + tmp2 = tmp1 & colorC; + dstColor = tmp2 ^ colorA; + //dstColor = (colorA ^ colorB) & (colorC ^ colorA); WriteColor(dstp, hdcDest->format, dstColor); } } @@ -444,7 +445,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, /* D = (S & D) | (~S & P) */ if (hdcDest->brush->style == GDI_BS_SOLID) { - UINT32 colorC = hdcDest->brush->color; + UINT32 colorA = hdcDest->brush->color; for (y = 0; y < nHeight; y++) { @@ -458,11 +459,11 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { UINT32 color; - UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - colorA = ConvertColor(colorA, hdcSrc->format, + UINT32 colorB = ReadColor(srcp, hdcSrc->format); + UINT32 colorC = ReadColor(dstp, hdcDest->format); + colorB = ConvertColor(colorB, hdcSrc->format, hdcDest->format, palette); - color = (colorA & colorB) | (~colorA & colorC); + color = ((colorA ^ colorB) & colorC) ^ colorA; WriteColor(dstp, hdcDest->format, color); } } @@ -484,12 +485,12 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { UINT32 color; - UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - UINT32 colorC = ReadColor(patp, hdcDest->format); + UINT32 colorB = ReadColor(srcp, hdcSrc->format); + UINT32 colorC = ReadColor(dstp, hdcDest->format); + UINT32 colorA = ReadColor(patp, hdcDest->format); colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, palette); - color = (colorA & colorB) | (~colorA & colorC); + color = ((colorA ^ colorB) & colorC) ^ colorA; WriteColor(dstp, hdcDest->format, color); } } @@ -511,7 +512,7 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, /* D = S ^ (P & (D ^ S)) */ if (hdcDest->brush->style == GDI_BS_SOLID) { - UINT32 color = hdcDest->brush->color; + UINT32 colorB = hdcDest->brush->color; for (y = 0; y < nHeight; y++) { @@ -524,12 +525,12 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { - UINT32 colorD; + UINT32 color; UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); + UINT32 colorC = ReadColor(dstp, hdcDest->format); colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, palette); - colorD = colorA ^ (color & (colorB ^ colorA)); + color = ((colorA ^ colorB) & colorC) ^ colorA; WriteColor(dstp, hdcDest->format, color); } } @@ -550,13 +551,13 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (srcp && dstp) { - UINT32 colorD; + UINT32 color; UINT32 colorA = ReadColor(srcp, hdcSrc->format); - UINT32 colorB = ReadColor(dstp, hdcDest->format); - UINT32 color = ReadColor(patp, hdcDest->format); + UINT32 colorB = ReadColor(patp, hdcDest->format); + UINT32 colorC = ReadColor(dstp, hdcDest->format); colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, palette); - colorD = colorA ^ (color & (colorB ^ colorA)); + color = ((colorA ^ colorB) & colorC) ^ colorA; WriteColor(dstp, hdcDest->format, color); } } @@ -590,7 +591,7 @@ static BOOL BitBlt_SPna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 colorB = ReadColor(patp, hdcDest->format); colorB = ConvertColor(colorB, hdcDest->format, hdcSrc->format, palette); - color = colorA & ~colorB; + color = (~colorA) & colorB; color = ConvertColor(color, hdcSrc->format, hdcDest->format, palette); WriteColor(dstp, hdcDest->format, color); } @@ -625,7 +626,7 @@ static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 colorB = ReadColor(dstp, hdcDest->format); colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, palette); - color = ~colorA & colorB; + color = colorA & (~colorB); WriteColor(dstp, hdcDest->format, color); } } @@ -695,7 +696,7 @@ static BOOL BitBlt_MERGEPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 color; colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, palette); - color = ~colorA | colorB; + color = colorA | (~colorB); WriteColor(dstp, hdcDest->format, color); } } diff --git a/libfreerdp/gdi/brush.c b/libfreerdp/gdi/brush.c index 1e95a9d..03f2450 100644 --- a/libfreerdp/gdi/brush.c +++ b/libfreerdp/gdi/brush.c @@ -347,7 +347,9 @@ static BOOL BitBlt_DPa(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, if (dstp && patp) { - UINT32 color = ReadColor(patp, hdcDest->format); + UINT32 colorA = ReadColor(patp, hdcDest->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + UINT32 color = colorB & colorA; WriteColor(dstp, hdcDest->format, color); } } @@ -450,7 +452,7 @@ static BOOL BitBlt_PATPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 colorA = ReadColor(dstp, hdcDest->format); UINT32 colorB = ReadColor(patp, hdcDest->format); UINT32 colorC = ReadColor(srcp, hdcDest->format); - UINT32 color = colorA | colorB | ~colorC; + UINT32 color = ~colorA | colorB | colorC; WriteColor(dstp, hdcDest->format, color); } } diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index 09a39fc..5133442 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -138,9 +138,13 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, UINT32 SrcSize = length; UINT32 SrcFormat; UINT32 bytesPerPixel; - UINT32 DstWidth = MIN(width, bitmap->width); - UINT32 DstHeight = MIN(height, bitmap->height); + UINT32 DstWidth = width; + UINT32 DstHeight = height; rdpGdi* gdi = context->gdi; + + if (!Bitmap_SetDimensions(bitmap, width, height)) + return FALSE; + bytesPerPixel = (bpp + 7) / 8; size = width * height * GetBytesPerPixel(gdi->dstFormat); bitmap->data = (BYTE*) _aligned_malloc(size, 16); @@ -275,6 +279,8 @@ static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y, UINT32 fgcolor, BOOL fOpRedundant) { rdpGdi* gdi; + GDI_RECT rect; + HGDI_BRUSH brush; if (!context || !context->gdi) return FALSE;