[cairo] Static caches and thread-safety

Carl Worth cworth at cworth.org
Fri Nov 12 08:08:38 PST 2004


On Fri, 12 Nov 2004 10:51:11 -0500, Keith Packard wrote:
> The use of FreeType and the Render extension to draw fonts on the screen is
> unique in the X environment; that is the combination for which sharing the 
> results of rasterization will most visibly affect the usability of the 
> library.

OK, so there are current 4 different static caches in the font code:

	cairo_font.c:
		_global_font_cache
		_global_image_glyph_cache

	cairo_ft_font.c:
		_global_ft_cache

	cairo_xlib_surface.c:
		_xlib_glyphset_caches

Which of these are necessary for that "most visible effect" ? Just the
xlib_glyphset stuff ? or the global_ft cache as well?

> I think it should be relatively easy to structure the font cache code so 
> that on systems with viable locking primitives we use a shared cache and 
> on other systems we use a per-cairo_t cache.

I'm inclined to move the generic caches to be per-cairo_t now and wait
for compelling reasons to do something more clever.

In addition to static and per-cairo_t caches, another option is a cached
shared between cairo_t objects that were all cloned from a common
root. Doing this kind of thing rather than sharing based on a static
cache would address the problem Bill pointed out on some systems of
missing static initializers for mutual exclusion primitives.

-Carl




More information about the cairo mailing list