[cairo] [Patch] Surface cache

Jorn Baayen jorn at openedhand.com
Mon Jan 29 08:56:49 PST 2007


Hi,

Last month, Xan xtraced[1] cairo text drawing (using xlib), and noticed
that cairo creates (and afterward destroys) a 1x1 pixmap (a cairo
surface) every time it draws some text. Xft doesn't do this.

Carl and Behdad suggested ways to, like Xft, cache surfaces so as not to
have to recreate them all the time.

As suggested by Carl in the same thread, I first investigated
per-pattern caching of acquired surfaces. This didn't work as patterns
mostly get copied before their surfaces are requested. 

Attached patch adds a simple 16-entry static cache to
_cairo_pattern_acquire_surface_for_solid(). It still needs work, however
this already yields a speedup[2] of 12% when drawing text using GTK+
2.10, exceeding the performance of GTK+ 2.6. Yay!

Comments appreciated,

Jorn

[1]
http://lists.freedesktop.org/archives/cairo/2006-December/008916.html
[2] Compare
http://folks.o-hand.com/jorn/cairo-benchmarks/1.3.12-surface-cache/gtklabel/timewidgets.txt
with
http://folks.o-hand.com/jorn/cairo-benchmarks/1.3.12/gtklabel/timewidgets.txt
and
http://folks.o-hand.com/jorn/cairo-benchmarks/no-cairo/gtklabel/timewidgets.txt


-- 
OpenedHand Ltd.
http://o-hand.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-surface-cache.patch
Type: text/x-patch
Size: 2046 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070129/cdd677ac/cairo-surface-cache.bin


More information about the cairo mailing list