<div><div dir="auto">I thought pixman allowed you to choose between premultiplied and not premultiplied but I checked and apparently not. I think I'm getting my libraries mixed up. The problem I have with premultiplied alpha is that you lose precision when you have to un-premultiply. That's something I need in my application. I want to get the color of a pixel without losing precision with semi-transparent pixels.</div></div><div dir="auto"><br></div><div dir="auto">So if I don't want to lose precision, I'll have to store images in regular alpha and then multiply the alpha every time I want to composite. That's kind of annoying.</div><div dir="auto"><br></div><div dir="auto">To render a polygon, I could divide it into triangles and render those with pixman.</div><div dir="auto"><br></div><div dir="auto">Thanks for your help. I think I'll explore other libraries.</div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, 6 Feb 2019 at 20:24 Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 6 Feb 2019 19:25:48 +1030<br>
Indi Kernick <<a href="mailto:kerndog73@gmail.com" target="_blank">kerndog73@gmail.com</a>> wrote:<br>
<br>
> The only problem I can find with Cairo is that it uses premultiplied alpha.<br>
<br>
Pixman uses premultiplied alpha. Also Wayland uses premultiplied alpha<br>
FWIW. I think you will find it quite common in general.<br>
<br>
> That's so annoying! Also, I'm not sure if the Cairo renderer is GPU or CPU<br>
> based.<br>
<br>
You choose through the API which one you use. Use the image API, and<br>
you get CPU rendering.<br>
<br>
> I'm using Qt to render the images. Qt can render surfaces so I can use<br>
> pixman to manipulate a surface and then Qt to upload it to the GPU when<br>
> it's time to render. Cairo can do the same thing but then I have to worry<br>
> about premultiplied alpha. I could use pixman to do the compositing and<br>
> Cairo to do other stuff but that's just a mess.<br>
> <br>
> I'm guessing that using a GPU backend for Cairo and then making it play<br>
> nice with the Qt layout engine will be a nightmare. If I have to go back<br>
> and forth between CPU and GPU, it might actually be faster to use CPU<br>
> rendering. The only thing I'm worried about is compositing. Compositing is<br>
> much faster on the GPU (I presume) but if I use Cairo, I'll have to fiddle<br>
> around with the alpha channel. That means a round trip between CPU and GPU<br>
> memory.<br>
<br>
You don't need to fiddle with alpha. Just write your fragment shaders<br>
and blending state to expect it.<br>
<br>
The point of using premultiplied alpha is to pre-compute values you<br>
would be computing in any case during blending.<br>
<br>
> I only really need non-antialiased circle rendering (antialiasing is a<br>
> nice-to-have). I can figure out to do that myself (Bresenham comes to<br>
> mind). I think I'll use pixman and do everything on the CPU.<br>
> <br>
> Another question: can pixman render a filled polygon without antialiasing?<br>
> If not, I might have to do that myself too. 😢<br>
<br>
That I don't know. I have never used Pixman beyond<br>
pixman_image_composite32(). I am guessing the trapezoids or triangles<br>
API could be used, but there does not seem to be anything about polygons<br>
per se. You can see the header yourself, that is all the documentation<br>
there is, which is practically none. Cairo at least has documentation.<br>
<br>
I believe there are also other CPU rendering libraries, but I wouldn't<br>
know to point to them.<br>
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div></div>