Fixed post disconnect hook.
authorArmin Novak <armin.novak@thincast.com>
Tue, 6 Sep 2016 12:20:07 +0000 (14:20 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:43:12 +0000 (13:43 +0200)
libfreerdp/codec/color.c
libfreerdp/codec/interleaved.c
libfreerdp/core/freerdp.c
libfreerdp/gdi/graphics.c

index 3620d11..26cbd79 100644 (file)
@@ -472,10 +472,10 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
                        break;
        }
 
-       if (nDstStep <= 0)
+       if (nDstStep == 0)
                nDstStep = nWidth * GetBytesPerPixel(DstFormat);
 
-       if (nSrcStep <= 0)
+       if (nSrcStep == 0)
                nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
 
        if (vSrcVFlip)
index e05a605..6a577fe 100644 (file)
@@ -109,7 +109,7 @@ static INLINE UINT32 ExtractCodeId(BYTE bOrderHdr)
  * Extract the run length of a compression order.
  */
 static INLINE UINT32 ExtractRunLength(UINT32 code, const BYTE* pbOrderHdr,
-                                      UINT32* advance)
+                                     UINT32* advance)
 {
        UINT32 runLength;
        UINT32 ladvance;
@@ -252,9 +252,9 @@ static INLINE UINT32 ExtractRunLength(UINT32 code, const BYTE* pbOrderHdr,
 #define DESTWRITEPIXEL(_buf, _pix) do { (_buf)[0] = (BYTE)(_pix);  \
                (_buf)[1] = (BYTE)((_pix) >> 8); (_buf)[2] = (BYTE)((_pix) >> 16); } while (0)
 #define DESTREADPIXEL(_pix, _buf) _pix = (_buf)[0] | ((_buf)[1] << 8) | \
-        ((_buf)[2] << 16)
+       ((_buf)[2] << 16)
 #define SRCREADPIXEL(_pix, _buf) _pix = (_buf)[0] | ((_buf)[1] << 8) | \
-                                        ((_buf)[2] << 16)
+                                       ((_buf)[2] << 16)
 #define DESTNEXTPIXEL(_buf) _buf += 3
 #define SRCNEXTPIXEL(_buf) _buf += 3
 #define WRITEFGBGIMAGE WriteFgBgImage24to24
@@ -264,28 +264,21 @@ static INLINE UINT32 ExtractRunLength(UINT32 code, const BYTE* pbOrderHdr,
 #include "include/bitmap.c"
 
 BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
-                            const BYTE* pSrcData, UINT32 SrcSize,
-                            UINT32 nSrcWidth, UINT32 nSrcHeight,
-                            UINT32 bpp,
-                            BYTE* pDstData, UINT32 DstFormat,
-                            UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
-                            UINT32 nDstWidth, UINT32 nDstHeight,
-                            const gdiPalette* palette)
+                           const BYTE* pSrcData, UINT32 SrcSize,
+                           UINT32 nSrcWidth, UINT32 nSrcHeight,
+                           UINT32 bpp,
+                           BYTE* pDstData, UINT32 DstFormat,
+                           UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+                           UINT32 nDstWidth, UINT32 nDstHeight,
+                           const gdiPalette* palette)
 {
        UINT32 scanline;
        UINT32 SrcFormat;
        UINT32 BufferSize;
-       UINT32 dstBitsPerPixel;
-       UINT32 dstBytesPerPixel;
-       dstBitsPerPixel = GetBitsPerPixel(DstFormat);
-       dstBytesPerPixel = GetBytesPerPixel(DstFormat);
 
        if (!interleaved)
                return FALSE;
 
-       if (nDstStep <= 0)
-               nDstStep = nDstWidth * dstBytesPerPixel;
-
        switch (bpp)
        {
                case 24:
@@ -318,8 +311,8 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
        if (BufferSize > interleaved->TempSize)
        {
                interleaved->TempBuffer = _aligned_realloc(
-                                             interleaved->TempBuffer,
-                                             BufferSize, 16);
+                                             interleaved->TempBuffer,
+                                             BufferSize, 16);
                interleaved->TempSize = BufferSize;
        }
 
@@ -330,18 +323,18 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
        {
                case 24:
                        RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer,
-                                           scanline, nSrcWidth, nSrcHeight);
+                                           scanline, nSrcWidth, nSrcHeight);
                        break;
 
                case 16:
                case 15:
                        RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer,
-                                           scanline, nSrcWidth, nSrcHeight);
+                                           scanline, nSrcWidth, nSrcHeight);
                        break;
 
                case 8:
                        RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer,
-                                         scanline, nSrcWidth, nSrcHeight);
+                                         scanline, nSrcWidth, nSrcHeight);
                        break;
 
                default:
@@ -349,16 +342,16 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
        }
 
        return freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
