[cairo] Repainting existing cached similar solid surfaces (was Re: [cairo-commit] 10 commits)

Chris Wilson chris at chris-wilson.co.uk
Thu May 8 06:00:40 PDT 2008

On Thu, 2008-05-08 at 14:32 -0400, Behdad Esfahbod wrote:
> 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.

Yes, I also worried what the effect of imposing the one-quarter limit
would be. I guess one-half would have been a better limit, given that
one would expect only a couple of backends to be in the cache
simultaneously. However, simply repainting the evicted surface will
simplify the code and allow the cache to be shared naturally. A much
more elegant solution, thanks!
Chris Wilson

More information about the cairo mailing list