[cairo] Repainting existing cached similar solid surfaces (was Re: [cairo-commit] 10 commits)
behdad at behdad.org
Thu May 8 11:32:28 PDT 2008
On Wed, 2008-05-07 at 00:22 -0700, Chris Wilson wrote:
> commit 8457374c9cf350841a7c16f1ef1657aeb354e5c9
> Author: Chris Wilson <chris at chris-wilson.co.uk>
> Date: Wed Apr 30 22:03:21 2008 +0100
> [cairo-pattern] Repaint existing cached similar solid surfaces.
> The current solid surface cache returns an existing similar surface only
> if it is an exact match for the desired colour. This gives a high hit
> rate for the original goal of drawing text, but fails when using a lot
> of colours - for example drawing a pie-chart, the mosaic perf case, or
> browsing the web. So instead of creating a new surface from scratch we
> can repaint an existing one, providing that we have sufficient surfaces
> already cached, i.e. if we are going to evict a surface, we may as well
> just repaint it.
A *much* simpler approach is to find the surface you are going to evict,
and if it's similar to what you want to create, just shortcircuit and
reuse it. You current code limits caches for each format to a fourth of
the cache size if the cache is already full. That's not necessarily a
problem, but the added complexity of that function is. i also
particularly dislike calling is_similar on all cache entries.
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
More information about the cairo