Code refactoring.

This commit is contained in:
Armin Novak 2016-07-14 12:42:24 +02:00
parent e6e8f2d4f2
commit 5e9c9f90ab
4 changed files with 349 additions and 348 deletions

View File

@ -415,13 +415,13 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
if (srcp && dstp) if (srcp && dstp)
{ {
UINT32 color; UINT32 dstColor;
UINT32 colorA = ReadColor(srcp, hdcSrc->format); UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format); UINT32 colorB = ReadColor(dstp, hdcDest->format);
colorA = ConvertColor(colorA, hdcSrc->format, colorA = ConvertColor(colorA, hdcSrc->format,
hdcDest->format, palette); hdcDest->format, palette);
color = (colorA & color) | (~colorA & colorB); dstColor = (colorA & color) | (~colorA & colorB);
WriteColor(dstp, hdcDest->format, color); WriteColor(dstp, hdcDest->format, dstColor);
} }
} }
} }
@ -799,9 +799,7 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
hdcSrc, nXSrc, nYSrc, palette); hdcSrc, nXSrc, nYSrc, palette);
default: default:
break; WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop);
return FALSE;
} }
WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop);
return FALSE;
} }

View File

@ -563,7 +563,7 @@ static BOOL BitBlt_WHITENESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight) UINT32 nWidth, UINT32 nHeight)
{ {
UINT32 x, y; UINT32 x, y;
UINT32 color = GetColor(hdcDest->format, 0, 0, 0, 0); UINT32 color = GetColor(hdcDest->format, 0xFF, 0xFF, 0xFF, 0xFF);
for (y = 0; y < nHeight; y++) for (y = 0; y < nHeight; y++)
{ {

View File

@ -308,7 +308,7 @@ static const DWORD rop3_code_table[] =
}; };
/* Hatch Patterns as monochrome data */ /* Hatch Patterns as monochrome data */
static BYTE GDI_BS_HATCHED_PATTERNS[] = static const BYTE GDI_BS_HATCHED_PATTERNS[] =
{ {
0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* HS_HORIZONTAL */ 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* HS_HORIZONTAL */
0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_VERTICAL */ 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_VERTICAL */
@ -319,7 +319,6 @@ static BYTE GDI_BS_HATCHED_PATTERNS[] =
}; };
/* GDI Helper Functions */ /* GDI Helper Functions */
INLINE DWORD gdi_rop3_code(BYTE code) INLINE DWORD gdi_rop3_code(BYTE code)
{ {
return rop3_code_table[code]; return rop3_code_table[code];
@ -368,8 +367,8 @@ BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y)
else else
{ {
WLog_ERR(TAG, WLog_ERR(TAG,
"gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d", "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
x, y, hBmp->width, hBmp->height); x, y, hBmp->width, hBmp->height);
return 0; return 0;
} }
} }
@ -403,7 +402,7 @@ BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) % y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
hBmpBrush->height; hBmpBrush->height;
p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * GetBytesPerPixel( p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * GetBytesPerPixel(
hBmpBrush->format)); hBmpBrush->format));
return p; return p;
} }
} }
@ -414,7 +413,7 @@ BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
} }
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
BYTE* data) BYTE* data)
{ {
gdiBitmap* bitmap; gdiBitmap* bitmap;
bitmap = (gdiBitmap*) calloc(1, sizeof(gdiBitmap)); bitmap = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
@ -458,7 +457,7 @@ void gdi_bitmap_free_ex(gdiBitmap* bitmap)
} }
static BOOL gdi_bitmap_update(rdpContext* context, static BOOL gdi_bitmap_update(rdpContext* context,
const BITMAP_UPDATE* bitmapUpdate) const BITMAP_UPDATE* bitmapUpdate)
{ {
int status; int status;
UINT32 index; UINT32 index;
@ -484,29 +483,31 @@ static BOOL gdi_bitmap_update(rdpContext* context,
if (bitsPerPixel < 32) if (bitsPerPixel < 32)
{ {
if (!freerdp_client_codecs_prepare(codecs, if (!freerdp_client_codecs_prepare(codecs,
FREERDP_CODEC_INTERLEAVED, FREERDP_CODEC_INTERLEAVED,
gdi->width, gdi->height)) gdi->width, gdi->height))
return FALSE; return FALSE;
status = interleaved_decompress(codecs->interleaved, status = interleaved_decompress(codecs->interleaved,
pSrcData, SrcSize, pSrcData, SrcSize,
bitsPerPixel, bitsPerPixel,
gdi->primary_buffer, gdi->primary_buffer,
gdi->dstFormat, gdi->dstFormat,
gdi->stride, nXDst, nYDst, gdi->stride, nXDst, nYDst,
nWidth, nHeight, nWidth, nHeight,
&gdi->palette); &gdi->palette);
} }
else else
{ {
if (!freerdp_client_codecs_prepare(codecs, if (!freerdp_client_codecs_prepare(codecs,
FREERDP_CODEC_PLANAR, FREERDP_CODEC_PLANAR,
gdi->width, gdi->height)) gdi->width, gdi->height))
return FALSE; return FALSE;
status = planar_decompress(codecs->planar, pSrcData, status = planar_decompress(codecs->planar, pSrcData,
SrcSize, gdi->primary_buffer, SrcSize, gdi->primary_buffer,
gdi->dstFormat, gdi->dstFormat,
gdi->stride, gdi->stride,
nXDst, nYDst, nWidth, nHeight, TRUE); nXDst, nYDst, nWidth, nHeight, TRUE);
} }
if (status < 0) if (status < 0)
@ -520,19 +521,19 @@ static BOOL gdi_bitmap_update(rdpContext* context,
UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE); UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
UINT32 nSrcStep = nWidth * GetBytesPerPixel(SrcFormat); UINT32 nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
nWidth = MIN(bitmap->destRight, nWidth = MIN(bitmap->destRight,
gdi->width - 1) - bitmap->destLeft + 1; /* clip width */ gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
nHeight = MIN(bitmap->destBottom, nHeight = MIN(bitmap->destBottom,
gdi->height - 1) - bitmap->destTop + 1; /* clip height */ gdi->height - 1) - bitmap->destTop + 1; /* clip height */
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride, if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
nXDst, nYDst, nWidth, nHeight, nXDst, nYDst, nWidth, nHeight,
pSrcData, SrcFormat, nSrcStep, pSrcData, SrcFormat, nSrcStep,
nXSrc, nYSrc, &gdi->palette)) nXSrc, nYSrc, &gdi->palette))
return FALSE; return FALSE;
} }
if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst,
nWidth, nHeight)) nWidth, nHeight))
return FALSE; return FALSE;
} }
@ -540,16 +541,15 @@ static BOOL gdi_bitmap_update(rdpContext* context,
} }
static BOOL gdi_palette_update(rdpContext* context, static BOOL gdi_palette_update(rdpContext* context,
const PALETTE_UPDATE* palette) const PALETTE_UPDATE* palette)
{ {
int index; UINT32 index;
const PALETTE_ENTRY* pe;
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
gdi->palette.format = gdi->dstFormat; gdi->palette.format = gdi->dstFormat;
for (index = 0; index < (int) palette->number; index++) for (index = 0; index < palette->number; index++)
{ {
pe = &(palette->entries[index]); const PALETTE_ENTRY* pe = &(palette->entries[index]);
gdi->palette.palette[index] = gdi->palette.palette[index] =
GetColor(gdi->dstFormat, pe->red, pe->green, pe->blue, 0xFF); GetColor(gdi->dstFormat, pe->red, pe->green, pe->blue, 0xFF);
} }
@ -564,12 +564,10 @@ static BOOL gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
if (bounds) if (bounds)
{ {
gdi_SetClipRgn(gdi->drawing->hdc, bounds->left, bounds->top, gdi_SetClipRgn(gdi->drawing->hdc, bounds->left, bounds->top,
bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1); bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1);
} }
else else
{
gdi_SetNullClipRgn(gdi->drawing->hdc); gdi_SetNullClipRgn(gdi->drawing->hdc);
}
return TRUE; return TRUE;
} }
@ -578,13 +576,12 @@ static BOOL gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
{ {
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
return gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect, return gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
gdi_rop3_code(dstblt->bRop), &gdi->palette); gdi_rop3_code(dstblt->bRop), &gdi->palette);
} }
static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{ {
BYTE* data;
const rdpBrush* brush = &patblt->brush; const rdpBrush* brush = &patblt->brush;
UINT32 foreColor; UINT32 foreColor;
UINT32 backColor; UINT32 backColor;
@ -597,152 +594,157 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
UINT32 nXSrc = 0; UINT32 nXSrc = 0;
UINT32 nYSrc = 0; UINT32 nYSrc = 0;
foreColor = ConvertColor(patblt->foreColor, SrcFormat, foreColor = ConvertColor(patblt->foreColor, SrcFormat,
gdi->dstFormat, &gdi->palette); gdi->dstFormat, &gdi->palette);
backColor = ConvertColor(patblt->backColor, SrcFormat, backColor = ConvertColor(patblt->backColor, SrcFormat,
gdi->dstFormat, &gdi->palette); gdi->dstFormat, &gdi->palette);
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor); originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
if (brush->style == GDI_BS_SOLID) switch (brush->style)
{ {
originalBrush = gdi->drawing->hdc->brush; case GDI_BS_SOLID:
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor); originalBrush = gdi->drawing->hdc->brush;
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
if (!gdi->drawing->hdc->brush) if (!gdi->drawing->hdc->brush)
{
ret = FALSE;
goto out_error;
}
if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
patblt->nWidth, patblt->nHeight, rop,
gdi->primary->hdc, nXSrc, nYSrc))
{
ret = FALSE;
}
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
}
else if (brush->style == GDI_BS_HATCHED)
{
BYTE* hatched;
HGDI_BITMAP hBmp;
data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
if (!data)
{
ret = FALSE;
goto out_error;
}
hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
hatched, backColor, foreColor, &gdi->palette);
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
if (!hBmp)
{
_aligned_free(data);
ret = FALSE;
goto out_error;
}
originalBrush = gdi->drawing->hdc->brush;
gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
if (!gdi->drawing->hdc->brush)
{
_aligned_free(data);
ret = FALSE;
goto out_error;
}
gdi->drawing->hdc->brush->nXOrg = brush->x;
gdi->drawing->hdc->brush->nYOrg = brush->y;
if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
patblt->nWidth, patblt->nHeight, rop,
gdi->primary->hdc, nXSrc, nYSrc))
{
ret = FALSE;
}
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
}
else if (brush->style == GDI_BS_PATTERN)
{
HGDI_BITMAP hBmp;
UINT32 brushFormat;
if (brush->bpp > 1)
{
brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
if (!data)
{ {
ret = FALSE; ret = FALSE;
goto out_error; goto out_error;
} }
if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0, if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
8, 8, brush->data, brushFormat, 0, 0, 0, patblt->nWidth, patblt->nHeight, rop,
&gdi->palette)) gdi->primary->hdc, nXSrc, nYSrc))
{ {
ret = FALSE; ret = FALSE;
goto out_error;
} }
}
else
{
data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
if (!data) gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
break;
case GDI_BS_HATCHED:
{ {
ret = FALSE; const BYTE* hatched;
goto out_error; HGDI_BITMAP hBmp;
BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
16);
if (!data)
{
ret = FALSE;
goto out_error;
}
hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
hatched, backColor, foreColor, &gdi->palette);
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
if (!hBmp)
{
_aligned_free(data);
ret = FALSE;
goto out_error;
}
originalBrush = gdi->drawing->hdc->brush;
gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
if (!gdi->drawing->hdc->brush)
{
ret = FALSE;
goto out_error;
}
gdi->drawing->hdc->brush->nXOrg = brush->x;
gdi->drawing->hdc->brush->nYOrg = brush->y;
if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
patblt->nWidth, patblt->nHeight, rop,
gdi->primary->hdc, nXSrc, nYSrc))
{
ret = FALSE;
}
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
} }
break;
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8, case GDI_BS_PATTERN:
brush->data, backColor, foreColor, &gdi->palette); {
} HGDI_BITMAP hBmp;
UINT32 brushFormat;
BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
16);
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data); if (!data)
{
ret = FALSE;
goto out_error;
}
if (!hBmp) if (brush->bpp > 1)
{ {
_aligned_free(data); brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
ret = FALSE;
goto out_error;
}
originalBrush = gdi->drawing->hdc->brush; if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp); 8, 8, brush->data, brushFormat, 0, 0, 0,
&gdi->palette))
{
_aligned_free(data);
ret = FALSE;
goto out_error;
}
}
else
{
if (!freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
brush->data, backColor, foreColor, &gdi->palette))
{
_aligned_free(data);
ret = FALSE;
goto out_error;
}
}
if (!gdi->drawing->hdc->brush) hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
{
_aligned_free(data);
ret = FALSE;
goto out_error;
}
gdi->drawing->hdc->brush->nXOrg = brush->x; if (!hBmp)
gdi->drawing->hdc->brush->nYOrg = brush->y; {
_aligned_free(data);
ret = FALSE;
goto out_error;
}
if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect, originalBrush = gdi->drawing->hdc->brush;
patblt->nWidth, patblt->nHeight, rop, gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
gdi->primary->hdc, nXSrc, nYSrc))
{
ret = FALSE;
}
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush); if (!gdi->drawing->hdc->brush)
gdi->drawing->hdc->brush = originalBrush; {
} _aligned_free(data);
else ret = FALSE;
{ goto out_error;
WLog_ERR(TAG, "unimplemented brush style:%d", brush->style); }
gdi->drawing->hdc->brush->nXOrg = brush->x;
gdi->drawing->hdc->brush->nYOrg = brush->y;
if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
patblt->nWidth, patblt->nHeight, rop,
gdi->primary->hdc, nXSrc, nYSrc))
{
ret = FALSE;
}
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
}
break;
default:
WLog_ERR(TAG, "unimplemented brush style:%d", brush->style);
break;
} }
out_error: out_error:
@ -754,13 +756,13 @@ static BOOL gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
{ {
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
return gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect, return gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc, scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop), scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
&gdi->palette); &gdi->palette);
} }
static BOOL gdi_opaque_rect(rdpContext* context, static BOOL gdi_opaque_rect(rdpContext* context,
const OPAQUE_RECT_ORDER* opaque_rect) const OPAQUE_RECT_ORDER* opaque_rect)
{ {
GDI_RECT rect; GDI_RECT rect;
HGDI_BRUSH hBrush; HGDI_BRUSH hBrush;
@ -769,9 +771,9 @@ static BOOL gdi_opaque_rect(rdpContext* context,
BOOL ret; BOOL ret;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE); UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight, &rect); opaque_rect->nWidth, opaque_rect->nHeight, &rect);
brush_color = ConvertColor(opaque_rect->color, SrcFormat, brush_color = ConvertColor(opaque_rect->color, SrcFormat,
gdi->dstFormat, &gdi->palette); gdi->dstFormat, &gdi->palette);
if (!(hBrush = gdi_CreateSolidBrush(brush_color))) if (!(hBrush = gdi_CreateSolidBrush(brush_color)))
return FALSE; return FALSE;
@ -782,7 +784,7 @@ static BOOL gdi_opaque_rect(rdpContext* context,
} }
static BOOL gdi_multi_opaque_rect(rdpContext* context, static BOOL gdi_multi_opaque_rect(rdpContext* context,
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{ {
UINT32 i; UINT32 i;
GDI_RECT rect; GDI_RECT rect;
@ -797,9 +799,9 @@ static BOOL gdi_multi_opaque_rect(rdpContext* context,
{ {
rectangle = &multi_opaque_rect->rectangles[i]; rectangle = &multi_opaque_rect->rectangles[i];
gdi_CRgnToRect(rectangle->left, rectangle->top, gdi_CRgnToRect(rectangle->left, rectangle->top,
rectangle->width, rectangle->height, &rect); rectangle->width, rectangle->height, &rect);
brush_color = ConvertColor(multi_opaque_rect->color, SrcFormat, brush_color = ConvertColor(multi_opaque_rect->color, SrcFormat,
gdi->dstFormat, &gdi->palette); gdi->dstFormat, &gdi->palette);
hBrush = gdi_CreateSolidBrush(brush_color); hBrush = gdi_CreateSolidBrush(brush_color);
if (!hBrush) if (!hBrush)
@ -824,7 +826,7 @@ static BOOL gdi_line_to(rdpContext* context, const LINE_TO_ORDER* lineTo)
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE); UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color, if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color,
SrcFormat, &gdi->palette))) SrcFormat, &gdi->palette)))
return FALSE; return FALSE;
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen); gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
@ -871,120 +873,119 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{ {
gdiBitmap* bitmap; gdiBitmap* bitmap = (gdiBitmap*) memblt->bitmap;
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
bitmap = (gdiBitmap*) memblt->bitmap;
return gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect, return gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
memblt->nWidth, memblt->nHeight, bitmap->hdc, memblt->nWidth, memblt->nHeight, bitmap->hdc,
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop), memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
&gdi->palette); &gdi->palette);
} }
static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{ {
BYTE* data;
const rdpBrush* brush;
UINT32 foreColor;
UINT32 backColor;
gdiBitmap* bitmap;
UINT32 originalColor;
HGDI_BRUSH originalBrush; HGDI_BRUSH originalBrush;
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
BOOL ret = TRUE; BOOL ret = TRUE;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE); const UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth,
brush = &mem3blt->brush; FALSE);
bitmap = (gdiBitmap*) mem3blt->bitmap; const rdpBrush* brush = &mem3blt->brush;
foreColor = ConvertColor(mem3blt->foreColor, SrcFormat, gdiBitmap* bitmap = (gdiBitmap*) mem3blt->bitmap;
gdi->dstFormat, &gdi->palette); const UINT32 foreColor = ConvertColor(mem3blt->foreColor, SrcFormat,
backColor = ConvertColor(mem3blt->backColor, SrcFormat, gdi->dstFormat, &gdi->palette);
gdi->dstFormat, &gdi->palette); const UINT32 backColor = ConvertColor(mem3blt->backColor, SrcFormat,
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor); gdi->dstFormat, &gdi->palette);
const UINT32 originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
if (brush->style == GDI_BS_SOLID) switch (brush->style)
{ {
originalBrush = gdi->drawing->hdc->brush; case GDI_BS_SOLID:
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor); originalBrush = gdi->drawing->hdc->brush;
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
if (!gdi->drawing->hdc->brush) if (!gdi->drawing->hdc->brush)
{
ret = FALSE;
goto out_fail;
}
gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
&gdi->palette);
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
}
else if (brush->style == GDI_BS_PATTERN)
{
HGDI_BITMAP hBmp;
UINT32 brushFormat;
if (brush->bpp > 1)
{
brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
if (!data)
{ {
ret = FALSE; ret = FALSE;
goto out_fail; goto out_fail;
} }
if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0, ret = gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
8, 8, brush->data, brushFormat, 0, 0, 0, &gdi->palette)) mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
&gdi->palette);
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
break;
case GDI_BS_PATTERN:
{ {
ret = FALSE; HGDI_BITMAP hBmp;
goto out_fail; UINT32 brushFormat;
BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
16);
if (!data)
{
ret = FALSE;
goto out_fail;
}
if (brush->bpp > 1)
{
brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
8, 8, brush->data, brushFormat,
0, 0, 0, &gdi->palette))
{
ret = FALSE;
_aligned_free(data);
goto out_fail;
}
}
else
{
if (!freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
brush->data, backColor, foreColor,
&gdi->palette))
{
ret = FALSE;
_aligned_free(data);
goto out_fail;
}
}
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
if (!hBmp)
{
ret = FALSE;
_aligned_free(data);
goto out_fail;
}
originalBrush = gdi->drawing->hdc->brush;
gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
if (!gdi->drawing->hdc->brush)
{
gdi_DeleteObject((HGDIOBJECT) hBmp);
goto out_fail;
}
gdi->drawing->hdc->brush->nXOrg = brush->x;
gdi->drawing->hdc->brush->nYOrg = brush->y;
ret = gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
&gdi->palette);
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
} }
} break;
else
{
data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
if (!data) default:
{ WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%d", brush->style);
ret = FALSE; break;
goto out_fail;
}
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
brush->data, backColor, foreColor, &gdi->palette);
}
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
if (!hBmp)
{
_aligned_free(data);
ret = FALSE;
goto out_fail;
}
originalBrush = gdi->drawing->hdc->brush;
gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
if (!gdi->drawing->hdc->brush)
{
gdi_DeleteObject((HGDIOBJECT) hBmp);
goto out_fail;
}
gdi->drawing->hdc->brush->nXOrg = brush->x;
gdi->drawing->hdc->brush->nYOrg = brush->y;
gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
&gdi->palette);
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
gdi->drawing->hdc->brush = originalBrush;
}
else
{
WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%d", brush->style);
} }
out_fail: out_fail:
@ -993,7 +994,7 @@ out_fail:
} }
static BOOL gdi_polygon_sc(rdpContext* context, static BOOL gdi_polygon_sc(rdpContext* context,
const POLYGON_SC_ORDER* polygon_sc) const POLYGON_SC_ORDER* polygon_sc)
{ {
WLog_VRB(TAG, "%s: not implemented", __FUNCTION__); WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
return TRUE; return TRUE;
@ -1006,31 +1007,31 @@ static BOOL gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
} }
static BOOL gdi_ellipse_sc(rdpContext* context, static BOOL gdi_ellipse_sc(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipse_sc) const ELLIPSE_SC_ORDER* ellipse_sc)
{ {
WLog_VRB(TAG, "%s: not implemented", __FUNCTION__); WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
return TRUE; return TRUE;
} }
static BOOL gdi_ellipse_cb(rdpContext* context, static BOOL gdi_ellipse_cb(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipse_cb) const ELLIPSE_CB_ORDER* ellipse_cb)
{ {
WLog_VRB(TAG, "%s: not implemented", __FUNCTION__); WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
return TRUE; return TRUE;
} }
static BOOL gdi_frame_marker(rdpContext* context, static BOOL gdi_frame_marker(rdpContext* context,
const FRAME_MARKER_ORDER* frameMarker) const FRAME_MARKER_ORDER* frameMarker)
{ {
return TRUE; return TRUE;
} }
BOOL gdi_surface_frame_marker(rdpContext* context, BOOL gdi_surface_frame_marker(rdpContext* context,
const SURFACE_FRAME_MARKER* surfaceFrameMarker) const SURFACE_FRAME_MARKER* surfaceFrameMarker)
{ {
DEBUG_GDI("frameId %d frameAction %d", DEBUG_GDI("frameId %d frameAction %d",
surfaceFrameMarker->frameId, surfaceFrameMarker->frameId,
surfaceFrameMarker->frameAction); surfaceFrameMarker->frameAction);
switch (surfaceFrameMarker->frameAction) switch (surfaceFrameMarker->frameAction)
{ {
@ -1051,25 +1052,25 @@ 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)
{ {
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d " DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
"bpp %d codecID %d width %d height %d length %d", "bpp %d codecID %d width %d height %d length %d",
cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom, cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength); cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
switch (cmd->codecID) switch (cmd->codecID)
{ {
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,
PIXEL_FORMAT_BGRX32, PIXEL_FORMAT_BGRX32,
cmd->bitmapDataLength, cmd->bitmapDataLength,
0, 0, 0, 0,
gdi->bitmap_buffer, gdi->dstFormat, gdi->bitmap_buffer, gdi->dstFormat,
cmd->width * GetBytesPerPixel(gdi->dstFormat), cmd->width * GetBytesPerPixel(gdi->dstFormat),
cmd->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;
@ -1080,10 +1081,10 @@ static BOOL gdi_surface_bits(rdpContext* context,
case RDP_CODEC_ID_NSCODEC: case RDP_CODEC_ID_NSCODEC:
{ {
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, gdi->dstFormat, gdi->stride, cmd->destLeft, cmd->destTop,
cmd->width, cmd->height)) cmd->width, cmd->height))
return FALSE; return FALSE;
} }
break; break;
@ -1091,9 +1092,9 @@ static BOOL gdi_surface_bits(rdpContext* context,
case RDP_CODEC_ID_NONE: case RDP_CODEC_ID_NONE:
{ {
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, PIXEL_FORMAT_XRGB32_VF, 0, 0, 0,
&gdi->palette)) &gdi->palette))
return FALSE; return FALSE;
} }
break; break;
@ -1145,7 +1146,7 @@ void gdi_register_update_callbacks(rdpUpdate* update)
} }
static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer, static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
void (*pfree)(void*)) void (*pfree)(void*))
{ {
gdi->primary = (gdiBitmap*) calloc(1, sizeof(gdiBitmap)); gdi->primary = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
@ -1158,14 +1159,14 @@ static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
if (!buffer) if (!buffer)
{ {
gdi->primary->bitmap = gdi_CreateCompatibleBitmap( gdi->primary->bitmap = gdi_CreateCompatibleBitmap(
gdi->hdc, gdi->width, gdi->height); gdi->hdc, gdi->width, gdi->height);
} }
else else
{ {
gdi->primary->bitmap = gdi_CreateBitmapEx(gdi->width, gdi->height, gdi->primary->bitmap = gdi_CreateBitmapEx(gdi->width, gdi->height,
gdi->dstFormat, gdi->dstFormat,
gdi->stride, gdi->stride,
gdi->primary_buffer, pfree); gdi->primary_buffer, pfree);
} }
gdi->stride = gdi->primary->bitmap->scanline; gdi->stride = gdi->primary->bitmap->scanline;
@ -1187,7 +1188,7 @@ static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
gdi->primary->hdc->hwnd->count = 32; gdi->primary->hdc->hwnd->count = 32;
if (!(gdi->primary->hdc->hwnd->cinvalid = (HGDI_RGN) calloc( if (!(gdi->primary->hdc->hwnd->cinvalid = (HGDI_RGN) calloc(
gdi->primary->hdc->hwnd->count, sizeof(GDI_RGN)))) gdi->primary->hdc->hwnd->count, sizeof(GDI_RGN))))
goto fail_hwnd; goto fail_hwnd;
gdi->primary->hdc->hwnd->ninvalid = 0; gdi->primary->hdc->hwnd->ninvalid = 0;
@ -1213,8 +1214,8 @@ BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height)
} }
BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height, BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
INT32 stride, INT32 format, BYTE* buffer, INT32 stride, INT32 format, BYTE* buffer,
void (*pfree)(void*)) void (*pfree)(void*))
{ {
if (!gdi || !gdi->primary) if (!gdi || !gdi->primary)
return FALSE; return FALSE;
@ -1244,7 +1245,7 @@ BOOL gdi_init(freerdp* instance, UINT32 format)
} }
BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer, BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
void (*pfree)(void*)) void (*pfree)(void*))
{ {
UINT32 SrcFormat = gdi_get_pixel_format(instance->settings->ColorDepth, FALSE); UINT32 SrcFormat = gdi_get_pixel_format(instance->settings->ColorDepth, FALSE);
rdpGdi* gdi = (rdpGdi*) calloc(1, sizeof(rdpGdi)); rdpGdi* gdi = (rdpGdi*) calloc(1, sizeof(rdpGdi));
@ -1260,9 +1261,9 @@ BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
gdi->dstFormat = format; gdi->dstFormat = format;
/* default internal buffer format */ /* default internal buffer format */
WLog_INFO(TAG, "Local framebuffer format %s", WLog_INFO(TAG, "Local framebuffer format %s",
GetColorFormatName(gdi->dstFormat)); GetColorFormatName(gdi->dstFormat));
WLog_INFO(TAG, "Remote framebuffer format %s", WLog_INFO(TAG, "Remote framebuffer format %s",
GetColorFormatName(SrcFormat)); GetColorFormatName(SrcFormat));
if (!(gdi->hdc = gdi_GetDC())) if (!(gdi->hdc = gdi_GetDC()))
goto fail; goto fail;
@ -1279,7 +1280,7 @@ BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
} }
if (!freerdp_client_codecs_reset(context->codecs, FREERDP_CODEC_ALL, gdi->width, if (!freerdp_client_codecs_reset(context->codecs, FREERDP_CODEC_ALL, gdi->width,
gdi->height)) gdi->height))
goto fail; goto fail;
gdi_register_update_callbacks(instance->update); gdi_register_update_callbacks(instance->update);
@ -1309,6 +1310,7 @@ void gdi_free(freerdp* instance)
return; return;
gdi = instance->context->gdi; gdi = instance->context->gdi;
if (gdi) if (gdi)
{ {
gdi_bitmap_free_ex(gdi->primary); gdi_bitmap_free_ex(gdi->primary);
@ -1317,6 +1319,7 @@ void gdi_free(freerdp* instance)
} }
context = instance->context; context = instance->context;
if (context->cache) if (context->cache)
{ {
cache_free(context->cache); cache_free(context->cache);

View File

@ -39,7 +39,7 @@
/* Bitmap Class */ /* Bitmap Class */
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight, HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
UINT32 SrcFormat, BYTE* data) UINT32 SrcFormat, BYTE* data)
{ {
UINT32 nSrcStep; UINT32 nSrcStep;
UINT32 nDstStep; UINT32 nDstStep;
@ -56,8 +56,8 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat); nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0, if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
&gdi->palette)) &gdi->palette))
{ {
_aligned_free(pDstData); _aligned_free(pDstData);
return NULL; return NULL;
@ -79,15 +79,14 @@ static BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
if (!bitmap->data) if (!bitmap->data)
gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap( gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(
gdi->hdc, bitmap->width, gdi->hdc, bitmap->width,
bitmap->height); bitmap->height);
else else
{ {
UINT32 format = bitmap->format; UINT32 format = bitmap->format;
gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width, gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width,
bitmap->height, bitmap->height,
format, bitmap->data); format, bitmap->data);
} }
if (!gdi_bitmap->bitmap) if (!gdi_bitmap->bitmap)
@ -115,20 +114,19 @@ static void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap) static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{ {
int width, height;
gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap; gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
width = bitmap->right - bitmap->left + 1; UINT32 width = bitmap->right - bitmap->left + 1;
height = bitmap->bottom - bitmap->top + 1; UINT32 height = bitmap->bottom - bitmap->top + 1;
return gdi_BitBlt(context->gdi->primary->hdc, return gdi_BitBlt(context->gdi->primary->hdc,
bitmap->left, bitmap->top, bitmap->left, bitmap->top,
width, height, gdi_bitmap->hdc, width, height, gdi_bitmap->hdc,
0, 0, GDI_SRCCOPY, &context->gdi->palette); 0, 0, GDI_SRCCOPY, &context->gdi->palette);
} }
static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
const BYTE* data, UINT32 width, UINT32 height, const BYTE* data, UINT32 width, UINT32 height,
UINT32 bpp, UINT32 length, BOOL compressed, UINT32 bpp, UINT32 length, BOOL compressed,
UINT32 codecId) UINT32 codecId)
{ {
int status; int status;
UINT16 size; UINT16 size;
@ -150,25 +148,27 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
if (bpp < 32) if (bpp < 32)
{ {
if (!freerdp_client_codecs_prepare(context->codecs, if (!freerdp_client_codecs_prepare(context->codecs,
FREERDP_CODEC_INTERLEAVED, FREERDP_CODEC_INTERLEAVED,
gdi->width, gdi->height)) gdi->width, gdi->height))
return FALSE; return FALSE;
status = interleaved_decompress(context->codecs->interleaved, status = interleaved_decompress(context->codecs->interleaved,
pSrcData, SrcSize, pSrcData, SrcSize,
bpp, bpp,
pDstData, gdi->dstFormat, pDstData, gdi->dstFormat,
0, 0, 0, width, height, 0, 0, 0, width, height,
&gdi->palette); &gdi->palette);
} }
else else
{ {
if (!freerdp_client_codecs_prepare(context->codecs, if (!freerdp_client_codecs_prepare(context->codecs,
FREERDP_CODEC_PLANAR, FREERDP_CODEC_PLANAR,
gdi->width, gdi->height)) gdi->width, gdi->height))
return FALSE; return FALSE;
status = planar_decompress(context->codecs->planar, pSrcData, SrcSize, status = planar_decompress(context->codecs->planar, pSrcData, SrcSize,
pDstData, gdi->dstFormat, 0, 0, 0, pDstData, gdi->dstFormat, 0, 0, 0,
width, height, TRUE); width, height, TRUE);
} }
if (status < 0) if (status < 0)
@ -181,8 +181,8 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
{ {
SrcFormat = gdi_get_pixel_format(bpp, FALSE); SrcFormat = gdi_get_pixel_format(bpp, FALSE);
status = freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0, status = freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
width, height, pSrcData, SrcFormat, width, height, pSrcData, SrcFormat,
0, 0, 0, &gdi->palette); 0, 0, 0, &gdi->palette);
} }
bitmap->compressed = FALSE; bitmap->compressed = FALSE;
@ -192,7 +192,7 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
} }
static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
BOOL primary) BOOL primary)
{ {
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
@ -225,7 +225,7 @@ static BOOL gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph)
} }
gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO, gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
data); data);
if (!gdi_glyph->bitmap) if (!gdi_glyph->bitmap)
{ {
@ -254,19 +254,19 @@ static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
} }
static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x, static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x,
UINT32 y) UINT32 y)
{ {
gdiGlyph* gdi_glyph; gdiGlyph* gdi_glyph;
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
gdi_glyph = (gdiGlyph*) glyph; gdi_glyph = (gdiGlyph*) glyph;
return gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width, return gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0,
GDI_DSPDxax, &context->gdi->palette); GDI_DSPDxax, &context->gdi->palette);
} }
static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y, static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 width, UINT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant) UINT32 fgcolor, BOOL fOpRedundant)
{ {
GDI_RECT rect; GDI_RECT rect;
HGDI_BRUSH brush; HGDI_BRUSH brush;
@ -289,12 +289,12 @@ out:
} }
static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y, static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor) UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
{ {
rdpGdi* gdi = context->gdi; rdpGdi* gdi = context->gdi;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE); UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
bgcolor = ConvertColor(bgcolor, SrcFormat, bgcolor = ConvertColor(bgcolor, SrcFormat,
gdi->dstFormat, &gdi->palette); gdi->dstFormat, &gdi->palette);
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
return TRUE; return TRUE;
} }