return TRUE;
}
-UINT32 xf_convert_rdp_order_color(xfContext* xfc, UINT32 color)
-{
- BYTE r = 0, g = 0, b = 0;
-
- switch (xfc->srcBpp)
- {
- case 32:
- case 24:
- if (xfc->visual->red_mask == 0xFF0000 &&
- xfc->visual->green_mask == 0xFF00 &&
- xfc->visual->blue_mask == 0xFF)
- {
- return color;
- }
-
- color = GetColor(xfc->format, r, g, b, 0xFF);
- break;
-
- case 16:
- color = (color & 0xFF00) | ((color >> 16) & 0xFF);
-
- if (xfc->visual->red_mask == 0xF800 &&
- xfc->visual->green_mask == 0x07E0 &&
- xfc->visual->blue_mask == 0x001F)
- {
- return color;
- }
-
- color = GetColor(xfc->format, r, g, b, 0xFF);
- break;
-
- case 15:
- color = (color & 0xFF00) | ((color >> 16) & 0xFF);
- color = GetColor(xfc->format, r, g, b, 0xFF);
- break;
-
- case 8:
- color = (color >> 16) & (UINT32) 0xFF;
- UINT32 dstColor = xfc->context.gdi->palette.palette[color];
- SplitColor(dstColor, xfc->format, &r, &g, &b,
- NULL, NULL);
- break;
-
- default:
- return color;
- }
-
- return (((r >> xfc->red_shift_r) << xfc->red_shift_l) |
- ((g >> xfc->green_shift_r) << xfc->green_shift_l) |
- ((b >> xfc->blue_shift_r) << xfc->blue_shift_l));
-}
-
Pixmap xf_brush_new(xfContext* xfc, int width, int height, int bpp, BYTE* data)
{
GC gc;
UINT32 backColor;
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;
+
+ if (!gdi_decode_color(context->gdi, patblt->foreColor, &foreColor, NULL))
+ return FALSE;
+
+ if (!gdi_decode_color(context->gdi, patblt->backColor, &backColor, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
brush = &patblt->brush;
xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop));
- foreColor = xf_convert_rdp_order_color(xfc, patblt->foreColor);
- backColor = xf_convert_rdp_order_color(xfc, patblt->backColor);
if (brush->style == GDI_BS_SOLID)
{
UINT32 color;
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;
+
+ if (!gdi_decode_color(context->gdi, line_to->penColor, &color, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, line_to->bRop2);
- color = xf_convert_rdp_order_color(xfc, line_to->penColor);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color);
XDrawLine(xfc->display, xfc->drawing, xfc->gc,
XPoint* points;
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;
+
+ if (!gdi_decode_color(context->gdi, polyline->penColor, &color, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, polyline->bRop2);
- color = xf_convert_rdp_order_color(xfc, polyline->penColor);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color);
npoints = polyline->numDeltaEntries + 1;
if (!xfc->display || !xfc->drawing)
return FALSE;
+ if (!gdi_decode_color(context->gdi, mem3blt->foreColor, &foreColor, NULL))
+ return FALSE;
+
+ if (!gdi_decode_color(context->gdi, mem3blt->backColor, &backColor, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
brush = &mem3blt->brush;
bitmap = (xfBitmap*) mem3blt->bitmap;
xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop));
- foreColor = xf_convert_rdp_order_color(xfc, mem3blt->foreColor);
- backColor = xf_convert_rdp_order_color(xfc, mem3blt->backColor);
if (brush->style == GDI_BS_PATTERN)
{
UINT32 brush_color;
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;
+
+ if (!gdi_decode_color(context->gdi, polygon_sc->brushColor, &brush_color, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, polygon_sc->bRop2);
- brush_color = xf_convert_rdp_order_color(xfc, polygon_sc->brushColor);
npoints = polygon_sc->numPoints + 1;
points = malloc(sizeof(XPoint) * npoints);
UINT32 backColor;
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;
+
+ if (!gdi_decode_color(context->gdi, polygon_cb->foreColor, &foreColor, NULL))
+ return FALSE;
+
+ if (!gdi_decode_color(context->gdi, polygon_cb->backColor, &backColor, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
brush = &(polygon_cb->brush);
xf_set_rop2(xfc, polygon_cb->bRop2);
- foreColor = xf_convert_rdp_order_color(xfc, polygon_cb->foreColor);
- backColor = xf_convert_rdp_order_color(xfc, polygon_cb->backColor);
npoints = polygon_cb->numPoints + 1;
points = malloc(sizeof(XPoint) * npoints);
#include "xfreerdp.h"
void xf_gdi_register_update_callbacks(rdpUpdate* update);
-BOOL xf_gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate);
-UINT32 xf_convert_rdp_order_color(xfContext* xfc, UINT32 color);
+BOOL xf_gdi_bitmap_update(rdpContext* context,
+ const BITMAP_UPDATE* bitmapUpdate);
#endif /* __XF_GDI_H */
UINT32 fgcolor, BOOL fOpRedundant)
{
xfContext* xfc = (xfContext*) context;
- bgcolor = xf_convert_rdp_order_color(xfc, bgcolor);
- fgcolor = xf_convert_rdp_order_color(xfc, fgcolor);
+
+ if (!gdi_decode_color(context->gdi, bgcolor, &bgcolor, NULL))
+ return FALSE;
+
+ if (!gdi_decode_color(context->gdi, fgcolor, &fgcolor, NULL))
+ return FALSE;
+
xf_lock_x11(xfc, FALSE);
XSetFunction(xfc->display, xfc->gc, GXcopy);
FREERDP_API DWORD gdi_rop3_code(BYTE code);
FREERDP_API UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel, BOOL vFlip);
+FREERDP_API BOOL gdi_decode_color(rdpGdi* gdi, const UINT32 srcColor,
+ UINT32* color, UINT32* format);
FREERDP_API BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y);
FREERDP_API BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y);
FREERDP_API BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height);
FREERDP_API BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
- INT32 stride, INT32 format, BYTE* buffer,
+ UINT32 stride, UINT32 format, BYTE* buffer,
void (*pfree)(void*));
FREERDP_API BOOL gdi_init(freerdp* instance, UINT32 format);
FREERDP_API BOOL gdi_init_ex(freerdp* instance, UINT32 format,
static BYTE TEST_CLEAR_EXAMPLE_1[] = "\x03\xc3\x11\x00";
static BYTE TEST_CLEAR_EXAMPLE_2[] =
- "\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x00\x82\x00\x00\x00\x00\x00"
- "\x00\x00\x4e\x00\x11\x00\x75\x00\x00\x00\x02\x0e\xff\xff\xff\x00"
- "\x00\x00\xdb\xff\xff\x00\x3a\x90\xff\xb6\x66\x66\xb6\xff\xb6\x66"
- "\x00\x90\xdb\xff\x00\x00\x3a\xdb\x90\x3a\x3a\x90\xdb\x66\x00\x00"
- "\xff\xff\xb6\x64\x64\x64\x11\x04\x11\x4c\x11\x4c\x11\x4c\x11\x4c"
- "\x11\x4c\x00\x47\x13\x00\x01\x01\x04\x00\x01\x00\x00\x47\x16\x00"
- "\x11\x02\x00\x47\x29\x00\x11\x01\x00\x49\x0a\x00\x01\x00\x04\x00"
- "\x01\x00\x00\x4a\x0a\x00\x09\x00\x01\x00\x00\x47\x05\x00\x01\x01"
- "\x1c\x00\x01\x00\x11\x4c\x11\x4c\x11\x4c\x00\x47\x0d\x4d\x00\x4d";
+ "\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x00\x82\x00\x00\x00\x00\x00"
+ "\x00\x00\x4e\x00\x11\x00\x75\x00\x00\x00\x02\x0e\xff\xff\xff\x00"
+ "\x00\x00\xdb\xff\xff\x00\x3a\x90\xff\xb6\x66\x66\xb6\xff\xb6\x66"
+ "\x00\x90\xdb\xff\x00\x00\x3a\xdb\x90\x3a\x3a\x90\xdb\x66\x00\x00"
+ "\xff\xff\xb6\x64\x64\x64\x11\x04\x11\x4c\x11\x4c\x11\x4c\x11\x4c"
+ "\x11\x4c\x00\x47\x13\x00\x01\x01\x04\x00\x01\x00\x00\x47\x16\x00"
+ "\x11\x02\x00\x47\x29\x00\x11\x01\x00\x49\x0a\x00\x01\x00\x04\x00"
+ "\x01\x00\x00\x4a\x0a\x00\x09\x00\x01\x00\x00\x47\x05\x00\x01\x01"
+ "\x1c\x00\x01\x00\x11\x4c\x11\x4c\x11\x4c\x00\x47\x0d\x4d\x00\x4d";
static BYTE TEST_CLEAR_EXAMPLE_3[] =
- "\x00\xdf\x0e\x00\x00\x00\x8b\x00\x00\x00\x00\x00\x00\x00\xfe\xfe"
- "\xfe\xff\x80\x05\xff\xff\xff\x40\xfe\xfe\xfe\x40\x00\x00\x3f\x00"
- "\x03\x00\x0b\x00\xfe\xfe\xfe\xc5\xd0\xc6\xd0\xc7\xd0\x68\xd4\x69"
- "\xd4\x6a\xd4\x6b\xd4\x6c\xd4\x6d\xd4\x1a\xd4\x1a\xd4\xa6\xd0\x6e"
- "\xd4\x6f\xd4\x70\xd4\x71\xd4\x72\xd4\x73\xd4\x74\xd4\x21\xd4\x22"
- "\xd4\x23\xd4\x24\xd4\x25\xd4\xd9\xd0\xda\xd0\xdb\xd0\xc5\xd0\xc5"
- "\xd0\xdc\xd0\xc2\xd0\x21\xd4\x22\xd4\x23\xd4\x24\xd4\x25\xd4\xc9"
- "\xd0\xca\xd0\x5a\xd4\x2b\xd1\x28\xd1\x2c\xd1\x75\xd4\x27\xd4\x28"
- "\xd4\x29\xd4\x2a\xd4\x1a\xd4\x1a\xd4\x1a\xd4\xb7\xd0\xb8\xd0\xb9"
- "\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf\xd0\xc0\xd0\xc1"
- "\xd0\xc2\xd0\xc3\xd0\xc4\xd0";
+ "\x00\xdf\x0e\x00\x00\x00\x8b\x00\x00\x00\x00\x00\x00\x00\xfe\xfe"
+ "\xfe\xff\x80\x05\xff\xff\xff\x40\xfe\xfe\xfe\x40\x00\x00\x3f\x00"
+ "\x03\x00\x0b\x00\xfe\xfe\xfe\xc5\xd0\xc6\xd0\xc7\xd0\x68\xd4\x69"
+ "\xd4\x6a\xd4\x6b\xd4\x6c\xd4\x6d\xd4\x1a\xd4\x1a\xd4\xa6\xd0\x6e"
+ "\xd4\x6f\xd4\x70\xd4\x71\xd4\x72\xd4\x73\xd4\x74\xd4\x21\xd4\x22"
+ "\xd4\x23\xd4\x24\xd4\x25\xd4\xd9\xd0\xda\xd0\xdb\xd0\xc5\xd0\xc5"
+ "\xd0\xdc\xd0\xc2\xd0\x21\xd4\x22\xd4\x23\xd4\x24\xd4\x25\xd4\xc9"
+ "\xd0\xca\xd0\x5a\xd4\x2b\xd1\x28\xd1\x2c\xd1\x75\xd4\x27\xd4\x28"
+ "\xd4\x29\xd4\x2a\xd4\x1a\xd4\x1a\xd4\x1a\xd4\xb7\xd0\xb8\xd0\xb9"
+ "\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf\xd0\xc0\xd0\xc1"
+ "\xd0\xc2\xd0\xc3\xd0\xc4\xd0";
static BYTE TEST_CLEAR_EXAMPLE_4[] =
- "\x01\x0b\x78\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x06\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x0f\xff\xff\xff"
- "\xff\xff\xff\xff\xff\xff\xb6\xff\xff\xff\xff\xff\xff\xff\xff\xff"
- "\xb6\x66\xff\xff\xff\xff\xff\xff\xff\xb6\x66\xdb\x90\x3a\xff\xff"
- "\xb6\xff\xff\xff\xff\xff\xff\xff\xff\xff\x46\x91\x47\x91\x48\x91"
- "\x49\x91\x4a\x91\x1b\x91";
+ "\x01\x0b\x78\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x06\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x0f\xff\xff\xff"
+ "\xff\xff\xff\xff\xff\xff\xb6\xff\xff\xff\xff\xff\xff\xff\xff\xff"
+ "\xb6\x66\xff\xff\xff\xff\xff\xff\xff\xb6\x66\xdb\x90\x3a\xff\xff"
+ "\xb6\xff\xff\xff\xff\xff\xff\xff\xff\xff\x46\x91\x47\x91\x48\x91"
+ "\x49\x91\x4a\x91\x1b\x91";
static int test_ClearDecompressExample1(void)
{
UINT32 SrcSize;
BYTE pDstData[16384];
CLEAR_CONTEXT* clear;
-
clear = clear_context_new(FALSE);
-
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_1) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_1;
-
status = clear_decompress(clear, pSrcData, SrcSize, 0, 0,
- pDstData, PIXEL_FORMAT_XRGB32, 64 * 4, 1, 1, 64, 64,
- NULL);
-
+ pDstData, PIXEL_FORMAT_XRGB32, 64 * 4, 1, 1, 64, 64,
+ NULL);
printf("clear_decompress example 1 status: %d\n", status);
-
clear_context_free(clear);
-
return status;
}
UINT32 SrcSize;
BYTE* pDstData = NULL;
CLEAR_CONTEXT* clear;
-
clear = clear_context_new(FALSE);
-
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_2) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_2;
-
status = clear_decompress(clear, pSrcData, SrcSize, 0, 0,
- pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0,
- NULL);
-
+ pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0,
+ NULL);
printf("clear_decompress example 2 status: %d\n", status);
-
clear_context_free(clear);
-
return status;
}
UINT32 SrcSize;
BYTE* pDstData = NULL;
CLEAR_CONTEXT* clear;
-
clear = clear_context_new(FALSE);
-
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_3) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_3;
-
status = clear_decompress(clear, pSrcData, SrcSize, 0, 0,
- pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0,
- NULL);
-
+ pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0,
+ NULL);
printf("clear_decompress example 3 status: %d\n", status);
-
clear_context_free(clear);
-
return status;
}
UINT32 SrcSize;
BYTE* pDstData = NULL;
CLEAR_CONTEXT* clear;
-
clear = clear_context_new(FALSE);
-
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_4) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_4;
-
status = clear_decompress(clear, pSrcData, SrcSize, 0, 0,
- pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0,
- NULL);
-
+ pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0,
+ NULL);
printf("clear_decompress example 4 status: %d\n", status);
-
clear_context_free(clear);
-
return status;
}
int TestFreeRDPCodecClear(int argc, char* argv[])
{
- /* TODO: These samples are not working at all...
if (test_ClearDecompressExample1())
return -1;
+
if (test_ClearDecompressExample2())
return -1;
+
if (test_ClearDecompressExample3())
return -1;
+
if (test_ClearDecompressExample4())
return -1;
- */
- fprintf(stderr, "TODO: %s not implemented!!!\n", __FUNCTION__);
+ fprintf(stderr, "TODO: %s not implemented!!!\n", __FUNCTION__);
return 0;
}
0x7E, 0xBD, 0xDB, 0xE7, 0xE7, 0xDB, 0xBD, 0x7E /* HS_DIACROSS */
};
-static INLINE BOOL decode_color(rdpGdi* gdi, const UINT32 srcColor,
- UINT32* color, UINT32* format)
+INLINE BOOL gdi_decode_color(rdpGdi* gdi, const UINT32 srcColor,
+ UINT32* color, UINT32* format)
{
UINT32 SrcFormat = gdi_get_pixel_format(gdi->context->settings->ColorDepth,
FALSE);
static BOOL gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
{
- rdpGdi* gdi = context->gdi;
+ rdpGdi* gdi;
+
+ if (!context || !dstblt)
+ return FALSE;
+
+ 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);
UINT32 nXSrc = 0;
UINT32 nYSrc = 0;
- if (!decode_color(gdi, patblt->foreColor, &foreColor, NULL))
+ if (!gdi_decode_color(gdi, patblt->foreColor, &foreColor, NULL))
return FALSE;
- if (!decode_color(gdi, patblt->backColor, &backColor, NULL))
+ if (!gdi_decode_color(gdi, patblt->backColor, &backColor, NULL))
return FALSE;
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight, &rect);
- if (!decode_color(gdi, opaque_rect->color, &brush_color, NULL))
+ if (!gdi_decode_color(gdi, opaque_rect->color, &brush_color, NULL))
return FALSE;
if (!(hBrush = gdi_CreateSolidBrush(brush_color)))
rdpGdi* gdi = context->gdi;
BOOL ret = TRUE;
- if (!decode_color(gdi, multi_opaque_rect->color, &brush_color, NULL))
+ if (!gdi_decode_color(gdi, multi_opaque_rect->color, &brush_color, NULL))
return FALSE;
hBrush = gdi_CreateSolidBrush(brush_color);
UINT32 SrcFormat;
rdpGdi* gdi = context->gdi;
- if (!decode_color(gdi, lineTo->backColor, &color, &SrcFormat))
+ if (!gdi_decode_color(gdi, lineTo->backColor, &color, &SrcFormat))
return FALSE;
if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color,
UINT32 SrcFormat;
rdpGdi* gdi = context->gdi;
- if (!decode_color(gdi, polyline->penColor, &color, &SrcFormat))
+ if (!gdi_decode_color(gdi, polyline->penColor, &color, &SrcFormat))
return FALSE;
if (!(hPen = gdi_CreatePen(GDI_PS_SOLID, 1, color, SrcFormat, &gdi->palette)))
UINT32 backColor;
UINT32 originalColor;
- if (!decode_color(gdi, mem3blt->foreColor, &foreColor, NULL))
+ if (!gdi_decode_color(gdi, mem3blt->foreColor, &foreColor, NULL))
return FALSE;
- if (!decode_color(gdi, mem3blt->backColor, &backColor, NULL))
+ if (!gdi_decode_color(gdi, mem3blt->backColor, &backColor, NULL))
return FALSE;
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
update->altsec->FrameMarker = gdi_frame_marker;
}
-static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
- void (*pfree)(void*))
+static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, UINT32 format,
+ BYTE* buffer, void (*pfree)(void*))
{
gdi->primary = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
+ if (format > 0)
+ gdi->dstFormat = format;
+
+ if (stride > 0)
+ gdi->stride = stride;
+
if (!gdi->primary)
goto fail_primary;
}
BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
- INT32 stride, INT32 format, BYTE* buffer,
+ UINT32 stride, UINT32 format, BYTE* buffer,
void (*pfree)(void*))
{
if (!gdi || !gdi->primary)
gdi_bitmap_free_ex(gdi->primary);
gdi->primary = NULL;
gdi->primary_buffer = NULL;
- return gdi_init_primary(gdi, stride, buffer, pfree);
+ return gdi_init_primary(gdi, stride, format, buffer, pfree);
}
/**
gdi->hdc->format = gdi->dstFormat;
- if (!gdi_init_primary(gdi, stride, buffer, pfree))
+ if (!gdi_init_primary(gdi, stride, gdi->dstFormat, buffer, pfree))
goto fail;
if (!(context->cache = cache_new(instance->settings)))
HGDI_BRUSH brush;
rdpGdi* gdi = context->gdi;
BOOL ret = FALSE;
- UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
- /* TODO: handle fOpRedundant! See xf_Glyph_BeginDraw() */
- bgcolor = ConvertColor(bgcolor, SrcFormat, gdi->drawing->hdc->format,
- &gdi->palette);
- fgcolor = ConvertColor(fgcolor, SrcFormat, gdi->drawing->hdc->format,
- &gdi->palette);
+
+ if (!gdi_decode_color(gdi, bgcolor, &bgcolor, NULL))
+ return FALSE;
+
+ if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL))
+ return FALSE;
if (!(brush = gdi_CreateSolidBrush(fgcolor)))
goto out;
gdi_CRgnToRect(x, y, width, height, &rect);
- ret = gdi_FillRect(gdi->drawing->hdc, &rect, brush);
+
+ switch (fOpRedundant)
+ {
+ case 0:
+ ret = gdi_FillRect(gdi->drawing->hdc, &rect, brush);
+ break;
+
+ default:
+ ret = TRUE;
+ break;
+ }
+
gdi_DeleteObject((HGDIOBJECT) brush);
out:
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
*/
HGDI_RGN gdi_CreateRectRgn(UINT32 nLeftRect, UINT32 nTopRect,
- UINT32 nRightRect, UINT32 nBottomRect)
+ UINT32 nRightRect, UINT32 nBottomRect)
{
HGDI_RGN hRgn = (HGDI_RGN) calloc(1, sizeof(GDI_RGN));
+
if (!hRgn)
return NULL;
*/
HGDI_RECT gdi_CreateRect(UINT32 xLeft, UINT32 yTop,
- UINT32 xRight, UINT32 yBottom)
+ UINT32 xRight, UINT32 yBottom)
{
HGDI_RECT hRect = (HGDI_RECT) calloc(1, sizeof(GDI_RECT));
+
if (!hRect)
return NULL;
*/
INLINE void gdi_CRectToRgn(UINT32 left, UINT32 top,
- UINT32 right, UINT32 bottom, HGDI_RGN rgn)
+ UINT32 right, UINT32 bottom, HGDI_RGN rgn)
{
rgn->x = left;
rgn->y = top;
* @param h height
*/
-INLINE void gdi_RectToCRgn(const HGDI_RECT rect, UINT32 *x, UINT32 *y,
- UINT32 *w, UINT32 *h)
+INLINE void gdi_RectToCRgn(const HGDI_RECT rect, UINT32* x, UINT32* y,
+ UINT32* w, UINT32* h)
{
*x = rect->left;
*y = rect->top;
* @param h height
*/
-INLINE void gdi_CRectToCRgn(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom,
- UINT32 *x, UINT32 *y, UINT32 *w, UINT32 *h)
+INLINE void gdi_CRectToCRgn(UINT32 left, UINT32 top, UINT32 right,
+ UINT32 bottom,
+ UINT32* x, UINT32* y, UINT32* w, UINT32* h)
{
*x = left;
*y = top;
* @param rect destination rectangle
*/
-INLINE void gdi_CRgnToRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h, HGDI_RECT rect)
+INLINE void gdi_CRgnToRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
+ HGDI_RECT rect)
{
+ memset(rect, 0, sizeof(GDI_RECT));
rect->left = x;
rect->top = y;
- rect->right = x + w - 1;
- rect->bottom = y + h - 1;
+
+ if (w > 0)
+ rect->right = x + w - 1;
+
+ if (h > 0)
+ rect->bottom = y + h - 1;
}
/**
* @param bottom y2
*/
-INLINE void gdi_RgnToCRect(HGDI_RGN rgn, UINT32 *left, UINT32 *top,
- UINT32 *right, UINT32 *bottom)
+INLINE void gdi_RgnToCRect(HGDI_RGN rgn, UINT32* left, UINT32* top,
+ UINT32* right, UINT32* bottom)
{
*left = rgn->x;
*top = rgn->y;
*/
INLINE void gdi_CRgnToCRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
- UINT32 *left, UINT32 *top, UINT32 *right, UINT32 *bottom)
+ UINT32* left, UINT32* top, UINT32* right, UINT32* bottom)
{
*left = x;
*top = y;
*/
INLINE BOOL gdi_CopyOverlap(UINT32 x, UINT32 y, UINT32 width, UINT32 height,
- UINT32 srcx, UINT32 srcy)
+ UINT32 srcx, UINT32 srcy)
{
GDI_RECT dst;
GDI_RECT src;
-
gdi_CRgnToRect(x, y, width, height, &dst);
gdi_CRgnToRect(srcx, srcy, width, height, &src);
-
return (dst.right >= src.left && dst.left <= src.right &&
- dst.bottom >= src.top && dst.top <= src.bottom) ? TRUE : FALSE;
+ dst.bottom >= src.top && dst.top <= src.bottom) ? TRUE : FALSE;
}
/**
*/
INLINE BOOL gdi_SetRect(HGDI_RECT rc, UINT32 xLeft, UINT32 yTop,
- UINT32 xRight, UINT32 yBottom)
+ UINT32 xRight, UINT32 yBottom)
{
rc->left = xLeft;
rc->top = yTop;
*/
INLINE BOOL gdi_SetRgn(HGDI_RGN hRgn, UINT32 nXLeft, UINT32 nYLeft,
- UINT32 nWidth, UINT32 nHeight)
+ UINT32 nWidth, UINT32 nHeight)
{
hRgn->x = nXLeft;
hRgn->y = nYLeft;
*/
INLINE BOOL gdi_SetRectRgn(HGDI_RGN hRgn, UINT32 nLeftRect, UINT32 nTopRect,
- UINT32 nRightRect, UINT32 nBottomRect)
+ UINT32 nRightRect, UINT32 nBottomRect)
{
gdi_CRectToRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, hRgn);
hRgn->null = 0;
* points on the left and top sides are considered in,
* while points on the right and bottom sides are considered out
*/
-
if (x >= rc->left && x <= rc->right)
{
if (y >= rc->top && y <= rc->bottom)
* @return nonzero on success, 0 otherwise
*/
-INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, UINT32 x, UINT32 y, UINT32 w, UINT32 h)
+INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, UINT32 x, UINT32 y, UINT32 w,
+ UINT32 h)
{
GDI_RECT inv;
GDI_RECT rgn;
{
int new_cnt;
HGDI_RGN new_rgn;
-
new_cnt = hdc->hwnd->count * 2;
new_rgn = (HGDI_RGN) realloc(cinvalid, sizeof(GDI_RGN) * new_cnt);
+
if (!new_rgn)
return FALSE;
+
hdc->hwnd->count = new_cnt;
cinvalid = new_rgn;
}
gdi_SetRgn(&cinvalid[hdc->hwnd->ninvalid++], x, y, w, h);
hdc->hwnd->cinvalid = cinvalid;
-
invalid = hdc->hwnd->invalid;
if (invalid->null)
inv.bottom = rgn.bottom;
gdi_RectToRgn(&inv, invalid);
-
return TRUE;
}
#include "line.h"
#include "brush.h"
+#include "helpers.h"
/* BitBlt() Test Data */
{
UINT32 rop;
const BYTE* src;
- HGDI_BITMAP* bmp;
+ HGDI_BITMAP bmp;
};
static BOOL test_rop(HGDI_DC hdcDst, HGDI_DC hdcSrc, HGDI_BITMAP hBmpSrc,
HGDI_BITMAP hBmpDst,
- HGDI_BITMAP hBmpDstOriginal, UINT32 rop, HGDI_BITMAP* expected,
+ HGDI_BITMAP hBmpDstOriginal, UINT32 rop, HGDI_BITMAP expected,
const gdiPalette* hPalette)
{
/* restore original destination bitmap */
- gdi_SelectObject(hdcSrc, hBmpDstOriginal);
- gdi_SelectObject(hdcDst, hBmpDst);
+ gdi_SelectObject(hdcSrc, (HGDIOBJECT)hBmpDstOriginal);
+ gdi_SelectObject(hdcDst, (HGDIOBJECT)hBmpDst);
if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY, hPalette))
return FALSE;
#include <freerdp/gdi/pen.h>
#include <freerdp/gdi/region.h>
#include <freerdp/gdi/bitmap.h>
+#include <freerdp/gdi/gdi.h>
#include <winpr/crt.h>
#include "line.h"
#include "brush.h"
+#include "drawing.h"
static int test_gdi_GetDC(void)
{
HGDI_PEN hPen;
HGDI_POINT prevPoint;
const UINT32 format = PIXEL_FORMAT_RGBA32;
- rdpPalette* palette = NULL;
+ gdiPalette* palette = NULL;
if (!(hdc = gdi_GetDC()))
{
int TestGdiEllipse(int argc, char* argv[])
{
int rc = -1;
- UINT32 i, j;
+ UINT32 i;
HGDI_DC hdc;
HGDI_PEN pen;
HGDI_BITMAP hBmp;
for (i = 0; i < number_formats; i++)
{
const UINT32 format = colorFormats[i];
- rdpPalette* hPalette = &g;
+ gdiPalette* hPalette = &g;
g.format = format;
for (i = 0; i < 256; i++)
#include "line.h"
#include "brush.h"
#include "clipping.h"
+#include "drawing.h"
#include "helpers.h"
{
UINT32 rop;
HGDI_BITMAP bmp;
- BYTE* src;
+ const BYTE* src;
};
static BOOL test_line(HGDI_DC hdc, const gdiPalette* hPalette, UINT32 mX,
int TestGdiLine(int argc, char* argv[])
{
int rc = -1;
- UINT32 x, i, j;
+ UINT32 x, i;
gdiPalette g;
const UINT32 RawFormat = PIXEL_FORMAT_RGB8;
const UINT32 colorFormats[] =