Fixed Windows 7 RFX issues.
authorArmin Novak <armin.novak@thincast.com>
Tue, 11 Oct 2016 12:34:07 +0000 (14:34 +0200)
committerArmin Novak <armin.novak@thincast.com>
Tue, 11 Oct 2016 12:34:07 +0000 (14:34 +0200)
client/X11/xf_gdi.c
libfreerdp/gdi/gdi.c

index 6c8827b..d53f374 100644 (file)
@@ -970,48 +970,49 @@ static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty,
        return ret;
 }
 
+static BOOL xf_gdi_update_screen(xfContext* xfc,
+                                 const SURFACE_BITS_COMMAND* cmd,
+                                 const BYTE* pSrcData)
+{
+       BOOL ret;
+       XImage* image;
+
+       if (!xfc || !pSrcData)
+               return FALSE;
+
+       XSetFunction(xfc->display, xfc->gc, GXcopy);
+       XSetFillStyle(xfc->display, xfc->gc, FillSolid);
+       image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
+                            (char*) pSrcData, cmd->width, cmd->height, xfc->scanline_pad, 0);
+       XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
+                 cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
+       XFree(image);
+       ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width,
+                                         cmd->height);
+       XSetClipMask(xfc->display, xfc->gc, None);
+       return ret;
+}
+
 static BOOL xf_gdi_surface_bits(rdpContext* context,
                                 const SURFACE_BITS_COMMAND* cmd)
 {
-       XImage* image;
        BYTE* pSrcData;
-       BYTE* pDstData;
        xfContext* xfc = (xfContext*) context;
-       BOOL ret = TRUE;
+       BOOL ret = FALSE;
        rdpGdi* gdi = context->gdi;
-       REGION16 invalidRegion;
        xf_lock_x11(xfc, FALSE);
 
        switch (cmd->codecID)
        {
                case RDP_CODEC_ID_REMOTEFX:
                        if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
-                                                PIXEL_FORMAT_XRGB32, cmd->bitmapDataLength,
+                                                PIXEL_FORMAT_BGRX32, cmd->bitmapDataLength,
                                                 cmd->destLeft, cmd->destTop,
                                                 gdi->primary_buffer, gdi->dstFormat, gdi->stride,
-                                                gdi->height, &invalidRegion))
-                       {
-                               WLog_ERR(TAG, "Failed to process RemoteFX message");
-                               xf_unlock_x11(xfc, FALSE);
-                               return FALSE;
-                       }
-
-                       XRectangle rect;
-                       rect.x = cmd->destLeft;
-                       rect.y = cmd->destTop;
-                       rect.width = cmd->width;
-                       rect.height = cmd->height;
-                       XSetFunction(xfc->display, xfc->gc, GXcopy);
-                       XSetFillStyle(xfc->display, xfc->gc, FillSolid);
-                       XSetClipRectangles(xfc->display, xfc->gc, cmd->destLeft, cmd->destTop,
-                                          &rect, 1, YXBanded);
+                                                gdi->height, NULL))
+                               goto fail;
 
-                       /* Invalidate the updated region */
-                       if (!xf_gdi_surface_update_frame(xfc, rect.x, rect.y,
-                                                        rect.width, rect.height))
-                               ret = FALSE;
-
-                       XSetClipMask(xfc->display, xfc->gc, None);
+                       ret = xf_gdi_update_screen(xfc, cmd, gdi->primary_buffer);
                        break;
 
                case RDP_CODEC_ID_NSCODEC:
@@ -1019,47 +1020,29 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
                                                 cmd->height,
                                                 cmd->bitmapData, cmd->bitmapDataLength,
                                                 gdi->primary_buffer, gdi->dstFormat, 0, 0, 0, cmd->width, cmd->height))
-                       {
-                               xf_unlock_x11(xfc, FALSE);
-                               return FALSE;
-                       }
+                               goto fail;
 
-                       XSetFunction(xfc->display, xfc->gc, GXcopy);
-                       XSetFillStyle(xfc->display, xfc->gc, FillSolid);
-                       pDstData = gdi->primary_buffer;
-                       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,
-                                 cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
-                       XFree(image);
-                       ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width,
-                                                         cmd->height);
-                       XSetClipMask(xfc->display, xfc->gc, None);
+                       ret = xf_gdi_update_screen(xfc, cmd, gdi->primary_buffer);
                        break;
 
                case RDP_CODEC_ID_NONE:
-                       XSetFunction(xfc->display, xfc->gc, GXcopy);
-                       XSetFillStyle(xfc->display, xfc->gc, FillSolid);
                        pSrcData = cmd->bitmapData;
-                       pDstData = gdi->primary_buffer;
-                       freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
-                                          cmd->width, cmd->height, pSrcData,
-                                          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,
-                                 cmd->destLeft, cmd->destTop,
-                                 cmd->width, cmd->height);
-                       XFree(image);
-                       ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width,
-                                                         cmd->height);
-                       XSetClipMask(xfc->display, xfc->gc, None);
+
+                       if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, 0, 0, 0,
+                                               cmd->width, cmd->height, pSrcData,
+                                               PIXEL_FORMAT_BGRX32_VF, 0, 0, 0, &xfc->context.gdi->palette))
+                               goto fail;
+
+                       ret = xf_gdi_update_screen(xfc, cmd, gdi->primary_buffer);
                        break;
 
                default:
                        WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID);
+                       ret = TRUE;
+                       break;
        }
 
+fail:
        xf_unlock_x11(xfc, FALSE);
        return ret;
 }
index 719a160..88d1b57 100644 (file)
@@ -1024,10 +1024,9 @@ static BOOL gdi_surface_bits(rdpContext* context,
                                if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
                                                         PIXEL_FORMAT_BGRX32,
                                                         cmd->bitmapDataLength,
-                                                        0, 0,
+                                                        cmd->destLeft, cmd->destTop,
                                                         gdi->primary_buffer, gdi->dstFormat,
-                                                        cmd->width * GetBytesPerPixel(gdi->dstFormat),
-                                                        cmd->height, NULL))
+                                                        gdi->stride, gdi->height, NULL))
                                {
                                        WLog_ERR(TAG, "Failed to process RemoteFX message");
                                        return FALSE;
@@ -1061,7 +1060,8 @@ static BOOL gdi_surface_bits(rdpContext* context,
                        break;
        }
 
-       if (!gdi_InvalidateRegion(gdi->primary->hdc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height))
+       if (!gdi_InvalidateRegion(gdi->primary->hdc, cmd->destLeft, cmd->destTop,
+                                 cmd->width, cmd->height))
        {
                WLog_ERR(TAG, "Failed to update invalid region");
                return FALSE;