Bugfixes.
authorArmin Novak <armin.novak@thincast.com>
Tue, 19 Jul 2016 11:02:08 +0000 (13:02 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:43:02 +0000 (13:43 +0200)
15 files changed:
client/X11/xf_client.c
client/X11/xf_gdi.c
client/X11/xf_graphics.c
include/freerdp/codec/color.h
include/freerdp/gdi/gdi.h
libfreerdp/cache/bitmap.c
libfreerdp/cache/offscreen.c
libfreerdp/codec/color.c
libfreerdp/core/orders.c
libfreerdp/gdi/bitmap.c
libfreerdp/gdi/gdi.c
libfreerdp/gdi/gfx.c
libfreerdp/gdi/graphics.c
libfreerdp/gdi/line.c
libfreerdp/gdi/region.c

index 0997375..e03baf8 100644 (file)
@@ -1886,6 +1886,8 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        else
                xfc->format = PIXEL_FORMAT_RGBX32;
 
+       xfc->format = PIXEL_FORMAT_RGBX32;
+
        if (xfc->debug)
        {
                WLog_INFO(TAG, "Enabling X11 debug mode.");
index 417a505..184ffa1 100644 (file)
@@ -232,8 +232,8 @@ static Pixmap xf_brush_new(xfContext* xfc, int width, int height, int bpp,
        {
                brushFormat = gdi_get_pixel_format(bpp, FALSE);
                cdata = (BYTE*) _aligned_malloc(width * height * 4, 16);
-               freerdp_image_copy(cdata, xfc->format, -1, 0, 0,
-                                  width, height, data, brushFormat, -1, 0, 0,
+               freerdp_image_copy(cdata, xfc->format, 0, 0, 0,
+                                  width, height, data, brushFormat, 0, 0, 0,
                                   &xfc->context.gdi->palette);
                image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
                                     ZPixmap, 0, (char*) cdata, width, height, xfc->scanline_pad, 0);
@@ -312,7 +312,7 @@ BOOL xf_gdi_bitmap_update(rdpContext* context,
                                                            pSrcData, SrcSize,
                                                            bitsPerPixel,
                                                            pDstData,
-                                                           xfc->format, -1,
+                                                           xfc->format, 0,
                                                            0, 0,
                                                            nWidth, nHeight,
                                                            &xfc->context.gdi->palette))
@@ -321,7 +321,7 @@ BOOL xf_gdi_bitmap_update(rdpContext* context,
                        else
                        {
                                if (!planar_decompress(codecs->planar, pSrcData, SrcSize, pDstData,
-                                                      xfc->format, -1, 0, 0, nWidth, nHeight, TRUE))
+                                                      xfc->format, 0, 0, 0, nWidth, nHeight, TRUE))
                                        return FALSE;
                        }
 
@@ -331,9 +331,9 @@ BOOL xf_gdi_bitmap_update(rdpContext* context,
                {
                        pDstData = xfc->bitmap_buffer;
 
-                       if (!freerdp_image_copy(pDstData, xfc->format, -1, 0, 0,
+                       if (!freerdp_image_copy(pDstData, xfc->format, 0, 0, 0,
                                                nWidth, nHeight, pSrcData, SrcFormat,
-                                               -1, 0, 0, &xfc->context.gdi->palette))
+                                               0, 0, 0, &xfc->context.gdi->palette))
                                return FALSE;
 
                        pSrcData = xfc->bitmap_buffer;
@@ -575,7 +575,7 @@ static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
        XSetFillStyle(xfc->display, xfc->gc, FillSolid);
        XSetForeground(xfc->display, xfc->gc, color);
 
-       for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++)
+       for (i = 0; i < multi_opaque_rect->numRectangles; i++)
        {
                const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
                XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
@@ -1133,9 +1133,9 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
                        XSetFillStyle(xfc->display, xfc->gc, FillSolid);
                        pSrcData = cmd->bitmapData;
                        pDstData = xfc->bitmap_buffer;
-                       freerdp_image_copy(pDstData, xfc->format, -1, 0, 0,
+                       freerdp_image_copy(pDstData, xfc->format, 0, 0, 0,
                                           cmd->width, cmd->height, pSrcData,
-                                          PIXEL_FORMAT_BGRX32_VF, -1, 0, 0, &xfc->context.gdi->palette);
+                                          PIXEL_FORMAT_BGRX32_VF, 0, 0, 0, &xfc->context.gdi->palette);
                        image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
                                             (char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0);
                        XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
index 3acadae..c860c31 100644 (file)
@@ -70,10 +70,10 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
                        }
 
                        SrcFormat = bitmap->format;
-                       freerdp_image_copy(data, xfc->format, -1, 0, 0,
+                       freerdp_image_copy(data, xfc->format, 0, 0, 0,
                                           bitmap->width, bitmap->height,
                                           bitmap->data, SrcFormat,
-                                          -1, 0, 0, &context->gdi->palette);
+                                          0, 0, 0, &context->gdi->palette);
                        _aligned_free(bitmap->data);
                        bitmap->data = data;
                        bitmap->format = xfc->format;
@@ -153,14 +153,14 @@ static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
                        if (!interleaved_decompress(context->codecs->interleaved,
                                                    pSrcData, SrcSize, bpp,
                                                    pDstData, xfc->format,
-                                                   -1, 0, 0, width, height,
+                                                   0, 0, 0, width, height,
                                                    &context->gdi->palette))
                                return FALSE;
                }
                else
                {
                        if (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,
-                                              pDstData, xfc->format, -1, 0, 0, width, height, TRUE))
+                                              pDstData, xfc->format, 0, 0, 0, width, height, TRUE))
                                return FALSE;
                }
        }
