[cairo] Transparent pattern may be wrong

Bill Spitzak spitzak at d2.com
Mon Feb 28 13:43:58 PST 2005



David Reveman wrote:

> We need to specify what EXTEND_TRANSPARENT means for surfaces without an
> alpha channel.
> 
> surface         pixels              extend-transparent-pixel
> RGBA          (r, g, b, a)         (0, 0, 0, 0)
> A                 (0, 0, 0, a)        (0, 0, 0, 0)
> RGB            (r, g, b, 1)         (0, 0, 0, ?)
> 
> It could either be:
> 1. (0, 0, 0, 1)
> or
> 2. (0, 0, 0, 0)
> 
> If we want to be able to accelerate it with OpenGL, then it would have
> to be option 1. And yes, I can imagine that this black border you
> mentioned above could then be quite annoying and EXTEND_NEAREST as
> default is probably a good idea.

I think everybody expects option 2.

I am unaware of any way to accelerate TRANSPARENT_OUTSIDE that produces 
an *antialiased* result other than to pad the image with a pixel of 
black and then loading it as a texture. Can you explain what you are 
doing? In the pad-the-image solution it is trivial to make that edge be 
any color or alpha wanted.

In any case it looks like everybody agrees that EXTEND_NEAREST should be 
the default, which addresses my problems. Anybody knowledgable enough to 
change it to TRANSPARENT will also realize that they should be drawing 
shapes that are larger than the image to get the correct results.

> If we specify it as option 2. Then this black border around rectangles
> will always be a transparent black border and maybe not as annoying.

Unfortunately this is wrong. It will still be double-premultiplied, 
which is basically "bad antialiasing". We might as well put a completly 
incorrect antialiasing algorithm in if this is going to be considered 
acceptable.



More information about the cairo mailing list