Re: Question with regards to componentAlpha

Keith Packard <[email protected]> Mon, 16 Sep 2002 16:03:30 -0700
Newsgroups gmane.comp.xfree86.render
Message-ID <E17r4tu-0001J7-00@localhost>
Around 16 o'clock on Sep 16, Thomas Roell wrote:

> >  "A Direct PictFormat with zero bits of alpha component is declared to have
> >   alpha == 1 everywhere."
> 
> This is relative to "direct" formats only.

Index formats have alpha as defined in the INDEXVALUE entries in the 
colormap and we just added wording to make the alpha values for pixels not 
present in that mapping defined to be 1.

> > You may advertise both depth 24 and depth 32 windows.
> 
> We opted not to. If youn also support OpenGL, have this additional
> number of visuals bumps up the number from 50 to 100 in our
> environment.

Then you won't have windows which advertise embedded alpha through Render.
That's fine, but it is a limitation.

> Well, it would have worked with other CPUs, where you can explicitely
> specify a set of cachelines to be flushed directly, rather than to
> flush the whole cache.

Yeah, and we all know how popular other CPUs are...

> What is fundamentally wrong with switching from	using
> 
> 	(src.a * mask.b, src.a * mask.g, src.a * mask.r, src.a * mask.a)
> 
> to
> 
> 	(src.b * mask.b, src.g * mask.g, src.r * mask.r, src.a * mask.a)

That conflates the source color with the mask alpha value.  I'd like to be 
able to use black source pixels.  The key is that 'mask' is being 
interpreted as per-channel alpha, not as color values.

Please consider what operation is desired.  The most common is to compute a
per-component alpha value for glyphs and then paint text in an arbitrary
color using those masks.  Each component of 'mask' is treated as an alpha
value which is applied only to that component.  Each component of 'src' is
treated as the component value, only the 'alpha' component is treated as
the alpha value for all four components.  

The intermediate value after the 'IN' operator has four separate alpha
values, one for each component.  Each of these alpha values is computed
from the alpha value of the source and mask -- except that the alpha value 
for the source is only in 'src.a' while the alpha value in the mask is 
per-component, and held in that components representation.  Hence, the 
intermediate alpha values are computed as 'src.a * mask.red', not 'src.red 
* mask.red'

Keith Packard        XFree86 Core Team        HP Cambridge Research Lab