[cairo] Question about gstate transitions and scaled fonts

Martin Robinson mrobinson at igalia.com
Fri Nov 4 14:20:11 PDT 2011

I noticed recently that when rendering some text with the Cairo GL
backend, I was always getting glyph cache misses from the in-texture
cache. After some tracing I realized the issue was that I had code like

for (...) {

It seems that _cairo_gstate_ensure_scaled_font and
_cairo_gstate_ensure_font_face are only called until after
cairo_save(...). Now it's quite possible to simply copy back the lazily
initialized fonts when they haven't been invalidated by adding a simple
check to _cairo_gstate_restore.

The problem with this is that, judging by the code, scaled fonts are
often invalidated. For instance, translating the CTM will clear the
scaled font completely. Is this necessary to properly handle subpixel
antialiasing or can we avoid clearing the font in this case?

The main problem with texture glyph cache misses in the GL backend is
that they involve uploading a bunch of bitmap data to texture memory,
which carries some overhead. Avoiding it would be great.

It's possible I've completely misunderstood this entire bundle of ideas
though, so feel free to correct me!


More information about the cairo mailing list