third_party/cairo/src/cairo-pattern.c
void
_cairo_pattern_alpha_range (const cairo_pattern_t *pattern,
			    double                *out_min,
			    double                *out_max)
{
    double alpha_min, alpha_max;

    switch (pattern->type) {
    case CAIRO_PATTERN_TYPE_SOLID: {
	const cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) pattern;
	alpha_min = alpha_max = solid->color.alpha;
	break;
    }

    case CAIRO_PATTERN_TYPE_LINEAR:
    case CAIRO_PATTERN_TYPE_RADIAL: {
	const cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern;
	unsigned int i;

	assert (gradient->n_stops >= 1);

	alpha_min = alpha_max = gradient->stops[0].color.alpha;
	for (i = 1; i < gradient->n_stops; i++) {
	    if (alpha_min > gradient->stops[i].color.alpha)
		alpha_min = gradient->stops[i].color.alpha;
	    else if (alpha_max < gradient->stops[i].color.alpha)
		alpha_max = gradient->stops[i].color.alpha;
	}

	break;
    }

    case CAIRO_PATTERN_TYPE_MESH: {
	const cairo_mesh_pattern_t *mesh = (const cairo_mesh_pattern_t *) pattern;
	const cairo_mesh_patch_t *patch = _cairo_array_index_const (&mesh->patches, 0);
	unsigned int i, j, n = _cairo_array_num_elements (&mesh->patches);

	assert (n >= 1);

	alpha_min = alpha_max = patch[0].colors[0].alpha;
	for (i = 0; i < n; i++) {
	    for (j = 0; j < 4; j++) {
		if (patch[i].colors[j].alpha < alpha_min)
		    alpha_min = patch[i].colors[j].alpha;
		else if (patch[i].colors[j].alpha > alpha_max)
		    alpha_max = patch[i].colors[j].alpha;
	    }
	}

	break;
    }

    default:
	ASSERT_NOT_REACHED;
	/* fall through */

    case CAIRO_PATTERN_TYPE_SURFACE:
    case CAIRO_PATTERN_TYPE_RASTER_SOURCE:
	alpha_min = 0;
	alpha_max = 1;
	break;
    }

    if (out_min)
	*out_min = alpha_min;
    if (out_max)
	*out_max = alpha_max;
}
/**
 * _cairo_pattern_alpha_range:
 *
 * Convenience function to determine the minimum and maximum alpha in
 * the drawn part of a pattern (i.e. ignoring clear parts caused by
 * extend modes and/or pattern shape).
 *
 * If not NULL, out_min and out_max will be set respectively to the
 * minimum and maximum alpha value of the pattern.
 **/
Convenience function to determine the minimum and maximum alpha in
the drawn part of a pattern .

