summaryrefslogtreecommitdiff
path: root/src/cairo-mutex-list-private.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-05-02 10:00:22 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-05-04 14:29:38 +0100
commita8c8e17d845c7060286dac58b553fb717b270788 (patch)
treefd7da623d081cdd6e675d441725ef37c26fa242e /src/cairo-mutex-list-private.h
parent52472b740e821dee444ede1fff041a99d344daab (diff)
downloadcairo-a8c8e17d845c7060286dac58b553fb717b270788.tar.gz
[cairo-pattern] Cache surface for solid patterns
Original work by Jorn Baayen <jorn@openedhand.com>, 2715f2098127d04d2f9e304580a26cd0842c0e64 We use a small cache of size 16 for surfaces created for solid patterns. This mainly helps with the X backends where we don't have to create a pattern for every operation, so we save a lot on X traffic. Xft uses a similar cache, so cairo's text rendering traffic with the xlib backend now completely matches that of Xft. The cache uses an static index variable, which itself acts like a cache of size 1, remembering the most recently used solid pattern. So repeated lookups for the same pattern hit immediately. If that fails, the cache is searched linearly, and if that fails too, a new surface is created and a random member of the cache is evicted. A cached surface can only be reused if it is similar to the destination. In order to check for similar surfaces a new test is introduced for the backends to determine that the cached surface is as would be returned by a _create_similar() call for the destination and content. As surfaces are in general complex encapsulation of graphics state we only return unshared cached surfaces and reset them (to clear any error conditions and graphics state). In practice this makes little difference to the efficacy of the cache during various benchmarks. However, in order to transparently share solid surfaces it would be possible to implement a COW scheme. Cache hit rates: (hit same index + hit in cache) / lookups cairo-perf: (42346 + 28480) / 159600 = 44.38% gtk-theme-torturer: (3023 + 3502) / 6528 = 99.95% gtk-perf: (8270 + 3190) / 21504 = 53.29% This translates into a reduction of about 25% of the XRENDER traffic during cairo-perf.
Diffstat (limited to 'src/cairo-mutex-list-private.h')
-rw-r--r--src/cairo-mutex-list-private.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cairo-mutex-list-private.h b/src/cairo-mutex-list-private.h
index 37378310e..abb4a9a3d 100644
--- a/src/cairo-mutex-list-private.h
+++ b/src/cairo-mutex-list-private.h
@@ -32,7 +32,8 @@
*/
-CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_cache_lock);
+CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_pattern_cache_lock);
+CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_surface_cache_lock);
CAIRO_MUTEX_DECLARE (_cairo_font_face_mutex);
CAIRO_MUTEX_DECLARE (_cairo_scaled_font_map_mutex);