mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 21:08:10 +02:00
[cairo-surface] Remove optional pattern argument from create_similar_solid()
This was added in 41c6eebcd1, to avoid
allocating short-lived patterns. However, this was error prune as the
color information was duplicated in the pattern and could get out of
sync. Indeed, it was out of sync before this commit in the call from
cairo-clip.c.
By allocating the solid pattern on the stack we fix the original problem
without creating new ones.
This commit is contained in:
parent
240cb59fe8
commit
ff1371a0a7
5 changed files with 11 additions and 28 deletions
|
|
@ -485,8 +485,7 @@ _cairo_clip_intersect_mask (cairo_clip_t *clip,
|
|||
CAIRO_CONTENT_ALPHA,
|
||||
surface_rect.width,
|
||||
surface_rect.height,
|
||||
CAIRO_COLOR_TRANSPARENT,
|
||||
&pattern.base);
|
||||
CAIRO_COLOR_TRANSPARENT);
|
||||
if (surface->status) {
|
||||
_cairo_pattern_fini (&pattern.base);
|
||||
return surface->status;
|
||||
|
|
|
|||
|
|
@ -1161,8 +1161,7 @@ _cairo_glitz_surface_fill_rectangles (void *abstract_dst,
|
|||
_cairo_surface_create_similar_solid (&dst->base,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
1, 1,
|
||||
(cairo_color_t *) color,
|
||||
NULL);
|
||||
(cairo_color_t *) color);
|
||||
if (src->base.status)
|
||||
return src->base.status;
|
||||
|
||||
|
|
|
|||
|
|
@ -1488,8 +1488,7 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t *pattern,
|
|||
surface = _cairo_surface_create_similar_solid (dst,
|
||||
pattern->content,
|
||||
1, 1,
|
||||
&pattern->color,
|
||||
&pattern->base);
|
||||
&pattern->color);
|
||||
if (surface->status) {
|
||||
status = surface->status;
|
||||
goto UNLOCK;
|
||||
|
|
|
|||
|
|
@ -301,8 +301,7 @@ cairo_surface_create_similar (cairo_surface_t *other,
|
|||
|
||||
return _cairo_surface_create_similar_solid (other, content,
|
||||
width, height,
|
||||
CAIRO_COLOR_TRANSPARENT,
|
||||
NULL);
|
||||
CAIRO_COLOR_TRANSPARENT);
|
||||
}
|
||||
slim_hidden_def (cairo_surface_create_similar);
|
||||
|
||||
|
|
@ -311,34 +310,25 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other,
|
|||
cairo_content_t content,
|
||||
int width,
|
||||
int height,
|
||||
const cairo_color_t *color,
|
||||
cairo_pattern_t *pattern)
|
||||
const cairo_color_t *color)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_surface_t *surface;
|
||||
cairo_pattern_t *source;
|
||||
cairo_solid_pattern_t solid_pattern;
|
||||
|
||||
surface = _cairo_surface_create_similar_scratch (other, content,
|
||||
width, height);
|
||||
if (surface->status)
|
||||
return surface;
|
||||
|
||||
if (pattern == NULL) {
|
||||
source = _cairo_pattern_create_solid (color, content);
|
||||
if (source->status) {
|
||||
cairo_surface_destroy (surface);
|
||||
return _cairo_surface_create_in_error (source->status);
|
||||
}
|
||||
} else
|
||||
source = pattern;
|
||||
_cairo_pattern_init_solid (&solid_pattern, color, content);
|
||||
|
||||
status = _cairo_surface_paint (surface,
|
||||
color == CAIRO_COLOR_TRANSPARENT ?
|
||||
CAIRO_OPERATOR_CLEAR :
|
||||
CAIRO_OPERATOR_SOURCE, source);
|
||||
CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_SOURCE,
|
||||
&solid_pattern.base);
|
||||
|
||||
if (source != pattern)
|
||||
cairo_pattern_destroy (source);
|
||||
_cairo_pattern_fini (&solid_pattern.base);
|
||||
|
||||
if (status) {
|
||||
cairo_surface_destroy (surface);
|
||||
|
|
|
|||
|
|
@ -1603,16 +1603,12 @@ _cairo_surface_create_similar_scratch (cairo_surface_t *other,
|
|||
int width,
|
||||
int height);
|
||||
|
||||
/* Note: the color_pattern argument is optional - if provided it will reuse
|
||||
* that pattern instead of creating a very short-lived fresh solid pattern
|
||||
*/
|
||||
cairo_private cairo_surface_t *
|
||||
_cairo_surface_create_similar_solid (cairo_surface_t *other,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height,
|
||||
const cairo_color_t *color,
|
||||
cairo_pattern_t *color_pattern);
|
||||
const cairo_color_t *color);
|
||||
|
||||
cairo_private void
|
||||
_cairo_surface_init (cairo_surface_t *surface,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue