aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2024-12-28 14:39:49 +0200
committerEli Zaretskii2024-12-28 14:39:49 +0200
commitad5c8f25b36aac71870ff26b6549014c452a2145 (patch)
tree46141b4ccb12de3ab01e39f883fdd7fd6e3fa838 /src
parentc9be6f731de12b1c9eda0c51e188953e56ba0767 (diff)
parent691c161a81221905f7e2690ee747ba9163b1b645 (diff)
downloademacs-ad5c8f25b36aac71870ff26b6549014c452a2145.tar.gz
emacs-ad5c8f25b36aac71870ff26b6549014c452a2145.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h3
-rw-r--r--src/image.c45
2 files changed, 37 insertions, 11 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index ea7b0399adc..c876856717a 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3257,6 +3257,9 @@ struct image
3257 /* Width and height of the image. */ 3257 /* Width and height of the image. */
3258 int width, height; 3258 int width, height;
3259 3259
3260 /* The scale factor applied to the image. */
3261 double scale;
3262
3260 /* These values are used for the rectangles displayed for images 3263 /* These values are used for the rectangles displayed for images
3261 that can't be loaded. */ 3264 that can't be loaded. */
3262#define DEFAULT_IMAGE_WIDTH 30 3265#define DEFAULT_IMAGE_WIDTH 30
diff --git a/src/image.c b/src/image.c
index 0012abcb451..7b34b24ada9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -210,6 +210,9 @@ static void image_disable_image (struct frame *, struct image *);
210static void image_edge_detection (struct frame *, struct image *, Lisp_Object, 210static void image_edge_detection (struct frame *, struct image *, Lisp_Object,
211 Lisp_Object); 211 Lisp_Object);
212 212
213static double image_compute_scale (struct frame *f, Lisp_Object spec,
214 struct image *img);
215
213static void init_color_table (void); 216static void init_color_table (void);
214static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b); 217static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b);
215#ifdef COLOR_TABLE_SUPPORT 218#ifdef COLOR_TABLE_SUPPORT
@@ -2222,9 +2225,12 @@ search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash,
2222 image spec specifies :background. However, the extra memory 2225 image spec specifies :background. However, the extra memory
2223 usage is probably negligible in practice, so we don't bother. */ 2226 usage is probably negligible in practice, so we don't bother. */
2224 2227
2228 double scale = image_compute_scale (f, spec, NULL);
2229
2225 for (img = c->buckets[i]; img; img = img->next) 2230 for (img = c->buckets[i]; img; img = img->next)
2226 if (img->hash == hash 2231 if (img->hash == hash
2227 && !NILP (Fequal (img->spec, spec)) 2232 && !NILP (Fequal (img->spec, spec))
2233 && scale == img->scale
2228 && (ignore_colors || (img->face_foreground == foreground 2234 && (ignore_colors || (img->face_foreground == foreground
2229 && img->face_background == background 2235 && img->face_background == background
2230 && img->face_font_size == font_size 2236 && img->face_font_size == font_size
@@ -2667,18 +2673,15 @@ image_get_dimension (struct image *img, Lisp_Object symbol)
2667 return -1; 2673 return -1;
2668} 2674}
2669 2675
2670/* Compute the desired size of an image with native size WIDTH x HEIGHT, 2676/* Calculate the scale of the image. IMG may be null as it is only
2671 which is to be displayed on F. Use IMG to deduce the size. Store 2677 required when creating an image, and this function is called from
2672 the desired size into *D_WIDTH x *D_HEIGHT. Store -1 x -1 if the 2678 image cache related functions that do not have access to the image
2673 native size is OK. */ 2679 structure. */
2674 2680static double
2675static void 2681image_compute_scale (struct frame *f, Lisp_Object spec, struct image *img)
2676compute_image_size (struct frame *f, double width, double height,
2677 struct image *img,
2678 int *d_width, int *d_height)
2679{ 2682{
2680 double scale = 1; 2683 double scale = 1;
2681 Lisp_Object value = image_spec_value (img->spec, QCscale, NULL); 2684 Lisp_Object value = image_spec_value (spec, QCscale, NULL);
2682 2685
2683 if (EQ (value, Qdefault)) 2686 if (EQ (value, Qdefault))
2684 { 2687 {
@@ -2692,7 +2695,9 @@ compute_image_size (struct frame *f, double width, double height,
2692 { 2695 {
2693 /* This is a tag with which callers of `clear_image_cache' can 2696 /* This is a tag with which callers of `clear_image_cache' can
2694 refer to this image and its likenesses. */ 2697 refer to this image and its likenesses. */
2695 img->dependencies = Fcons (Qauto, img->dependencies); 2698 if (img)
2699 img->dependencies = Fcons (Qauto, img->dependencies);
2700
2696 scale = (FRAME_COLUMN_WIDTH (f) > 10 2701 scale = (FRAME_COLUMN_WIDTH (f) > 10
2697 ? (FRAME_COLUMN_WIDTH (f) / 10.0f) : 1); 2702 ? (FRAME_COLUMN_WIDTH (f) / 10.0f) : 1);
2698 } 2703 }
@@ -2716,6 +2721,24 @@ compute_image_size (struct frame *f, double width, double height,
2716 scale = dval; 2721 scale = dval;
2717 } 2722 }
2718 2723
2724 if (img)
2725 img->scale = scale;
2726
2727 return scale;
2728}
2729
2730/* Compute the desired size of an image with native size WIDTH x HEIGHT,
2731 which is to be displayed on F. Use IMG to deduce the size. Store
2732 the desired size into *D_WIDTH x *D_HEIGHT. Store -1 x -1 if the
2733 native size is OK. */
2734
2735static void
2736compute_image_size (struct frame *f, double width, double height,
2737 struct image *img,
2738 int *d_width, int *d_height)
2739{
2740 double scale = image_compute_scale(f, img->spec, img);
2741
2719 /* If width and/or height is set in the display spec assume we want 2742 /* If width and/or height is set in the display spec assume we want
2720 to scale to those values. If either h or w is unspecified, the 2743 to scale to those values. If either h or w is unspecified, the
2721 unspecified should be calculated from the specified to preserve 2744 unspecified should be calculated from the specified to preserve