]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor tweaks to HAVE_NATIVE_SCALING code
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jan 2019 23:29:21 +0000 (15:29 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jan 2019 23:30:13 +0000 (15:30 -0800)
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’.

src/dispextern.h
src/image.c
src/xterm.c

index b064875ac465029a58bf2b4992c3f3b86757f5a8..9cea3218c161e8abba805623c9736dde4a84cc4b 100644 (file)
@@ -32,7 +32,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #endif /* USE_X_TOOLKIT */
 
 #ifdef HAVE_XRENDER
-#include <X11/extensions/Xrender.h>
+# include <X11/extensions/Xrender.h>
 #endif
 #else /* !HAVE_X_WINDOWS */
 
@@ -2938,10 +2938,9 @@ struct redisplay_interface
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-#if defined (HAVE_X_WINDOWS) && defined (HAVE_XRENDER) \
-  || defined (HAVE_NS)
-#define HAVE_NATIVE_SCALING
-#endif
+# if defined HAVE_XRENDER || defined HAVE_NS
+#  define HAVE_NATIVE_SCALING
+# endif
 
 /* Structure describing an image.  Specific image formats like XBM are
    converted into this form, so that display only has to deal with
@@ -2967,10 +2966,10 @@ struct image
      synchronized to Pixmap.  */
   XImagePtr ximg, mask_img;
 
-#ifdef HAVE_NATIVE_SCALING
+# ifdef HAVE_NATIVE_SCALING
   /* Picture versions of pixmap and mask for compositing.  */
   Picture picture, mask_picture;
-#endif
+# endif
 #endif
 
   /* Colors allocated for this image, if any.  Allocated via xmalloc.  */
index 84c31dcfc3c16b9f8883bd75053f926f64218891..2fae105815db70cb49a3ba1e1e53137986cff1ee 100644 (file)
@@ -1859,47 +1859,48 @@ compute_image_size (size_t width, size_t height,
   *d_width = desired_width;
   *d_height = desired_height;
 }
+#endif /* HAVE_IMAGEMAGICK || HAVE_NATIVE_SCALING */
 
-#ifdef HAVE_NATIVE_SCALING
 static void
 x_set_image_size (struct frame *f, struct image *img)
 {
-#ifdef HAVE_IMAGEMAGICK
+#ifdef HAVE_NATIVE_SCALING
+# ifdef HAVE_IMAGEMAGICK
   /* ImageMagick images are already the correct size.  */
-  if (!EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick))
-#endif
-    {
-      int width, height;
+  if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick))
+    return;
+# endif
 
-      compute_image_size (img->width, img->height, img->spec, &width, &height);
+  int width, height;
+  compute_image_size (img->width, img->height, img->spec, &width, &height);
 
-#ifdef HAVE_NS
-      ns_image_set_size (img->pixmap, width, height);
-      img->width = width;
-      img->height = height;
-#endif
+# ifdef HAVE_NS
+  ns_image_set_size (img->pixmap, width, height);
+  img->width = width;
+  img->height = height;
+# endif
 
-#ifdef HAVE_XRENDER
-      if (img->picture)
-      {
-        double xscale = (double) img->width/width;
-        double yscale = (double) img->height/height;
+# ifdef HAVE_XRENDER
+  if (img->picture)
+    {
+      double xscale = img->width / (double) width;
+      double yscale = img->height / (double) height;
 
-        XTransform tmat = {{{XDoubleToFixed (xscale), XDoubleToFixed (0), XDoubleToFixed (0)},
-                            {XDoubleToFixed (0), XDoubleToFixed (yscale), XDoubleToFixed (0)},
-                            {XDoubleToFixed (0), XDoubleToFixed (0), XDoubleToFixed (1)}}};
+      XTransform tmat
+       = {{{XDoubleToFixed (xscale), XDoubleToFixed (0), XDoubleToFixed (0)},
+           {XDoubleToFixed (0), XDoubleToFixed (yscale), XDoubleToFixed (0)},
+           {XDoubleToFixed (0), XDoubleToFixed (0), XDoubleToFixed (1)}}};
 
-        XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, FilterBest, 0, 0);
-        XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat);
+      XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, FilterBest,
+                              0, 0);
+      XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat);
 
