third_party/cairo/src/cairo-quartz-surface.c
static cairo_int_status_t
_cairo_quartz_setup_gradient_source (cairo_quartz_drawing_state_t *state,
				     const cairo_gradient_pattern_t *gradient,
				     const cairo_rectangle_int_t *extents)
{
    cairo_matrix_t mat;
    cairo_circle_double_t start, end;
    CGFunctionRef gradFunc;
    CGColorSpaceRef rgb;
    bool extend = gradient->base.extend != CAIRO_EXTEND_NONE;

    assert (gradient->n_stops > 0);

    mat = gradient->base.matrix;
    cairo_matrix_invert (&mat);
    _cairo_quartz_cairo_matrix_to_quartz (&mat, &state->transform);

    gradFunc = CairoQuartzCreateGradientFunction (gradient, extents,
						  &start, &end);

    if (unlikely (gradFunc == NULL))
	return CAIRO_INT_STATUS_UNSUPPORTED;

    rgb = CGColorSpaceCreateDeviceRGB ();

    if (gradient->base.type == CAIRO_PATTERN_TYPE_LINEAR) {
	state->shading = CGShadingCreateAxial (rgb,
					       CGPointMake (start.center.x,
							    start.center.y),
					       CGPointMake (end.center.x,
							    end.center.y),
					       gradFunc,
					       extend, extend);
    } else {
	state->shading = CGShadingCreateRadial (rgb,
						CGPointMake (start.center.x,
							     start.center.y),
						MAX (start.radius, 0),
						CGPointMake (end.center.x,
							     end.center.y),
						MAX (end.radius, 0),
						gradFunc,
						extend, extend);
    }

    CGColorSpaceRelease (rgb);
    CGFunctionRelease (gradFunc);

    state->action = DO_SHADING;
    return CAIRO_STATUS_SUCCESS;
}
/*
Quartz does not support repeating radients. We handle repeating gradients
by manually extending the gradient and repeating color stops. We need to
minimize the number of repetitions since Quartz seems to sample our color
function across the entire range, even if part of that range is not needed
for the visible area of the gradient, and it samples with some fixed resolution,
so if the gradient range is too large it samples with very low resolution and
the gradient is very coarse. _cairo_quartz_create_gradient_function computes
the number of repetitions needed based on the extents.
*/
Quartz does not support repeating radients. We handle repeating gradients
by manually extending the gradient and repeating color stops. We need to
minimize the number of repetitions since Quartz seems to sample our color
function across the entire range, even if part of that range is not needed
for the visible area of the gradient, and it samples with some fixed resolution,
so if the gradient range is too large it samples with very low resolution and
the gradient is very coarse. _cairo_quartz_create_gradient_function computes
the number of repetitions needed based on the extents.
Quartz does not support repeating radients . We handle repeating gradients by manually extending the gradient and repeating color stops . We need to minimize the number of repetitions since Quartz seems to sample our color function across the entire range even if part of that range is not needed for the visible area of the gradient and it samples with some fixed resolution so if the gradient range is too large it samples with very low resolution and the gradient is very coarse . _cairo_quartz_create_gradient_function computes the number of repetitions needed based on the extents .
static cairo_int_status_t
_cairo_quartz_setup_gradient_source (cairo_quartz_drawing_state_t *state,
				     const cairo_gradient_pattern_t *gradient,
				     const cairo_rectangle_int_t *extents)
{
    cairo_matrix_t mat;
    cairo_circle_double_t start, end;
    CGFunctionRef gradFunc;
    CGColorSpaceRef rgb;
    bool extend = gradient->base.extend != CAIRO_EXTEND_NONE;
    assert (gradient->n_stops > 0);
    mat = gradient->base.matrix;
    cairo_matrix_invert (&mat);
    _cairo_quartz_cairo_matrix_to_quartz (&mat, &state->transform);
    gradFunc = CairoQuartzCreateGradientFunction (gradient, extents,
						  &start, &end);
    if (unlikely (gradFunc == NULL))
	return CAIRO_INT_STATUS_UNSUPPORTED;
    rgb = CGColorSpaceCreateDeviceRGB ();
    if (gradient->base.type == CAIRO_PATTERN_TYPE_LINEAR) {
	state->shading = CGShadingCreateAxial (rgb,
					       CGPointMake (start.center.x,
							    start.center.y),
					       CGPointMake (end.center.x,
							    end.center.y),
					       gradFunc,
					       extend, extend);
    } else {
	state->shading = CGShadingCreateRadial (rgb,
						CGPointMake (start.center.x,
							     start.center.y),
						MAX (start.radius, 0),
						CGPointMake (end.center.x,
							     end.center.y),
						MAX (end.radius, 0),
						gradFunc,
						extend, extend);
    }
    CGColorSpaceRelease (rgb);
    CGFunctionRelease (gradFunc);
    state->action = DO_SHADING;
    return CAIRO_STATUS_SUCCESS;
}
static cairo_int_status_t _cairo_quartz_setup_gradient_source ( cairo_quartz_drawing_state_t * state , const cairo_gradient_pattern_t * gradient , const cairo_rectangle_int_t * extents ) { cairo_matrix_t mat ; cairo_circle_double_t start , end ; CGFunctionRef gradFunc ; CGColorSpaceRef rgb ; bool extend = gradient -> base . extend != CAIRO_EXTEND_NONE ; assert ( gradient -> n_stops > 0 ) ; mat = gradient -> base . matrix ; cairo_matrix_invert ( & mat ) ; _cairo_quartz_cairo_matrix_to_quartz ( & mat , & state -> transform ) ; gradFunc = CairoQuartzCreateGradientFunction ( gradient , extents , & start , & end ) ; if ( unlikely ( gradFunc == NULL ) ) return CAIRO_INT_STATUS_UNSUPPORTED ; rgb = CGColorSpaceCreateDeviceRGB ( ) ; if ( gradient -> base . type == CAIRO_PATTERN_TYPE_LINEAR ) { state -> shading = CGShadingCreateAxial ( rgb , CGPointMake ( start . center . x , start . center . y ) , CGPointMake ( end . center . x , end . center . y ) , gradFunc , extend , extend ) ; } else { state -> shading = CGShadingCreateRadial ( rgb , CGPointMake ( start . center . x , start . center . y ) , MAX ( start . radius , 0 ) , CGPointMake ( end . center . x , end . center . y ) , MAX ( end . radius , 0 ) , gradFunc , extend , extend ) ; } CGColorSpaceRelease ( rgb ) ; CGFunctionRelease ( gradFunc ) ; state -> action = DO_SHADING ; return CAIRO_STATUS_SUCCESS ; }
Quartz does not support repeating radients.
Quartz does not support repeating radients .