If not NULL, out_min and out_max will be set respectively to the
minimum and maximum alpha value of the pattern.
Convenience function to determine the minimum and maximum alpha in the drawn part of a pattern . If not NULL out_min and out_max will be set respectively to the minimum and maximum alpha value of the pattern .
void
_cairo_pattern_alpha_range (const cairo_pattern_t *pattern,
			    double                *out_min,
			    double                *out_max)
{
    double alpha_min, alpha_max;
    switch (pattern->type) {
    case CAIRO_PATTERN_TYPE_SOLID: {
	const cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) pattern;
	alpha_min = alpha_max = solid->color.alpha;
	break;
    }
    case CAIRO_PATTERN_TYPE_LINEAR:
    case CAIRO_PATTERN_TYPE_RADIAL: {
	const cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern;
	unsigned int i;
	assert (gradient->n_stops >= 1);
	alpha_min = alpha_max = gradient->stops[0].color.alpha;
	for (i = 1; i < gradient->n_stops; i++) {
	    if (alpha_min > gradient->stops[i].color.alpha)
		alpha_min = gradient->stops[i].color.alpha;
	    else if (alpha_max < gradient->stops[i].color.alpha)
		alpha_max = gradient->stops[i].color.alpha;
	}
	break;
    }
    case CAIRO_PATTERN_TYPE_MESH: {
	const cairo_mesh_pattern_t *mesh = (const cairo_mesh_pattern_t *) pattern;
	const cairo_mesh_patch_t *patch = _cairo_array_index_const (&mesh->patches, 0);
	unsigned int i, j, n = _cairo_array_num_elements (&mesh->patches);
	assert (n >= 1);
	alpha_min = alpha_max = patch[0].colors[0].alpha;
	for (i = 0; i < n; i++) {
	    for (j = 0; j < 4; j++) {
		if (patch[i].colors[j].alpha < alpha_min)
		    alpha_min = patch[i].colors[j].alpha;
		else if (patch[i].colors[j].alpha > alpha_max)
		    alpha_max = patch[i].colors[j].alpha;
	    }
	}
	break;
    }
    default:
	ASSERT_NOT_REACHED;
    case CAIRO_PATTERN_TYPE_SURFACE:
    case CAIRO_PATTERN_TYPE_RASTER_SOURCE:
	alpha_min = 0;
	alpha_max = 1;
	break;
    }
    if (out_min)
	*out_min = alpha_min;
    if (out_max)
	*out_max = alpha_max;
}
void _cairo_pattern_alpha_range ( const cairo_pattern_t * pattern , double * out_min , double * out_max ) { double alpha_min , alpha_max ; switch ( pattern -> type ) { case CAIRO_PATTERN_TYPE_SOLID : { const cairo_solid_pattern_t * solid = ( cairo_solid_pattern_t * ) pattern ; alpha_min = alpha_max = solid -> color . alpha ; break ; } case CAIRO_PATTERN_TYPE_LINEAR : case CAIRO_PATTERN_TYPE_RADIAL : { const cairo_gradient_pattern_t * gradient = ( cairo_gradient_pattern_t * ) pattern ; unsigned int i ; assert ( gradient -> n_stops >= 1 ) ; alpha_min = alpha_max = gradient -> stops [ 0 ] . color . alpha ; for ( i = 1 ; i < gradient -> n_stops ; i ++ ) { if ( alpha_min > gradient -> stops [ i ] . color . alpha ) alpha_min = gradient -> stops [ i ] . color . alpha ; else if ( alpha_max < gradient -> stops [ i ] . color . alpha ) alpha_max = gradient -> stops [ i ] . color . alpha ; } break ; } case CAIRO_PATTERN_TYPE_MESH : { const cairo_mesh_pattern_t * mesh = ( const cairo_mesh_pattern_t * ) pattern ; const cairo_mesh_patch_t * patch = _cairo_array_index_const ( & mesh -> patches , 0 ) ; unsigned int i , j , n = _cairo_array_num_elements ( & mesh -> patches ) ; assert ( n >= 1 ) ; alpha_min = alpha_max = patch [ 0 ] . colors [ 0 ] . alpha ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < 4 ; j ++ ) { if ( patch [ i ] . colors [ j ] . alpha < alpha_min ) alpha_min = patch [ i ] . colors [ j ] . alpha ; else if ( patch [ i ] . colors [ j ] . alpha > alpha_max ) alpha_max = patch [ i ] . colors [ j ] . alpha ; } } break ; } default : ASSERT_NOT_REACHED ; case CAIRO_PATTERN_TYPE_SURFACE : case CAIRO_PATTERN_TYPE_RASTER_SOURCE : alpha_min = 0 ; alpha_max = 1 ; break ; } if ( out_min ) * out_min = alpha_min ; if ( out_max ) * out_max = alpha_max ; }
_cairo_pattern_alpha_range:
 Convenience function to determine the minimum and maximum alpha in
 the drawn part of a pattern (i.e.
_cairo_pattern_alpha_range : Convenience function to determine the minimum and maximum alpha in the drawn part of a pattern ( i . e .
/* fall through */