[cairo] cairo-xlib patch to release glyph surfaces
behdad at behdad.org
Wed Oct 17 15:57:34 PDT 2007
I'd like to commit the attached patch to cairo-xlib that makes it
release glyph surface after uploading it to the X surface iff the
surface didn't exist in the cache before we asked for it.
The reasoning is that right now, applications render glyphs to images,
upload it to the X server, and keep a local copy in the cache. The X
server works hard to reuse glyph renderings, by hashing glyph images and
reusing them. So we are wasting memory in cairo apps that don't use the
glyph surface after uploading to the server, which is the case if you
don't use the glyph in an image surface. The patch does not release the
glyph surface if it already existed in the cache, so, worst case
scenario is that we render the glyph twice, if you first use it with
xlib, then with image surface. That effect should be negligible.
As a result of the change, it now upload empty 1x1 images to the server
for glyphs that have zero width or height. We previously used to skip
such glyphs at the beginning of a glyph run to work around an X server
bug. The new workaround should be as safe (and safer in fact). Review
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6273 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071017/24f60245/attachment-0001.bin
More information about the cairo