[Pixman] Is circle rendering possible?

Pekka Paalanen ppaalanen at gmail.com
Wed Feb 6 09:54:09 UTC 2019


On Wed, 6 Feb 2019 19:25:48 +1030
Indi Kernick <kerndog73 at gmail.com> wrote:

> The only problem I can find with Cairo is that it uses premultiplied alpha.

Pixman uses premultiplied alpha. Also Wayland uses premultiplied alpha
FWIW. I think you will find it quite common in general.

> That's so annoying! Also, I'm not sure if the Cairo renderer is GPU or CPU
> based.

You choose through the API which one you use. Use the image API, and
you get CPU rendering.

> I'm using Qt to render the images. Qt can render surfaces so I can use
> pixman to manipulate a surface and then Qt to upload it to the GPU when
> it's time to render. Cairo can do the same thing but then I have to worry
> about premultiplied alpha. I could use pixman to do the compositing and
> Cairo to do other stuff but that's just a mess.
> 
> I'm guessing that using a GPU backend for Cairo and then making it play
> nice with the Qt layout engine will be a nightmare. If I have to go back
> and forth between CPU and GPU, it might actually be faster to use CPU
> rendering. The only thing I'm worried about is compositing. Compositing is
> much faster on the GPU (I presume) but if I use Cairo, I'll have to fiddle
> around with the alpha channel. That means a round trip between CPU and GPU
> memory.

You don't need to fiddle with alpha. Just write your fragment shaders
and blending state to expect it.

The point of using premultiplied alpha is to pre-compute values you
would be computing in any case during blending.

> I only really need non-antialiased circle rendering (antialiasing is a
> nice-to-have). I can figure out to do that myself (Bresenham comes to
> mind). I think I'll use pixman and do everything on the CPU.
> 
> Another question: can pixman render a filled polygon without antialiasing?
> If not, I might have to do that myself too. 😢

That I don't know. I have never used Pixman beyond
pixman_image_composite32(). I am guessing the trapezoids or triangles
API could be used, but there does not seem to be anything about polygons
per se. You can see the header yourself, that is all the documentation
there is, which is practically none. Cairo at least has documentation.

I believe there are also other CPU rendering libraries, but I wouldn't
know to point to them.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/pixman/attachments/20190206/41551c2d/attachment.sig>


More information about the Pixman mailing list