gecko/gfx/cairo/quartz-const-globals.patch
Robert O'Callahan f64d147ce2 Add cairo patches for Quartz gradient fixes
--HG--
extra : rebase_source : 7b50d07ec411410c7fda7b8fba423610018fd6cc
2009-08-26 10:05:44 -07:00

135 lines
4.6 KiB
Diff

# HG changeset patch
# User Robert O'Callahan <robert@ocallahan.org>
# Date 1249558626 -43200
# Node ID 963b9451ad305924738d05d997a640698cd3af91
# Parent e564f3ab4ea6e3b5dd9c4e9e6042d3a84c229dde
Bug 508730. Clean up Quartz gradient code by moving some local variables to static const globals. r=jmuizelaar
diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
@@ -684,51 +684,50 @@ ComputeGradientValue (void *info, const
grad->stops[i-1].color.blue * ap +
grad->stops[i].color.blue * bp;
out[3] =
grad->stops[i-1].color.alpha * ap +
grad->stops[i].color.alpha * bp;
}
}
+static const float 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;
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
- };
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,
- output_value_ranges,
- &callbacks);
+ gradient_output_value_ranges,
+ &gradient_callbacks);
}
static CGFunctionRef
CreateRepeatingLinearGradientFunction (cairo_quartz_surface_t *surface,
const cairo_gradient_pattern_t *gpat,
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 = {
- 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
- };
CGPoint mstart, mend;
double dx, dy;
int x_rep_start = 0, x_rep_end = 0;
int y_rep_start = 0, y_rep_end = 0;
int rep_start, rep_end;
@@ -787,18 +786,18 @@ CreateRepeatingLinearGradientFunction (c
/* 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,
- output_value_ranges,
- &callbacks);
+ gradient_output_value_ranges,
+ &gradient_callbacks);
}
static void
UpdateRadialParameterToIncludePoint(double *max_t, CGPoint *center,
double dr, double dx, double dy,
double x, double y)
{
/* Compute a parameter t such that a circle centered at
@@ -847,20 +846,16 @@ CreateRepeatingRadialGradientFunction (c
const cairo_gradient_pattern_t *gpat,
CGPoint *start, double *start_radius,
CGPoint *end, double *end_radius)
{
CGRect clip = CGContextGetClipBoundingBox (surface->cgContext);
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;
double *outer_radius;
/* minimum and maximum t-parameter values that will make our gradient
cover the clipBox */
double t_min, t_max, t_temp;
/* outer minus inner */
@@ -927,18 +922,18 @@ CreateRepeatingRadialGradientFunction (c
/* 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,
- output_value_ranges,
- &callbacks);
+ gradient_output_value_ranges,
+ &gradient_callbacks);
}
/* Obtain a CGImageRef from a #cairo_surface_t * */
static void
DataProviderReleaseCallback (void *info, const void *data, size_t size)
{
cairo_surface_t *surface = (cairo_surface_t *) info;