aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
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/image.c
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/image.c')
-rw-r--r--src/image.c78
1 files changed, 37 insertions, 41 deletions
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