diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-09-07 08:49:05 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-12 23:18:13 +0200 |
commit | 620c43f50c2c613b8fb334b97d9edcbede0e61bb (patch) | |
tree | f29b38f8403ae8f6aa2bca87d3e98bb7f941ffa2 /src | |
parent | 2af3ae92ebe91e39b835eae048addc442533fb67 (diff) |
quartz: Fix EXTEND_PAD gradients
Make PAD extended gardients more robust, by computing the color
explicitly like for REPEAT and REFLECT extend modes.
This removes a hack introducing a small but non-0 negative value
that ensured that the gradient started with the correct color (but
not that it ended with the correct one, too).
Fixes linear-gradient-large.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-quartz-surface.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 935ab34b..ecfae5de 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -832,7 +832,7 @@ static const CGFunctionCallbacks gradient_callbacks = { function into an array of fixed size, so if the input range is larger than needed, the resolution of the gradient will be unnecessarily low. */ -static const cairo_quartz_float_t nonrepeating_gradient_input_value_range[2] = { -0.001f, 1.f }; +static const cairo_quartz_float_t nonrepeating_gradient_input_value_range[2] = { 0., 1. }; static CGFunctionRef CreateGradientFunction (const cairo_gradient_pattern_t *gpat) @@ -1346,7 +1346,7 @@ _cairo_quartz_setup_linear_source (cairo_quartz_surface_t *surface, CGPoint start, end; CGFunctionRef gradFunc; CGColorSpaceRef rgb; - bool extend = abspat->extend == CAIRO_EXTEND_PAD; + bool extend = abspat->extend != CAIRO_EXTEND_NONE; assert (lpat->base.n_stops > 0); @@ -1361,16 +1361,13 @@ _cairo_quartz_setup_linear_source (cairo_quartz_surface_t *surface, end = CGPointMake (_cairo_fixed_to_double (lpat->p2.x), _cairo_fixed_to_double (lpat->p2.y)); - if (abspat->extend == CAIRO_EXTEND_NONE || - abspat->extend == CAIRO_EXTEND_PAD) - { + if (!extend) gradFunc = CreateGradientFunction (&lpat->base); - } else { + else gradFunc = CreateRepeatingLinearGradientFunction (surface, &lpat->base, &start, &end, extents); - } surface->sourceShading = CGShadingCreateAxial (rgb, start, end, @@ -1393,7 +1390,7 @@ _cairo_quartz_setup_radial_source (cairo_quartz_surface_t *surface, CGPoint start, end; CGFunctionRef gradFunc; CGColorSpaceRef rgb; - bool extend = abspat->extend == CAIRO_EXTEND_PAD; + bool extend = abspat->extend != CAIRO_EXTEND_NONE; double c1x = _cairo_fixed_to_double (rpat->c1.x); double c1y = _cairo_fixed_to_double (rpat->c1.y); double c2x = _cairo_fixed_to_double (rpat->c2.x); @@ -1412,17 +1409,14 @@ _cairo_quartz_setup_radial_source (cairo_quartz_surface_t *surface, start = CGPointMake (c1x, c1y); end = CGPointMake (c2x, c2y); - if (abspat->extend == CAIRO_EXTEND_NONE || - abspat->extend == CAIRO_EXTEND_PAD) - { + if (!extend) gradFunc = CreateGradientFunction (&rpat->base); - } else { + else gradFunc = CreateRepeatingRadialGradientFunction (surface, &rpat->base, &start, &r1, &end, &r2, extents); - } surface->sourceShading = CGShadingCreateRadial (rgb, start, |