mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
xfreerdp: fix egfx SurfaceToSurface overlapping copies
This commit is contained in:
@@ -366,6 +366,9 @@ int rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream
|
||||
|
||||
Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */
|
||||
|
||||
if (pdu.bitmapDataLength > Stream_GetRemainingLength(s))
|
||||
return -1;
|
||||
|
||||
pdu.bitmapData = Stream_Pointer(s);
|
||||
Stream_Seek(s, pdu.bitmapDataLength);
|
||||
|
||||
@@ -383,8 +386,8 @@ int rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream
|
||||
cmd.top = pdu.destRect.top;
|
||||
cmd.right = pdu.destRect.right;
|
||||
cmd.bottom = pdu.destRect.bottom;
|
||||
cmd.width = cmd.right - cmd.left + 1;
|
||||
cmd.height = cmd.bottom - cmd.top + 1;
|
||||
cmd.width = cmd.right - cmd.left;
|
||||
cmd.height = cmd.bottom - cmd.top;
|
||||
cmd.length = pdu.bitmapDataLength;
|
||||
cmd.data = pdu.bitmapData;
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ int xf_OutputUpdate(xfContext* xfc)
|
||||
{
|
||||
extents = region16_extents(&(xfc->invalidRegion));
|
||||
|
||||
width = extents->right - extents->left;
|
||||
height = extents->bottom - extents->top;
|
||||
width = extents->right - extents->left + 1;
|
||||
height = extents->bottom - extents->top + 1;
|
||||
|
||||
if (width > xfc->width)
|
||||
width = xfc->width;
|
||||
@@ -159,17 +159,16 @@ int xf_SurfaceCommand_Uncompressed(xfContext* xfc, RdpgfxClientContext* context,
|
||||
if (!surface)
|
||||
return -1;
|
||||
|
||||
/* TODO: bitmap flipping in freerdp_image_copy */
|
||||
|
||||
freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, cmd->left, cmd->top,
|
||||
cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32_VF, cmd->width * 4, 0, 0);
|
||||
cmd->width, cmd->height, cmd->data, PIXEL_FORMAT_XRGB32, cmd->width * 4, 0, 0);
|
||||
|
||||
invalidRect.left = cmd->left;
|
||||
invalidRect.top = cmd->top;
|
||||
invalidRect.right = cmd->right;
|
||||
invalidRect.bottom = cmd->bottom;
|
||||
|
||||
printf("xf_SurfaceCommand_Uncompressed: x: %d y: %d w: %d h: %d\n", cmd->left, cmd->top, cmd->width, cmd->height);
|
||||
printf("xf_SurfaceCommand_Uncompressed: x: %d y: %d w: %d h: %d r: %d b: %d\n",
|
||||
cmd->left, cmd->top, cmd->width, cmd->height, cmd->right, cmd->bottom);
|
||||
|
||||
region16_union_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &invalidRect);
|
||||
|
||||
@@ -470,15 +469,14 @@ int xf_SurfaceToSurface(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE_
|
||||
{
|
||||
destPt = &surfaceToSurface->destPts[index];
|
||||
|
||||
/* TODO: copy overlap handling in freerdp_image_copy */
|
||||
|
||||
freerdp_image_copy(surfaceDst->data, PIXEL_FORMAT_XRGB32, surfaceDst->scanline, destPt->x, destPt->y,
|
||||
nWidth, nHeight, surfaceDst->data, PIXEL_FORMAT_XRGB32, surfaceSrc->scanline, 0, 0);
|
||||
freerdp_image_copy(surfaceDst->data, PIXEL_FORMAT_XRGB32, surfaceDst->scanline,
|
||||
destPt->x, destPt->y, nWidth, nHeight, surfaceSrc->data, PIXEL_FORMAT_XRGB32,
|
||||
surfaceSrc->scanline, rectSrc->left, rectSrc->top);
|
||||
|
||||
invalidRect.left = destPt->x;
|
||||
invalidRect.top = destPt->y;
|
||||
invalidRect.right = destPt->x + nWidth - 1;
|
||||
invalidRect.bottom = destPt->y + nHeight - 1;
|
||||
invalidRect.right = destPt->x + rectSrc->right;
|
||||
invalidRect.bottom = destPt->y + rectSrc->bottom;
|
||||
|
||||
region16_union_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &invalidRect);
|
||||
}
|
||||
|
||||
@@ -1175,8 +1175,9 @@ void freerdp_clrconv_free(HCLRCONV clrconv)
|
||||
int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDst, int nYDst,
|
||||
int nWidth, int nHeight, BYTE* pSrcData, DWORD dwSrcFormat, int nSrcStep, int nXSrc, int nYSrc)
|
||||
{
|
||||
int i, j;
|
||||
int y, x;
|
||||
BYTE a, r, g, b;
|
||||
int beg, end, inc;
|
||||
int srcBitsPerPixel;
|
||||
int srcBytesPerPixel;
|
||||
int dstBitsPerPixel;
|
||||
@@ -1215,9 +1216,9 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
|
||||
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * srcBytesPerPixel)];
|
||||
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * dstBytesPerPixel)];
|
||||
|
||||
for (i = 0; i < nHeight; i++)
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
for (j = 0; j < nWidth; j++)
|
||||
for (x = 0; x < nWidth; x++)
|
||||
{
|
||||
GetARGB32(a, r, g, b, *pSrcPixel);
|
||||
*pDstPixel = ARGB32(a, r, g, b);
|
||||
@@ -1238,22 +1239,24 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
|
||||
if (nDstStep < 0)
|
||||
nDstStep = dstBytesPerPixel * nWidth;
|
||||
|
||||
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * srcBytesPerPixel)];
|
||||
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * dstBytesPerPixel)];
|
||||
|
||||
for (i = 0; i < nHeight; i++)
|
||||
if (overlap && (nYSrc < nYDst))
|
||||
{
|
||||
for (j = 0; j < nWidth; j++)
|
||||
{
|
||||
GetRGB32(r, g, b, *pSrcPixel);
|
||||
*pDstPixel = RGB32(r, g, b);
|
||||
beg = nHeight - 1;
|
||||
inc = -1; /* downward copy */
|
||||
end = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
beg = 0;
|
||||
inc = 1; /* upward copy */
|
||||
end = nHeight;
|
||||
}
|
||||
|
||||
pSrcPixel++;
|
||||
pDstPixel++;
|
||||
}
|
||||
|
||||
pSrcPixel = (UINT32*) &((BYTE*) pSrcPixel)[(nSrcStep - (nWidth * srcBytesPerPixel))];
|
||||
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[(nDstStep - (nWidth * dstBytesPerPixel))];
|
||||
for (y = beg; y != end; y += inc)
|
||||
{
|
||||
pSrcPixel = (UINT32*) &pSrcData[((nYSrc + y) * nSrcStep) + (nXSrc * srcBytesPerPixel)];
|
||||
pDstPixel = (UINT32*) &pDstData[((nYDst + y) * nDstStep) + (nXDst * dstBytesPerPixel)];
|
||||
MoveMemory(pDstPixel, pSrcPixel, nWidth * 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1268,9 +1271,9 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
|
||||
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * srcBytesPerPixel)];
|
||||
pDstPixel = (BYTE*) &pDstData[(nYDst * nDstStep) + (nXDst * dstBytesPerPixel)];
|
||||
|
||||
for (i = 0; i < nHeight; i++)
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
for (j = 0; j < nWidth; j++)
|
||||
for (x = 0; x < nWidth; x++)
|
||||
{
|
||||
GetRGB32(r, g, b, *pSrcPixel);
|
||||
|
||||
@@ -1298,9 +1301,9 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
|
||||
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * srcBytesPerPixel)];
|
||||
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * dstBytesPerPixel)];
|
||||
|
||||
for (i = 0; i < nHeight; i++)
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
for (j = 0; j < nWidth; j++)
|
||||
for (x = 0; x < nWidth; x++)
|
||||
{
|
||||
GetRGB32(r, g, b, *pSrcPixel);
|
||||
RGB_888_565(r, g, b);
|
||||
@@ -1325,9 +1328,9 @@ int freerdp_image_copy(BYTE* pDstData, DWORD dwDstFormat, int nDstStep, int nXDs
|
||||
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * srcBytesPerPixel)];
|
||||
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * dstBytesPerPixel)];
|
||||
|
||||
for (i = 0; i < nHeight; i++)
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
for (j = 0; j < nWidth; j++)
|
||||
for (x = 0; x < nWidth; x++)
|
||||
{
|
||||
GetRGB32(r, g, b, *pSrcPixel);
|
||||
RGB_888_555(r, g, b);
|
||||
|
||||
Reference in New Issue
Block a user