};
/* 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 */
0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_VERTICAL */
};
/* GDI Helper Functions */
-
INLINE DWORD gdi_rop3_code(BYTE code)
{
return rop3_code_table[code];
else
{
WLog_ERR(TAG,
- "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
- x, y, hBmp->width, hBmp->height);
+ "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
+ x, y, hBmp->width, hBmp->height);
return 0;
}
}
y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
hBmpBrush->height;
p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * GetBytesPerPixel(
- hBmpBrush->format));
+ hBmpBrush->format));
return p;
}
}
}
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
- BYTE* data)
+ BYTE* data)
{
gdiBitmap* bitmap;
bitmap = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
}
static BOOL gdi_bitmap_update(rdpContext* context,
- const BITMAP_UPDATE* bitmapUpdate)
+ const BITMAP_UPDATE* bitmapUpdate)
{
int status;
UINT32 index;
if (bitsPerPixel < 32)
{
if (!freerdp_client_codecs_prepare(codecs,
- FREERDP_CODEC_INTERLEAVED,
- gdi->width, gdi->height))
+ FREERDP_CODEC_INTERLEAVED,
+ gdi->width, gdi->height))
return FALSE;
+
status = interleaved_decompress(codecs->interleaved,
- pSrcData, SrcSize,
- bitsPerPixel,
- gdi->primary_buffer,
- gdi->dstFormat,
- gdi->stride, nXDst, nYDst,
- nWidth, nHeight,
- &gdi->palette);
+ pSrcData, SrcSize,
+ bitsPerPixel,
+ gdi->primary_buffer,
+ gdi->dstFormat,
+ gdi->stride, nXDst, nYDst,
+ nWidth, nHeight,
+ &gdi->palette);
}
else
{
if (!freerdp_client_codecs_prepare(codecs,
- FREERDP_CODEC_PLANAR,
- gdi->width, gdi->height))
+ FREERDP_CODEC_PLANAR,
+ gdi->width, gdi->height))
return FALSE;
+
status = planar_decompress(codecs->planar, pSrcData,
- SrcSize, gdi->primary_buffer,
- gdi->dstFormat,
- gdi->stride,
- nXDst, nYDst, nWidth, nHeight, TRUE);
+ SrcSize, gdi->primary_buffer,
+ gdi->dstFormat,
+ gdi->stride,
+ nXDst, nYDst, nWidth, nHeight, TRUE);
}
if (status < 0)
UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
UINT32 nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
nWidth = MIN(bitmap->destRight,
- gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
+ gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
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,
- nXDst, nYDst, nWidth, nHeight,
- pSrcData, SrcFormat, nSrcStep,
- nXSrc, nYSrc, &gdi->palette))
+ nXDst, nYDst, nWidth, nHeight,
+ pSrcData, SrcFormat, nSrcStep,
+ nXSrc, nYSrc, &gdi->palette))
return FALSE;
}
if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst,
- nWidth, nHeight))
+ nWidth, nHeight))
return FALSE;
}
}
static BOOL gdi_palette_update(rdpContext* context,
- const PALETTE_UPDATE* palette)
+ const PALETTE_UPDATE* palette)
{
- int index;
- const PALETTE_ENTRY* pe;
+ UINT32 index;
rdpGdi* gdi = context->gdi;
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] =
GetColor(gdi->dstFormat, pe->red, pe->green, pe->blue, 0xFF);
}
if (bounds)
{
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
- {
gdi_SetNullClipRgn(gdi->drawing->hdc);
- }
return TRUE;
}
{
rdpGdi* gdi = context->gdi;
return gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
- dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
- gdi_rop3_code(dstblt->bRop), &gdi->palette);
+ dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
+ gdi_rop3_code(dstblt->bRop), &gdi->palette);
}
static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
- BYTE* data;
const rdpBrush* brush = &patblt->brush;
UINT32 foreColor;
UINT32 backColor;
UINT32 nXSrc = 0;
UINT32 nYSrc = 0;
foreColor = ConvertColor(patblt->foreColor, SrcFormat,
- gdi->dstFormat, &gdi->palette);
+ gdi->dstFormat, &gdi->palette);
backColor = ConvertColor(patblt->backColor, SrcFormat,
- gdi->dstFormat, &gdi->palette);
+ gdi->dstFormat, &gdi->palette);
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
- if (brush->style == GDI_BS_SOLID)
+ switch (brush->style)
{
- originalBrush = gdi->drawing->hdc->brush;
- gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
-
- if (!gdi->drawing->hdc->brush)
- {
- ret = FALSE;
- goto out_error;
- }
+ case GDI_BS_SOLID:
+ originalBrush = gdi->drawing->hdc->brush;
+ gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
- if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
- patblt->nWidth, patblt->nHeight, rop,
- gdi->primary->hdc, nXSrc, nYSrc))
- {
- ret = FALSE;
- }
+ if (!gdi->drawing->hdc->brush)
+ {
+ ret = FALSE;
+ goto out_error;
+ }
- 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 (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
+ patblt->nWidth, patblt->nHeight, rop,
+ gdi->primary->hdc, nXSrc, nYSrc))
+ {
+ ret = FALSE;
+ }
- if (!data)
- {
- ret = FALSE;
- goto out_error;
- }
+ gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+ gdi->drawing->hdc->brush = originalBrush;
+ break;
- 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);
+ case GDI_BS_HATCHED:
+ {
+ const BYTE* hatched;
+ HGDI_BITMAP hBmp;
+ BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
+ 16);
- if (!hBmp)
- {
- _aligned_free(data);
- ret = FALSE;
- goto out_error;
- }
+ if (!data)
+ {
+ ret = FALSE;
+ goto out_error;
+ }
- originalBrush = gdi->drawing->hdc->brush;
- gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
+ 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 (!gdi->drawing->hdc->brush)
- {
- _aligned_free(data);
- ret = FALSE;
- goto out_error;
- }
+ if (!hBmp)
+ {
+ _aligned_free(data);
+ ret = FALSE;
+ goto out_error;
+ }
- gdi->drawing->hdc->brush->nXOrg = brush->x;
- gdi->drawing->hdc->brush->nYOrg = brush->y;
+ originalBrush = gdi->drawing->hdc->brush;
+ gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
- if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
- patblt->nWidth, patblt->nHeight, rop,
- gdi->primary->hdc, nXSrc, nYSrc))
- {
- ret = FALSE;
- }
+ if (!gdi->drawing->hdc->brush)
+ {
+ ret = FALSE;
+ goto out_error;
+ }
- gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
- gdi->drawing->hdc->brush = originalBrush;
- }
- else if (brush->style == GDI_BS_PATTERN)
- {
- HGDI_BITMAP hBmp;
- UINT32 brushFormat;
+ gdi->drawing->hdc->brush->nXOrg = brush->x;
+ gdi->drawing->hdc->brush->nYOrg = brush->y;
- if (brush->bpp > 1)
- {
- brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
- data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+ if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
+ patblt->nWidth, patblt->nHeight, rop,
+ gdi->primary->hdc, nXSrc, nYSrc))
+ {
+ ret = FALSE;
+ }
- if (!data)
- {
- ret = FALSE;
- goto out_error;
+ gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+ gdi->drawing->hdc->brush = originalBrush;
}
+ break;
- if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
- 8, 8, brush->data, brushFormat, 0, 0, 0,
- &gdi->palette))
+ case GDI_BS_PATTERN:
{
- ret = FALSE;
- goto out_error;
- }
- }
- else
- {
- data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+ HGDI_BITMAP hBmp;
+ UINT32 brushFormat;
+ BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
+ 16);
- if (!data)
- {
- ret = FALSE;
- goto out_error;
- }
+ if (!data)
+ {
+ ret = FALSE;
+ goto out_error;
+ }
- freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
- brush->data, backColor, foreColor, &gdi->palette);
- }
+ 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))
+ {
+ _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;
+ }
+ }
- hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
+ hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
- if (!hBmp)
- {
- _aligned_free(data);
- ret = FALSE;
- goto out_error;
- }
+ if (!hBmp)
+ {
+ _aligned_free(data);
+ ret = FALSE;
+ goto out_error;
+ }
- originalBrush = gdi->drawing->hdc->brush;
- gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
+ originalBrush = gdi->drawing->hdc->brush;
+ gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
- if (!gdi->drawing->hdc->brush)
- {
- _aligned_free(data);
- ret = FALSE;
- goto out_error;
- }
+ 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;
+ 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;
- }
+ 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
- {
- WLog_ERR(TAG, "unimplemented brush style:%d", brush->style);
+ 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:
{
rdpGdi* gdi = context->gdi;
return gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
- scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
- scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
- &gdi->palette);
+ scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
+ scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
+ &gdi->palette);
}
static BOOL gdi_opaque_rect(rdpContext* context,
- const OPAQUE_RECT_ORDER* opaque_rect)
+ const OPAQUE_RECT_ORDER* opaque_rect)
{
GDI_RECT rect;
HGDI_BRUSH hBrush;
BOOL ret;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
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,
- gdi->dstFormat, &gdi->palette);
+ gdi->dstFormat, &gdi->palette);
if (!(hBrush = gdi_CreateSolidBrush(brush_color)))
return FALSE;
}
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;
GDI_RECT rect;
{
rectangle = &multi_opaque_rect->rectangles[i];
gdi_CRgnToRect(rectangle->left, rectangle->top,
- rectangle->width, rectangle->height, &rect);
+ rectangle->width, rectangle->height, &rect);
brush_color = ConvertColor(multi_opaque_rect->color, SrcFormat,
- gdi->dstFormat, &gdi->palette);
+ gdi->dstFormat, &gdi->palette);
hBrush = gdi_CreateSolidBrush(brush_color);
if (!hBrush)
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color,
- SrcFormat, &gdi->palette)))
+ SrcFormat, &gdi->palette)))
return FALSE;
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
- gdiBitmap* bitmap;
+ gdiBitmap* bitmap = (gdiBitmap*) memblt->bitmap;
rdpGdi* gdi = context->gdi;
- bitmap = (gdiBitmap*) memblt->bitmap;
return gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
- memblt->nWidth, memblt->nHeight, bitmap->hdc,
- memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
- &gdi->palette);
+ memblt->nWidth, memblt->nHeight, bitmap->hdc,
+ memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
+ &gdi->palette);
}
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;
rdpGdi* gdi = context->gdi;
BOOL ret = TRUE;
- UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
- brush = &mem3blt->brush;
- bitmap = (gdiBitmap*) mem3blt->bitmap;
- foreColor = ConvertColor(mem3blt->foreColor, SrcFormat,
- gdi->dstFormat, &gdi->palette);
- backColor = ConvertColor(mem3blt->backColor, SrcFormat,
- gdi->dstFormat, &gdi->palette);
- originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
-
- if (brush->style == GDI_BS_SOLID)
- {
- originalBrush = gdi->drawing->hdc->brush;
- gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
-
- 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)
+ const UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth,
+ FALSE);
+ const rdpBrush* brush = &mem3blt->brush;
+ gdiBitmap* bitmap = (gdiBitmap*) mem3blt->bitmap;
+ const UINT32 foreColor = ConvertColor(mem3blt->foreColor, SrcFormat,
+ gdi->dstFormat, &gdi->palette);
+ const UINT32 backColor = ConvertColor(mem3blt->backColor, SrcFormat,
+ gdi->dstFormat, &gdi->palette);
+ const UINT32 originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
+
+ switch (brush->style)
{
- HGDI_BITMAP hBmp;
- UINT32 brushFormat;
+ case GDI_BS_SOLID:
+ originalBrush = gdi->drawing->hdc->brush;
+ gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
- if (brush->bpp > 1)
- {
- brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
- data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
-
- if (!data)
+ if (!gdi->drawing->hdc->brush)
{
ret = FALSE;
goto out_fail;
}
- if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
- 8, 8, brush->data, brushFormat, 0, 0, 0, &gdi->palette))
- {
- ret = FALSE;
- goto out_fail;
- }
- }
- else
- {
- data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+ 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;
- if (!data)
+ case GDI_BS_PATTERN:
{
- ret = FALSE;
- goto out_fail;
- }
+ HGDI_BITMAP hBmp;
+ UINT32 brushFormat;
+ BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
+ 16);
- freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
- brush->data, backColor, foreColor, &gdi->palette);
- }
+ if (!data)
+ {
+ ret = FALSE;
+ goto out_fail;
+ }
- hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
+ 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;
+ }
+ }
- if (!hBmp)
- {
- _aligned_free(data);
- ret = FALSE;
- goto out_fail;
- }
+ hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
- originalBrush = gdi->drawing->hdc->brush;
- gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
+ if (!hBmp)
+ {
+ ret = FALSE;
+ _aligned_free(data);
+ goto out_fail;
+ }
- if (!gdi->drawing->hdc->brush)
- {
- gdi_DeleteObject((HGDIOBJECT) hBmp);
- goto out_fail;
- }
+ originalBrush = gdi->drawing->hdc->brush;
+ gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
- 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);
+ 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;
+
+ default:
+ WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%d", brush->style);
+ break;
}
out_fail:
}
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__);
return TRUE;
}
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__);
return TRUE;
}
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__);
return TRUE;
}
static BOOL gdi_frame_marker(rdpContext* context,
- const FRAME_MARKER_ORDER* frameMarker)
+ const FRAME_MARKER_ORDER* frameMarker)
{
return TRUE;
}
BOOL gdi_surface_frame_marker(rdpContext* context,
- const SURFACE_FRAME_MARKER* surfaceFrameMarker)
+ const SURFACE_FRAME_MARKER* surfaceFrameMarker)
{
DEBUG_GDI("frameId %d frameAction %d",
- surfaceFrameMarker->frameId,
- surfaceFrameMarker->frameAction);
+ surfaceFrameMarker->frameId,
+ surfaceFrameMarker->frameAction);
switch (surfaceFrameMarker->frameAction)
{
}
static BOOL gdi_surface_bits(rdpContext* context,
- const SURFACE_BITS_COMMAND* cmd)
+ const SURFACE_BITS_COMMAND* cmd)
{
rdpGdi* gdi = context->gdi;
DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
- "bpp %d codecID %d width %d height %d length %d",
- cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
- cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
+ "bpp %d codecID %d width %d height %d length %d",
+ cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
+ cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
switch (cmd->codecID)
{
case RDP_CODEC_ID_REMOTEFX:
{
if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
- PIXEL_FORMAT_BGRX32,
- cmd->bitmapDataLength,
- 0, 0,
- gdi->bitmap_buffer, gdi->dstFormat,
- cmd->width * GetBytesPerPixel(gdi->dstFormat),
- cmd->height, NULL))
+ PIXEL_FORMAT_BGRX32,
+ cmd->bitmapDataLength,
+ 0, 0,
+ gdi->bitmap_buffer, gdi->dstFormat,
+ cmd->width * GetBytesPerPixel(gdi->dstFormat),
+ cmd->height, NULL))
{
WLog_ERR(TAG, "Failed to process RemoteFX message");
return FALSE;
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, gdi->stride, cmd->destLeft, cmd->destTop,
- cmd->width, cmd->height))
+ cmd->height, cmd->bitmapData,
+ cmd->bitmapDataLength, gdi->primary_buffer,
+ gdi->dstFormat, gdi->stride, cmd->destLeft, cmd->destTop,
+ cmd->width, cmd->height))
return FALSE;
}
break;
case RDP_CODEC_ID_NONE:
{
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
- cmd->destLeft, cmd->destTop, cmd->width, cmd->height,
- cmd->bitmapData, PIXEL_FORMAT_XRGB32_VF, 0, 0, 0,
- &gdi->palette))
+ cmd->destLeft, cmd->destTop, cmd->width, cmd->height,
+ cmd->bitmapData, PIXEL_FORMAT_XRGB32_VF, 0, 0, 0,
+ &gdi->palette))
return FALSE;
}
break;
}
static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
- void (*pfree)(void*))
+ void (*pfree)(void*))
{
gdi->primary = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
if (!buffer)
{
gdi->primary->bitmap = gdi_CreateCompatibleBitmap(
- gdi->hdc, gdi->width, gdi->height);
+ gdi->hdc, gdi->width, gdi->height);
}
else
{
gdi->primary->bitmap = gdi_CreateBitmapEx(gdi->width, gdi->height,
- gdi->dstFormat,
- gdi->stride,
- gdi->primary_buffer, pfree);
+ gdi->dstFormat,
+ gdi->stride,
+ gdi->primary_buffer, pfree);
}
gdi->stride = gdi->primary->bitmap->scanline;
gdi->primary->hdc->hwnd->count = 32;
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;
gdi->primary->hdc->hwnd->ninvalid = 0;
}
BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
- INT32 stride, INT32 format, BYTE* buffer,
- void (*pfree)(void*))
+ INT32 stride, INT32 format, BYTE* buffer,
+ void (*pfree)(void*))
{
if (!gdi || !gdi->primary)
return FALSE;
}
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);
rdpGdi* gdi = (rdpGdi*) calloc(1, sizeof(rdpGdi));
gdi->dstFormat = format;
/* default internal buffer format */
WLog_INFO(TAG, "Local framebuffer format %s",
- GetColorFormatName(gdi->dstFormat));
+ GetColorFormatName(gdi->dstFormat));
WLog_INFO(TAG, "Remote framebuffer format %s",
- GetColorFormatName(SrcFormat));
+ GetColorFormatName(SrcFormat));
if (!(gdi->hdc = gdi_GetDC()))
goto fail;
}
if (!freerdp_client_codecs_reset(context->codecs, FREERDP_CODEC_ALL, gdi->width,
- gdi->height))
+ gdi->height))
goto fail;
gdi_register_update_callbacks(instance->update);
return;
gdi = instance->context->gdi;
+
if (gdi)
{
gdi_bitmap_free_ex(gdi->primary);
}
context = instance->context;
+
if (context->cache)
{
cache_free(context->cache);
/* Bitmap Class */
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
- UINT32 SrcFormat, BYTE* data)
+ UINT32 SrcFormat, BYTE* data)
{
UINT32 nSrcStep;
UINT32 nDstStep;
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
- nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
- &gdi->palette))
+ nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
+ &gdi->palette))
{
_aligned_free(pDstData);
return NULL;
if (!bitmap->data)
gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(
- gdi->hdc, bitmap->width,
- bitmap->height);
+ gdi->hdc, bitmap->width,
+ bitmap->height);
else
{
UINT32 format = bitmap->format;
-
gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width,
- bitmap->height,
- format, bitmap->data);
+ bitmap->height,
+ format, bitmap->data);
}
if (!gdi_bitmap->bitmap)
static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
- int width, height;
gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
- width = bitmap->right - bitmap->left + 1;
- height = bitmap->bottom - bitmap->top + 1;
+ UINT32 width = bitmap->right - bitmap->left + 1;
+ UINT32 height = bitmap->bottom - bitmap->top + 1;
return gdi_BitBlt(context->gdi->primary->hdc,
- bitmap->left, bitmap->top,
- width, height, gdi_bitmap->hdc,
- 0, 0, GDI_SRCCOPY, &context->gdi->palette);
+ bitmap->left, bitmap->top,
+ width, height, gdi_bitmap->hdc,
+ 0, 0, GDI_SRCCOPY, &context->gdi->palette);
}
static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
- const BYTE* data, UINT32 width, UINT32 height,
- UINT32 bpp, UINT32 length, BOOL compressed,
- UINT32 codecId)
+ const BYTE* data, UINT32 width, UINT32 height,
+ UINT32 bpp, UINT32 length, BOOL compressed,
+ UINT32 codecId)
{
int status;
UINT16 size;
if (bpp < 32)
{
if (!freerdp_client_codecs_prepare(context->codecs,
- FREERDP_CODEC_INTERLEAVED,
- gdi->width, gdi->height))
+ FREERDP_CODEC_INTERLEAVED,
+ gdi->width, gdi->height))
return FALSE;
+
status = interleaved_decompress(context->codecs->interleaved,
- pSrcData, SrcSize,
- bpp,
- pDstData, gdi->dstFormat,
- 0, 0, 0, width, height,
- &gdi->palette);
+ pSrcData, SrcSize,
+ bpp,
+ pDstData, gdi->dstFormat,
+ 0, 0, 0, width, height,
+ &gdi->palette);
}
else
{
if (!freerdp_client_codecs_prepare(context->codecs,
- FREERDP_CODEC_PLANAR,
- gdi->width, gdi->height))
+ FREERDP_CODEC_PLANAR,
+ gdi->width, gdi->height))
return FALSE;
+
status = planar_decompress(context->codecs->planar, pSrcData, SrcSize,
- pDstData, gdi->dstFormat, 0, 0, 0,
- width, height, TRUE);
+ pDstData, gdi->dstFormat, 0, 0, 0,
+ width, height, TRUE);
}
if (status < 0)
{
SrcFormat = gdi_get_pixel_format(bpp, FALSE);
status = freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
- width, height, pSrcData, SrcFormat,
- 0, 0, 0, &gdi->palette);
+ width, height, pSrcData, SrcFormat,
+ 0, 0, 0, &gdi->palette);
}
bitmap->compressed = FALSE;
}
static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
- BOOL primary)
+ BOOL primary)
{
rdpGdi* gdi = context->gdi;
}
gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
- data);
+ data);
if (!gdi_glyph->bitmap)
{
}
static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x,
- UINT32 y)
+ UINT32 y)
{
gdiGlyph* gdi_glyph;
rdpGdi* gdi = context->gdi;
gdi_glyph = (gdiGlyph*) glyph;
return gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
- gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0,
- GDI_DSPDxax, &context->gdi->palette);
+ gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0,
+ GDI_DSPDxax, &context->gdi->palette);
}
static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
- UINT32 width, UINT32 height, UINT32 bgcolor,
- UINT32 fgcolor, BOOL fOpRedundant)
+ UINT32 width, UINT32 height, UINT32 bgcolor,
+ UINT32 fgcolor, BOOL fOpRedundant)
{
GDI_RECT rect;
HGDI_BRUSH brush;
}
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;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
bgcolor = ConvertColor(bgcolor, SrcFormat,
- gdi->dstFormat, &gdi->palette);
+ gdi->dstFormat, &gdi->palette);
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
return TRUE;
}