Filling Trapezoids with XRender
Chris Wilson
chris at chris-wilson.co.uk
Sat Jun 12 09:30:58 PDT 2010
On Sat, 12 Jun 2010 21:47:39 +0530, Sunny Sachanandani <sunnysachanandani at gmail.com> wrote:
> I have this small section of code:
>
> XRenderColor foreground = {0xffff, 0x0000, 0x0000, 0xffff};
> Picture fill = XRenderCreateSolidFill(dpy, &foreground);
> XTrapezoid trap;
> trap.top = trap.left.p1.y = trap.right.p1.y = XDoubleToFixed(0.25);
> trap.bottom = trap.left.p2.y = trap.right.p2.y = XDoubleToFixed(0.50);
> trap.left.p1.x = trap.left.p2.x = XDoubleToFixed(0.25);
> trap.right.p1.x = trap.right.p2.x = XDoubleToFixed(0.50);
>
> XRenderCompositeTrapezoids(dpy, PictOpSrc, fill, win_pict,
> XRenderFindStandardFormat(dpy, PictStandardA1),
> 0, 0, &trap, 1);
> XSync(dpy, False);
>
> win_pict is a Picture created for the Window that I am drawing on. The
> Window is 400 by 400. I have been able to use XRenderFillRectangle(s)
> as well as XRenderComposite (with a pixmap loaded from an xpm file) on
> the same window. However I am unable to get this to work.
Let me guess, you weren't expecting the output to be the top-left pixel
filled with {0, 0, 0, 0} despite having drawn a square
(.25, .25), (.50, .50), i.e coverage of 0.125 pixels, into an a1 mask.
May I recommend that you not use XRender directly, but something with a
sane API like Cairo?
-ickle
--
Chris Wilson, Intel Open Source Technology Centre
More information about the xorg-devel
mailing list