-                                 nDstWidth, nDstHeight, interleaved->TempBuffer,
-                                 SrcFormat, scanline, 0, 0, palette);
+                                 nDstWidth, nDstHeight, interleaved->TempBuffer,
+                                 SrcFormat, scanline, 0, 0, palette);
 }
 
 BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
-                          BYTE* pDstData, UINT32* pDstSize,
-                          UINT32 nWidth, UINT32 nHeight,
-                          const BYTE* pSrcData, UINT32 SrcFormat,
-                          UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
-                          const gdiPalette* palette, UINT32 bpp)
+                         BYTE* pDstData, UINT32* pDstSize,
+                         UINT32 nWidth, UINT32 nHeight,
+                         const BYTE* pSrcData, UINT32 SrcFormat,
+                         UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
+                         const gdiPalette* palette, UINT32 bpp)
 {
        int status;
        wStream* s;
@@ -374,8 +367,8 @@ BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
        if ((nWidth > 64) || (nHeight > 64))
        {
                WLog_ERR(TAG,
-                        "interleaved_compress: width (%d) or height (%d) is greater than 64", nWidth,
-                        nHeight);
+                        "interleaved_compress: width (%d) or height (%d) is greater than 64", nWidth,
+                        nHeight);
                return FALSE;
        }
 
@@ -392,16 +385,16 @@ BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
                return FALSE;
 
        status = freerdp_image_copy(interleaved->TempBuffer, DstFormat, 0, 0, 0, nWidth,
-                                   nHeight,
-                                   pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
+                                   nHeight,
+                                   pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
        s = Stream_New(pDstData, maxSize);
 
        if (!s)
                return FALSE;
 
        status = freerdp_bitmap_compress((char*) interleaved->TempBuffer, nWidth,
-                                        nHeight,
-                                        s, bpp, maxSize, nHeight - 1, interleaved->bts, 0);
+                                        nHeight,
+                                        s, bpp, maxSize, nHeight - 1, interleaved->bts, 0);
        Stream_SealLength(s);
        *pDstSize = (UINT32) Stream_Length(s);
        Stream_Free(s, FALSE);
@@ -420,7 +413,7 @@ BITMAP_INTERLEAVED_CONTEXT* bitmap_interleaved_context_new(BOOL Compressor)
 {
        BITMAP_INTERLEAVED_CONTEXT* interleaved;
        interleaved = (BITMAP_INTERLEAVED_CONTEXT*) calloc(1,
-                     sizeof(BITMAP_INTERLEAVED_CONTEXT));
+                     sizeof(BITMAP_INTERLEAVED_CONTEXT));
 
        if (interleaved)
        {
index 180e58a..c62c5df 100644 (file)
@@ -403,12 +403,13 @@ BOOL freerdp_disconnect(freerdp* instance)
        rdp = instance->context->rdp;
        rdp_client_disconnect(rdp);
        update_post_disconnect(instance->update);
-       IFCALL(instance->PostDisconnect, instance);
 
        if (freerdp_channels_disconnect(instance->context->channels,
                                        instance) != CHANNEL_RC_OK)
                rc = FALSE;
 
+       IFCALL(instance->PostDisconnect, instance);
+
        if (instance->update->pcap_rfx)
        {
                instance->update->dump_rfx = FALSE;
index c4333fd..63ce8fc 100644 (file)
@@ -40,7 +40,7 @@
 /* Bitmap Class */
 
 HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
-                              UINT32 SrcFormat, BYTE* data)
+                             UINT32 SrcFormat, BYTE* data)
 {
        UINT32 nSrcStep;
        UINT32 nDstStep;
@@ -61,8 +61,8 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
        nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
 
        if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
-                               nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
-                               &gdi->palette))
+                               nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
+                               &gdi->palette))
        {
                _aligned_free(pDstData);
                return NULL;
@@ -84,14 +84,14 @@ static BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
 
        if (!bitmap->data)
                gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(
-                                        gdi->hdc, bitmap->width,
-                                        bitmap->height);
+                                        gdi->hdc, bitmap->width,
+                                        bitmap->height);
        else
        {
                UINT32 format = bitmap->format;
                gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width,
-                                                      bitmap->height,
-                                                      format, bitmap->data);
+                                                      bitmap->height,
+                                                      format, bitmap->data);
        }
 
        if (!gdi_bitmap->bitmap)
@@ -124,53 +124,50 @@ static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
        UINT32 width = bitmap->right - bitmap->left + 1;
        UINT32 height = bitmap->bottom - bitmap->top + 1;
        return gdi_BitBlt(context->gdi->primary->hdc,
-                         bitmap->left, bitmap->top,
-                         width, height, gdi_bitmap->hdc,
-                         0, 0, GDI_SRCCOPY, &context->gdi->palette);
+                         bitmap->left, bitmap->top,
+                         width, height, gdi_bitmap->hdc,
+                         0, 0, GDI_SRCCOPY, &context->gdi->palette);
 }
 
 static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
