Beispiel #1
0
void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{
    rdpBrush* brush;
    xfBitmap* bitmap;
    UINT32 foreColor;
    UINT32 backColor;
    Pixmap pattern = 0;
    xfContext* context_ = (xfContext*) context;
    xfInfo* xfi = context_->xfi;

    xf_lock_x11(xfi, FALSE);

    brush = &mem3blt->brush;
    bitmap = (xfBitmap*) mem3blt->bitmap;
    xf_set_rop3(xfi, gdi_rop3_code(mem3blt->bRop));
    foreColor = freerdp_color_convert_var(mem3blt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv);
    backColor = freerdp_color_convert_var(mem3blt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv);

    if (brush->style == GDI_BS_PATTERN)
    {
        if (brush->bpp > 1)
        {
            pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data);

            XSetFillStyle(xfi->display, xfi->gc, FillTiled);
            XSetTile(xfi->display, xfi->gc, pattern);
            XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);
        }
        else
        {
            pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data);

            XSetForeground(xfi->display, xfi->gc, backColor);
            XSetBackground(xfi->display, xfi->gc, foreColor);
            XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled);
            XSetStipple(xfi->display, xfi->gc, pattern);
            XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);
        }
    }
    else if (brush->style == GDI_BS_SOLID)
    {
        XSetFillStyle(xfi->display, xfi->gc, FillSolid);
        XSetForeground(xfi->display, xfi->gc, backColor);
        XSetBackground(xfi->display, xfi->gc, foreColor);

        XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);
    }
    else
    {
        fprintf(stderr, "Mem3Blt unimplemented brush style:%d\n", brush->style);
    }

    XCopyArea(xfi->display, bitmap->pixmap, xfi->drawing, xfi->gc,
              mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight,
              mem3blt->nLeftRect, mem3blt->nTopRect);

    if (xfi->drawing == xfi->primary)
    {
        gdi_InvalidateRegion(xfi->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight);
    }

    XSetFillStyle(xfi->display, xfi->gc, FillSolid);
    XSetTSOrigin(xfi->display, xfi->gc, 0, 0);

    if (pattern != 0)
        XFreePixmap(xfi->display, pattern);

    XSetFunction(xfi->display, xfi->gc, GXcopy);

    xf_unlock_x11(xfi, FALSE);
}
Beispiel #2
0
void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
{
    int i, npoints;
    XPoint* points;
    Pixmap pattern;
    rdpBrush* brush;
    UINT32 foreColor;
    UINT32 backColor;
    xfInfo* xfi = ((xfContext*) context)->xfi;

    xf_lock_x11(xfi, FALSE);

    brush = &(polygon_cb->brush);
    xf_set_rop2(xfi, polygon_cb->bRop2);
    foreColor = freerdp_color_convert_var(polygon_cb->foreColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv);
    backColor = freerdp_color_convert_var(polygon_cb->backColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv);

    npoints = polygon_cb->numPoints + 1;
    points = malloc(sizeof(XPoint) * npoints);

    points[0].x = polygon_cb->xStart;
    points[0].y = polygon_cb->yStart;

    for (i = 0; i < polygon_cb->numPoints; i++)
    {
        points[i + 1].x = polygon_cb->points[i].x;
        points[i + 1].y = polygon_cb->points[i].y;
    }

    switch (polygon_cb->fillMode)
    {
    case 1: /* alternate */
        XSetFillRule(xfi->display, xfi->gc, EvenOddRule);
        break;

    case 2: /* winding */
        XSetFillRule(xfi->display, xfi->gc, WindingRule);
        break;

    default:
        fprintf(stderr, "PolygonCB unknown fillMode: %d\n", polygon_cb->fillMode);
        break;
    }

    if (brush->style == GDI_BS_PATTERN)
    {
        if (brush->bpp > 1)
        {
            pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data);

            XSetFillStyle(xfi->display, xfi->gc, FillTiled);
            XSetTile(xfi->display, xfi->gc, pattern);
            XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

            XFillPolygon(xfi->display, xfi->drawing, xfi->gc,
                         points, npoints, Complex, CoordModePrevious);

            if (xfi->drawing == xfi->primary)
            {
                XFillPolygon(xfi->display, xfi->drawable, xfi->gc,
                             points, npoints, Complex, CoordModePrevious);
            }

            XSetFillStyle(xfi->display, xfi->gc, FillSolid);
            XSetTSOrigin(xfi->display, xfi->gc, 0, 0);
            XFreePixmap(xfi->display, pattern);
        }
        else
        {
            pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data);

            XSetForeground(xfi->display, xfi->gc, backColor);
            XSetBackground(xfi->display, xfi->gc, foreColor);

            if (polygon_cb->backMode == BACKMODE_TRANSPARENT)
                XSetFillStyle(xfi->display, xfi->gc, FillStippled);
            else if (polygon_cb->backMode == BACKMODE_OPAQUE)
                XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled);

            XSetStipple(xfi->display, xfi->gc, pattern);
            XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

            XFillPolygon(xfi->display, xfi->drawing, xfi->gc,
                         points, npoints, Complex, CoordModePrevious);

            if (xfi->drawing == xfi->primary)
            {
                XFillPolygon(xfi->display, xfi->drawable, xfi->gc,
                             points, npoints, Complex, CoordModePrevious);
            }

            XSetFillStyle(xfi->display, xfi->gc, FillSolid);
            XSetTSOrigin(xfi->display, xfi->gc, 0, 0);
            XFreePixmap(xfi->display, pattern);
        }
    }
    else
    {
        fprintf(stderr, "PolygonCB unimplemented brush style:%d\n", brush->style);
    }

    XSetFunction(xfi->display, xfi->gc, GXcopy);
    free(points);

    xf_unlock_x11(xfi, FALSE);
}
Beispiel #3
0
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
    Pixmap pattern;
    rdpBrush* brush;
    UINT32 foreColor;
    UINT32 backColor;
    xfContext* context_ = (xfContext*) context;
    xfInfo* xfi = context_->xfi;

    xf_lock_x11(xfi, FALSE);

    brush = &patblt->brush;
    xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop));

    foreColor = freerdp_color_convert_var(patblt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv);
    backColor = freerdp_color_convert_var(patblt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv);

    if (brush->style == GDI_BS_SOLID)
    {
        XSetFillStyle(xfi->display, xfi->gc, FillSolid);
        XSetForeground(xfi->display, xfi->gc, foreColor);

        XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
                       patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
    }
    else if (brush->style == GDI_BS_HATCHED)
    {
        pattern = xf_mono_bitmap_new(xfi, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch);

        XSetForeground(xfi->display, xfi->gc, backColor);
        XSetBackground(xfi->display, xfi->gc, foreColor);
        XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled);
        XSetStipple(xfi->display, xfi->gc, pattern);
        XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

        XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
                       patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);

        XFreePixmap(xfi->display, pattern);
    }
    else if (brush->style == GDI_BS_PATTERN)
    {
        if (brush->bpp > 1)
        {
            pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data);

            XSetFillStyle(xfi->display, xfi->gc, FillTiled);
            XSetTile(xfi->display, xfi->gc, pattern);
            XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

            XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
                           patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);

            XSetTile(xfi->display, xfi->gc, xfi->primary);

            XFreePixmap(xfi->display, pattern);
        }
        else
        {
            pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data);

            XSetForeground(xfi->display, xfi->gc, backColor);
            XSetBackground(xfi->display, xfi->gc, foreColor);
            XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled);
            XSetStipple(xfi->display, xfi->gc, pattern);
            XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

            XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
                           patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);

            XFreePixmap(xfi->display, pattern);
        }
    }
    else
    {
        fprintf(stderr, "unimplemented brush style:%d\n", brush->style);
    }

    if (xfi->drawing == xfi->primary)
    {
        gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
    }

    XSetFunction(xfi->display, xfi->gc, GXcopy);

    xf_unlock_x11(xfi, FALSE);
}
Beispiel #4
0
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
	Pixmap pattern;
	rdpBrush* brush;
	uint32 foreColor;
	uint32 backColor;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	brush = &patblt->brush;
	xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop));

	foreColor = freerdp_color_convert_rgb(patblt->foreColor, xfi->srcBpp, 32, xfi->clrconv);
	backColor = freerdp_color_convert_rgb(patblt->backColor, xfi->srcBpp, 32, xfi->clrconv);

	if (brush->style == GDI_BS_SOLID)
	{
		XSetFillStyle(xfi->display, xfi->gc, FillSolid);
		XSetForeground(xfi->display, xfi->gc, foreColor);

		XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
				patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
	}
	else if (brush->style == GDI_BS_PATTERN)
	{
		if (brush->bpp > 1)
		{
			pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data);

			XSetFillStyle(xfi->display, xfi->gc, FillTiled);
			XSetTile(xfi->display, xfi->gc, pattern);
			XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

			XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
					patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);

			XSetTile(xfi->display, xfi->gc, xfi->primary);

			XFreePixmap(xfi->display, pattern);
		}
		else
		{
			pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data);

			XSetForeground(xfi->display, xfi->gc, backColor);
			XSetBackground(xfi->display, xfi->gc, foreColor);
			XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled);
			XSetStipple(xfi->display, xfi->gc, pattern);
			XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);

			XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
					patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);

			XFreePixmap(xfi->display, pattern);
		}
	}
	else
	{
		printf("unimplemented brush style:%d\n", brush->style);
	}

	if (xfi->drawing == xfi->primary)
	{
		XSetFunction(xfi->display, xfi->gc, GXcopy);

		if (xfi->remote_app != true)
		{
			XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, patblt->nLeftRect, patblt->nTopRect,
				patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect);
		}

		gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
	}

	XSetFunction(xfi->display, xfi->gc, GXcopy);
}
Beispiel #5
0
static BOOL xf_gdi_polygon_cb(rdpContext* context,
                              POLYGON_CB_ORDER* polygon_cb)
{
	int i, npoints;
	XPoint* points;
	Pixmap pattern;
	const rdpBrush* brush;
	UINT32 foreColor;
	UINT32 backColor;
	xfContext* xfc = (xfContext*) context;
	BOOL ret = TRUE;

	if (!xf_decode_color(context->gdi, polygon_cb->foreColor, &foreColor, NULL))
		return FALSE;

	if (!xf_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);
	npoints = polygon_cb->numPoints + 1;
	points = malloc(sizeof(XPoint) * npoints);

	if (!points)
	{
		xf_unlock_x11(xfc, FALSE);
		return FALSE;
	}

	points[0].x = polygon_cb->xStart;
	points[0].y = polygon_cb->yStart;

	for (i = 0; i < polygon_cb->numPoints; i++)
	{
		points[i + 1].x = polygon_cb->points[i].x;
		points[i + 1].y = polygon_cb->points[i].y;
	}

	switch (polygon_cb->fillMode)
	{
		case GDI_FILL_ALTERNATE: /* alternate */
			XSetFillRule(xfc->display, xfc->gc, EvenOddRule);
			break;

		case GDI_FILL_WINDING: /* winding */
			XSetFillRule(xfc->display, xfc->gc, WindingRule);
			break;

		default:
			WLog_ERR(TAG, "PolygonCB unknown fillMode: %d", polygon_cb->fillMode);
			break;
	}

	if (brush->style == GDI_BS_PATTERN)
	{
		if (brush->bpp > 1)
		{
			pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data);
			XSetFillStyle(xfc->display, xfc->gc, FillTiled);
			XSetTile(xfc->display, xfc->gc, pattern);
		}
		else
		{
			pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data);
			XSetForeground(xfc->display, xfc->gc, backColor);
			XSetBackground(xfc->display, xfc->gc, foreColor);

			if (polygon_cb->backMode == BACKMODE_TRANSPARENT)
				XSetFillStyle(xfc->display, xfc->gc, FillStippled);
			else if (polygon_cb->backMode == BACKMODE_OPAQUE)
				XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);

			XSetStipple(xfc->display, xfc->gc, pattern);
		}

		XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
		XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
		             points, npoints, Complex, CoordModePrevious);
		XSetFillStyle(xfc->display, xfc->gc, FillSolid);
		XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
		XFreePixmap(xfc->display, pattern);

		if (xfc->drawing == xfc->primary)
		{
			if (!xf_gdi_invalidate_poly_region(xfc, points, npoints))
				ret = FALSE;
		}
	}
	else
	{
		WLog_ERR(TAG,  "PolygonCB unimplemented brush style:%d", brush->style);
	}

	XSetFunction(xfc->display, xfc->gc, GXcopy);
	free(points);
	xf_unlock_x11(xfc, FALSE);
	return ret;
}
Beispiel #6
0
static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{
	const rdpBrush* brush;
	xfBitmap* bitmap;
	UINT32 foreColor;
	UINT32 backColor;
	Pixmap pattern = 0;
	xfContext* xfc = (xfContext*) context;
	BOOL ret = FALSE;

	if (!xfc->display || !xfc->drawing)
		return FALSE;

	if (!xf_decode_color(context->gdi, mem3blt->foreColor, &foreColor, NULL))
		return FALSE;

	if (!xf_decode_color(context->gdi, mem3blt->backColor, &backColor, NULL))
		return FALSE;

	xf_lock_x11(xfc, FALSE);
	brush = &mem3blt->brush;
	bitmap = (xfBitmap*) mem3blt->bitmap;

	if (!xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop)))
		goto fail;

	switch (brush->style)
	{
		case GDI_BS_PATTERN:
			if (brush->bpp > 1)
			{
				pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data);
				XSetFillStyle(xfc->display, xfc->gc, FillTiled);
				XSetTile(xfc->display, xfc->gc, pattern);
				XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
			}
			else
			{
				pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data);
				XSetBackground(xfc->display, xfc->gc, backColor);
				XSetForeground(xfc->display, xfc->gc, foreColor);
				XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
				XSetStipple(xfc->display, xfc->gc, pattern);
				XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
			}

			break;

		case GDI_BS_SOLID:
			XSetFillStyle(xfc->display, xfc->gc, FillSolid);
			XSetBackground(xfc->display, xfc->gc, backColor);
			XSetForeground(xfc->display, xfc->gc, foreColor);
			XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
			break;

		default:
			WLog_ERR(TAG,  "Mem3Blt unimplemented brush style:%d", brush->style);
			goto fail;
	}

	XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc,
	          mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight,
	          mem3blt->nLeftRect, mem3blt->nTopRect);

	if (xfc->drawing == xfc->primary)
		ret = gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
		                           mem3blt->nWidth, mem3blt->nHeight);

	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XSetTSOrigin(xfc->display, xfc->gc, 0, 0);

	if (pattern != 0)
		XFreePixmap(xfc->display, pattern);

	ret = TRUE;
