2D antialiased graphics using OpenGL

Keith Packard keithp@keithp.com
Thu, 11 Dec 2003 16:15:17 -0800


Around 21 o'clock on Dec 11, "Martijn Sipkema" wrote:

> If other than the normal compositing is to be provided then this would
> still mean rendering to the auxiliary buffer first, since the fundamental
> object is not a triangle, but the stroked/filled path. Am I understanding
> this correctly?

The fundemental object in cairo is the path; how that is atomically 
applied to the underlying surface is a detail of the specific backend.  
It's possible to compute coverage from the path object itself (that's how 
libart works), but Render uses an intermediate alpha channel to hold the 
data because it's a lot simpler to just draw polygons.

> But how can one do compositing when gamma is not 1? AFAIK graphics
> hardware expects a framebuffer with a gamma of 1, i.e. a smooth shading
> will not render gamma corrected in hardware, right?

You would convert from frame buffer values to linear intensity, composite,
then convert back.  I've heard rumors of hardware that does this, but I 
haven't yet figured out how to integrate this into Render.  So, for now, 
we ignore the distinction and generate inaccurate results.  The worst of 
these is plainly visible when using light text on a dark background.

> I'd rather have convenient, fast rendering and suffer slightly worse
> resolution in some color range.

Remember that in 2D graphics land, the number of computed pixels is far 
outweighed by the number of precomputed pixels (from static images), and 
that those images almost universally assume a non-linear gamma.  So, we've 
got the choice of converting the bulk data back to linear values, or 
getting slightly inaccurate anti-aliasing results.

> If 8 bit per channel is not enough, then the hardware should provide more.
> OpenGL rendering clearly expects a gamma == 1 framebuffer I think...

It would be nice to see deeper frame buffers; I made sure that Render 
could describe 16 bit channels, which is probably sufficient, but unlikely 
to become prevalent as hardware vendors move to floating point pixels 
instead of deeper integer valeus.   That will take some modification of 
Render and the core drawing code, but it can be done in a backward 
compatible fashion.

I don't know what GL expects, but I know that I've run it only on gamma >> 
1 displays...

-keith