summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-06-19 21:06:07 -0400
committerBehdad Esfahbod <behdad@behdad.org>2008-06-19 21:06:07 -0400
commitff1371a0a7494f986385730a82823cbf56790d5b (patch)
treed4e0ac9818bd745b9a007f98695dcba66019c7ad
parent240cb59fe8706b1b0d3aae4a4ed3d13472033d1d (diff)
[cairo-surface] Remove optional pattern argument from create_similar_solid()
This was added in 41c6eebcd1fab94fd3a91d09f1ef6ee0d8c7a044, 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.
-rw-r--r--src/cairo-clip.c3
-rw-r--r--src/cairo-glitz-surface.c3
-rw-r--r--src/cairo-pattern.c3
-rw-r--r--src/cairo-surface.c24
-rw-r--r--src/cairoint.h6
5 files changed, 11 insertions, 28 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 3cee39863..8a7c98a34 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -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;
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 83e3e2080..d067e28b6 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -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;
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 0ac047c82..7c942650c 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -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;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index b3e457bd3..f5112d609 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -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);
diff --git a/src/cairoint.h b/src/cairoint.h
index fe58ff848..e1451ab8b 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -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,