[PATCH] Add cairo_pattern_create_copy to the public API

Mark Vender markv743 at yahoo.co.uk
Fri Mar 2 10:41:50 PST 2012


---
 src/cairo-pattern.c |   32 ++++++++++++++++++++++++++++++++
 src/cairo.h         |    3 +++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index f114ca8..337fe97 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1026,6 +1026,38 @@ cairo_pattern_create_mesh (void)
 }
 
 /**
+ * cairo_pattern_create_copy:
+ * @pattern: a #cairo_pattern_t
+ * 
+ * Creates a copy of @pattern. 
+ * 
+ * Return value: the newly created #cairo_pattern_t if successful, or an 
+ * error pattern in case of no memory. The caller owns the returned
+ * object and should call cairo_pattern_destroy() when finished with
+ * it.
+ *
+ * This function will always return a valid pointer, but if an error
+ * occurred the pattern status will be set to an error. To inspect the
+ * status of a pattern use cairo_pattern_status().
+ *
+ * Since: 1.12
+ */
+cairo_pattern_t *
+cairo_pattern_create_copy (const cairo_pattern_t *pattern)
+{
+    cairo_pattern_t *pattern_out;
+    cairo_status_t status;
+    
+    status = _cairo_pattern_create_copy (&pattern_out, pattern);
+    
+    if (unlikely (status)) {
+        // error has already been accounted for in _cairo_pattern_create_copy
+        return (cairo_pattern_t *) &_cairo_pattern_nil;
+    }
+    return pattern_out;
+}
+
+/**
  * cairo_pattern_reference:
  * @pattern: a #cairo_pattern_t
  *
diff --git a/src/cairo.h b/src/cairo.h
index d23cd10..0d6a337 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2644,6 +2644,9 @@ cairo_public cairo_pattern_t *
 cairo_pattern_create_mesh (void);
 
 cairo_public cairo_pattern_t *
+cairo_pattern_create_copy (const cairo_pattern_t *pattern);
+
+cairo_public cairo_pattern_t *
 cairo_pattern_reference (cairo_pattern_t *pattern);
 
 cairo_public void
-- 
1.7.9


--------------010209030302060302090902--


More information about the cairo mailing list