summaryrefslogtreecommitdiff
path: root/src/dispextern.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-06-06 08:09:58 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-06-06 08:10:31 -0700
commit7c26e0b18d0cdf656778d6dd332972b538491d95 (patch)
tree48674c6c1658fb5e45d69ca99285480b8655fe82 /src/dispextern.h
parente29fb7dfba96e63cb7ba2d2a68f91f8dec336100 (diff)
downloademacs-7c26e0b18d0cdf656778d6dd332972b538491d95.tar.gz
Fix overflow issues in image rotation
Also, do some refactoring to simplify code. * src/dispextern.h (INIT_MATRIX, COPY_MATRIX, MULT_MATRICES): Remove. * src/image.c (matrix3x3): New type, replacing all uses of 3x3 double. (matrix3x3_copy, matrix3x3_mult): New functions, replacing COPY_MATRIX, MULT_MATRICES. Replace INIT_MATRIX by C initializers. (image_set_rotation): Use Fmod to avoid undefined behavior on double-to-int conversion and to reduce bignum rotations correctly. (image_set_crop): Finish up previous correction, by not re-setting width and height if compute_image_size has set them. Prefer shifting right by 1 to dividing by 2 if either will do.
Diffstat (limited to 'src/dispextern.h')
-rw-r--r--src/dispextern.h21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index a21edd818f0..cc15950d5df 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2988,26 +2988,9 @@ struct redisplay_interface
#ifdef HAVE_WINDOW_SYSTEM
-# if defined USE_CAIRO || defined HAVE_XRENDER || defined HAVE_NS || defined HAVE_NTGUI
+# if (defined USE_CAIRO || defined HAVE_XRENDER \
+ || defined HAVE_NS || defined HAVE_NTGUI)
# define HAVE_NATIVE_TRANSFORMS
-
-# define INIT_MATRIX(m) \
- for (int i = 0 ; i < 3 ; i++) \
- for (int j = 0 ; j < 3 ; j++) \
- m[i][j] = (i == j) ? 1 : 0;
-
-# define COPY_MATRIX(a, b) \
- for (int i = 0 ; i < 3 ; i++) \
- for (int j = 0 ; j < 3 ; j++) \
- b[i][j] = a[i][j];
-
-# define MULT_MATRICES(a, b, result) \
- for (int i = 0 ; i < 3 ; i++) \
- for (int j = 0 ; j < 3 ; j++) { \
- double sum = 0; \
- for (int k = 0 ; k < 3 ; k++) \
- sum += a[k][j] * b[i][k]; \
- result[i][j] = sum;}
# endif
/* Structure describing an image. Specific image formats like XBM are