Merge pull request #3710 from akallabeth/local_16bpp_fixes

Local 16bpp fixes
This commit is contained in:
Martin Fleisz 2017-01-23 11:59:52 +01:00 committed by GitHub
commit 13d69cadde
4 changed files with 84 additions and 41 deletions

View File

@ -972,7 +972,7 @@ static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty,
static BOOL xf_gdi_update_screen(xfContext* xfc, static BOOL xf_gdi_update_screen(xfContext* xfc,
const SURFACE_BITS_COMMAND* cmd, const SURFACE_BITS_COMMAND* cmd,
const BYTE* pSrcData) const BYTE* pSrcData, UINT32 scanline)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
XImage* image; XImage* image;
@ -983,7 +983,8 @@ static BOOL xf_gdi_update_screen(xfContext* xfc,
XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetFillStyle(xfc->display, xfc->gc, FillSolid);
image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
(char*) pSrcData, cmd->width, cmd->height, xfc->scanline_pad, 0); (char*) pSrcData, cmd->width, cmd->height,
xfc->scanline_pad, scanline);
if (image) if (image)
{ {
@ -1005,14 +1006,12 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
xfContext* xfc = (xfContext*) context; xfContext* xfc = (xfContext*) context;
BOOL ret = FALSE; BOOL ret = FALSE;
DWORD format; DWORD format;
DWORD stride;
rdpGdi* gdi; rdpGdi* gdi;
if (!context || !cmd || !context->gdi) if (!context || !cmd || !context->gdi)
return FALSE; return FALSE;
gdi = context->gdi; gdi = context->gdi;
stride = cmd->width * GetBytesPerPixel(gdi->dstFormat);
xf_lock_x11(xfc, FALSE); xf_lock_x11(xfc, FALSE);
switch (cmd->codecID) switch (cmd->codecID)
@ -1020,18 +1019,16 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
case RDP_CODEC_ID_REMOTEFX: case RDP_CODEC_ID_REMOTEFX:
if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData, if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
cmd->bitmapDataLength, 0, 0, cmd->bitmapDataLength, 0, 0,
gdi->primary_buffer, gdi->dstFormat, stride, gdi->primary_buffer, gdi->dstFormat, gdi->stride,
gdi->height, NULL)) gdi->height, NULL))
goto fail; goto fail;
break; break;
case RDP_CODEC_ID_NSCODEC: case RDP_CODEC_ID_NSCODEC:
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->bitmapDataLength, cmd->height, cmd->bitmapData, cmd->bitmapDataLength,
gdi->primary_buffer, format, stride, gdi->primary_buffer, gdi->dstFormat, gdi->stride,
0, 0, cmd->width, cmd->height, FREERDP_FLIP_VERTICAL)) 0, 0, cmd->width, cmd->height, FREERDP_FLIP_VERTICAL))
goto fail; goto fail;
@ -1041,10 +1038,10 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
pSrcData = cmd->bitmapData; pSrcData = cmd->bitmapData;
format = gdi_get_pixel_format(cmd->bpp); format = gdi_get_pixel_format(cmd->bpp);
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, stride, if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
0, 0, 0, 0, cmd->width, cmd->height,
cmd->width, cmd->height, pSrcData, pSrcData, format, 0, 0, 0,
format, 0, 0, 0, &xfc->context.gdi->palette, FREERDP_FLIP_VERTICAL)) &xfc->context.gdi->palette, FREERDP_FLIP_VERTICAL))
goto fail; goto fail;
break; break;
@ -1055,7 +1052,7 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
goto fail; goto fail;
} }
ret = xf_gdi_update_screen(xfc, cmd, gdi->primary_buffer); ret = xf_gdi_update_screen(xfc, cmd, gdi->primary_buffer, gdi->stride);
fail: fail:
xf_unlock_x11(xfc, FALSE); xf_unlock_x11(xfc, FALSE);
return ret; return ret;

View File

