mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 23:28:07 +02:00
[cairo-pattern] Don't cache fallback surfaces
_cairo_surface_create_similar_solid() may return an image surface, should the backend not support the required content or should it encounter an error whilst creating the surface. In those circumstances we choose not to cache the fallback surface.
This commit is contained in:
parent
a8c8e17d84
commit
056d149212
1 changed files with 7 additions and 1 deletions
|
|
@ -1318,7 +1318,12 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t *pattern,
|
|||
goto UNLOCK;
|
||||
}
|
||||
|
||||
assert (_cairo_surface_is_similar (surface, dst, pattern->content));
|
||||
if (! _cairo_surface_is_similar (surface, dst, pattern->content)) {
|
||||
/* in the rare event of a substitute surface being returned (e.g.
|
||||
* malloc failure) don't cache the fallback surface */
|
||||
*out = surface;
|
||||
goto NOCACHE;
|
||||
}
|
||||
|
||||
/* Cache new */
|
||||
if (solid_surface_cache.size < MAX_SURFACE_CACHE_SIZE) {
|
||||
|
|
@ -1336,6 +1341,7 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t *pattern,
|
|||
DONE:
|
||||
*out = cairo_surface_reference (solid_surface_cache.cache[i].surface);
|
||||
|
||||
NOCACHE:
|
||||
attribs->x_offset = attribs->y_offset = 0;
|
||||
cairo_matrix_init_identity (&attribs->matrix);
|
||||
attribs->extend = CAIRO_EXTEND_REPEAT;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue