Merge pull request #3545 from akallabeth/legacy_rfx_fixes

Fixed Windows 7 RFX issues.
This commit is contained in:
Bernhard Miklautz 2016-10-13 13:01:53 +02:00 committed by GitHub
commit 5a5f091b7c
5 changed files with 418 additions and 405 deletions

View File

@ -970,96 +970,96 @@ static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty,
return ret; return ret;
} }
static BOOL xf_gdi_surface_bits(rdpContext* context, static BOOL xf_gdi_update_screen(xfContext* xfc,
const SURFACE_BITS_COMMAND* cmd) const SURFACE_BITS_COMMAND* cmd,
const BYTE* pSrcData)
{ {
BOOL ret;
XImage* image; XImage* image;
BYTE* pSrcData;
BYTE* pDstData;
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;
rdpGdi* gdi = context->gdi;
REGION16 invalidRegion;
xf_lock_x11(xfc, FALSE);
switch (cmd->codecID) if (!xfc || !pSrcData)
{
case RDP_CODEC_ID_REMOTEFX:
if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
PIXEL_FORMAT_XRGB32, 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; 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);
/* 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);
break;
case RDP_CODEC_ID_NSCODEC:
if (!nsc_process_message(context->codecs->nsc, cmd->bpp, cmd->width,
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;
}
XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetFillStyle(xfc->display, xfc->gc, FillSolid);
pDstData = gdi->primary_buffer;
image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
(char*) pDstData, cmd->width, cmd->height, xfc->scanline_pad, 0); (char*) pSrcData, cmd->width, cmd->height, xfc->scanline_pad, 0);
if (image)
{
XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
cmd->destLeft, cmd->destTop, cmd->width, cmd->height); cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
XFree(image); XFree(image);
ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width, ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width,
cmd->height); cmd->height);
}
XSetClipMask(xfc->display, xfc->gc, None); XSetClipMask(xfc->display, xfc->gc, None);
return ret;
}
static BOOL xf_gdi_surface_bits(rdpContext* context,
const SURFACE_BITS_COMMAND* cmd)
{
BYTE* pSrcData;
xfContext* xfc = (xfContext*) context;
BOOL ret = FALSE;
DWORD format;
DWORD stride;
rdpGdi* gdi;
if (!context || !cmd || !context->gdi)
return FALSE;
gdi = context->gdi;
stride = cmd->width * GetBytesPerPixel(gdi->dstFormat);
xf_lock_x11(xfc, FALSE);
switch (cmd->codecID)
{
case RDP_CODEC_ID_REMOTEFX:
format = PIXEL_FORMAT_BGRX32;
if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
format, cmd->bitmapDataLength,
0, 0,
gdi->primary_buffer, gdi->dstFormat, stride,
gdi->height, NULL))
goto fail;
break;
case RDP_CODEC_ID_NSCODEC:
format = FREERDP_VFLIP_PIXEL_FORMAT(gdi->dstFormat);
if (!nsc_process_message(context->codecs->nsc, cmd->bpp, cmd->width,
cmd->height, cmd->bitmapData, cmd->bitmapDataLength,
gdi->primary_buffer, format, stride,
0, 0, cmd->width, cmd->height))
goto fail;
break; break;
case RDP_CODEC_ID_NONE: case RDP_CODEC_ID_NONE:
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
pSrcData = cmd->bitmapData; pSrcData = cmd->bitmapData;
pDstData = gdi->primary_buffer; format = PIXEL_FORMAT_BGRX32_VF;
freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, stride,
0, 0,
cmd->width, cmd->height, pSrcData, cmd->width, cmd->height, pSrcData,
PIXEL_FORMAT_BGRX32_VF, 0, 0, 0, &xfc->context.gdi->palette); format, 0, 0, 0, &xfc->context.gdi->palette))
image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, goto fail;
(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);
break; break;
default: default:
WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID); WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID);
ret = TRUE;
goto fail;
} }
ret = xf_gdi_update_screen(xfc, cmd, gdi->primary_buffer);
fail:
xf_unlock_x11(xfc, FALSE); xf_unlock_x11(xfc, FALSE);
return ret; return ret;
} }

View File

@ -45,6 +45,12 @@
#define FREERDP_PIXEL_FORMAT_FLIP_MASKED(_format) (_format & 0x3FFFFFFF) #define FREERDP_PIXEL_FORMAT_FLIP_MASKED(_format) (_format & 0x3FFFFFFF)
#define FREERDP_VFLIP_PIXEL_FORMAT(format) \
FREERDP_PIXEL_FORMAT_FLIP_MASKED(format) | (FREERDP_PIXEL_FLIP_VERTICAL << 30)
#define FREERDP_HFLIP_PIXEL_FORMAT(format) \
FREERDP_PIXEL_FORMAT_FLIP_MASKED(format) | (FREERDP_PIXEL_FLIP_HORIZONTAL << 30)
/*** Design considerations /*** Design considerations
* *
* The format naming scheme is based on byte position in memory. * The format naming scheme is based on byte position in memory.

View File

@ -407,7 +407,7 @@ BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
if (!freerdp_image_copy(pDstData, DstFormat, nDstStride, nXDst, nYDst, if (!freerdp_image_copy(pDstData, DstFormat, nDstStride, nXDst, nYDst,
width, height, context->BitmapData, width, height, context->BitmapData,
PIXEL_FORMAT_BGRX32_VF, 0, 0, 0, NULL)) PIXEL_FORMAT_BGRA32, 0, 0, 0, NULL))
return FALSE; return FALSE;
return TRUE; return TRUE;

View File

@ -1178,14 +1178,17 @@ BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data,
for (j = 0; j < nbUpdateRects; j++) for (j = 0; j < nbUpdateRects; j++)
{ {
UINT32 stride = 64 * GetBytesPerPixel(format);
UINT32 nXDst = updateRects[j].left; UINT32 nXDst = updateRects[j].left;
UINT32 nYDst = updateRects[j].top; UINT32 nYDst = updateRects[j].top;
UINT32 nWidth = updateRects[j].right - updateRects[j].left; UINT32 nXSrc = nXDst - updateRect.left;
UINT32 nHeight = updateRects[j].bottom - updateRects[j].top; UINT32 nYSrc = nYDst - updateRect.top;
UINT32 nWidth = MIN(64, updateRects[j].right - updateRects[j].left);
UINT32 nHeight = MIN(64, updateRects[j].bottom - updateRects[j].top);
if (!freerdp_image_copy(dst, dstFormat, dstStride, if (!freerdp_image_copy(dst, dstFormat, dstStride,
nXDst, nYDst, nWidth, nHeight, nXDst, nYDst, nWidth, nHeight,
tile->data, format, 64 * GetBytesPerPixel(format), 0, 0, NULL)) tile->data, format, stride, nXSrc, nYSrc, NULL))
goto fail; goto fail;
if (invalidRegion) if (invalidRegion)

View File

@ -946,6 +946,7 @@ BOOL gdi_surface_frame_marker(rdpContext* context,
static BOOL gdi_surface_bits(rdpContext* context, static BOOL gdi_surface_bits(rdpContext* context,
const SURFACE_BITS_COMMAND* cmd) const SURFACE_BITS_COMMAND* cmd)
{ {
DWORD format;
rdpGdi* gdi; rdpGdi* gdi;
if (!context || !cmd) if (!context || !cmd)
@ -961,40 +962,42 @@ static BOOL gdi_surface_bits(rdpContext* context,
switch (cmd->codecID) switch (cmd->codecID)
{ {
case RDP_CODEC_ID_REMOTEFX: case RDP_CODEC_ID_REMOTEFX:
{ format = PIXEL_FORMAT_BGRX32;
if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData, if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
PIXEL_FORMAT_BGRX32, format,
cmd->bitmapDataLength, cmd->bitmapDataLength,
0, 0, cmd->destLeft, cmd->destTop,
gdi->primary_buffer, gdi->dstFormat, gdi->primary_buffer, gdi->dstFormat,
cmd->width * GetBytesPerPixel(gdi->dstFormat), gdi->stride, gdi->height, NULL))
cmd->height, NULL))
{ {
WLog_ERR(TAG, "Failed to process RemoteFX message"); WLog_ERR(TAG, "Failed to process RemoteFX message");
return FALSE; return FALSE;
} }
}
break; break;
case RDP_CODEC_ID_NSCODEC: case RDP_CODEC_ID_NSCODEC:
{ format = FREERDP_VFLIP_PIXEL_FORMAT(gdi->dstFormat);
if (!nsc_process_message(context->codecs->nsc, cmd->bpp, cmd->width, if (!nsc_process_message(context->codecs->nsc, cmd->bpp, cmd->width,
cmd->height, cmd->bitmapData, cmd->height, cmd->bitmapData,
cmd->bitmapDataLength, gdi->primary_buffer, cmd->bitmapDataLength, gdi->primary_buffer,
gdi->dstFormat, gdi->stride, cmd->destLeft, cmd->destTop, format, gdi->stride, cmd->destLeft, cmd->destTop,
cmd->width, cmd->height)) cmd->width, cmd->height))
return FALSE; return FALSE;
}
break; break;
case RDP_CODEC_ID_NONE: case RDP_CODEC_ID_NONE:
{ format = PIXEL_FORMAT_BGRX32_VF;
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride, if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
cmd->destLeft, cmd->destTop, cmd->width, cmd->height, cmd->destLeft, cmd->destTop, cmd->width, cmd->height,
cmd->bitmapData, PIXEL_FORMAT_XRGB32_VF, 0, 0, 0, cmd->bitmapData, format, 0, 0, 0,
&gdi->palette)) &gdi->palette))
return FALSE; return FALSE;
}
break; break;
default: default:
@ -1002,7 +1005,8 @@ static BOOL gdi_surface_bits(rdpContext* context,
break; 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"); WLog_ERR(TAG, "Failed to update invalid region");
return FALSE; return FALSE;