[cairo-commit] src/cairo-clip.c src/cairo-glitz-surface.c
src/cairoint.h src/cairo-pattern.c src/cairo-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Apr 19 03:57:29 PDT 2007
src/cairo-clip.c | 3 ++-
src/cairo-glitz-surface.c | 3 ++-
src/cairo-pattern.c | 3 ++-
src/cairo-surface.c | 24 +++++++++++++++---------
src/cairoint.h | 6 +++++-
5 files changed, 26 insertions(+), 13 deletions(-)
New commits:
diff-tree 41c6eebcd1fab94fd3a91d09f1ef6ee0d8c7a044 (from ef60e7c65144edd1aa14757b269f2c196df732a2)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Apr 19 11:56:15 2007 +0100
Optionally provide a pattern to use for creating a similar solid surface.
_cairo_surface_create_similar_solid() creates a fresh pattern to wrap
color, however sometimes the caller already has that pattern available.
In those circumstances we can pass the pattern as well as the color and
avoid the extra allocation.
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 6e52ab2..bce6117 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -404,7 +404,8 @@ _cairo_clip_intersect_mask (cairo_clip_t
CAIRO_CONTENT_ALPHA,
surface_rect.width,
surface_rect.height,
- CAIRO_COLOR_WHITE);
+ CAIRO_COLOR_WHITE,
+ NULL);
if (surface->status)
return CAIRO_STATUS_NO_MEMORY;
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index f8207e7..cfebc32 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -1002,7 +1002,8 @@ _cairo_glitz_surface_fill_rectangles (vo
_cairo_surface_create_similar_solid (&dst->base,
CAIRO_CONTENT_COLOR_ALPHA,
1, 1,
- (cairo_color_t *) color);
+ (cairo_color_t *) color,
+ NULL);
if (src->base.status)
return CAIRO_STATUS_NO_MEMORY;
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 2bc893e..e29778d 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1250,7 +1250,8 @@ _cairo_pattern_acquire_surface_for_solid
CAIRO_CONTENT_COLOR :
CAIRO_CONTENT_COLOR_ALPHA,
1, 1,
- &pattern->color);
+ &pattern->color,
+ &pattern->base);
if ((*out)->status)
return CAIRO_STATUS_NO_MEMORY;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index efd1936..1049964 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -288,7 +288,8 @@ cairo_surface_create_similar (cairo_surf
return _cairo_surface_create_similar_solid (other, content,
width, height,
- CAIRO_COLOR_TRANSPARENT);
+ CAIRO_COLOR_TRANSPARENT,
+ NULL);
}
slim_hidden_def (cairo_surface_create_similar);
@@ -297,7 +298,8 @@ _cairo_surface_create_similar_solid (cai
cairo_content_t content,
int width,
int height,
- const cairo_color_t *color)
+ const cairo_color_t *color,
+ cairo_pattern_t *pattern)
{
cairo_status_t status;
cairo_surface_t *surface;
@@ -310,19 +312,23 @@ _cairo_surface_create_similar_solid (cai
return (cairo_surface_t*) &_cairo_surface_nil;
}
- source = _cairo_pattern_create_solid (color);
- if (source->status) {
- cairo_surface_destroy (surface);
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return (cairo_surface_t*) &_cairo_surface_nil;
- }
+ if (pattern == NULL) {
+ source = _cairo_pattern_create_solid (color);
+ if (source->status) {
+ cairo_surface_destroy (surface);
+ _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ return (cairo_surface_t*) &_cairo_surface_nil;
+ }
+ } else
+ source = pattern;
status = _cairo_surface_paint (surface,
color == CAIRO_COLOR_TRANSPARENT ?
CAIRO_OPERATOR_CLEAR :
CAIRO_OPERATOR_SOURCE, source);
- cairo_pattern_destroy (source);
+ if (source != pattern)
+ cairo_pattern_destroy (source);
if (status) {
cairo_surface_destroy (surface);
diff --git a/src/cairoint.h b/src/cairoint.h
index 2a3ff01..76397e2 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1851,12 +1851,16 @@ _cairo_surface_create_similar_scratch (c
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);
+ const cairo_color_t *color,
+ cairo_pattern_t *color_pattern);
cairo_private void
_cairo_surface_init (cairo_surface_t *surface,
More information about the cairo-commit
mailing list