third_party/cairo/src/cairo-pattern.c
cairo_filter_t
_cairo_pattern_analyze_filter (const cairo_pattern_t *pattern)
{
    switch (pattern->filter) {
    case CAIRO_FILTER_GOOD:
    case CAIRO_FILTER_BEST:
    case CAIRO_FILTER_BILINEAR:
    case CAIRO_FILTER_FAST:
	/* If source pixels map 1:1 onto destination pixels, we do
	 * not need to filter (and do not want to filter, since it
	 * will cause blurriness)
	 */
	if (_cairo_matrix_is_pixel_exact (&pattern->matrix)) {
	    return CAIRO_FILTER_NEAREST;
	} else {
	    /* Use BILINEAR for any scale greater than .75 instead
	     * of GOOD. For scales of 1 and larger this is identical,
	     * for the smaller sizes it was judged that the artifacts
	     * were not worse than the artifacts from a box filer.
	     * BILINEAR can also be used if the scale is exactly .5
	     * and the translation in that direction is an integer.
	     */
	    if (pattern->filter == CAIRO_FILTER_GOOD &&
		use_bilinear (pattern->matrix.xx, pattern->matrix.xy,
			      pattern->matrix.x0) &&
		use_bilinear (pattern->matrix.yx, pattern->matrix.yy,
			      pattern->matrix.y0))
		return CAIRO_FILTER_BILINEAR;
	}
	break;

    case CAIRO_FILTER_NEAREST:
    case CAIRO_FILTER_GAUSSIAN:
    default:
	break;
    }

    return pattern->filter;
}
/**
 * _cairo_pattern_analyze_filter:
 * @pattern: surface pattern
 * Returns: the optimized #cairo_filter_t to use with @pattern.
 *
 * Possibly optimize the filter to a simpler value depending on transformation
 **/
@pattern: surface pattern
Returns: the optimized #cairo_filter_t to use with @pattern.

Possibly optimize the filter to a simpler value depending on transformation
@pattern : surface pattern Returns : the optimized #cairo_filter_t to use with @pattern . Possibly optimize the filter to a simpler value depending on transformation
cairo_filter_t
_cairo_pattern_analyze_filter (const cairo_pattern_t *pattern)
{
    switch (pattern->filter) {
    case CAIRO_FILTER_GOOD:
    case CAIRO_FILTER_BEST:
    case CAIRO_FILTER_BILINEAR:
    case CAIRO_FILTER_FAST:
	if (_cairo_matrix_is_pixel_exact (&pattern->matrix)) {
	    return CAIRO_FILTER_NEAREST;
	} else {
	    if (pattern->filter == CAIRO_FILTER_GOOD &&
		use_bilinear (pattern->matrix.xx, pattern->matrix.xy,
			      pattern->matrix.x0) &&
		use_bilinear (pattern->matrix.yx, pattern->matrix.yy,
			      pattern->matrix.y0))
		return CAIRO_FILTER_BILINEAR;
	}
	break;
    case CAIRO_FILTER_NEAREST:
    case CAIRO_FILTER_GAUSSIAN:
    default:
	break;
    }
    return pattern->filter;
}
cairo_filter_t _cairo_pattern_analyze_filter ( const cairo_pattern_t * pattern ) { switch ( pattern -> filter ) { case CAIRO_FILTER_GOOD : case CAIRO_FILTER_BEST : case CAIRO_FILTER_BILINEAR : case CAIRO_FILTER_FAST : if ( _cairo_matrix_is_pixel_exact ( & pattern -> matrix ) ) { return CAIRO_FILTER_NEAREST ; } else { if ( pattern -> filter == CAIRO_FILTER_GOOD && use_bilinear ( pattern -> matrix . xx , pattern -> matrix . xy , pattern -> matrix . x0 ) && use_bilinear ( pattern -> matrix . yx , pattern -> matrix . yy , pattern -> matrix . y0 ) ) return CAIRO_FILTER_BILINEAR ; } break ; case CAIRO_FILTER_NEAREST : case CAIRO_FILTER_GAUSSIAN : default : break ; } return pattern -> filter ; }
_cairo_pattern_analyze_filter:
 @pattern: surface pattern
 Returns: the optimized #cairo_filter_t to use with @pattern.
_cairo_pattern_analyze_filter : @pattern : surface pattern Returns : the optimized #cairo_filter_t to use with @pattern .
/* If source pixels map 1:1 onto destination pixels, we do
	 * not need to filter (and do not want to filter, since it
	 * will cause blurriness)
	 */ /* Use BILINEAR for any scale greater than .75 instead
	     * of GOOD. For scales of 1 and larger this is identical,
	     * for the smaller sizes it was judged that the artifacts
	     * were not worse than the artifacts from a box filer.
	     * BILINEAR can also be used if the scale is exactly .5
	     * and the translation in that direction is an integer.
	     */