-                                  const BYTE* pSrcData, UINT32 width, UINT32 height,
-                                  UINT32 bpp, UINT32 length, BOOL compressed,
-                                  UINT32 codecId)
+                                 const BYTE* pSrcData, UINT32 DstWidth, UINT32 DstHeight,
+                                 UINT32 bpp, UINT32 length, BOOL compressed,
+                                 UINT32 codecId)
 {
-       UINT16 size;
        UINT32 SrcSize = length;
        UINT32 SrcFormat;
        UINT32 bytesPerPixel;
-       UINT32 DstWidth = width;
-       UINT32 DstHeight = height;
        rdpGdi* gdi = context->gdi;
-       bytesPerPixel = (bpp + 7) / 8;
-       size = width * height * GetBytesPerPixel(gdi->dstFormat);
-       bitmap->data = (BYTE*) _aligned_malloc(size, 16);
-
-       if (!bitmap->data)
-               return FALSE;
 
        bitmap->compressed = FALSE;
-       bitmap->length = size;
        bitmap->format = gdi->dstFormat;
+       bitmap->length = DstWidth * DstHeight * GetBytesPerPixel(bitmap->format);
+
+       bytesPerPixel = GetBytesPerPixel(bpp);
+       bitmap->data = (BYTE*) _aligned_malloc(bitmap->length, 16);
+
+       if (!bitmap->data)
+               return FALSE;
 
        if (compressed)
        {
                if (bpp < 32)
                {
                        if (!interleaved_decompress(context->codecs->interleaved,
-                                                   pSrcData, SrcSize,
-                                                   width, height,
-                                                   bpp,
-                                                   bitmap->data, bitmap->format,
-                                                   0, 0, 0, DstWidth, DstHeight,
-                                                   &gdi->palette))
+                                                   pSrcData, SrcSize,
+                                                   DstWidth, DstHeight,
+                                                   bpp,
+                                                   bitmap->data, bitmap->format,
+                                                   0, 0, 0, DstWidth, DstHeight,
+                                                   &gdi->palette))
                                return FALSE;
                }
                else
                {
                        if (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,
-                                              width, height,
-                                              bitmap->data, bitmap->format, 0, 0, 0,
-                                              width, height, TRUE))
+                                              DstWidth, DstHeight,
+                                              bitmap->data, bitmap->format, 0, 0, 0,
+                                              DstWidth, DstHeight, TRUE))
                                return FALSE;
                }
        }
@@ -179,8 +176,8 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
                SrcFormat = gdi_get_pixel_format(bpp, TRUE);
 
                if (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0,
-                                       DstWidth, DstHeight, pSrcData, SrcFormat,
-                                       0, 0, 0, &gdi->palette))
+                                       DstWidth, DstHeight, pSrcData, SrcFormat,
+                                       0, 0, 0, &gdi->palette))
                        return FALSE;
        }
 
@@ -188,7 +185,7 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
 }
 
 static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
-                                  BOOL primary)
+                                 BOOL primary)
 {
        rdpGdi* gdi = context->gdi;
 
@@ -225,7 +222,7 @@ static BOOL gdi_Glyph_New(rdpContext* context, const rdpGlyph* glyph)
        }
 
        gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
-                                            data);
+                                            data);
 
        if (!gdi_glyph->bitmap)
        {
@@ -255,7 +252,7 @@ static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
 }
 
 static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x,
-                           UINT32 y, UINT32 w, UINT32 h, UINT32 sx, UINT32 sy, BOOL fOpRedundant)
+                          UINT32 y, UINT32 w, UINT32 h, UINT32 sx, UINT32 sy, BOOL fOpRedundant)
 {
        gdiGlyph* gdi_glyph;
        rdpGdi* gdi;
@@ -303,14 +300,14 @@ static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x,
 
        gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT)brush);
        rc = gdi_BitBlt(gdi->drawing->hdc, x, y, w, h, gdi_glyph->hdc, sx, sy,
-                       GDI_GLYPH_ORDER, &context->gdi->palette);
+                       GDI_GLYPH_ORDER, &context->gdi->palette);
        gdi_DeleteObject((HGDIOBJECT)brush);
        return rc;
 }
 
 static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
-                                UINT32 width, UINT32 height, UINT32 bgcolor,
-                                UINT32 fgcolor, BOOL fOpRedundant)
+                               UINT32 width, UINT32 height, UINT32 bgcolor,
+                               UINT32 fgcolor, BOOL fOpRedundant)
 {
        rdpGdi* gdi;
 
@@ -358,7 +355,7 @@ static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
 }
 
 static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
-                              UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
+                             UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
 {
        rdpGdi* gdi;