diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-21 15:04:47 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-01-29 10:10:39 +0000 |
commit | aaec63d48386ec825cd4d6e67b6adf7c5fd3b167 (patch) | |
tree | 6b13aa509a009acd55c7e4a15b0ff6fd45f0012d /src/cairo-scaled-font-private.h | |
parent | 54f6a49ebb18cf396823d0d70b95e4e264142171 (diff) | |
download | cairo-aaec63d48386ec825cd4d6e67b6adf7c5fd3b167.tar.gz |
[scaled-font] Global glyph cache
Currently glyphs are cached independently in each font i.e. each font
maintains a cache of up to 256 glyphs, and there can be as many scaled fonts
in use as the application needs and references (we maintain a holdover
cache of 512 scaled fonts as well).
Alternatively, as in this patch, we can maintain a global pool of glyphs
split between all open fonts. This allows a heavily used individual font
to cache more glyphs than we could allow if we used per-font glyph caches,
but at the same time maintains fairness across all fonts (by using random
replacement) and provides a cap on the maximum number of global glyphs.
The glyphs are allocated in pages, which are cached in the global pool.
Using pages means we can exploit spatial locality within the font
(nearby indices are typically used in clusters) to reduce frequency of small
allocations and allow the scaled font to reserve a single MRU page of
glyphs. This caching dramatically reduces the cairo overhead during the
cairo-perf benchmarks, and drastically reduces the number of allocations
made by the application (for example browsing multi-lingual site with
firefox).
Diffstat (limited to 'src/cairo-scaled-font-private.h')
-rw-r--r-- | src/cairo-scaled-font-private.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cairo-scaled-font-private.h b/src/cairo-scaled-font-private.h index 86a50bbbd..13d89ebe5 100644 --- a/src/cairo-scaled-font-private.h +++ b/src/cairo-scaled-font-private.h @@ -44,6 +44,8 @@ #include "cairo-mutex-type-private.h" #include "cairo-reference-count-private.h" +typedef struct _cairo_scaled_glyph_page cairo_scaled_glyph_page_t; + struct _cairo_scaled_font { /* For most cairo objects, the rule for multiple threads is that * the user is responsible for any locking if the same object is @@ -75,7 +77,6 @@ struct _cairo_scaled_font { * scaled_font->mutex in the generic scaled_font code. */ - /* must be first to be stored in a hash table */ cairo_hash_entry_t hash_entry; /* useful bits for _cairo_scaled_font_nil */ @@ -103,7 +104,8 @@ struct _cairo_scaled_font { /* The mutex protects modification to all subsequent fields. */ cairo_mutex_t mutex; - cairo_cache_t *glyphs; /* glyph index -> cairo_scaled_glyph_t */ + int cache_frozen; + cairo_scaled_glyph_page_t *mru_page; /* * One surface backend may store data in each glyph. |