@ -275,7 +275,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
surface->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, surface->image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
ZPixmap, 0, (char*) surface->stage, ZPixmap, 0, (char*) surface->stage,
surface->gdi.width, surface->gdi.height, surface->gdi.width, surface->gdi.height,
xfc->scanline_pad, surface->gdi.scanline); xfc->scanline_pad, surface->stageScanline);
} }
surface->gdi.outputMapped = FALSE; surface->gdi.outputMapped = FALSE;

View File

@ -71,7 +71,6 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
BYTE* data; BYTE* data;
Pixmap pixmap; Pixmap pixmap;
XImage* image; XImage* image;
UINT32 SrcFormat;
rdpGdi* gdi; rdpGdi* gdi;
xfContext* xfc = (xfContext*) context; xfContext* xfc = (xfContext*) context;
gdi = context->gdi; gdi = context->gdi;
@ -93,10 +92,9 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
return FALSE; return FALSE;
} }
SrcFormat = bitmap->format;
freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0, freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
bitmap->width, bitmap->height, bitmap->width, bitmap->height,
bitmap->data, SrcFormat, bitmap->data, bitmap->format,
0, 0, 0, &context->gdi->palette, FREERDP_FLIP_NONE); 0, 0, 0, &context->gdi->palette, FREERDP_FLIP_NONE);
_aligned_free(bitmap->data); _aligned_free(bitmap->data);
bitmap->data = data; bitmap->data = data;
@ -490,7 +488,7 @@ BOOL xf_register_graphics(rdpGraphics* graphics)
UINT32 xf_get_local_color_format(xfContext* xfc, BOOL aligned) UINT32 xf_get_local_color_format(xfContext* xfc, BOOL aligned)
{ {
UINT32 DstFormat; UINT32 DstFormat;
BOOL invert = !(aligned ^ xfc->invert); BOOL invert = xfc->invert;
if (!xfc) if (!xfc)
return 0; return 0;
@ -505,9 +503,9 @@ UINT32 xf_get_local_color_format(xfContext* xfc, BOOL aligned)
DstFormat = (!invert) ? PIXEL_FORMAT_RGB24 : PIXEL_FORMAT_BGR24; DstFormat = (!invert) ? PIXEL_FORMAT_RGB24 : PIXEL_FORMAT_BGR24;
} }
else if (xfc->depth == 16) else if (xfc->depth == 16)
DstFormat = (!invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16; DstFormat = PIXEL_FORMAT_RGB16;
else if (xfc->depth == 15) else if (xfc->depth == 15)
DstFormat = (!invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16; DstFormat = PIXEL_FORMAT_RGB15;
else else
DstFormat = (!invert) ? PIXEL_FORMAT_RGBX32 : PIXEL_FORMAT_BGRX32; DstFormat = (!invert) ? PIXEL_FORMAT_RGBX32 : PIXEL_FORMAT_BGRX32;

View File

@ -223,12 +223,71 @@ static INLINE INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 Src
return (INT32)(srcp - pSrcData); return (INT32)(srcp - pSrcData);
} }
static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, const BYTE** ppR,
const BYTE** ppG, const BYTE** ppB, const BYTE** ppA)
{
UINT32 x;
if (!ppRgba || !ppR || !ppG || !ppB)
return FALSE;
switch (DstFormat)
{
case PIXEL_FORMAT_BGRA32:
for (x = 0; x < width; x++)
{
*(*ppRgba)++ = *(*ppB)++;
*(*ppRgba)++ = *(*ppG)++;
*(*ppRgba)++ = *(*ppR)++;
*(*ppRgba)++ = *(*ppA)++;
}
return TRUE;
case PIXEL_FORMAT_BGRX32:
for (x = 0; x < width; x++)
{
*(*ppRgba)++ = *(*ppB)++;
*(*ppRgba)++ = *(*ppG)++;
*(*ppRgba)++ = *(*ppR)++;
*(*ppRgba)++ = 0xFF;
}
return TRUE;
default:
if (ppA)
{
for (x = 0; x < width; x++)
{
BYTE alpha = *(*ppA)++;
UINT32 color = GetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha);
WriteColor(*ppRgba, DstFormat, color);
*ppRgba += GetBytesPerPixel(DstFormat);
}
}
else
{
const BYTE alpha = 0xFF;
for (x = 0; x < width; x++)
{
UINT32 color = GetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha);
WriteColor(*ppRgba, DstFormat, color);
*ppRgba += GetBytesPerPixel(DstFormat);
}
}
return TRUE;
}
}
static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
BYTE* pDstData, UINT32 DstFormat, BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
BOOL alpha, BOOL vFlip) BOOL alpha, BOOL vFlip)
{ {
INT32 x, y; INT32 y;
INT32 beg, end, inc; INT32 beg, end, inc;
const BYTE* pR = pSrcData[0]; const BYTE* pR = pSrcData[0];
const BYTE* pG = pSrcData[1]; const BYTE* pG = pSrcData[1];
@ -255,12 +314,8 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel( BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))]; DstFormat))];
for (x = 0; x < nWidth; x++) if (!writeLine(&pRGB, DstFormat, nWidth, &pR, &pG, &pB, &pA))
{ return FALSE;
UINT32 color = GetColor(DstFormat, *pR++, *pG++, *pB++, *pA++);
WriteColor(pRGB, DstFormat, color);
pRGB += GetBytesPerPixel(DstFormat);
}
} }
} }
else else
@ -270,12 +325,8 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel( BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))]; DstFormat))];
for (x = 0; x < nWidth; x++) if (!writeLine(&pRGB, DstFormat, nWidth, &pR, &pG, &pB, &pA))
{ return FALSE;
UINT32 color = GetColor(DstFormat, *pR++, *pG++, *pB++, 0xFF);
WriteColor(pRGB, DstFormat, color);
pRGB += GetBytesPerPixel(DstFormat);
}
} }
} }
@ -304,15 +355,11 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
UINT32 rawWidths[4]; UINT32 rawWidths[4];
UINT32 rawHeights[4]; UINT32 rawHeights[4];
BYTE FormatHeader; BYTE FormatHeader;
UINT32 dstBitsPerPixel;
UINT32 dstBytesPerPixel;
const BYTE* planes[4];
UINT32 UncompressedSize; UINT32 UncompressedSize;
const BYTE* planes[4];
const UINT32 w = MIN(nSrcWidth, nDstWidth); const UINT32 w = MIN(nSrcWidth, nDstWidth);
const UINT32 h = MIN(nSrcHeight, nDstHeight); const UINT32 h = MIN(nSrcHeight, nDstHeight);
const primitives_t* prims = primitives_get(); const primitives_t* prims = primitives_get();
dstBitsPerPixel = GetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat);
if (nDstStep <= 0) if (nDstStep <= 0)
nDstStep = nDstWidth * GetBytesPerPixel(DstFormat); nDstStep = nDstWidth * GetBytesPerPixel(DstFormat);
@ -470,13 +517,14 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
|| (nSrcHeight != nDstHeight)) || (nSrcHeight != nDstHeight))
{ {
pTempData = planar->pTempData; pTempData = planar->pTempData;
nTempStep = planar->nTempStep;
} }
if (!rle) /* RAW */ if (!rle) /* RAW */
{ {
if (alpha) if (alpha)
{ {
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nDstStep, if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip)) nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE; return FALSE;
@ -484,7 +532,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
} }
else /* NoAlpha */ else /* NoAlpha */
{ {
if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nDstStep, if (!planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip)) nXDst, nYDst, nSrcWidth, nSrcHeight, alpha, vFlip))
return FALSE; return FALSE;
@ -573,7 +621,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
{ {
BYTE* pTempData = planar->pTempData; BYTE* pTempData = planar->pTempData;
UINT32 nTempStep = planar->nTempStep; UINT32 nTempStep = planar->nTempStep;
UINT32 TempFormat = PIXEL_FORMAT_RGBA32; UINT32 TempFormat = PIXEL_FORMAT_BGRA32;
if (!pTempData) if (!pTempData)
return FALSE; return FALSE;