[cairo] Transparent pattern may be wrong
David Reveman
davidr at novell.com
Mon Feb 28 15:43:12 PST 2005
On Mon, 2005-02-28 at 13:43 -0800, Bill Spitzak wrote:
>
> 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.
Wrap mode GL_CLAMP_TO_BORDER and transformation using the texture
matrix.
>
> 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.
Yes, I know it will be double-premultiplied, but even though this might
not be the expected behavior, it's still the correct result for when
using EXTEND_TRANSPARENT. The question is if this unexpected behavior is
such a big problem that we should avoid EXTEND_TRANSPARENT as default? I
don't have enough experience with writing applications that expose this
problem to answer it.
-David
More information about the cairo
mailing list