summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2011-07-06 15:14:55 +0200
committerAndrea Canciani <ranma42@gmail.com>2011-07-08 11:14:16 +0200
commit9374cf0a9730843881043c39ab4c6f6d31af7cce (patch)
treed3b5e7ed968ab05e894fecc6bba9f3291bf65279
parentd7cc30eb0112010533d05b4579a12e7a2910b08d (diff)
pattern: Implement _rgb functions as wrappers over _rgba functions
cairo_pattern_create_rgb() and cairo_pattern_add_color_stop_rgb() implement the same logic as cairo_pattern_create_rgba() and cairo_pattern_add_color_stop_rgba() with an alpha == 1.0. Instead of duplicating the code, they can simply call into the more general functions.
-rw-r--r--src/cairo-pattern.c31
-rw-r--r--src/cairoint.h1
2 files changed, 4 insertions, 28 deletions
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 1e9326d3..7fab4f33 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -587,17 +587,7 @@ _cairo_pattern_create_in_error (cairo_status_t status)
cairo_pattern_t *
cairo_pattern_create_rgb (double red, double green, double blue)
{
- cairo_color_t color;
-
- red = _cairo_restrict_value (red, 0.0, 1.0);
- green = _cairo_restrict_value (green, 0.0, 1.0);
- blue = _cairo_restrict_value (blue, 0.0, 1.0);
-
- _cairo_color_init_rgb (&color, red, green, blue);
-
- CAIRO_MUTEX_INITIALIZE ();
-
- return _cairo_pattern_create_solid (&color);
+ return cairo_pattern_create_rgba (red, green, blue, 1.0);
}
slim_hidden_def (cairo_pattern_create_rgb);
@@ -1821,23 +1811,7 @@ cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern,
double green,
double blue)
{
- if (pattern->status)
- return;
-
- if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR &&
- pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
- {
- _cairo_pattern_set_error (pattern, CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
- return;
- }
-
- offset = _cairo_restrict_value (offset, 0.0, 1.0);
- red = _cairo_restrict_value (red, 0.0, 1.0);
- green = _cairo_restrict_value (green, 0.0, 1.0);
- blue = _cairo_restrict_value (blue, 0.0, 1.0);
-
- _cairo_pattern_add_color_stop ((cairo_gradient_pattern_t *) pattern,
- offset, red, green, blue, 1.0);
+ cairo_pattern_add_color_stop_rgba (pattern, offset, red, green, blue, 1.0);
}
/**
@@ -1894,6 +1868,7 @@ cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern,
_cairo_pattern_add_color_stop ((cairo_gradient_pattern_t *) pattern,
offset, red, green, blue, alpha);
}
+slim_hidden_def (cairo_pattern_add_color_stop_rgba);
/**
* cairo_pattern_set_matrix:
diff --git a/src/cairoint.h b/src/cairoint.h
index 424457f1..121676ca 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2438,6 +2438,7 @@ slim_hidden_proto (cairo_matrix_translate);
slim_hidden_proto (cairo_move_to);
slim_hidden_proto (cairo_new_path);
slim_hidden_proto (cairo_paint);
+slim_hidden_proto (cairo_pattern_add_color_stop_rgba);
slim_hidden_proto (cairo_pattern_create_for_surface);
slim_hidden_proto (cairo_pattern_create_rgb);
slim_hidden_proto (cairo_pattern_create_rgba);