[cairo] [PATCH] Clean up Quartz gradient code by moving some local variables to static const globals.
Jeff Muizelaar
jeff at infidigm.net
Thu May 6 19:22:16 PDT 2010
commit ecaddc2ef9bef0737698115374cf622d0ebbdbd6
Author: Robert O'Callahan <robert at ocallahan.org>
Date: Tue Sep 8 13:18:02 2009 -0400
Clean up Quartz gradient code by moving some local variables to
static const globals.
From https://bugzilla.mozilla.org/show_bug.cgi?id=508730
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index ba34763..bba466f 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -794,15 +794,18 @@ ComputeGradientValue (void *info,
}
}
+static const cairo_quartz_float_t gradient_output_value_ranges[8] = {
+ 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f
+};
+static const CGFunctionCallbacks gradient_callbacks = {
+ 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback)
cairo_pattern_destroy
+};
+
static CGFunctionRef
CreateGradientFunction (const cairo_gradient_pattern_t *gpat)
{
cairo_pattern_t *pat;
cairo_quartz_float_t input_value_range[2] = { 0.f, 1.f };
- cairo_quartz_float_t 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
- };
if (_cairo_pattern_create_copy (&pat, &gpat->base))
/* quartz doesn't deal very well with malloc failing, so there's
@@ -813,8 +816,8 @@ CreateGradientFunction (const
cairo_gradient_pattern_t *gpat)
1,
input_value_range,
4,
- output_value_ranges,
- &callbacks);
+ gradient_output_value_ranges,
+ &gradient_callbacks);
}
static CGFunctionRef
@@ -825,10 +828,6 @@ CreateRepeatingLinearGradientFunction
(cairo_quartz_surface_t *surface,
{
cairo_pattern_t *pat;
cairo_quartz_float_t input_value_range[2];
- cairo_quartz_float_t 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
- };
CGPoint mstart, mend;
@@ -897,8 +896,8 @@ CreateRepeatingLinearGradientFunction
(cairo_quartz_surface_t *surface,
1,
input_value_range,
4,
- output_value_ranges,
- &callbacks);
+ gradient_output_value_ranges,
+ &gradient_callbacks);
}
static void
@@ -957,10 +956,6 @@ CreateRepeatingRadialGradientFunction
(cairo_quartz_surface_t *surface,
CGAffineTransform transform;
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 = {
- 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback)
cairo_pattern_destroy
- };
CGPoint *inner;
double *inner_radius;
CGPoint *outer;
@@ -1037,8 +1032,8 @@ CreateRepeatingRadialGradientFunction
(cairo_quartz_surface_t *surface,
1,
input_value_range,
4,
- output_value_ranges,
- &callbacks);
+ gradient_output_value_ranges,
+ &gradient_callbacks);
}
/* Obtain a CGImageRef from a #cairo_surface_t * */
More information about the cairo
mailing list