Mercurial > hg > xemacs-beta
diff lwlib/lwlib-colors.c @ 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 | 308d34e9f07d |
children |
line wrap: on
line diff
--- 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 */