aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-05-03 11:45:22 +0200
committerLars Ingebrigtsen2021-05-03 11:45:22 +0200
commit4aa4a8f9525efa6453816aa588ad178b01df554d (patch)
tree6b9939191e6b0c463a91600a5c6f91c7985b2bc5
parenteddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd (diff)
downloademacs-4aa4a8f9525efa6453816aa588ad178b01df554d.tar.gz
emacs-4aa4a8f9525efa6453816aa588ad178b01df554d.zip
Speed up animation of non-displayed images
* lisp/image.el (image-animate): Only compute the animation data once -- this avoids recomputing the image on every iteration when the image is not displayed (bug#47895).
-rw-r--r--lisp/image.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 610d020aab5..5e84536b669 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -839,6 +839,9 @@ number, play until that number of seconds has elapsed."
839 (cancel-timer timer)) 839 (cancel-timer timer))
840 (plist-put (cdr image) :animate-buffer (current-buffer)) 840 (plist-put (cdr image) :animate-buffer (current-buffer))
841 (plist-put (cdr image) :animate-tardiness 0) 841 (plist-put (cdr image) :animate-tardiness 0)
842 ;; Stash the data about the animation here so that we don't
843 ;; trigger image recomputation unnecessarily later.
844 (plist-put (cdr image) :animate-multi-frame-data animation)
842 (run-with-timer 0.2 nil #'image-animate-timeout 845 (run-with-timer 0.2 nil #'image-animate-timeout
843 image (or index 0) (car animation) 846 image (or index 0) (car animation)
844 0 limit (+ (float-time) 0.2))))) 847 0 limit (+ (float-time) 0.2)))))
@@ -869,7 +872,8 @@ Frames are indexed from 0. Optional argument NOCHECK non-nil means
869do not check N is within the range of frames present in the image." 872do not check N is within the range of frames present in the image."
870 (unless nocheck 873 (unless nocheck
871 (if (< n 0) (setq n 0) 874 (if (< n 0) (setq n 0)
872 (setq n (min n (1- (car (image-multi-frame-p image))))))) 875 (setq n (min n (1- (car (plist-get (cdr image)
876 :animate-multi-frame-data)))))))
873 (plist-put (cdr image) :index n) 877 (plist-put (cdr image) :index n)
874 (force-window-update)) 878 (force-window-update))
875 879
@@ -917,11 +921,11 @@ for the animation speed. A negative value means to animate in reverse."
917 (image-show-frame image n t) 921 (image-show-frame image n t)
918 (let* ((speed (image-animate-get-speed image)) 922 (let* ((speed (image-animate-get-speed image))
919 (time (current-time)) 923 (time (current-time))
920 (animation (image-multi-frame-p image))
921 (time-to-load-image (time-since time)) 924 (time-to-load-image (time-since time))
922 (stated-delay-time (/ (or (cdr animation) 925 (stated-delay-time
923 image-default-frame-delay) 926 (/ (or (cdr (plist-get (cdr image) :animate-multi-frame-data))
924 (float (abs speed)))) 927 image-default-frame-delay)
928 (float (abs speed))))
925 ;; Subtract off the time we took to load the image from the 929 ;; Subtract off the time we took to load the image from the
926 ;; stated delay time. 930 ;; stated delay time.
927 (delay (max (float-time (time-subtract stated-delay-time 931 (delay (max (float-time (time-subtract stated-delay-time