michael@0: # HG changeset patch michael@0: # User Robert O'Callahan michael@0: # Date 1249558626 -43200 michael@0: # Node ID 963b9451ad305924738d05d997a640698cd3af91 michael@0: # Parent e564f3ab4ea6e3b5dd9c4e9e6042d3a84c229dde michael@0: Bug 508730. Clean up Quartz gradient code by moving some local variables to static const globals. r=jmuizelaar michael@0: michael@0: diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c michael@0: --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c michael@0: +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c michael@0: @@ -684,51 +684,50 @@ ComputeGradientValue (void *info, const michael@0: grad->stops[i-1].color.blue * ap + michael@0: grad->stops[i].color.blue * bp; michael@0: out[3] = michael@0: grad->stops[i-1].color.alpha * ap + michael@0: grad->stops[i].color.alpha * bp; michael@0: } michael@0: } michael@0: michael@0: +static const float gradient_output_value_ranges[8] = { michael@0: + 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f michael@0: +}; michael@0: +static const CGFunctionCallbacks gradient_callbacks = { michael@0: + 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy michael@0: +}; michael@0: + michael@0: static CGFunctionRef michael@0: CreateGradientFunction (const cairo_gradient_pattern_t *gpat) michael@0: { michael@0: cairo_pattern_t *pat; michael@0: float input_value_range[2] = { 0.f, 1.f }; michael@0: - float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f }; michael@0: - CGFunctionCallbacks callbacks = { michael@0: - 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy michael@0: - }; michael@0: michael@0: if (_cairo_pattern_create_copy (&pat, &gpat->base)) michael@0: /* quartz doesn't deal very well with malloc failing, so there's michael@0: * not much point in us trying either */ michael@0: return NULL; michael@0: michael@0: return CGFunctionCreate (pat, michael@0: 1, michael@0: input_value_range, michael@0: 4, michael@0: - output_value_ranges, michael@0: - &callbacks); michael@0: + gradient_output_value_ranges, michael@0: + &gradient_callbacks); michael@0: } michael@0: michael@0: static CGFunctionRef michael@0: CreateRepeatingLinearGradientFunction (cairo_quartz_surface_t *surface, michael@0: const cairo_gradient_pattern_t *gpat, michael@0: CGPoint *start, CGPoint *end, michael@0: CGAffineTransform matrix) michael@0: { michael@0: cairo_pattern_t *pat; michael@0: float input_value_range[2]; michael@0: - float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f }; michael@0: - CGFunctionCallbacks callbacks = { michael@0: - 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy michael@0: - }; michael@0: michael@0: CGPoint mstart, mend; michael@0: michael@0: double dx, dy; michael@0: int x_rep_start = 0, x_rep_end = 0; michael@0: int y_rep_start = 0, y_rep_end = 0; michael@0: michael@0: int rep_start, rep_end; michael@0: @@ -787,18 +786,18 @@ CreateRepeatingLinearGradientFunction (c michael@0: /* quartz doesn't deal very well with malloc failing, so there's michael@0: * not much point in us trying either */ michael@0: return NULL; michael@0: michael@0: return CGFunctionCreate (pat, michael@0: 1, michael@0: input_value_range, michael@0: 4, michael@0: - output_value_ranges, michael@0: - &callbacks); michael@0: + gradient_output_value_ranges, michael@0: + &gradient_callbacks); michael@0: } michael@0: michael@0: static void michael@0: UpdateRadialParameterToIncludePoint(double *max_t, CGPoint *center, michael@0: double dr, double dx, double dy, michael@0: double x, double y) michael@0: { michael@0: /* Compute a parameter t such that a circle centered at michael@0: @@ -847,20 +846,16 @@ CreateRepeatingRadialGradientFunction (c michael@0: const cairo_gradient_pattern_t *gpat, michael@0: CGPoint *start, double *start_radius, michael@0: CGPoint *end, double *end_radius) michael@0: { michael@0: CGRect clip = CGContextGetClipBoundingBox (surface->cgContext); michael@0: CGAffineTransform transform; michael@0: cairo_pattern_t *pat; michael@0: float input_value_range[2]; michael@0: - float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f }; michael@0: - CGFunctionCallbacks callbacks = { michael@0: - 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy michael@0: - }; michael@0: CGPoint *inner; michael@0: double *inner_radius; michael@0: CGPoint *outer; michael@0: double *outer_radius; michael@0: /* minimum and maximum t-parameter values that will make our gradient michael@0: cover the clipBox */ michael@0: double t_min, t_max, t_temp; michael@0: /* outer minus inner */ michael@0: @@ -927,18 +922,18 @@ CreateRepeatingRadialGradientFunction (c michael@0: /* quartz doesn't deal very well with malloc failing, so there's michael@0: * not much point in us trying either */ michael@0: return NULL; michael@0: michael@0: return CGFunctionCreate (pat, michael@0: 1, michael@0: input_value_range, michael@0: 4, michael@0: - output_value_ranges, michael@0: - &callbacks); michael@0: + gradient_output_value_ranges, michael@0: + &gradient_callbacks); michael@0: } michael@0: michael@0: /* Obtain a CGImageRef from a #cairo_surface_t * */ michael@0: michael@0: static void michael@0: DataProviderReleaseCallback (void *info, const void *data, size_t size) michael@0: { michael@0: cairo_surface_t *surface = (cairo_surface_t *) info;