@@ -168,9 +168,9 @@ static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
        {
                SrcFormat = gdi_get_pixel_format(bpp, TRUE);
 
-               if (!freerdp_image_copy(pDstData, xfc->format, -1, 0, 0,
+               if (!freerdp_image_copy(pDstData, xfc->format, 0, 0, 0,
                                        width, height, pSrcData,
-                                       SrcFormat, -1, 0, 0, &context->gdi->palette))
+                                       SrcFormat, 0, 0, 0, &context->gdi->palette))
                        return FALSE;
        }
 
index 86f2272..6f41991 100644 (file)
@@ -756,10 +756,10 @@ FREERDP_API BOOL freerdp_image_copy_from_pointer_data(
     UINT32 xorBpp, const gdiPalette* palette);
 
 FREERDP_API BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
-                                    INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+                                    UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
                                     UINT32 nWidth, UINT32 nHeight,
                                     const BYTE* pSrcData, DWORD SrcFormat,
-                                    INT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
+                                    UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
                                     const gdiPalette* palette);
 
 FREERDP_API BOOL freerdp_image_fill(BYTE* pDstData, DWORD DstFormat,
index cf3ffcb..93e4d04 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef FREERDP_GDI_H
 #define FREERDP_GDI_H
 
+#include <winpr/wlog.h>
+
 #include <freerdp/api.h>
 #include <freerdp/log.h>
 #include <freerdp/freerdp.h>
@@ -294,7 +296,6 @@ struct rdp_gdi
        UINT32 bitmap_stride;
        BYTE* bitmap_buffer;
        BYTE* primary_buffer;
-       UINT32 textColor;
        gdiPalette palette;
        gdiBitmap* image;
        void (*free)(void*);
@@ -304,6 +305,8 @@ struct rdp_gdi
        UINT16 outputSurfaceId;
        REGION16 invalidRegion;
        RdpgfxClientContext* gfx;
+
+       wLog* log;
 };
 
 #ifdef __cplusplus
@@ -330,11 +333,4 @@ FREERDP_API void gdi_free(freerdp* instance);
 }
 #endif
 
-#define GDI_TAG FREERDP_TAG("gdi")
-#ifdef WITH_DEBUG_GDI
-#define DEBUG_GDI(fmt, ...) WLog_DBG(GDI_TAG, fmt, ## __VA_ARGS__)
-#else
-#define DEBUG_GDI(fmt, ...)
-#endif
-
 #endif /* FREERDP_GDI_H */
