third_party/cairo/src/cairo-quartz-surface.c
static void
ComputeGradientValue (void *info,
                      const cairo_quartz_float_t *in,
                      cairo_quartz_float_t *out)
{
    double fdist = *in;
    const cairo_gradient_pattern_t *grad = (cairo_gradient_pattern_t*) info;
    unsigned int i;

    /* Put fdist back in the 0.0..1.0 range if we're doing
     * REPEAT/REFLECT
     */
    if (grad->base.extend == CAIRO_EXTEND_REPEAT) {
	fdist = fdist - floor (fdist);
    } else if (grad->base.extend == CAIRO_EXTEND_REFLECT) {
	fdist = fmod (fabs (fdist), 2.0);
	if (fdist > 1.0)
	    fdist = 2.0 - fdist;
    }

    for (i = 0; i < grad->n_stops; i++)
	if (grad->stops[i].offset > fdist)
	    break;

    if (i == 0 || i == grad->n_stops) {
	if (i == grad->n_stops)
	    --i;
	out[0] = grad->stops[i].color.red;
	out[1] = grad->stops[i].color.green;
	out[2] = grad->stops[i].color.blue;
	out[3] = grad->stops[i].color.alpha;
    } else {
	cairo_quartz_float_t ax = grad->stops[i-1].offset;
	cairo_quartz_float_t bx = grad->stops[i].offset - ax;
	cairo_quartz_float_t bp = (fdist - ax)/bx;
	cairo_quartz_float_t ap = 1.0 - bp;

	out[0] =
	    grad->stops[i-1].color.red * ap +
	    grad->stops[i].color.red * bp;
	out[1] =
	    grad->stops[i-1].color.green * ap +
	    grad->stops[i].color.green * bp;
	out[2] =
	    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;
    }
}
/*
 * Source -> Quartz setup and finish functions
 */
> Quartz setup and finish functions
> Quartz setup and finish functions
static void
ComputeGradientValue (void *info,
                      const cairo_quartz_float_t *in,
                      cairo_quartz_float_t *out)
{
    double fdist = *in;
    const cairo_gradient_pattern_t *grad = (cairo_gradient_pattern_t*) info;
    unsigned int i;
    if (grad->base.extend == CAIRO_EXTEND_REPEAT) {
	fdist = fdist - floor (fdist);
    } else if (grad->base.extend == CAIRO_EXTEND_REFLECT) {
	fdist = fmod (fabs (fdist), 2.0);
	if (fdist > 1.0)
	    fdist = 2.0 - fdist;
    }
    for (i = 0; i < grad->n_stops; i++)
	if (grad->stops[i].offset > fdist)
	    break;
    if (i == 0 || i == grad->n_stops) {
	if (i == grad->n_stops)
	    --i;
	out[0] = grad->stops[i].color.red;
	out[1] = grad->stops[i].color.green;
	out[2] = grad->stops[i].color.blue;
	out[3] = grad->stops[i].color.alpha;
    } else {
	cairo_quartz_float_t ax = grad->stops[i-1].offset;
	cairo_quartz_float_t bx = grad->stops[i].offset - ax;
	cairo_quartz_float_t bp = (fdist - ax)/bx;
	cairo_quartz_float_t ap = 1.0 - bp;
	out[0] =
	    grad->stops[i-1].color.red * ap +
	    grad->stops[i].color.red * bp;
	out[1] =
	    grad->stops[i-1].color.green * ap +
	    grad->stops[i].color.green * bp;
	out[2] =
	    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 void ComputeGradientValue ( void * info , const cairo_quartz_float_t * in , cairo_quartz_float_t * out ) { double fdist = * in ; const cairo_gradient_pattern_t * grad = ( cairo_gradient_pattern_t * ) info ; unsigned int i ; if ( grad -> base . extend == CAIRO_EXTEND_REPEAT ) { fdist = fdist - floor ( fdist ) ; } else if ( grad -> base . extend == CAIRO_EXTEND_REFLECT ) { fdist = fmod ( fabs ( fdist ) , 2.0 ) ; if ( fdist > 1.0 ) fdist = 2.0 - fdist ; } for ( i = 0 ; i < grad -> n_stops ; i ++ ) if ( grad -> stops [ i ] . offset > fdist ) break ; if ( i == 0 || i == grad -> n_stops ) { if ( i == grad -> n_stops ) -- i ; out [ 0 ] = grad -> stops [ i ] . color . red ; out [ 1 ] = grad -> stops [ i ] . color . green ; out [ 2 ] = grad -> stops [ i ] . color . blue ; out [ 3 ] = grad -> stops [ i ] . color . alpha ; } else { cairo_quartz_float_t ax = grad -> stops [ i - 1 ] . offset ; cairo_quartz_float_t bx = grad -> stops [ i ] . offset - ax ; cairo_quartz_float_t bp = ( fdist - ax ) / bx ; cairo_quartz_float_t ap = 1.0 - bp ; out [ 0 ] = grad -> stops [ i - 1 ] . color . red * ap + grad -> stops [ i ] . color . red * bp ; out [ 1 ] = grad -> stops [ i - 1 ] . color . green * ap + grad -> stops [ i ] . color . green * bp ; out [ 2 ] = 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 ; } }
Source -> Quartz setup and finish functions
Source - > Quartz setup and finish functions
/* Put fdist back in the 0.0..1.0 range if we're doing
     * REPEAT/REFLECT
     */