# HG changeset patch # User Mike Sperber # Date 1427468715 -3600 # Node ID cb65bfaf7110db022418813ef36e1d6e502d5628 # Parent ffb5abc8dc4e37878272e66a6b39c928ba03d89c Speed up XEmacs on X. Avoid many calls to XQueryColor. diff -r ffb5abc8dc4e -r cb65bfaf7110 lwlib/ChangeLog --- 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 + + * lwlib-colors.h: + * lwlib-colors.c (xft_convert_color_1): Introduce, and make + `xft_convert_color' use it. + 2015-01-08 Stephen J. Turnbull Fix progress bar crashes. diff -r ffb5abc8dc4e -r cb65bfaf7110 lwlib/lwlib-colors.c --- 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 */ diff -r ffb5abc8dc4e -r cb65bfaf7110 lwlib/lwlib-colors.h --- 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_ */ diff -r ffb5abc8dc4e -r cb65bfaf7110 src/ChangeLog --- 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 + + * redisplay-xlike-inc.c (XFT_FROB_LISP_COLOR): Use + `xft_convert_color_1' instead of `xft_convert_color'. + 2015-06-03 Aidan Kehoe * lread.c (Fload_internal): diff -r ffb5abc8dc4e -r cb65bfaf7110 src/redisplay-xlike-inc.c --- 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)