changeset 5918:cb65bfaf7110 default

Speed up XEmacs on X. Avoid many calls to XQueryColor.
author Mike Sperber <sperber@deinprogramm.de>
date Fri, 27 Mar 2015 16:05:15 +0100
parents ffb5abc8dc4e
children
files lwlib/ChangeLog lwlib/lwlib-colors.c lwlib/lwlib-colors.h src/ChangeLog src/redisplay-xlike-inc.c
diffstat 5 files changed, 41 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/ChangeLog	Thu Jun 11 16:09:11 2015 +0100
+++ b/lwlib/ChangeLog	Fri Mar 27 16:05:15 2015 +0100
@@ -1,3 +1,9 @@
+2015-06-22  Michael Sperber  <mike@xemacs.org>
+
+	* lwlib-colors.h: 
+	* lwlib-colors.c (xft_convert_color_1): Introduce, and make
+	`xft_convert_color' use it.
+
 2015-01-08  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	Fix progress bar crashes.
--- a/lwlib/lwlib-colors.c	Thu Jun 11 16:09:11 2015 +0100
+++ b/lwlib/lwlib-colors.c	Fri Mar 27 16:05:15 2015 +0100
@@ -329,6 +329,29 @@
 #ifdef HAVE_XFT
 
 XftColor
+xft_convert_color_1 (Display *dpy, Colormap cmap, Visual *visual, XColor *pcolor, int dim)
+{
+  XColor color = *pcolor;
+  XftColor result;
+
+  if (dim)
+    {
+      color.red   = MINL (65535, color.red   * 1.5);
+      color.green = MINL (65535, color.green * 1.5);
+      color.blue  = MINL (65535, color.blue  * 1.5);
+      x_allocate_nearest_color (dpy, cmap, visual, &color);
+    }
+
+  result.pixel = color.pixel;
+  result.color.red = color.red;
+  result.color.green = color.green;
+  result.color.blue = color.blue;
+  result.color.alpha = 0xffff;
+
+  return result;
+}
+
+XftColor
 xft_convert_color (Display *dpy, Colormap cmap, Visual *visual, int c, int dim)
 {
   static XColor color;		/* #### why is this static ?? */
@@ -337,22 +360,10 @@
   color.pixel = c;
   XQueryColor(dpy, cmap, &color);
 
-  if (dim)
-    {
-      color.red   = MINL (65535, color.red   * 1.5);
-      color.green = MINL (65535, color.green * 1.5);
-      color.blue  = MINL (65535, color.blue  * 1.5);
-      x_allocate_nearest_color (dpy, cmap, visual, &color);
-    }     
+  return xft_convert_color_1 (dpy, cmap, visual, &color, dim);
+}
 
-  result.pixel = color.pixel;
-  result.color.red = color.red;
-  result.color.green = color.green;
-  result.color.blue = color.blue;
-  result.color.alpha = 0xffff;
-  
-  return result;
-}
+
 
 #endif /* HAVE_XFT */
 
--- a/lwlib/lwlib-colors.h	Thu Jun 11 16:09:11 2015 +0100
+++ b/lwlib/lwlib-colors.h	Fri Mar 27 16:05:15 2015 +0100
@@ -52,6 +52,8 @@
 
 XftColor xft_convert_color (Display *dpy, Colormap cmap, Visual *visual,
 			    int c, int dim);
+XftColor xft_convert_color_1 (Display *dpy, Colormap cmap, Visual *visual,
+			    XColor *pcolor, int dim);
 #endif /* HAVE_XFT */
 
 #endif /* INCLUDED_lwlib_colors_h_ */
--- a/src/ChangeLog	Thu Jun 11 16:09:11 2015 +0100
+++ b/src/ChangeLog	Fri Mar 27 16:05:15 2015 +0100
@@ -1,3 +1,8 @@
+2015-06-22  Michael Sperber  <mike@xemacs.org>
+
+	* redisplay-xlike-inc.c (XFT_FROB_LISP_COLOR): Use
+	`xft_convert_color_1' instead of `xft_convert_color'.
+
 2015-06-03  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* lread.c (Fload_internal):
--- a/src/redisplay-xlike-inc.c	Thu Jun 11 16:09:11 2015 +0100
+++ b/src/redisplay-xlike-inc.c	Fri Mar 27 16:05:15 2015 +0100
@@ -1033,8 +1033,8 @@
      color.  See ca. line 759 this file.
      #### Maybe xft_convert_color should take an XColor, not a pixel. */
 #define XFT_FROB_LISP_COLOR(color, dim)					\
-  xft_convert_color (dpy, cmap, visual,					\
-		     XCOLOR_INSTANCE_X_COLOR (color).pixel, (dim))
+  xft_convert_color_1 (dpy, cmap, visual,					\
+		     &(XCOLOR_INSTANCE_X_COLOR (color)), (dim))
 #endif /* USE_XFT */
 
   if (width < 0)