diff options
author | Chris Wilson <chris at chris-wilson.co.uk> | 2007-03-13 22:51:12 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2007-03-20 18:21:53 -0400 |
commit | 9b53bc7c6585db7ae647bb992fb9817d7bd75b38 (patch) | |
tree | 6c1d82676d71b82dbdc970cd59c4239ca2294961 /src/cairo-color.c | |
parent | 39679b1b21b07b0fbc05ee21745f384a123ba8da (diff) |
Cache solid patterns
We use a small cache of size 16 for patterns created from solid colors,
e.g. cairo_set_source_rgb(). This helps with toolkits that draw many
widgets using the same colour scheme.
The cache uses a static index variable, which itself acts like a cache
of size 1, remembering the most recently used colour. So repeated
lookups for the same colour hit immediately. If that fails, the cache
is searched linearly, and if that fails too, a new pattern is created
and a random member of the cache is evicted.
Diffstat (limited to 'src/cairo-color.c')
-rw-r--r-- | src/cairo-color.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cairo-color.c b/src/cairo-color.c index ad6316e1..257f8d26 100644 --- a/src/cairo-color.c +++ b/src/cairo-color.c @@ -160,3 +160,10 @@ _cairo_color_get_rgba_premultiplied (cairo_color_t *color, *blue = color->blue * color->alpha; *alpha = color->alpha; } + +cairo_bool_t +_cairo_color_equal (const cairo_color_t *color_a, + const cairo_color_t *color_b) +{ + return memcmp (color_a, color_b, sizeof (cairo_color_t)) == 0; +} |