Subject: Re: bug#38394: Fwd: Use different image filtering when zooming in vs zooming out

From: Robert Pluim <[email-masked]>
Date: Mon, 03 Aug 2020 16:04:56 +0200

>>>>> On Mon, 3 Aug 2020 10:10:06 +0100, Alan Third <[email-masked]> said:

    Alan> diff --git a/src/image.c b/src/image.c
    Alan> index e7e0a93313..a6b24e6652 100644
    Alan> --- a/src/image.c
    Alan> +++ b/src/image.c
    Alan> @@ -259,6 +259,8 @@ cr_put_image_to_cr_data (struct image *img)
    Alan>  	  cairo_matrix_t matrix;
    Alan>  	  cairo_pattern_get_matrix (img->cr_data, &matrix);
    Alan>  	  cairo_pattern_set_matrix (pattern, &matrix);
    Alan> +          cairo_pattern_set_filter
    Alan> +            (pattern, cairo_pattern_get_filter (img->cr_data));
    Alan>  	  cairo_pattern_destroy (img->cr_data);
    Alan>  	}
    Alan>        cairo_surface_destroy (surface);
    Alan> @@ -2114,6 +2116,15 @@ image_set_transform (struct frame *f, struct image *img)
    Alan>    double rotation = 0.0;
    Alan>    compute_image_rotation (img, &rotation);
 
    Alan> +# if defined HAVE_XRENDER
    Alan> +  /* We want scale up operations to use a nearest neighbour filter to
    Alan> +     show real pixels instead of munging them, but scale down
    Alan> +     operations to use a blended filter, to avoid aliasing and the like.
    Alan> +
    Alan> +     TODO: implement for NS and Windows.  */
    Alan> +  bool scale_down = (width < img->width) || (height < img->height);
    Alan> +# endif
    Alan> +
    Alan>    /* Perform scale transformation.  */
 
    Alan>    matrix3x3 matrix
    Alan> @@ -2230,6 +2241,8 @@ image_set_transform (struct frame *f, struct image *img)
    Alan>  			      matrix[1][1], matrix[2][0], matrix[2][1]};
    Alan>    cairo_pattern_t *pattern = cairo_pattern_create_rgb (0, 0, 0);
    Alan>    cairo_pattern_set_matrix (pattern, &cr_matrix);
    Alan> +  cairo_pattern_set_filter (pattern, scale_down

Isnʼt scale_down only defined if HAVE_XRENDER? This usage is under
USE_CAIRO