-        img->width = width;
-        img->height = height;
-      }
-#endif
+      img->width = width;
+      img->height = height;
     }
-}
+# endif
 #endif
-#endif /* HAVE_IMAGEMAGICK || HAVE_XRENDER || HAVE_NS  */
+}
 
 
 /* Return the id of image with Lisp specification SPEC on frame F.
@@ -1956,9 +1957,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
             `:background COLOR'.  */
          Lisp_Object ascent, margin, relief, bg;
          int relief_bound;
-#ifdef HAVE_NATIVE_SCALING
           x_set_image_size (f, img);
-#endif
 
          ascent = image_spec_value (spec, QCascent, NULL);
          if (FIXNUMP (ascent))
@@ -2139,9 +2138,6 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
   Display *display = FRAME_X_DISPLAY (f);
   Drawable drawable = FRAME_X_DRAWABLE (f);
   Screen *screen = FRAME_X_SCREEN (f);
-#ifdef HAVE_XRENDER
-  int event_basep, error_basep;
-#endif
 
   eassert (input_blocked_p ());
 
@@ -2178,7 +2174,8 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
       return 0;
     }
 
-#ifdef HAVE_XRENDER
+# ifdef HAVE_XRENDER
+  int event_basep, error_basep;
   if (picture && XRenderQueryExtension (display, &event_basep, &error_basep))
     {
       XRenderPictFormat *format;
@@ -2191,7 +2188,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
                                           : PictStandardA8);
       *picture = XRenderCreatePicture (display, *pixmap, format, 0, &attr);
     }
-#endif
+# endif
 
   return 1;
 #endif /* HAVE_X_WINDOWS */
@@ -2367,14 +2364,13 @@ image_create_x_image_and_pixmap (struct frame *f, struct image *img,
 {
   eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP);
 
-  return x_create_x_image_and_pixmap (f, width, height, depth, ximg,
-                                     !mask_p ? &img->pixmap : &img->mask,
+  Picture *picture = NULL;
 #ifdef HAVE_XRENDER
-                                      !mask_p ? &img->picture : &img->mask_picture
-#else
-                                      NULL
+  picture = !mask_p ? &img->picture : &img->mask_picture;
 #endif
-                                      );
+  return x_create_x_image_and_pixmap (f, width, height, depth, ximg,
+                                     !mask_p ? &img->pixmap : &img->mask,
+                                     picture);
 }
 
 /* Put X image XIMG into image IMG on frame F, as a mask if and only
index fbbf61d320df7064fbcd5922c0b1a1e97440891d..632703849f8ab966512da00df750943fb72c97cb 100644 (file)
@@ -3001,13 +3001,14 @@ x_composite_image (struct glyph_string *s, Pixmap dest,
                         width, height);
 
       XRenderFreePicture (s->display, destination);
+      return;
     }
-  else
 #endif
-    XCopyArea (s->display, s->img->pixmap,
-               dest, s->gc,
-               srcX, srcY,
-               width, height, dstX, dstY);
+
+  XCopyArea (s->display, s->img->pixmap,
+            dest, s->gc,
+            srcX, srcY,
+            width, height, dstX, dstY);
 }
 
 
@@ -3060,7 +3061,8 @@ x_draw_image_foreground (struct glyph_string *s)
          image_rect.width = s->slice.width;
          image_rect.height = s->slice.height;
          if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
-            x_composite_image (s, FRAME_X_DRAWABLE (s->f), s->slice.x + r.x - x, s->slice.y + r.y - y,
+            x_composite_image (s, FRAME_X_DRAWABLE (s->f),
+                              s->slice.x + r.x - x, s->slice.y + r.y - y,
                                r.x, r.y, r.width, r.height);
        }
       else