Subject: bug#69992: closed (Re: bug#69992: Minor improvement to image map transformation logic)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 30 Mar 2024 13:38:04 +0000

Your bug report

#69992: Minor improvement to image map transformation logic

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
69992: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69992
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#69992: Minor improvement to image map transformation logic
From: Eli Zaretskii <[email-masked]>
To: David Ponce <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 30 Mar 2024 16:37:15 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sat, 30 Mar 2024 13:59:41 +0100
> From: David Ponce <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> Here is my last patch. The only change compared to the previous patch is that
> now the scale factor is correctly calculated based on the size of the image and
> the displayed size. To minimize the performance impact, I saved a call to
> `image-size' by doing the calculation directly in the `image--compute-map' and
> `image--compute-original-map' functions. I did some benchmarks and the
> difference is not significant. The tests still give the same results :-)
> 
> Here is the new change log:

Thanks, installed on master, and closing the bug.

Subject: Minor improvement to image map transformation logic
From: Joseph Turner <[email-masked]>
To: Emacs Bugs Mailing List <[email-masked]>
Date: Sun, 24 Mar 2024 18:00:52 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

This patch is slight simplification/optimization.

Joseph

>From 96a30a0450384eaeda21f234911f947952c4dcde Mon Sep 17 00:00:00 2001
From: Joseph Turner <[email-masked]>
Date: Sat, 23 Mar 2024 13:29:17 -0700
Subject: [PATCH] copy-tree just image map, not entire image.

* lisp/image.el (image--compute-original-map):
---
 lisp/image.el | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/lisp/image.el b/lisp/image.el
index 55340ea03dc..d7496485aca 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -1455,24 +1455,23 @@ image--compute-original-map
 If IMAGE lacks :map property, return nil.
 When :rotation is not a multiple of 90, return copy of :map."
   (when (image-property image :map)
-    (let* ((image-copy (copy-tree image t))
-           (map (image-property image-copy :map))
-           (scale (or (image-property image-copy :scale) 1))
-           (rotation (or (image-property image-copy :rotation) 0))
-           (flip (image-property image-copy :flip))
-           (size (image-size image-copy t)))
+    (let* ((original-map (copy-tree (image-property image :map) t))
+           (scale (or (image-property image :scale) 1))
+           (rotation (or (image-property image :rotation) 0))
+           (flip (image-property image :flip))
+           (size (image-size image t)))
       (when (and ; Handle only 90-degree rotations
              (zerop (mod rotation 1))
              (zerop (% (truncate rotation) 90)))
         ;; In rendered images, rotation is always applied before flip.
-        ;; To undo the transformation, flip before rotating.
-        ;; SIZE fits MAP before it is transformed back to ORIGINAL-MAP.
-        ;; Therefore, scale MAP after flip and rotate operations, since
-        ;; both need MAP to fit SIZE.
-        (image--flip-map map flip size)
-        (image--rotate-map map (- rotation) size)
-        (image--scale-map map (/ 1.0 scale)))
-      map)))
+        ;; To undo the transformation, flip before rotating.  SIZE fits
+        ;; ORIGINAL-MAP before transformations are applied.  Therefore,
+        ;; scale ORIGINAL-MAP after flip and rotate operations, since
+        ;; both need ORIGINAL-MAP to fit SIZE.
+        (image--flip-map original-map flip size)
+        (image--rotate-map original-map (- rotation) size)
+        (image--scale-map original-map (/ 1.0 scale)))
+      original-map)))
 
 (defun image--scale-map (map scale)
   "Scale MAP according to SCALE.
-- 
2.41.0