index 7a04a11..143d982 100644 (file)
@@ -108,8 +108,12 @@ static BOOL update_gdi_cache_bitmap(rdpContext* context,
        if (!bitmap)
                return FALSE;
 
-       Bitmap_SetDimensions(bitmap, cacheBitmap->bitmapWidth,
-                            cacheBitmap->bitmapHeight);
+       if (!Bitmap_SetDimensions(bitmap, cacheBitmap->bitmapWidth,
+                                 cacheBitmap->bitmapHeight))
+       {
+               bitmap->Free(context, bitmap);
+               return FALSE;
+       }
 
        if (!bitmap->Decompress(context, bitmap,
                                cacheBitmap->bitmapDataStream, cacheBitmap->bitmapWidth,
@@ -122,7 +126,10 @@ static BOOL update_gdi_cache_bitmap(rdpContext* context,
        }
 
        if (!bitmap->New(context, bitmap))
+       {
+               bitmap->Free(context, bitmap);
                return FALSE;
+       }
 
        prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmap->cacheId,
                                      cacheBitmap->cacheIndex);
index 62cf5ee..88bd1d6 100644 (file)
@@ -84,9 +84,9 @@ static BOOL update_gdi_switch_surface(rdpContext* context,
        }
        else
        {
-               rdpBitmap* bitmap;
-               bitmap = offscreen_cache_get(cache->offscreen, switchSurface->bitmapId);
-               bitmap->SetSurface(context, bitmap, FALSE);
+               rdpBitmap* bmp;
+               bmp = offscreen_cache_get(cache->offscreen, switchSurface->bitmapId);
+               bitmap->SetSurface(context, bmp, FALSE);
        }
 
        cache->offscreen->currentSurface = switchSurface->bitmapId;
index 584f9c3..9ab9e11 100644 (file)
@@ -410,10 +410,10 @@ static BOOL overlapping(const BYTE* pDstData, UINT32 nXDst, UINT32 nYDst,
 }
 
 BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
-                        INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+                        UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
                         UINT32 nWidth, UINT32 nHeight,
                         const BYTE* pSrcData, DWORD SrcFormat,
-                        INT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
+                        UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
                         const gdiPalette* palette)
 {
        const UINT32 dstByte = GetBytesPerPixel(DstFormat);
index 7ede9e7..b61b605 100644 (file)
@@ -639,9 +639,9 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush,
 }
 
 static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles,
-        int number)
+        UINT32 number)
 {
-       int i;
+       UINT32 i;
        BYTE flags = 0;
        BYTE* zeroBits;
        UINT32 zeroBitsSize;
@@ -656,12 +656,12 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles,
 
        Stream_GetPointer(s, zeroBits);
        Stream_Seek(s, zeroBitsSize);
-       ZeroMemory(rectangles, sizeof(DELTA_RECT) * (number + 1));
+       ZeroMemory(rectangles, sizeof(DELTA_RECT) * number);
 
-       for (i = 1; i < number + 1; i++)
+       for (i = 0; i < number; i++)
        {
-               if ((i - 1) % 2 == 0)
-                       flags = zeroBits[(i - 1) / 2];
+               if (i % 2 == 0)
+                       flags = zeroBits[i / 2];
 
                if ((~flags & 0x80) && !update_read_delta(s, &rectangles[i].left))
                        return FALSE;
@@ -674,23 +674,27 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles,
                        if (!update_read_delta(s, &rectangles[i].width))
                                return FALSE;
                }
-               else
-               {
+               else if (i > 0)
                        rectangles[i].width = rectangles[i - 1].width;
-               }
+               else
+                       rectangles[i].width = 0;
 
                if (~flags & 0x10)
                {
                        if (!update_read_delta(s, &rectangles[i].height))
                                return FALSE;
                }
+               else if (i > 0)
+                       rectangles[i].height = rectangles[i - 1].height;
                else
+                       rectangles[i].height = 0;
+
+               if (i > 0)
                {
-                       rectangles[i].height = rectangles[i - 1].height;
+                       rectangles[i].left += rectangles[i - 1].left;
+                       rectangles[i].top += rectangles[i - 1].top;
                }
 
-               rectangles[i].left = rectangles[i].left + rectangles[i - 1].left;
-               rectangles[i].top = rectangles[i].top + rectangles[i - 1].top;
                flags <<= 4;
        }
 
