Re: [Pixman] Is circle rendering possible?
If you are rendering a solid color (so the result is either that color or transparent black) then you can just fill the entire RGB with that color to turn the premulitplied output into unpremultiplied. However I am unsure what your precision problem is. You would have to composite several dozen mostly-transparent pixels for it to make any visible difference. On Wed, Feb 6, 2019 at 2:28 AM Indi Kernick wrote: > 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. > > 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. > > To render a polygon, I could divide it into triangles and render those > with pixman. > > Thanks for your help. I think I'll explore other libraries. > > > On Wed, 6 Feb 2019 at 20:24 Pekka Paalanen wrote: > >> On Wed, 6 Feb 2019 19:25:48 +1030 >> Indi Kernick 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 >> > ___ > Pixman mailing list > Pixman@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/pixman > ___ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman
Re: [Pixman] Is circle rendering possible?
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. 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. To render a polygon, I could divide it into triangles and render those with pixman. Thanks for your help. I think I'll explore other libraries. On Wed, 6 Feb 2019 at 20:24 Pekka Paalanen wrote: > On Wed, 6 Feb 2019 19:25:48 +1030 > Indi Kernick 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 > ___ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman
Re: [Pixman] Is circle rendering possible?
On Wed, 6 Feb 2019 19:25:48 +1030 Indi Kernick 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 pgppzirACMdM0.pgp Description: OpenPGP digital signature ___ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman
Re: [Pixman] Is circle rendering possible?
The only problem I can find with Cairo is that it uses premultiplied alpha. That's so annoying! Also, I'm not sure if the Cairo renderer is GPU or CPU based. 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. 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. On Wed, 6 Feb 2019 at 17:54 Pekka Paalanen wrote: > On Wed, 6 Feb 2019 15:00:58 +1030 > Indi Kernick wrote: > > > Is it possible to render a filled circle onto an image? How about > rendering > > the outline of a circle? Could I do this with or without antialiasing? > How > > about lines with or without antialiasing? > > > > I might be able to hack something together with radial gradients but I'm > > hoping there's a better way. I'm not actually using pixman yet. I'm just > > trying to determine whether this is the library I need. > > > > If pixman cannot do these things, could someone recommend a library that > > does? I need something that can do compositing (with options to set the > > compositing operation), transformations, masking, indexed (palette) > images, > > kernel convolution filters, gradients, basic line, circle and rectangle > > rendering. > > > > Rendering a circle myself isn't that complicated but I'd rather use > someone > > else's code that does it properly and fast. > > Hi, > > sounds like Cairo (with the image backend) might fit better for you. It > uses Pixman under the hood. > > https://cairographics.org/ > > > Thanks, > pq > ___ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman
Re: [Pixman] Is circle rendering possible?
On Wed, 6 Feb 2019 15:00:58 +1030 Indi Kernick wrote: > Is it possible to render a filled circle onto an image? How about rendering > the outline of a circle? Could I do this with or without antialiasing? How > about lines with or without antialiasing? > > I might be able to hack something together with radial gradients but I'm > hoping there's a better way. I'm not actually using pixman yet. I'm just > trying to determine whether this is the library I need. > > If pixman cannot do these things, could someone recommend a library that > does? I need something that can do compositing (with options to set the > compositing operation), transformations, masking, indexed (palette) images, > kernel convolution filters, gradients, basic line, circle and rectangle > rendering. > > Rendering a circle myself isn't that complicated but I'd rather use someone > else's code that does it properly and fast. Hi, sounds like Cairo (with the image backend) might fit better for you. It uses Pixman under the hood. https://cairographics.org/ Thanks, pq pgpNdUUjriGsH.pgp Description: OpenPGP digital signature ___ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman
[Pixman] Is circle rendering possible?
Is it possible to render a filled circle onto an image? How about rendering the outline of a circle? Could I do this with or without antialiasing? How about lines with or without antialiasing? I might be able to hack something together with radial gradients but I'm hoping there's a better way. I'm not actually using pixman yet. I'm just trying to determine whether this is the library I need. If pixman cannot do these things, could someone recommend a library that does? I need something that can do compositing (with options to set the compositing operation), transformations, masking, indexed (palette) images, kernel convolution filters, gradients, basic line, circle and rectangle rendering. Rendering a circle myself isn't that complicated but I'd rather use someone else's code that does it properly and fast. ___ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman