diff options
| author | Lars Magne Ingebrigtsen | 2013-08-15 18:01:13 +0200 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2013-08-15 18:01:13 +0200 |
| commit | 995be755ab5fb225325ec912c53dcd49ae1c939a (patch) | |
| tree | 9f77c77cd2723fb29a3a8eb9f27adcb774734f7d /src | |
| parent | 42fe2e88d62c3ff866317f3252f1e78ed0b066a2 (diff) | |
| download | emacs-995be755ab5fb225325ec912c53dcd49ae1c939a.tar.gz emacs-995be755ab5fb225325ec912c53dcd49ae1c939a.zip | |
(imagemagick_compute_animated_image): Implement a simple cache
(imagemagick_compute_animated_image): Fix some compilation
warnings. Implement a very simple cache to make the animation
usable at all, but it should be replaced with a per-image cache.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/image.c | 21 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 888db1f8cf4..b17dec01e2c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -18,6 +18,9 @@ | |||
| 18 | 18 | ||
| 19 | * image.c (imagemagick_compute_animated_image): Implement animated | 19 | * image.c (imagemagick_compute_animated_image): Implement animated |
| 20 | images (bug#14700). | 20 | images (bug#14700). |
| 21 | (imagemagick_compute_animated_image): Fix some compilation | ||
| 22 | warnings. Implement a very simple cache to make the animation | ||
| 23 | usable at all, but it should be replaced with a per-image cache. | ||
| 21 | 24 | ||
| 22 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> | 25 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> |
| 23 | 26 | ||
diff --git a/src/image.c b/src/image.c index c534f181e5c..c9ad4c8ef76 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7871,19 +7871,26 @@ imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent]) | |||
| 7871 | compute ann the preceding images to be able to display a particular | 7871 | compute ann the preceding images to be able to display a particular |
| 7872 | sub-image. */ | 7872 | sub-image. */ |
| 7873 | 7873 | ||
| 7874 | static MagickWand *animation_cache = NULL; | ||
| 7875 | static int animation_index = 0; | ||
| 7876 | |||
| 7874 | static MagickWand * | 7877 | static MagickWand * |
| 7875 | imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | 7878 | imagemagick_compute_animated_image (MagickWand *super_wand, int ino) |
| 7876 | { | 7879 | { |
| 7877 | MagickWand *composite_wand; | 7880 | MagickWand *composite_wand; |
| 7878 | 7881 | ||
| 7879 | MagickSetIteratorIndex (super_wand, 0); | 7882 | MagickSetIteratorIndex (super_wand, 0); |
| 7880 | composite_wand = MagickGetImage (super_wand); | ||
| 7881 | 7883 | ||
| 7882 | for (int i = 1; i <= ino; i++) { | 7884 | if (ino == 0 || animation_cache == NULL) |
| 7885 | composite_wand = MagickGetImage (super_wand); | ||
| 7886 | else | ||
| 7887 | composite_wand = animation_cache; | ||
| 7888 | |||
| 7889 | for (int i = max (1, animation_index); i <= ino; i++) { | ||
| 7883 | MagickWand *sub_wand; | 7890 | MagickWand *sub_wand; |
| 7884 | PixelIterator *source_iterator, *dest_iterator; | 7891 | PixelIterator *source_iterator, *dest_iterator; |
| 7885 | PixelWand **source, **dest; | 7892 | PixelWand **source, **dest; |
| 7886 | long source_width, dest_width; | 7893 | unsigned long source_width, dest_width; |
| 7887 | MagickPixelPacket pixel; | 7894 | MagickPixelPacket pixel; |
| 7888 | 7895 | ||
| 7889 | MagickSetIteratorIndex (super_wand, i); | 7896 | MagickSetIteratorIndex (super_wand, i); |
| @@ -7910,7 +7917,8 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | |||
| 7910 | return NULL; | 7917 | return NULL; |
| 7911 | } | 7918 | } |
| 7912 | 7919 | ||
| 7913 | while (source = PixelGetNextIteratorRow (source_iterator, &source_width)) { | 7920 | while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) |
| 7921 | != NULL) { | ||
| 7914 | dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); | 7922 | dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); |
| 7915 | for (int x = 0; x < source_width; x++) | 7923 | for (int x = 0; x < source_width; x++) |
| 7916 | { | 7924 | { |
| @@ -7929,6 +7937,11 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | |||
| 7929 | DestroyMagickWand (sub_wand); | 7937 | DestroyMagickWand (sub_wand); |
| 7930 | } | 7938 | } |
| 7931 | 7939 | ||
| 7940 | /* Cache a copy for the next iteration. The current wand will be | ||
| 7941 | destroyed by the caller. */ | ||
| 7942 | animation_cache = CloneMagickWand (composite_wand); | ||
| 7943 | animation_index = ino; | ||
| 7944 | |||
| 7932 | return composite_wand; | 7945 | return composite_wand; |
| 7933 | } | 7946 | } |
| 7934 | 7947 | ||