@@ -2078,8 +2082,6 @@ static BOOL update_read_cache_glyph_order(wStream* s,
         UINT16 flags)
 {
        UINT32 i;
-       INT16 lsi16;
-       GLYPH_DATA* glyph;
 
        if (Stream_GetRemainingLength(s) < 2)
                return FALSE;
@@ -2089,16 +2091,14 @@ static BOOL update_read_cache_glyph_order(wStream* s,
 
        for (i = 0; i < cache_glyph_order->cGlyphs; i++)
        {
-               glyph = &cache_glyph_order->glyphData[i];
+               GLYPH_DATA* glyph = &cache_glyph_order->glyphData[i];
 
                if (Stream_GetRemainingLength(s) < 10)
                        return FALSE;
 
                Stream_Read_UINT16(s, glyph->cacheIndex);
-               Stream_Read_UINT16(s, lsi16);
-               glyph->x = lsi16;
-               Stream_Read_UINT16(s, lsi16);
-               glyph->y = lsi16;
+               Stream_Read_INT16(s, glyph->x);
+               Stream_Read_INT16(s, glyph->y);
                Stream_Read_UINT16(s, glyph->cx);
                Stream_Read_UINT16(s, glyph->cy);
                glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
@@ -2169,15 +2169,14 @@ static BOOL update_read_cache_glyph_v2_order(wStream* s,
         CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
         UINT16 flags)
 {
-       int i;
-       GLYPH_DATA_V2* glyph;
+       UINT32 i;
        cache_glyph_v2->cacheId = (flags & 0x000F);
        cache_glyph_v2->flags = (flags & 0x00F0) >> 4;
        cache_glyph_v2->cGlyphs = (flags & 0xFF00) >> 8;
 
-       for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++)
+       for (i = 0; i < cache_glyph_v2->cGlyphs; i++)
        {
-               glyph = &cache_glyph_v2->glyphData[i];
+               GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i];
 
                if (Stream_GetRemainingLength(s) < 1)
                        return FALSE;
@@ -2207,9 +2206,7 @@ static BOOL update_read_cache_glyph_v2_order(wStream* s,
        }
 
        if (flags & CG_GLYPH_UNICODE_PRESENT)
-       {
                return Stream_SafeSeek(s, cache_glyph_v2->cGlyphs * 2);
-       }
 
        return TRUE;
 }
@@ -2222,7 +2219,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s,
                                        const CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
                                        UINT16* flags)
 {
-       int i, inf;
+       UINT32 i, inf;
        inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, flags);
 
        if (!Stream_EnsureRemainingCapacity(s, inf))
@@ -2232,7 +2229,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s,
                 ((cache_glyph_v2->flags & 0x000F) << 4) |
                 ((cache_glyph_v2->cGlyphs & 0x00FF) << 8);
 
-       for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++)
+       for (i = 0; i < cache_glyph_v2->cGlyphs; i++)
        {
                UINT32 cb;
                const GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i];
index 59c3643..ffd00fd 100644 (file)
@@ -180,6 +180,9 @@ static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
        hSrcBmp = (HGDI_BITMAP) hdcSrc->selectedObject;
        hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
 
+       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,
@@ -401,7 +404,7 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
-       /* D = (S & P) | (~S & D) */
+       /* D = (D ^ S) & (P ^ D) */
        color = hdcDest->textColor;
 
        for (y = 0; y < nHeight; y++)
@@ -420,7 +423,7 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
                                colorA = ConvertColor(colorA, hdcSrc->format,
                                                      hdcDest->format, palette);
-                               dstColor = (colorA & color) | (~colorA & colorB);
+                               dstColor = (colorB ^ colorA) & (color & colorB);
                                WriteColor(dstp, hdcDest->format, dstColor);
                        }
                }
