Commit 49ceb676 authored by Lars Magne Ingebrigtsen's avatar Lars Magne Ingebrigtsen
Browse files

(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.
parent 4b5fe4ee
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
* image.c: Implement an ImageMagick per-image cache. * image.c: Implement an ImageMagick per-image cache.
(imagemagick_get_animation_cache): Fix a double-free error. (imagemagick_get_animation_cache): Fix a double-free error.
(imagemagick_load_image): Remove the ping_wand code, which only
apparently saved time on invalid animated images, and slowed down
everything else. Optimise for the common case.
2013-08-16 Xue Fuqiao <xfq.free@gmail.com> 2013-08-16 Xue Fuqiao <xfq.free@gmail.com>
......
...@@ -8095,7 +8095,6 @@ imagemagick_load_image (struct frame *f, struct image *img, ...@@ -8095,7 +8095,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
XImagePtr ximg; XImagePtr ximg;
int x, y; int x, y;
MagickWand *image_wand; MagickWand *image_wand;
MagickWand *ping_wand;
PixelIterator *iterator; PixelIterator *iterator;
PixelWand **pixels, *bg_wand = NULL; PixelWand **pixels, *bg_wand = NULL;
MagickPixelPacket pixel; MagickPixelPacket pixel;
...@@ -8118,60 +8117,38 @@ imagemagick_load_image (struct frame *f, struct image *img, ...@@ -8118,60 +8117,38 @@ imagemagick_load_image (struct frame *f, struct image *img,
MagickWandGenesis (); MagickWandGenesis ();
image = image_spec_value (img->spec, QCindex, NULL); image = image_spec_value (img->spec, QCindex, NULL);
ino = INTEGERP (image) ? XFASTINT (image) : 0; ino = INTEGERP (image) ? XFASTINT (image) : 0;
ping_wand = NewMagickWand (); image_wand = NewMagickWand ();
/* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */
if (filename) if (filename)
status = MagickPingImage (ping_wand, filename); status = MagickReadImage (image_wand, filename);
else else
{ {
filename_hint = imagemagick_filename_hint (img->spec, hint_buffer); filename_hint = imagemagick_filename_hint (img->spec, hint_buffer);
MagickSetFilename (ping_wand, filename_hint); MagickSetFilename (image_wand, filename_hint);
status = MagickPingImageBlob (ping_wand, contents, size); status = MagickReadImageBlob (image_wand, contents, size);
} }
if (status == MagickFalse) if (status == MagickFalse)
{ {
imagemagick_error (ping_wand); imagemagick_error (image_wand);
DestroyMagickWand (ping_wand); DestroyMagickWand (image_wand);
return 0; return 0;
} }
if (ino < 0 || ino >= MagickGetNumberImages (ping_wand)) if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
{ {
image_error ("Invalid image number `%s' in image `%s'", image_error ("Invalid image number `%s' in image `%s'",
image, img->spec); image, img->spec);
DestroyMagickWand (ping_wand); DestroyMagickWand (image_wand);
return 0; return 0;
} }
if (MagickGetNumberImages (ping_wand) > 1) if (MagickGetNumberImages (image_wand) > 1)
img->lisp_data = img->lisp_data =
Fcons (Qcount, Fcons (Qcount,
Fcons (make_number (MagickGetNumberImages (ping_wand)), Fcons (make_number (MagickGetNumberImages (image_wand)),
img->lisp_data)); img->lisp_data));
DestroyMagickWand (ping_wand);
/* Now we know how many images are inside the file. If it's not a
bundle, the number is one. Load the image data. */
image_wand = NewMagickWand ();
if (filename)
status = MagickReadImage (image_wand, filename);
else
{
MagickSetFilename (image_wand, filename_hint);
status = MagickReadImageBlob (image_wand, contents, size);
}
if (status == MagickFalse)
{
imagemagick_error (image_wand);
goto imagemagick_error;
}
/* If we have an animated image, get the new wand based on the /* If we have an animated image, get the new wand based on the
"super-wand". */ "super-wand". */
if (MagickGetNumberImages (image_wand) > 1) if (MagickGetNumberImages (image_wand) > 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment