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,
const SURFACE_BITS_COMMAND* cmd,
const BYTE* pSrcData)
const BYTE* pSrcData, UINT32 scanline)
{
BOOL ret = FALSE;
XImage* image;
@ -983,7 +983,8 @@ static BOOL xf_gdi_update_screen(xfContext* xfc,
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);
(char*) pSrcData, cmd->width, cmd->height,
xfc->scanline_pad, scanline);
if (image)
{
@ -1005,14 +1006,12 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
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)
@ -1020,18 +1019,16 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
case RDP_CODEC_ID_REMOTEFX:
if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
cmd->bitmapDataLength, 0, 0,
gdi->primary_buffer, gdi->dstFormat, stride,
gdi->primary_buffer, gdi->dstFormat, gdi->stride,
gdi->height, NULL))
goto fail;
break;
case RDP_CODEC_ID_NSCODEC:
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,
gdi->primary_buffer, gdi->dstFormat, gdi->stride,
0, 0, cmd->width, cmd->height, FREERDP_FLIP_VERTICAL))
goto fail;
@ -1041,10 +1038,10 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
pSrcData = cmd->bitmapData;
format = gdi_get_pixel_format(cmd->bpp);
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, stride,
0, 0,
cmd->width, cmd->height, pSrcData,
format, 0, 0, 0, &xfc->context.gdi->palette, FREERDP_FLIP_VERTICAL))
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
0, 0, cmd->width, cmd->height,
pSrcData, format, 0, 0, 0,
&xfc->context.gdi->palette, FREERDP_FLIP_VERTICAL))
goto fail;
break;
@ -1055,7 +1052,7 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
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:
xf_unlock_x11(xfc, FALSE);
return ret;

View File

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

View File

@ -71,7 +71,6 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
BYTE* data;
Pixmap pixmap;
XImage* image;
UINT32 SrcFormat;
rdpGdi* gdi;
xfContext* xfc = (xfContext*) context;
gdi = context->gdi;
@ -93,10 +92,9 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
return FALSE;
}
SrcFormat = bitmap->format;
freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
bitmap->width, bitmap->height,
bitmap->data, SrcFormat,
bitmap->data, bitmap->format,
0, 0, 0, &context->gdi->palette, FREERDP_FLIP_NONE);
_aligned_free(bitmap->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 DstFormat;
BOOL invert = !(aligned ^ xfc->invert);
BOOL invert = xfc->invert;
if (!xfc)
return 0;
@ -505,9 +503,9 @@ UINT32 xf_get_local_color_format(xfContext* xfc, BOOL aligned)
DstFormat = (!invert) ? PIXEL_FORMAT_RGB24 : PIXEL_FORMAT_BGR24;
}
else if (xfc->depth == 16)
DstFormat = (!invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16;
DstFormat = PIXEL_FORMAT_RGB16;
else if (xfc->depth == 15)
DstFormat = (!invert) ? PIXEL_FORMAT_RGB16 : PIXEL_FORMAT_BGR16;
DstFormat = PIXEL_FORMAT_RGB15;
else
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);
}
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],
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
BOOL alpha, BOOL vFlip)
{
INT32 x, y;
INT32 y;
INT32 beg, end, inc;
const BYTE* pR = pSrcData[0];
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(
DstFormat))];
for (x = 0; x < nWidth; x++)
{
UINT32 color = GetColor(DstFormat, *pR++, *pG++, *pB++, *pA++);
WriteColor(pRGB, DstFormat, color);
pRGB += GetBytesPerPixel(DstFormat);
}
if (!writeLine(&pRGB, DstFormat, nWidth, &pR, &pG, &pB, &pA))
return FALSE;
}
}
else
@ -270,12 +325,8 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))];
for (x = 0; x < nWidth; x++)
{
UINT32 color = GetColor(DstFormat, *pR++, *pG++, *pB++, 0xFF);
WriteColor(pRGB, DstFormat, color);
pRGB += GetBytesPerPixel(DstFormat);
}
if (!writeLine(&pRGB, DstFormat, nWidth, &pR, &pG, &pB, &pA))
return FALSE;
}
}
@ -304,15 +355,11 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
UINT32 rawWidths[4];
UINT32 rawHeights[4];
BYTE FormatHeader;
UINT32 dstBitsPerPixel;
UINT32 dstBytesPerPixel;
const BYTE* planes[4];
UINT32 UncompressedSize;
const BYTE* planes[4];
const UINT32 w = MIN(nSrcWidth, nDstWidth);
const UINT32 h = MIN(nSrcHeight, nDstHeight);
const primitives_t* prims = primitives_get();
dstBitsPerPixel = GetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat);
if (nDstStep <= 0)
nDstStep = nDstWidth * GetBytesPerPixel(DstFormat);
@ -470,13 +517,14 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
|| (nSrcHeight != nDstHeight))
{
pTempData = planar->pTempData;
nTempStep = planar->nTempStep;
}
if (!rle) /* RAW */
{
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))
return FALSE;
@ -484,7 +532,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
}
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))
return FALSE;
@ -573,7 +621,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
{
BYTE* pTempData = planar->pTempData;
UINT32 nTempStep = planar->nTempStep;
UINT32 TempFormat = PIXEL_FORMAT_RGBA32;
UINT32 TempFormat = PIXEL_FORMAT_BGRA32;
if (!pTempData)
return FALSE;