index 580292e..b7a59c6 100644 (file)
@@ -438,7 +438,8 @@ gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
        if (!(bitmap->hdc = gdi_CreateCompatibleDC(gdi->hdc)))
                goto fail_hdc;
 
-       DEBUG_GDI("gdi_bitmap_new: width:%d height:%d bpp:%d", width, height, bpp);
+       WLog_Print(gdi->log, WLOG_DEBUG, "gdi_bitmap_new: width:%d height:%d bpp:%d",
+                  width, height, bpp);
 
        if (!data)
                bitmap->bitmap = gdi_CreateCompatibleBitmap(gdi->hdc, width, height);
@@ -803,9 +804,6 @@ static BOOL gdi_opaque_rect(rdpContext* context,
        BOOL ret;
        gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
                       opaque_rect->nWidth, opaque_rect->nHeight, &rect);
-       WLog_INFO(TAG, "%s x=%lu, y=%lu, w=%lu, h=%lu",
-                 __FUNCTION__, opaque_rect->nLeftRect, opaque_rect->nTopRect,
-                 opaque_rect->nWidth, opaque_rect->nHeight);
 
        if (!gdi_decode_color(gdi, opaque_rect->color, &brush_color, NULL))
                return FALSE;
@@ -827,9 +825,6 @@ static BOOL gdi_multi_opaque_rect(rdpContext* context,
        UINT32 brush_color;
        rdpGdi* gdi = context->gdi;
        BOOL ret = TRUE;
-       WLog_INFO(TAG, "%s x=%lu, y=%lu, w=%lu, h=%lu",
-                 __FUNCTION__, multi_opaque_rect->nLeftRect, multi_opaque_rect->nTopRect,
-                 multi_opaque_rect->nWidth, multi_opaque_rect->nHeight);
 
        if (!gdi_decode_color(gdi, multi_opaque_rect->color, &brush_color, NULL))
                return FALSE;
@@ -839,12 +834,15 @@ static BOOL gdi_multi_opaque_rect(rdpContext* context,
        if (!hBrush)
                return FALSE;
 
-       for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++)
+       for (i = 0; i < multi_opaque_rect->numRectangles; i++)
        {
                const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
                gdi_CRgnToRect(rectangle->left, rectangle->top,
                               rectangle->width, rectangle->height, &rect);
-               gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
+               ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
+
+               if (!ret)
+                       break;
        }
 
        gdi_DeleteObject((HGDIOBJECT) hBrush);
@@ -857,9 +855,6 @@ static BOOL gdi_line_to(rdpContext* context, const LINE_TO_ORDER* lineTo)
        HGDI_PEN hPen;
        UINT32 SrcFormat;
        rdpGdi* gdi = context->gdi;
-       WLog_INFO(TAG, "%s x=%lu, y=%lu, w=%lu, h=%lu",
-                 __FUNCTION__, lineTo->nXStart, lineTo->nYStart,
-                 lineTo->nXEnd, lineTo->nYEnd);
 
        if (!gdi_decode_color(gdi, lineTo->backColor, &color, &SrcFormat))
                return FALSE;
@@ -900,12 +895,10 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
        gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
        points = polyline->points;
 
-       for (i = 0; i < (int) polyline->numDeltaEntries; i++)
+       for (i = 0; i < polyline->numDeltaEntries; i++)
        {
                x += points[i].x;
                y += points[i].y;
-               WLog_INFO(TAG, "%s x=%lu, y=%lu",
-                         __FUNCTION__, x, y);
                gdi_LineTo(gdi->drawing->hdc, x, y);
                gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
        }
@@ -1051,28 +1044,28 @@ out_fail:
 static BOOL gdi_polygon_sc(rdpContext* context,
                            const POLYGON_SC_ORDER* polygon_sc)
 {
-       WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
-       return TRUE;
+       WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
+       return FALSE;
 }
 
 static BOOL gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
 {
-       WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
-       return TRUE;
+       WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
+       return FALSE;
 }
 
 static BOOL gdi_ellipse_sc(rdpContext* context,
                            const ELLIPSE_SC_ORDER* ellipse_sc)
 {
-       WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
-       return TRUE;
+       WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
+       return FALSE;
 }
 
 static BOOL gdi_ellipse_cb(rdpContext* context,
                            const ELLIPSE_CB_ORDER* ellipse_cb)
 {
-       WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
-       return TRUE;
+       WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
+       return FALSE;
 }
 
 static BOOL gdi_frame_marker(rdpContext* context,
@@ -1084,9 +1077,9 @@ static BOOL gdi_frame_marker(rdpContext* context,
 BOOL gdi_surface_frame_marker(rdpContext* context,
                               const SURFACE_FRAME_MARKER* surfaceFrameMarker)
 {
-       DEBUG_GDI("frameId %d frameAction %d",
-                 surfaceFrameMarker->frameId,
-                 surfaceFrameMarker->frameAction);
+       WLog_Print(context->gdi->log, WLOG_DEBUG, "frameId %d frameAction %d",
+                  surfaceFrameMarker->frameId,
+                  surfaceFrameMarker->frameAction);
 
        switch (surfaceFrameMarker->frameAction)
        {
@@ -1110,10 +1103,11 @@ static BOOL gdi_surface_bits(rdpContext* context,
                              const SURFACE_BITS_COMMAND* cmd)
 {
        rdpGdi* gdi = context->gdi;
-       DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
-                 "bpp %d codecID %d width %d height %d length %d",
-                 cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
-                 cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
+       WLog_Print(gdi->log, WLOG_DEBUG,
+                  "destLeft %d destTop %d destRight %d destBottom %d "
+                  "bpp %d codecID %d width %d height %d length %d",
+                  cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
+                  cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
 
        switch (cmd->codecID)
        {
@@ -1315,16 +1309,21 @@ BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
        if (!gdi)
                goto fail;
 
+       gdi->log = WLog_Get(TAG);
+
+       if (!gdi->log)
+               goto fail;
+
        instance->context->gdi = gdi;
        gdi->context = instance->context;
        gdi->width = instance->settings->DesktopWidth;
        gdi->height = instance->settings->DesktopHeight;
        gdi->dstFormat = format;
        /* default internal buffer format */
-       WLog_INFO(TAG, "Local framebuffer format  %s",
-                 GetColorFormatName(gdi->dstFormat));
-       WLog_INFO(TAG, "Remote framebuffer format %s",
-                 GetColorFormatName(SrcFormat));
+       WLog_Print(gdi->log, WLOG_INFO, "Local framebuffer format  %s",
+                  GetColorFormatName(gdi->dstFormat));
+       WLog_Print(gdi->log, WLOG_INFO, "Remote framebuffer format %s",
+                  GetColorFormatName(SrcFormat));
 
        if (!(gdi->hdc = gdi_GetDC()))
                goto fail;
index 35b4fbe..8593959 100644 (file)
@@ -491,7 +491,7 @@ static UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context,
        if (!surface)
                return ERROR_INTERNAL_ERROR;
 
-       WLog_DBG(TAG, "TODO gdi_SurfaceCommand_Alpha: status: %d", status);
+       WLog_WARN(TAG, "TODO gdi_SurfaceCommand_Alpha: status: %d", status);
 
        /* fill with green for now to distinguish from the rest */
        if (!freerdp_image_fill(surface->data, surface->format, surface->scanline,
index 7edec36..281ce17 100644 (file)
@@ -31,6 +31,7 @@
 #include <freerdp/gdi/region.h>
 #include <freerdp/gdi/bitmap.h>
 
+#include "clipping.h"
 #include "drawing.h"
 #include "brush.h"
 #include "graphics.h"
@@ -46,6 +47,10 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
        BYTE* pSrcData;
        BYTE* pDstData;
        HGDI_BITMAP bitmap;
+
+       if (!gdi)
+               return NULL;
+
        nDstStep = nWidth * GetBytesPerPixel(gdi->dstFormat);
        pDstData = _aligned_malloc(nHeight * nDstStep, 16);
 
@@ -265,46 +270,41 @@ static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
                                 UINT32 width, UINT32 height, UINT32 bgcolor,
                                 UINT32 fgcolor, BOOL fOpRedundant)
 {
-       GDI_RECT rect;
-       HGDI_BRUSH brush;
-       rdpGdi* gdi = context->gdi;
-       BOOL ret = FALSE;
+       rdpGdi* gdi;
 
-       if (!gdi_decode_color(gdi, bgcolor, &bgcolor, NULL))
+       if (!context || !context->gdi)
                return FALSE;
 
-       if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL))
-               return FALSE;
+       gdi = context->gdi;
 
-       if (!(brush = gdi_CreateSolidBrush(fgcolor)))
+       if (!gdi->drawing || !gdi->drawing->hdc)
                return FALSE;
 
-       gdi_CRgnToRect(x, y, width, height, &rect);
-
-       switch (fOpRedundant)
-       {
-               case 0:
-                       ret = gdi_FillRect(gdi->drawing->hdc, &rect, brush);
-                       break;
+       if (!gdi_decode_color(gdi, bgcolor, &bgcolor, NULL))
+               return FALSE;
 
-               default:
-                       ret = TRUE;
-                       break;
-       }
+       if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL))
+               return FALSE;
 
-       gdi_DeleteObject((HGDIOBJECT) brush);
-       gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
-       return ret;
+       gdi_SetTextColor(gdi->drawing->hdc, fgcolor);
+       gdi_SetBkColor(gdi->drawing->hdc, bgcolor);
+       return gdi_SetClipRgn(gdi->drawing->hdc, x, y, width, height);
 }
 
 static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
                               UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
 {
-       rdpGdi* gdi = context->gdi;
-       UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
-       bgcolor = ConvertColor(bgcolor, SrcFormat,
-                              gdi->drawing->hdc->format, &gdi->palette);
-       gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
+       rdpGdi* gdi;
+
+       if (!context || !context->gdi)
+               return FALSE;
+
+       gdi = context->gdi;
+
+       if (!gdi->drawing || !gdi->drawing->hdc)
+               return FALSE;
+
+       gdi_SetNullClipRgn(gdi->drawing->hdc);
        return TRUE;
 }
 
index 99d9b89..de91e1d 100644 (file)
  */
 static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
 {
-       UINT32 pixel = ReadColor(pixelPtr, format);
+       UINT32 dstPixel;
+       const UINT32 srcPixel = ReadColor(pixelPtr, format);
 
        switch (rop)
        {
                case GDI_R2_BLACK: /* LineTo_BLACK */
-                       pixel = GetColor(format, 0, 0, 0, 0xFF);
+                       dstPixel = GetColor(format, 0, 0, 0, 0xFF);
                        break;
 
                case GDI_R2_NOTMERGEPEN: /* LineTo_NOTMERGEPEN */
-                       pixel = ~(pixel | pen);
+                       dstPixel = ~(srcPixel | pen);
                        break;
 
                case GDI_R2_MASKNOTPEN: /* LineTo_MASKNOTPEN */
-                       pixel &= ~pen;
+                       dstPixel = srcPixel & ~pen;
                        break;
 
                case GDI_R2_NOTCOPYPEN: /* LineTo_NOTCOPYPEN */
-                       pixel = ~pen;
+                       dstPixel = ~pen;
                        break;
 
                case GDI_R2_MASKPENNOT: /* LineTo_MASKPENNOT */
-                       pixel = pen & ~pixel;
+                       dstPixel = pen & ~srcPixel;
                        break;
 
                case GDI_R2_NOT: /* LineTo_NOT */
-                       pixel = ~pixel;
+                       dstPixel = ~srcPixel;
                        break;
 
                case GDI_R2_XORPEN: /* LineTo_XORPEN */
-                       pixel = pixel ^ pen;
+                       dstPixel = srcPixel ^ pen;
                        break;
 
                case GDI_R2_NOTMASKPEN: /* LineTo_NOTMASKPEN */
-                       pixel = ~(pixel & pen);
+                       dstPixel = ~(srcPixel & pen);
                        break;
 
                case GDI_R2_MASKPEN: /* LineTo_MASKPEN */
-                       pixel &= pen;
+                       dstPixel = srcPixel & pen;
                        break;
 
                case GDI_R2_NOTXORPEN: /* LineTo_NOTXORPEN */
-                       pixel = ~(pixel ^ pen);
+                       dstPixel = ~(srcPixel ^ pen);
                        break;
 
                case GDI_R2_NOP: /* LineTo_NOP */
                        break;
 
                case GDI_R2_MERGENOTPEN: /* LineTo_MERGENOTPEN */
-                       pixel |= ~pen;
+                       dstPixel = srcPixel | ~pen;
                        break;
 
                case GDI_R2_COPYPEN: /* LineTo_COPYPEN */
-                       pixel = pen;
+                       dstPixel = pen;
                        break;
 
                case GDI_R2_MERGEPENNOT: /* LineTo_MERGEPENNOT */
-                       pixel = pixel | ~pen;
+                       dstPixel = srcPixel | ~pen;
                        break;
 
                case GDI_R2_MERGEPEN: /* LineTo_MERGEPEN */
-                       pixel = pixel | pen;
+                       dstPixel = srcPixel | pen;
                        break;
 
                case GDI_R2_WHITE: /* LineTo_WHITE */
-                       pixel = GetColor(format, 0, 0, 0, 0);
+                       dstPixel = GetColor(format, 0, 0, 0, 0xFF);
                        break;
 
                default:
                        return FALSE;
        }
 
-       WriteColor(pixelPtr, format, pixel);
+       WriteColor(pixelPtr, format, dstPixel);
        return TRUE;
 }
 
 BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
 {
-       UINT32 x, y;
-       UINT32 x1, y1;
-       UINT32 x2, y2;
-       INT32 e, e2;
-       INT32 dx, dy;
-       INT32 sx, sy;
-       INT32 bx1, by1;
-       INT32 bx2, by2;
-       HGDI_BITMAP bmp;
+       INT64 e2;
+       INT64 bx1, by1;
+       INT64 bx2, by2;
+       HGDI_BITMAP bmp = (HGDI_BITMAP) hdc->selectedObject;
        UINT32 pen;
        UINT32 rop2 = gdi_GetROP2(hdc);
-       x1 = hdc->pen->posX;
-       y1 = hdc->pen->posY;
-       x2 = nXEnd;
-       y2 = nYEnd;
-       dx = (x1 > x2) ? x1 - x2 : x2 - x1;
-       dy = (y1 > y2) ? y1 - y2 : y2 - y1;
-       sx = (x1 < x2) ? 1 : -1;
-       sy = (y1 < y2) ? 1 : -1;
-       e = dx - dy;
-       x = x1;
-       y = y1;
-       bmp = (HGDI_BITMAP) hdc->selectedObject;
+       UINT32 x1 = hdc->pen->posX;
+       UINT32 y1 = hdc->pen->posY;
+       UINT32 x2 = nXEnd;
+       UINT32 y2 = nYEnd;
+       INT64 dx = (x1 > x2) ? x1 - x2 : x2 - x1;
+       INT64 dy = (y1 > y2) ? y1 - y2 : y2 - y1;
+       INT64 sx = (x1 < x2) ? 1 : -1;
+       INT64 sy = (y1 < y2) ? 1 : -1;
+       INT64 e = dx - dy;
+       UINT32 x = x1;
+       UINT32 y = y1;
 
        if (hdc->clip->null)
        {
index ac1565b..28dbcfa 100644 (file)
@@ -189,9 +189,13 @@ INLINE void gdi_CRgnToRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
 
        if (w > 0)
                rect->right = x + w - 1;
+       else
+               WLog_ERR("xxxxxx", "");
 
        if (h > 0)
                rect->bottom = y + h - 1;
+       else
+               WLog_ERR("xxxxxx", "");
 }
 
 /**