diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-05-03 11:45:22 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-05-03 11:45:22 +0200 |
commit | 4aa4a8f9525efa6453816aa588ad178b01df554d (patch) | |
tree | 6b9939191e6b0c463a91600a5c6f91c7985b2bc5 /lisp/image.el | |
parent | eddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd (diff) | |
download | emacs-4aa4a8f9525efa6453816aa588ad178b01df554d.tar.gz emacs-4aa4a8f9525efa6453816aa588ad178b01df554d.tar.bz2 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).
Diffstat (limited to 'lisp/image.el')
-rw-r--r-- | lisp/image.el | 14 |
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." (cancel-timer timer)) (plist-put (cdr image) :animate-buffer (current-buffer)) (plist-put (cdr image) :animate-tardiness 0) + ;; Stash the data about the animation here so that we don't + ;; trigger image recomputation unnecessarily later. + (plist-put (cdr image) :animate-multi-frame-data animation) (run-with-timer 0.2 nil #'image-animate-timeout image (or index 0) (car animation) 0 limit (+ (float-time) 0.2))))) @@ -869,7 +872,8 @@ Frames are indexed from 0. Optional argument NOCHECK non-nil means do not check N is within the range of frames present in the image." (unless nocheck (if (< n 0) (setq n 0) - (setq n (min n (1- (car (image-multi-frame-p image))))))) + (setq n (min n (1- (car (plist-get (cdr image) + :animate-multi-frame-data))))))) (plist-put (cdr image) :index n) (force-window-update)) @@ -917,11 +921,11 @@ for the animation speed. A negative value means to animate in reverse." (image-show-frame image n t) (let* ((speed (image-animate-get-speed image)) (time (current-time)) - (animation (image-multi-frame-p image)) (time-to-load-image (time-since time)) - (stated-delay-time (/ (or (cdr animation) - image-default-frame-delay) - (float (abs speed)))) + (stated-delay-time + (/ (or (cdr (plist-get (cdr image) :animate-multi-frame-data)) + image-default-frame-delay) + (float (abs speed)))) ;; Subtract off the time we took to load the image from the ;; stated delay time. (delay (max (float-time (time-subtract stated-delay-time |