>From c9345f094179372b0b83c2b6bafaf9276fd59b29 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 24 Feb 2019 11:16:42 +0000 Subject: [PATCH 2/2] Rename image scaling to image transforms * src/dispextern.h (HAVE_NATIVE_SCALING, HAVE_NATIVE_TRANSFORMS): Rename and change all relevant locations. * src/image.c (Fimage_scaling_p, Fimage_transforms_p): Rename and update all callers. --- doc/lispref/display.texi | 15 ++++++++------- etc/NEWS | 4 ++-- lisp/image.el | 2 +- src/dispextern.h | 4 ++-- src/image.c | 30 ++++++++++++++++-------------- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index b0f1fd2676..801ab9595a 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -5302,14 +5302,15 @@ Image Descriptors (@pxref{Input Focus}). @end defun address@hidden image-scaling-p &optional frame -This function returns @code{t} if @var{frame} supports image scaling. address@hidden @code{nil} or omitted means to use the selected frame -(@pxref{Input Focus}). address@hidden image-transforms-p &optional frame +This function returns @code{t} if @var{frame} supports image scaling +and rotation. @var{frame} @code{nil} or omitted means to use the +selected frame (@pxref{Input Focus}). -If image scaling is not supported, @code{:width}, @code{:height}, address@hidden:scale}, @code{:max-width} and @code{:max-height} will only be -usable through ImageMagick, if available (@pxref{ImageMagick Images}). +If image transforms are not supported, @code{:rotation}, address@hidden:width}, @code{:height}, @code{:scale}, @code{:max-width} and address@hidden:max-height} will only be usable through ImageMagick, if +available (@pxref{ImageMagick Images}). @end defun @node XBM Images diff --git a/etc/NEWS b/etc/NEWS index 3a50a51637..4cc0ccaf07 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1575,8 +1575,8 @@ systems, the XRender extension to X11 is required for this to be available; the configure script will test for it and, if found, enable scaling.) -The new function 'image-scaling-p' can be used to test whether any -given frame supports resizing. +The new function 'image-transforms-p' can be used to test whether any +given frame supports this capability. +++ ** (locale-info 'paper) now returns the paper size on systems that support it. diff --git a/lisp/image.el b/lisp/image.el index 3aa3b0aa24..42e906b3ad 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -989,7 +989,7 @@ image--get-image image)) (defun image--get-imagemagick-and-warn () - (unless (or (fboundp 'imagemagick-types) (image-scaling-p)) + (unless (or (fboundp 'imagemagick-types) (image-transforms-p)) (error "Cannot rescale images on this terminal")) (let ((image (image--get-image))) (image-flush image) diff --git a/src/dispextern.h b/src/dispextern.h index d45bc03d09..0eb7776056 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2939,7 +2939,7 @@ struct redisplay_interface #ifdef HAVE_WINDOW_SYSTEM # if defined HAVE_XRENDER || defined HAVE_NS || defined HAVE_NTGUI -# define HAVE_NATIVE_SCALING +# define HAVE_NATIVE_TRANSFORMS # define INIT_MATRIX(m) \ for (int i = 0 ; i < 3 ; i++) \ @@ -2984,7 +2984,7 @@ struct image synchronized to Pixmap. */ XImagePtr ximg, mask_img; -# ifdef HAVE_NATIVE_SCALING +# ifdef HAVE_NATIVE_TRANSFORMS /* Picture versions of pixmap and mask for compositing. */ Picture picture, mask_picture; # endif diff --git a/src/image.c b/src/image.c index f48db69a24..dcc8cd06b6 100644 --- a/src/image.c +++ b/src/image.c @@ -56,7 +56,7 @@ along with GNU Emacs. If not, see . */ #include #endif /* HAVE_SYS_TYPES_H */ -#ifdef HAVE_NATIVE_SCALING +#ifdef HAVE_NATIVE_TRANSFORMS #include #endif @@ -1765,7 +1765,7 @@ postprocess_image (struct frame *f, struct image *img) } } -#if defined (HAVE_IMAGEMAGICK) || defined (HAVE_NATIVE_SCALING) +#if defined (HAVE_IMAGEMAGICK) || defined (HAVE_NATIVE_TRANSFORMS) /* Scale an image size by returning SIZE / DIVISOR * MULTIPLIER, safely rounded and clipped to int range. */ @@ -1864,12 +1864,12 @@ compute_image_size (size_t width, size_t height, *d_width = desired_width; *d_height = desired_height; } -#endif /* HAVE_IMAGEMAGICK || HAVE_NATIVE_SCALING */ +#endif /* HAVE_IMAGEMAGICK || HAVE_NATIVE_TRANSFORMS */ static void x_set_image_rotation (struct image *img, double tm[3][3]) { -#ifdef HAVE_NATIVE_SCALING +#ifdef HAVE_NATIVE_TRANSFORMS # ifdef HAVE_IMAGEMAGICK /* ImageMagick images are already rotated. */ if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick)) @@ -1939,7 +1939,7 @@ x_set_image_rotation (struct image *img, double tm[3][3]) static void x_set_image_size (struct image *img, double tm[3][3]) { -#ifdef HAVE_NATIVE_SCALING +#ifdef HAVE_NATIVE_TRANSFORMS # ifdef HAVE_IMAGEMAGICK /* ImageMagick images are already the correct size. */ if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick)) @@ -1951,16 +1951,17 @@ x_set_image_size (struct image *img, double tm[3][3]) return; # endif - double rm[3][3], tmp[3][3]; - double xscale, yscale; int width, height; compute_image_size (img->width, img->height, img->spec, &width, &height); +# if defined (HAVE_NS) || defined (HAVE_XRENDER) + double rm[3][3], tmp[3][3]; + double xscale, yscale; + xscale = img->width / (double) width; yscale = img->height / (double) height; -# if defined (HAVE_NS) || defined (HAVE_XRENDER) INIT_MATRIX (rm); rm[0][0] = xscale; rm[1][1] = yscale; @@ -1984,7 +1985,8 @@ x_set_image_size (struct image *img, double tm[3][3]) static void x_set_transform (struct frame *f, struct image *img, double matrix[3][3]) { -#ifdef HAVE_NATIVE_SCALING + /* TODO: Add MS Windows support. */ +#ifdef HAVE_NATIVE_TRANSFORMS # if defined (HAVE_NS) /* Under NS the transform is applied to the drawing surface at drawing time, so store it for later. */ @@ -2066,7 +2068,7 @@ lookup_image (struct frame *f, Lisp_Object spec) Lisp_Object ascent, margin, relief, bg; int relief_bound; -#ifdef HAVE_NATIVE_SCALING +#ifdef HAVE_NATIVE_TRANSFORMS double transform_matrix[3][3]; INIT_MATRIX (transform_matrix); @@ -10025,9 +10027,9 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, Initialization ***********************************************************************/ -DEFUN ("image-scaling-p", Fimage_scaling_p, Simage_scaling_p, 0, 1, 0, - doc: /* Test whether FRAME supports resizing images. -Return t if FRAME supports native scaling, nil otherwise. */) +DEFUN ("image-transforms-p", Fimage_transforms_p, Simage_transforms_p, 0, 1, 0, + doc: /* Test whether FRAME supports image transformation. +Return t if FRAME supports native transforms, nil otherwise. */) (Lisp_Object frame) { #if defined (HAVE_NS) || defined (HAVE_NTGUI) @@ -10288,7 +10290,7 @@ non-numeric, there is no explicit limit on the size of images. */); defsubr (&Slookup_image); #endif - defsubr (&Simage_scaling_p); + defsubr (&Simage_transforms_p); DEFVAR_BOOL ("cross-disabled-images", cross_disabled_images, doc: /* Non-nil means always draw a cross over disabled images. -- 2.20.1