fail:
	XSetFunction(xfc->display, xfc->gc, GXcopy);
	xf_unlock_x11(xfc, FALSE);
	return ret;
}
Beispiel #7
0
static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
	const rdpBrush* brush;
	UINT32 foreColor;
	UINT32 backColor;
	xfContext* xfc = (xfContext*) context;
	BOOL ret = FALSE;

	if (!xf_decode_color(context->gdi, patblt->foreColor, &foreColor, NULL))
		return FALSE;

	if (!xf_decode_color(context->gdi, patblt->backColor, &backColor, NULL))
		return FALSE;

	xf_lock_x11(xfc, FALSE);
	brush = &patblt->brush;

	if (!xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop)))
		goto fail;

	switch (brush->style)
	{
		case GDI_BS_SOLID:
			XSetFillStyle(xfc->display, xfc->gc, FillSolid);
			XSetBackground(xfc->display, xfc->gc, backColor);
			XSetForeground(xfc->display, xfc->gc, foreColor);
			XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
			               patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
			break;

		case GDI_BS_HATCHED:
			{
				Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8,
				                                    &GDI_BS_HATCHED_PATTERNS[8 * brush->hatch]);
				XSetBackground(xfc->display, xfc->gc, backColor);
				XSetForeground(xfc->display, xfc->gc, foreColor);
				XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
				XSetStipple(xfc->display, xfc->gc, pattern);
				XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
				XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
				               patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
				XFreePixmap(xfc->display, pattern);
			}
			break;

		case GDI_BS_PATTERN:
			if (brush->bpp > 1)
			{
				Pixmap pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data);
				XSetFillStyle(xfc->display, xfc->gc, FillTiled);
				XSetTile(xfc->display, xfc->gc, pattern);
				XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
				XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
				               patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
				XSetTile(xfc->display, xfc->gc, xfc->primary);
				XFreePixmap(xfc->display, pattern);
			}
			else
			{
				Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data);
				XSetBackground(xfc->display, xfc->gc, backColor);
				XSetForeground(xfc->display, xfc->gc, foreColor);
				XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
				XSetStipple(xfc->display, xfc->gc, pattern);
				XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
				XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
				               patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
				XFreePixmap(xfc->display, pattern);
			}

			break;

		default:
			WLog_ERR(TAG,  "unimplemented brush style:%d", brush->style);
			goto fail;
	}

	if (xfc->drawing == xfc->primary)
		ret = gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect,
		                           patblt->nWidth, patblt->nHeight);

	ret = TRUE;
fail:
	XSetFunction(xfc->display, xfc->gc, GXcopy);
	xf_unlock_x11(xfc, FALSE);
	return ret;
}