X/Render, rotation transform, Src PICTOP: can I ignore pixels in the bounding box but outside the polygon?

Ilya Anfimov ilan at astelecom.ru
Wed May 18 10:07:09 UTC 2016


On Wed, May 18, 2016 at 10:06:03AM +1000, Nigel Tao wrote:
> I sent this a few months ago, but got no response, not even a "what
> you're asking for isn't possible". I'd still like to know the answer
> (even if it's no), so I'm sending it out another (final) time.

 Well,  don't  know about RENDER capabilities (I always miss what
is in the spec, what is wanted by the designer and what is really
implemented with this extension).

 But  anyway  you can specify clip-mask with ChangePicture to use
bitmap of enabled pixels. Whould be better IMO  than  restricting
output line-by-line.
 And that mask bitmap also could be calculated by RENDER.

> 
> 
> On Sat, Oct 10, 2015 at 3:38 PM, Nigel Tao <nigeltao at golang.org> wrote:
> > I'm using X Render, and want to draw a playing card image onto my
> > window, rotated (e.g. as part of a fan of cards in hand).
> >
> > For simplicity, suppose that playing cards are square and the rotation
> > is by 45 degrees. The result is a diamond shape, so that in its
> > bounding box, the pixels in (1) and out of (0) that diamond looks
> > like:
> >
> > 00100
> > 01110
> > 11111
> > 01110
> > 00100
> >
> > Labeling the interesting points on the edges of that bounding box as:
> >
> > ABC
> > HXD
> > GFE
> >
> > with the center point as X, that means that the bounding box is ACEG
> > and the playing card is BDFH.
> >
> > For a fully opaque source image, the result is the same inside the
> > diamond BDFH, for the Src and Over Render PICTOPs.
> >
> > I am also guessing that, in general, the Src operator is faster than
> > Over, since it does not have to read and blend the destination pixels
> > at all. Thus, I'd like to use the Src operator if possible.
> >
> > The thing is, outside the diamond, in the '0' pixels above, the
> > resultant pixels are black with Src, and unchanged, obviously, with
> > Over.
> >
> > In contrast, in OpenGL say, if my (transformed) vertices are BDFH,
> > then the pixel shader only touches the '1' pixels and leaves the '0'
> > pixels alone, regardless of whether I use the equivalent of Src or
> > Over in my pixel shader.
> >
> > Is there a way I can use the Src operator, in Render, and touch only
> > the '1' pixels? I've tried a mixture of the Composite and TriStrip
> > requests, with SetPictureTransform, and setting a clip (but
> > SetPictureClipRectangles takes a union of axis-aligned rects, AFAICT),
> > but I haven't been able to make it do what I want. Am I missing
> > something obvious?
> >
> > Sure, technically, I could calculate the diamond client-side, and send
> > a series of one-pixel-high strips to the server, but that feels
> > inelegant at best.
> >
> > For this particular card-playing app, an easy, practical solution is
> > to just use the Over operator instead of Src. I'm not really writing a
> > card-playing app, though. I'm writing a graphics library, for which
> > there'll be both OpenGL-based and X11/Render-based backends, and I'd
> > like 'draw this texture with this affine transform and this
> > Porter-Duff operator' to work the same on both backends.
> >
> > I had a quick skim through the cairo xlib render source code, but
> > nothing leapt out as specifically looking at this case.
> _______________________________________________
> xorg at lists.x.org: X.Org support
> Archives: http://lists.freedesktop.org/archives/xorg
> Info: https://lists.x.org/mailman/listinfo/xorg
> Your subscription address: %(user_address)s


More information about the xorg mailing list