aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-01-10 15:29:21 -0800
committerPaul Eggert2019-01-10 15:30:13 -0800
commit9609db9d98babfe8782a03aebe46176e57905c63 (patch)
tree0210ea06203f5cb67c93dce0f42858bd3c48e0fb /src
parenta1b7a3f2a3957a399d6c3c7bcffa07ac67da82fc (diff)
downloademacs-9609db9d98babfe8782a03aebe46176e57905c63.tar.gz
emacs-9609db9d98babfe8782a03aebe46176e57905c63.zip
Minor tweaks to HAVE_NATIVE_SCALING code
This mostly just reindents. * src/image.c (x_set_image_size): Always define, but to a no-op if !HAVE_NATIVE_SCALING, to avoid an #ifdef elsewhere. (x_create_x_image_and_pixmap): Move decl to avoid an #ifdef. (image_create_x_image_and_pixmap): Move #ifdef outside of call. * src/xterm.c (x_composite_image): Avoid ‘else #endif’.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h13
-rw-r--r--src/image.c78
-rw-r--r--src/xterm.c14
3 files changed, 51 insertions, 54 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index b064875ac46..9cea3218c16 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -32,7 +32,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
32#endif /* USE_X_TOOLKIT */ 32#endif /* USE_X_TOOLKIT */
33 33
34#ifdef HAVE_XRENDER 34#ifdef HAVE_XRENDER
35#include <X11/extensions/Xrender.h> 35# include <X11/extensions/Xrender.h>
36#endif 36#endif
37#else /* !HAVE_X_WINDOWS */ 37#else /* !HAVE_X_WINDOWS */
38 38
@@ -2938,10 +2938,9 @@ struct redisplay_interface
2938 2938
2939#ifdef HAVE_WINDOW_SYSTEM 2939#ifdef HAVE_WINDOW_SYSTEM
2940 2940
2941#if defined (HAVE_X_WINDOWS) && defined (HAVE_XRENDER) \ 2941# if defined HAVE_XRENDER || defined HAVE_NS
2942 || defined (HAVE_NS) 2942# define HAVE_NATIVE_SCALING
2943#define HAVE_NATIVE_SCALING 2943# endif
2944#endif
2945 2944
2946/* Structure describing an image. Specific image formats like XBM are 2945/* Structure describing an image. Specific image formats like XBM are
2947 converted into this form, so that display only has to deal with 2946 converted into this form, so that display only has to deal with
@@ -2967,10 +2966,10 @@ struct image
2967 synchronized to Pixmap. */ 2966 synchronized to Pixmap. */
2968 XImagePtr ximg, mask_img; 2967 XImagePtr ximg, mask_img;
2969 2968
2970#ifdef HAVE_NATIVE_SCALING 2969# ifdef HAVE_NATIVE_SCALING
2971 /* Picture versions of pixmap and mask for compositing. */ 2970 /* Picture versions of pixmap and mask for compositing. */
2972 Picture picture, mask_picture; 2971 Picture picture, mask_picture;
2973#endif 2972# endif
2974#endif 2973#endif
2975 2974
2976 /* Colors allocated for this image, if any. Allocated via xmalloc. */ 2975 /* Colors allocated for this image, if any. Allocated via xmalloc. */
diff --git a/src/image.c b/src/image.c
index 84c31dcfc3c..2fae105815d 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1859,47 +1859,48 @@ compute_image_size (size_t width, size_t height,
1859 *d_width = desired_width; 1859 *d_width = desired_width;
1860 *d_height = desired_height; 1860 *d_height = desired_height;
1861} 1861}
1862#endif /* HAVE_IMAGEMAGICK || HAVE_NATIVE_SCALING */
1862 1863
1863#ifdef HAVE_NATIVE_SCALING
1864static void 1864static void
1865x_set_image_size (struct frame *f, struct image *img) 1865x_set_image_size (struct frame *f, struct image *img)
1866{ 1866{
1867#ifdef HAVE_IMAGEMAGICK 1867#ifdef HAVE_NATIVE_SCALING
1868# ifdef HAVE_IMAGEMAGICK
1868 /* ImageMagick images are already the correct size. */ 1869 /* ImageMagick images are already the correct size. */
1869 if (!EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick)) 1870 if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick))
1870#endif 1871 return;
1871 { 1872# endif
1872 int width, height;
1873 1873
1874 compute_image_size (img->width, img->height, img->spec, &width, &height); 1874 int width, height;
1875 compute_image_size (img->width, img->height, img->spec, &width, &height);
1875 1876
1876#ifdef HAVE_NS 1877# ifdef HAVE_NS
1877 ns_image_set_size (img->pixmap, width, height); 1878 ns_image_set_size (img->pixmap, width, height);
1878 img->width = width; 1879 img->width = width;
1879 img->height = height; 1880 img->height = height;
1880#endif 1881# endif
1881 1882
1882#ifdef HAVE_XRENDER 1883# ifdef HAVE_XRENDER
1883 if (img->picture) 1884 if (img->picture)
1884 { 1885 {
1885 double xscale = (double) img->width/width; 1886 double xscale = img->width / (double) width;
1886 double yscale = (double) img->height/height; 1887 double yscale = img->height / (double) height;
1887 1888
1888 XTransform tmat = {{{XDoubleToFixed (xscale), XDoubleToFixed (0), XDoubleToFixed (0)}, 1889 XTransform tmat
1889 {XDoubleToFixed (0), XDoubleToFixed (yscale), XDoubleToFixed (0)}, 1890 = {{{XDoubleToFixed (xscale), XDoubleToFixed (0), XDoubleToFixed (0)},
1890 {XDoubleToFixed (0), XDoubleToFixed (0), XDoubleToFixed (1)}}}; 1891 {XDoubleToFixed (0), XDoubleToFixed (yscale), XDoubleToFixed (0)},
1892 {XDoubleToFixed (0), XDoubleToFixed (0), XDoubleToFixed (1)}}};
1891 1893
1892 XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, FilterBest, 0, 0); 1894 XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, FilterBest,
1893 XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat); 1895 0, 0);
1896 XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat);
1894 1897
1895 img->width = width; 1898 img->width = width;
1896 img->height = height; 1899 img->height = height;
1897 }
1898#endif
1899 } 1900 }
1900} 1901# endif
1901#endif 1902#endif
1902#endif /* HAVE_IMAGEMAGICK || HAVE_XRENDER || HAVE_NS */ 1903}
1903 1904
1904 1905
1905/* Return the id of image with Lisp specification SPEC on frame F. 1906/* Return the id of image with Lisp specification SPEC on frame F.
@@ -1956,9 +1957,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
1956 `:background COLOR'. */ 1957 `:background COLOR'. */
1957 Lisp_Object ascent, margin, relief, bg; 1958 Lisp_Object ascent, margin, relief, bg;
1958 int relief_bound; 1959 int relief_bound;
1959#ifdef HAVE_NATIVE_SCALING
1960 x_set_image_size (f, img); 1960 x_set_image_size (f, img);
1961#endif
1962 1961
1963 ascent = image_spec_value (spec, QCascent, NULL); 1962 ascent = image_spec_value (spec, QCascent, NULL);
1964 if (FIXNUMP (ascent)) 1963 if (FIXNUMP (ascent))
@@ -2139,9 +2138,6 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2139 Display *display = FRAME_X_DISPLAY (f); 2138 Display *display = FRAME_X_DISPLAY (f);
2140 Drawable drawable = FRAME_X_DRAWABLE (f); 2139 Drawable drawable = FRAME_X_DRAWABLE (f);
2141 Screen *screen = FRAME_X_SCREEN (f); 2140 Screen *screen = FRAME_X_SCREEN (f);
2142#ifdef HAVE_XRENDER
2143 int event_basep, error_basep;
2144#endif
2145 2141
2146 eassert (input_blocked_p ()); 2142 eassert (input_blocked_p ());
2147 2143
@@ -2178,7 +2174,8 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2178 return 0; 2174 return 0;
2179 } 2175 }
2180 2176
2181#ifdef HAVE_XRENDER 2177# ifdef HAVE_XRENDER
2178 int event_basep, error_basep;
2182 if (picture && XRenderQueryExtension (display, &event_basep, &error_basep)) 2179 if (picture && XRenderQueryExtension (display, &event_basep, &error_basep))
2183 { 2180 {
2184 XRenderPictFormat *format; 2181 XRenderPictFormat *format;
@@ -2191,7 +2188,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2191 : PictStandardA8); 2188 : PictStandardA8);
2192 *picture = XRenderCreatePicture (display, *pixmap, format, 0, &attr); 2189 *picture = XRenderCreatePicture (display, *pixmap, format, 0, &attr);
2193 } 2190 }
2194#endif 2191# endif
2195 2192
2196 return 1; 2193 return 1;
2197#endif /* HAVE_X_WINDOWS */ 2194#endif /* HAVE_X_WINDOWS */
@@ -2367,14 +2364,13 @@ image_create_x_image_and_pixmap (struct frame *f, struct image *img,
2367{ 2364{
2368 eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP); 2365 eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP);
2369 2366
2370 return x_create_x_image_and_pixmap (f, width, height, depth, ximg, 2367 Picture *picture = NULL;
2371 !mask_p ? &img->pixmap : &img->mask,
2372#ifdef HAVE_XRENDER 2368#ifdef HAVE_XRENDER
2373 !mask_p ? &img->picture : &img->mask_picture 2369 picture = !mask_p ? &img->picture : &img->mask_picture;
2374#else
2375 NULL
2376#endif 2370#endif
2377 ); 2371 return x_create_x_image_and_pixmap (f, width, height, depth, ximg,
2372 !mask_p ? &img->pixmap : &img->mask,
2373 picture);
2378} 2374}
2379 2375
2380/* Put X image XIMG into image IMG on frame F, as a mask if and only 2376/* Put X image XIMG into image IMG on frame F, as a mask if and only
diff --git a/src/xterm.c b/src/xterm.c
index fbbf61d320d..632703849f8 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3001,13 +3001,14 @@ x_composite_image (struct glyph_string *s, Pixmap dest,
3001 width, height); 3001 width, height);
3002 3002
3003 XRenderFreePicture (s->display, destination); 3003 XRenderFreePicture (s->display, destination);
3004 return;
3004 } 3005 }
3005 else
3006#endif 3006#endif
3007 XCopyArea (s->display, s->img->pixmap, 3007
3008 dest, s->gc, 3008 XCopyArea (s->display, s->img->pixmap,
3009 srcX, srcY, 3009 dest, s->gc,
3010 width, height, dstX, dstY); 3010 srcX, srcY,
3011 width, height, dstX, dstY);
3011} 3012}
3012 3013
3013 3014
@@ -3060,7 +3061,8 @@ x_draw_image_foreground (struct glyph_string *s)
3060 image_rect.width = s->slice.width; 3061 image_rect.width = s->slice.width;
3061 image_rect.height = s->slice.height; 3062 image_rect.height = s->slice.height;
3062 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 3063 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
3063 x_composite_image (s, FRAME_X_DRAWABLE (s->f), s->slice.x + r.x - x, s->slice.y + r.y - y, 3064 x_composite_image (s, FRAME_X_DRAWABLE (s->f),
3065 s->slice.x + r.x - x, s->slice.y + r.y - y,
3064 r.x, r.y, r.width, r.height); 3066 r.x, r.y, r.width, r.height);
3065 } 3067 }
3066 else 3068 else