[cairo] [PATCH] fix bugs 15797 (1.8) and 18632 (master)

Jeff Muizelaar jeff at infidigm.net
Wed Dec 10 14:01:43 PST 2008


On Wed, Dec 10, 2008 at 09:57:10AM +0100, Paolo Bonzini wrote:
> 
> > The reason why cairo-gstate.c does not do the stack-copy is that it
> > incurs significant overhead on renderbench versus plain XRender (and the
> > heap copy that snuck into 1.6 was even more painful for all work loads).
> > If you have any doubts over the lifetime, just make the copy and only
> > worry about if it ever appears on a profile.
> 
> No, I don't think there are any doubt over the lifetime, especially if
> it is pointed out in a comment.

I don't really like trusting third party code to release the object at a
specific time, especially if it has callbacks for destruction.

I plan on applying something like the following patch to trunk.

-Jeff

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 36b0130..61151d4 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -682,13 +682,19 @@ ComputeGradientValue (void *info, const float *in, float *out)
 static CGFunctionRef
 CreateGradientFunction (const cairo_gradient_pattern_t *gpat)
 {
+    cairo_pattern_t *pat;
     float input_value_range[2] = { 0.f, 1.f };
     float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
     CGFunctionCallbacks callbacks = {
 	0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
     };
 
-    return CGFunctionCreate (cairo_pattern_reference (&gpat->base),
+    if (!_cairo_pattern_create_copy (&pat, &gpat->base))
+	/* quartz doesn't deal very well with malloc failing, so there's
+	* not much point in us trying either */
+	return NULL;
+
+    return CGFunctionCreate (pat,
 			     1,
 			     input_value_range,
 			     4,
@@ -702,6 +708,7 @@ CreateRepeatingGradientFunction (cairo_quartz_surface_t *surface,
 				 CGPoint *start, CGPoint *end,
 				 CGAffineTransform matrix)
 {
+    cairo_pattern_t *pat;
     float input_value_range[2];
     float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
     CGFunctionCallbacks callbacks = {
@@ -766,7 +773,12 @@ CreateRepeatingGradientFunction (cairo_quartz_surface_t *surface,
     input_value_range[0] = 0.0 - 1.0 * rep_start;
     input_value_range[1] = 1.0 + 1.0 * rep_end;
 
-    return CGFunctionCreate (cairo_pattern_reference (&gpat->base),
+    if (!_cairo_pattern_create_copy (&pat, &gpat->base))
+	/* quartz doesn't deal very well with malloc failing, so there's
+	 * not much point in us trying either */
+	return NULL;
+
+    return CGFunctionCreate (pat,
 			     1,
 			     input_value_range,
 			     4,


More information about the cairo mailing list