1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# 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;
|