[cairo] Re: cairo internal design ideas
graydon at redhat.com
Tue Sep 21 04:39:49 PDT 2004
On Tue, 21 Sep 2004 12:56:21 +0200, David Reveman <c99drn at cs.umu.se> wrote:
> The reason to why I'd like a different backend function for glyphs is
> that this would allow surface backends to ask a font backend for a
> specific representation of the glyphs. Possible scenario: a font backend
> could be able to provide three different glyph list representations, a
> list of image masks (would provide rendering to all types of surfaces),
> XGlyphElt's for use with XRender and some glyph list that a native win32
> surface backend could use.
I am part way through a patch (this week) which does something like this. so
on the glyph front I agree with your suggestion. I haven't worked on the
vertex / trap code much so I don't know the issues. my patch is more or less
as follows (deriving from a conversation keithp and I had on friday):
- a generic glyph cache object type is added, which maps glyph keys
([font,matrix,glyph] tuples) to void* and performs resource and
lifecycle management for the entries. caches are parameterized by
some constructor and destructor functions.
- surfaces own glyph caches, not fonts, and generally all surfaces using
a given backend share one (or a small number) of such caches. in the
case of xlib, there is one cache per display; the cache corresponds to
a GlyphSet and holds [XGlyphInfo,Glyph] pairs.
- glyph caches hold references to fonts in their entries. fonts thus die
when users drop all references *and* all cache entries are flushed.
- there is a "global" glyph cache which stores an entry type that contains
cairo_image_surface_t objects and metrics, from which any backend can
pick up glyph images and metrics. fonts are responsible for filling in
the global glyph image cache, and indeed fonts make *requests* against
the global glyph image cache in order to recalculate their metrics, when
asked (in a surface-independent way).
the hope is to get this working in a manner similar to Xft. we'll see how
close is possible.
More information about the cairo