aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2013-08-16 17:31:04 +0200
committerLars Magne Ingebrigtsen2013-08-16 17:31:04 +0200
commit49ceb676b01fadfd97c1a829c9228e3ca8ac733c (patch)
treeb01df4db62747223acd2f56c9592589288d4b850 /src
parent4b5fe4ee092b847504023d3a471e1924c63f0155 (diff)
downloademacs-49ceb676b01fadfd97c1a829c9228e3ca8ac733c.tar.gz
emacs-49ceb676b01fadfd97c1a829c9228e3ca8ac733c.zip
(imagemagick_load_image): Remove the ping_wand code
The apparently only saved time on invalid animated images, and slowed down everything else. Optimise for the common case.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog3
-rw-r--r--src/image.c43
2 files changed, 13 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index de9724238a0..035a4169399 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -2,6 +2,9 @@
2 2
3 * image.c: Implement an ImageMagick per-image cache. 3 * image.c: Implement an ImageMagick per-image cache.
4 (imagemagick_get_animation_cache): Fix a double-free error. 4 (imagemagick_get_animation_cache): Fix a double-free error.
5 (imagemagick_load_image): Remove the ping_wand code, which only
6 apparently saved time on invalid animated images, and slowed down
7 everything else. Optimise for the common case.
5 8
62013-08-16 Xue Fuqiao <xfq.free@gmail.com> 92013-08-16 Xue Fuqiao <xfq.free@gmail.com>
7 10
diff --git a/src/image.c b/src/image.c
index 3607be1e86c..198d5545c96 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8095,7 +8095,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
8095 XImagePtr ximg; 8095 XImagePtr ximg;
8096 int x, y; 8096 int x, y;
8097 MagickWand *image_wand; 8097 MagickWand *image_wand;
8098 MagickWand *ping_wand;
8099 PixelIterator *iterator; 8098 PixelIterator *iterator;
8100 PixelWand **pixels, *bg_wand = NULL; 8099 PixelWand **pixels, *bg_wand = NULL;
8101 MagickPixelPacket pixel; 8100 MagickPixelPacket pixel;
@@ -8118,60 +8117,38 @@ imagemagick_load_image (struct frame *f, struct image *img,
8118 MagickWandGenesis (); 8117 MagickWandGenesis ();
8119 image = image_spec_value (img->spec, QCindex, NULL); 8118 image = image_spec_value (img->spec, QCindex, NULL);
8120 ino = INTEGERP (image) ? XFASTINT (image) : 0; 8119 ino = INTEGERP (image) ? XFASTINT (image) : 0;
8121 ping_wand = NewMagickWand (); 8120 image_wand = NewMagickWand ();
8122 /* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */
8123 8121
8124 if (filename) 8122 if (filename)
8125 status = MagickPingImage (ping_wand, filename); 8123 status = MagickReadImage (image_wand, filename);
8126 else 8124 else
8127 { 8125 {
8128 filename_hint = imagemagick_filename_hint (img->spec, hint_buffer); 8126 filename_hint = imagemagick_filename_hint (img->spec, hint_buffer);
8129 MagickSetFilename (ping_wand, filename_hint); 8127 MagickSetFilename (image_wand, filename_hint);
8130 status = MagickPingImageBlob (ping_wand, contents, size); 8128 status = MagickReadImageBlob (image_wand, contents, size);
8131 } 8129 }
8132 8130
8133 if (status == MagickFalse) 8131 if (status == MagickFalse)
8134 { 8132 {
8135 imagemagick_error (ping_wand); 8133 imagemagick_error (image_wand);
8136 DestroyMagickWand (ping_wand); 8134 DestroyMagickWand (image_wand);
8137 return 0; 8135 return 0;
8138 } 8136 }
8139 8137
8140 if (ino < 0 || ino >= MagickGetNumberImages (ping_wand)) 8138 if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
8141 { 8139 {
8142 image_error ("Invalid image number `%s' in image `%s'", 8140 image_error ("Invalid image number `%s' in image `%s'",
8143 image, img->spec); 8141 image, img->spec);
8144 DestroyMagickWand (ping_wand); 8142 DestroyMagickWand (image_wand);
8145 return 0; 8143 return 0;
8146 } 8144 }
8147 8145
8148 if (MagickGetNumberImages (ping_wand) > 1) 8146 if (MagickGetNumberImages (image_wand) > 1)
8149 img->lisp_data = 8147 img->lisp_data =
8150 Fcons (Qcount, 8148 Fcons (Qcount,
8151 Fcons (make_number (MagickGetNumberImages (ping_wand)), 8149 Fcons (make_number (MagickGetNumberImages (image_wand)),
8152 img->lisp_data)); 8150 img->lisp_data));
8153 8151
8154 DestroyMagickWand (ping_wand);
8155
8156 /* Now we know how many images are inside the file. If it's not a
8157 bundle, the number is one. Load the image data. */
8158
8159 image_wand = NewMagickWand ();
8160
8161 if (filename)
8162 status = MagickReadImage (image_wand, filename);
8163 else
8164 {
8165 MagickSetFilename (image_wand, filename_hint);
8166 status = MagickReadImageBlob (image_wand, contents, size);
8167 }
8168
8169 if (status == MagickFalse)
8170 {
8171 imagemagick_error (image_wand);
8172 goto imagemagick_error;
8173 }
8174
8175 /* If we have an animated image, get the new wand based on the 8152 /* If we have an animated image, get the new wand based on the
8176 "super-wand". */ 8153 "super-wand". */
8177 if (MagickGetNumberImages (image_wand) > 1) 8154 if (MagickGetNumberImages (image_wand) > 1)