[cairo] Redoing the xlib surface constructors
Keith Packard
keithp at keithp.com
Sat Mar 12 08:43:19 PST 2005
Around 10 o'clock on Mar 12, Owen Taylor wrote:
> Now, RENDER really doesn't handle monochrome drawing at all, whether
> indexed or not. It's all tied to three-channel colors. RENDER doesn't
> have any provisions for direct-color visuals. And RENDER's handling
> of pseudocolor is crude, at best.
Render handles indexed visuals (i.e. StaticGray, GrayScale, StaticColor
and PseudoColor) by treating them all the same. For GrayScale and Pseudo
Color, it allocates a fixed set of colors within the default colormap, you
can even query what those colors are. With that in place, all of these
visuals become easy enough to manage -- just match the nearest color for
each pixel generated and lookup each pixel in the colormap. There are
caches in both directions making performance acceptable.
The Render spec includes dithering, so applications could choose which
parts of the output would be dithered. But, no-one has bothered to
implement that part of the spec, and I'm not sure it will ever happen.
I briefly considered allowing users to specify which colors should be used
for rendering, but discarded that notion as it would make sharing colors
between windows much harder (note that the ICCCM 'standard colormaps'
notion never took hold) and would require significant changes in the
color->pixel code which uses the wide spacing of colors in the fixed
Render map to reduce the precision needed within a precomputed table.
> I thought about mentioning it in my mail. I have the colormap in the
> constructors, but as currently, I don't actually use it. Colormaps
> are basically useful only for gray-scale (*), pseudo-color, and
> direct-color visuals.
When Render is present, the colormaps are never necessary -- applications
must use the colormap specified in the PictFormat.
The only question is what should be done for these visuals on X servers
without Render. Here's what I suggest:
StaticColor/StaticGray: When the default visual, just use the default
colormap.
When not the default visual, just create a
colormap, query the colors and free it.
PseudoColor/GrayScale: When the default visual, develop a protocol
for allocating a reasonable color cube such
that it can be shared.
When not the default visual, create a
colormap and fill it in with a known color cube.
This will cause flashing in some cases, but
multiple cairo applications will all use
the same colormap contents.
DirectColor: Don't support. I've never seen an X server
advertise support for this without also
supporting TrueColor.
For all of these cases, there isn't a huge amount of code to write as the
existing X server render implementation should suffice for everything
except the Xlib interface.
Note: StaticColor and StaticGray colors are per-visual, not per-colormap,
so creating another colormap is a fine way to find out what the colors in
that visual are.
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050312/fc06ef68/attachment.pgp
More information about the cairo
mailing list