libfreerdp-gdi: add support for ABGR plain colors

This commit is contained in:
Marc-André Moreau 2014-09-15 16:28:53 -04:00
parent 501386b790
commit b25258e8c6
6 changed files with 40 additions and 37 deletions

View File

@ -461,9 +461,9 @@ void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
brush = &patblt->brush;
xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop));
foreColor = freerdp_color_convert_drawing_order_color_to_gdi_color(patblt->foreColor, context->settings->ColorDepth, xfc->clrconv);
foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
foreColor = xf_gdi_get_color(xfc, foreColor);
backColor = freerdp_color_convert_drawing_order_color_to_gdi_color(patblt->backColor, context->settings->ColorDepth, xfc->clrconv);
backColor = freerdp_convert_gdi_order_color(patblt->backColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
backColor = xf_gdi_get_color(xfc, backColor);
if (brush->style == GDI_BS_SOLID)
@ -583,7 +583,7 @@ void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
xf_lock_x11(xfc, FALSE);
color = freerdp_color_convert_drawing_order_color_to_gdi_color(opaque_rect->color, context->settings->ColorDepth, xfc->clrconv);
color = freerdp_convert_gdi_order_color(opaque_rect->color, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
color = xf_gdi_get_color(xfc, color);
XSetFunction(xfc->display, xfc->gc, GXcopy);
@ -618,7 +618,7 @@ void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult
xf_lock_x11(xfc, FALSE);
color = freerdp_color_convert_drawing_order_color_to_gdi_color(multi_opaque_rect->color, context->settings->ColorDepth, xfc->clrconv);
color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
color = xf_gdi_get_color(xfc, color);
XSetFunction(xfc->display, xfc->gc, GXcopy);
@ -661,7 +661,7 @@ void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, line_to->bRop2);
color = freerdp_color_convert_drawing_order_color_to_gdi_color(line_to->penColor, context->settings->ColorDepth, xfc->clrconv);
color = freerdp_convert_gdi_order_color(line_to->penColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
color = xf_gdi_get_color(xfc, color);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
@ -712,7 +712,7 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, polyline->bRop2);
color = freerdp_color_convert_drawing_order_color_to_gdi_color(polyline->penColor, context->settings->ColorDepth, xfc->clrconv);
color = freerdp_convert_gdi_order_color(polyline->penColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
color = xf_gdi_get_color(xfc, color);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
@ -809,9 +809,9 @@ void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
brush = &mem3blt->brush;
bitmap = (xfBitmap*) mem3blt->bitmap;
xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop));
foreColor = freerdp_color_convert_drawing_order_color_to_gdi_color(mem3blt->foreColor, context->settings->ColorDepth, xfc->clrconv);
foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
foreColor = xf_gdi_get_color(xfc, foreColor);
backColor = freerdp_color_convert_drawing_order_color_to_gdi_color(mem3blt->backColor, context->settings->ColorDepth, xfc->clrconv);
backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
backColor = xf_gdi_get_color(xfc, backColor);
if (brush->style == GDI_BS_PATTERN)
@ -884,7 +884,7 @@ void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, polygon_sc->bRop2);
brush_color = freerdp_color_convert_drawing_order_color_to_gdi_color(polygon_sc->brushColor, context->settings->ColorDepth, xfc->clrconv);
brush_color = freerdp_convert_gdi_order_color(polygon_sc->brushColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
brush_color = xf_gdi_get_color(xfc, brush_color);
npoints = polygon_sc->numPoints + 1;
@ -946,9 +946,9 @@ void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
brush = &(polygon_cb->brush);
xf_set_rop2(xfc, polygon_cb->bRop2);
foreColor = freerdp_color_convert_drawing_order_color_to_gdi_color(polygon_cb->foreColor, context->settings->ColorDepth, xfc->clrconv);
foreColor = freerdp_convert_gdi_order_color(polygon_cb->foreColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
foreColor = xf_gdi_get_color(xfc, foreColor);
backColor = freerdp_color_convert_drawing_order_color_to_gdi_color(polygon_cb->backColor, context->settings->ColorDepth, xfc->clrconv);
backColor = freerdp_convert_gdi_order_color(polygon_cb->backColor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
backColor = xf_gdi_get_color(xfc, backColor);
npoints = polygon_cb->numPoints + 1;

View File

@ -356,9 +356,8 @@ void xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height
{
xfContext* xfc = (xfContext*) context;
bgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color(bgcolor, context->settings->ColorDepth, xfc->clrconv);
fgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color(fgcolor, context->settings->ColorDepth, xfc->clrconv);
bgcolor = freerdp_convert_gdi_order_color(bgcolor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
fgcolor = freerdp_convert_gdi_order_color(fgcolor, context->settings->ColorDepth, PIXEL_FORMAT_XRGB32);
xf_lock_x11(xfc, FALSE);

View File

@ -445,7 +445,7 @@ FREERDP_API UINT32 freerdp_color_convert_rgb_bgr(UINT32 srcColor, int srcBpp, in
FREERDP_API UINT32 freerdp_color_convert_bgr_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv);
FREERDP_API UINT32 freerdp_color_convert_var_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv);
FREERDP_API UINT32 freerdp_color_convert_var_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv);
FREERDP_API UINT32 freerdp_color_convert_drawing_order_color_to_gdi_color(UINT32 color, int bpp, HCLRCONV clrconv);
FREERDP_API UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format);
FREERDP_API HCLRCONV freerdp_clrconv_new(UINT32 flags);
FREERDP_API void freerdp_clrconv_free(HCLRCONV clrconv);

View File

@ -379,12 +379,20 @@ UINT32 freerdp_color_convert_var_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HC
return freerdp_color_convert_rgb_bgr(srcColor, srcBpp, dstBpp, clrconv);
}
UINT32 freerdp_color_convert_drawing_order_color_to_gdi_color(UINT32 color, int bpp, HCLRCONV clrconv)
UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format)
{
UINT32 r, g, b;
switch (bpp)
{
case 32:
GetRGB32(r, g, b, color);
break;
case 24:
GetRGB32(r, g, b, color);
break;
case 16:
color = (color & (UINT32) 0xFF00) | ((color >> 16) & (UINT32) 0xFF);
GetRGB16(r, g, b, color);
@ -397,9 +405,9 @@ UINT32 freerdp_color_convert_drawing_order_color_to_gdi_color(UINT32 color, int
case 8:
color = (color >> 16) & (UINT32) 0xFF;
r = clrconv->palette->entries[color].red;
g = clrconv->palette->entries[color].green;
b = clrconv->palette->entries[color].blue;
//r = clrconv->palette->entries[color].red;
//g = clrconv->palette->entries[color].green;
//b = clrconv->palette->entries[color].blue;
break;
case 1:
@ -413,6 +421,9 @@ UINT32 freerdp_color_convert_drawing_order_color_to_gdi_color(UINT32 color, int
break;
}
if (FREERDP_PIXEL_FORMAT_TYPE(format) == FREERDP_PIXEL_FORMAT_TYPE_ABGR)
return BGR32(r, g, b);
return RGB32(r, g, b);
}

View File

@ -622,8 +622,8 @@ void gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
brush = &patblt->brush;
foreColor = freerdp_color_convert_drawing_order_color_to_gdi_color(patblt->foreColor, gdi->srcBpp, gdi->clrconv);
backColor = freerdp_color_convert_drawing_order_color_to_gdi_color(patblt->backColor, gdi->srcBpp, gdi->clrconv);
foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, gdi->srcBpp, gdi->format);
backColor = freerdp_convert_gdi_order_color(patblt->backColor, gdi->srcBpp, gdi->format);
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
@ -709,8 +709,7 @@ void gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight, &rect);
brush_color = freerdp_color_convert_drawing_order_color_to_gdi_color(
opaque_rect->color, gdi->srcBpp, gdi->clrconv);
brush_color = freerdp_convert_gdi_order_color(opaque_rect->color, gdi->srcBpp, gdi->format);
hBrush = gdi_CreateSolidBrush(brush_color);
gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
@ -734,8 +733,7 @@ void gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_o
gdi_CRgnToRect(rectangle->left, rectangle->top,
rectangle->width, rectangle->height, &rect);
brush_color = freerdp_color_convert_drawing_order_color_to_gdi_color(
multi_opaque_rect->color, gdi->srcBpp, gdi->clrconv);
brush_color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, gdi->srcBpp, gdi->format);
hBrush = gdi_CreateSolidBrush(brush_color);
gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
@ -750,8 +748,7 @@ void gdi_line_to(rdpContext* context, LINE_TO_ORDER* lineTo)
HGDI_PEN hPen;
rdpGdi* gdi = context->gdi;
color = freerdp_color_convert_drawing_order_color_to_gdi_color(
lineTo->penColor, gdi->srcBpp, gdi->clrconv);
color = freerdp_convert_gdi_order_color(lineTo->penColor, gdi->srcBpp, gdi->format);
hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, (GDI_COLOR) color);
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
gdi_SetROP2(gdi->drawing->hdc, lineTo->bRop2);
@ -772,8 +769,7 @@ void gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
DELTA_POINT* points;
rdpGdi* gdi = context->gdi;
color = freerdp_color_convert_drawing_order_color_to_gdi_color(
polyline->penColor, gdi->srcBpp, gdi->clrconv);
color = freerdp_convert_gdi_order_color(polyline->penColor, gdi->srcBpp, gdi->format);
hPen = gdi_CreatePen(GDI_PS_SOLID, 1, (GDI_COLOR) color);
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
gdi_SetROP2(gdi->drawing->hdc, polyline->bRop2);
@ -820,8 +816,8 @@ void gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
brush = &mem3blt->brush;
bitmap = (gdiBitmap*) mem3blt->bitmap;
foreColor = freerdp_color_convert_drawing_order_color_to_gdi_color(mem3blt->foreColor, gdi->srcBpp, gdi->clrconv);
backColor = freerdp_color_convert_drawing_order_color_to_gdi_color(mem3blt->backColor, gdi->srcBpp, gdi->clrconv);
foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, gdi->srcBpp, gdi->format);
backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, gdi->srcBpp, gdi->format);
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);

View File

@ -268,10 +268,8 @@ void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh
HGDI_BRUSH brush;
rdpGdi* gdi = context->gdi;
bgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color(
bgcolor, gdi->srcBpp, gdi->clrconv);
fgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color(
fgcolor, gdi->srcBpp, gdi->clrconv);
bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format);
fgcolor = freerdp_convert_gdi_order_color(fgcolor, gdi->srcBpp, gdi->format);
gdi_CRgnToRect(x, y, width, height, &rect);
@ -286,8 +284,7 @@ void gdi_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height,
{
rdpGdi* gdi = context->gdi;
bgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color(
bgcolor, gdi->srcBpp, gdi->clrconv);
bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format);
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
}