aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorAlan Third2021-03-09 18:05:10 +0000
committerAlan Third2021-03-10 21:40:42 +0000
commitc93447eac6f801d7ff97ed6dad368dc49d55cc46 (patch)
tree4643e59abe2e6ca836250f65b9dd5dcc75058f8e /src/image.c
parentd07ed6dfee9338b0d715f8181703252c99e5133a (diff)
downloademacs-c93447eac6f801d7ff97ed6dad368dc49d55cc46.tar.gz
emacs-c93447eac6f801d7ff97ed6dad368dc49d55cc46.zip
Enable selectable image smoothing (bug#38394)
* lisp/doc-view.el (doc-view-insert-image): Always use smoothing in docview. * lisp/image-mode.el (image-transform-smoothing): New variable. (image-mode-map): Add smoothing binding. (image-transform-properties): Apply smoothing when requested. (image-transform-set-smoothing): New function. (image-transform-reset): Reset smoothing. * src/image.c (image_set_transform): Use new :transform-smoothing attribute. (syms_of_image): Add :transform-smoothing attribute. * doc/lispref/display.texi (Image Descriptors): Document new :transform-smoothing property.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/image.c b/src/image.c
index 8137dbea8d7..95ae573354d 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2230,7 +2230,12 @@ image_set_transform (struct frame *f, struct image *img)
2230 operations to use a blended filter, to avoid aliasing and the like. 2230 operations to use a blended filter, to avoid aliasing and the like.
2231 2231
2232 TODO: implement for Windows. */ 2232 TODO: implement for Windows. */
2233 bool scale_down = (width < img->width) || (height < img->height); 2233 bool smoothing;
2234 Lisp_Object s = image_spec_value (img->spec, QCtransform_smoothing, NULL);
2235 if (!s)
2236 smoothing = (width < img->width) || (height < img->height);
2237 else
2238 smoothing = !NILP (s);
2234# endif 2239# endif
2235 2240
2236 /* Perform scale transformation. */ 2241 /* Perform scale transformation. */
@@ -2344,13 +2349,13 @@ image_set_transform (struct frame *f, struct image *img)
2344 /* Under NS the transform is applied to the drawing surface at 2349 /* Under NS the transform is applied to the drawing surface at
2345 drawing time, so store it for later. */ 2350 drawing time, so store it for later. */
2346 ns_image_set_transform (img->pixmap, matrix); 2351 ns_image_set_transform (img->pixmap, matrix);
2347 ns_image_set_smoothing (img->pixmap, scale_down); 2352 ns_image_set_smoothing (img->pixmap, smoothing);
2348# elif defined USE_CAIRO 2353# elif defined USE_CAIRO
2349 cairo_matrix_t cr_matrix = {matrix[0][0], matrix[0][1], matrix[1][0], 2354 cairo_matrix_t cr_matrix = {matrix[0][0], matrix[0][1], matrix[1][0],
2350 matrix[1][1], matrix[2][0], matrix[2][1]}; 2355 matrix[1][1], matrix[2][0], matrix[2][1]};
2351 cairo_pattern_t *pattern = cairo_pattern_create_rgb (0, 0, 0); 2356 cairo_pattern_t *pattern = cairo_pattern_create_rgb (0, 0, 0);
2352 cairo_pattern_set_matrix (pattern, &cr_matrix); 2357 cairo_pattern_set_matrix (pattern, &cr_matrix);
2353 cairo_pattern_set_filter (pattern, scale_down 2358 cairo_pattern_set_filter (pattern, smoothing
2354 ? CAIRO_FILTER_BEST : CAIRO_FILTER_NEAREST); 2359 ? CAIRO_FILTER_BEST : CAIRO_FILTER_NEAREST);
2355 /* Dummy solid color pattern just to record pattern matrix. */ 2360 /* Dummy solid color pattern just to record pattern matrix. */
2356 img->cr_data = pattern; 2361 img->cr_data = pattern;
@@ -2369,13 +2374,13 @@ image_set_transform (struct frame *f, struct image *img)
2369 XDoubleToFixed (matrix[2][2])}}}; 2374 XDoubleToFixed (matrix[2][2])}}};
2370 2375
2371 XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, 2376 XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture,
2372 scale_down ? FilterBest : FilterNearest, 0, 0); 2377 smoothing ? FilterBest : FilterNearest, 0, 0);
2373 XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat); 2378 XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat);
2374 2379
2375 if (img->mask_picture) 2380 if (img->mask_picture)
2376 { 2381 {
2377 XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->mask_picture, 2382 XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->mask_picture,
2378 scale_down ? FilterBest : FilterNearest, 0, 0); 2383 smoothing ? FilterBest : FilterNearest, 0, 0);
2379 XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->mask_picture, 2384 XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->mask_picture,
2380 &tmat); 2385 &tmat);
2381 } 2386 }
@@ -10693,6 +10698,7 @@ non-numeric, there is no explicit limit on the size of images. */);
10693 DEFSYM (QCrotation, ":rotation"); 10698 DEFSYM (QCrotation, ":rotation");
10694 DEFSYM (QCmatrix, ":matrix"); 10699 DEFSYM (QCmatrix, ":matrix");
10695 DEFSYM (QCscale, ":scale"); 10700 DEFSYM (QCscale, ":scale");
10701 DEFSYM (QCtransform_smoothing, ":transform-smoothing");
10696 DEFSYM (QCcolor_adjustment, ":color-adjustment"); 10702 DEFSYM (QCcolor_adjustment, ":color-adjustment");
10697 DEFSYM (QCmask, ":mask"); 10703 DEFSYM (QCmask, ":mask");
10698 10704