summaryrefslogtreecommitdiff
path: root/src/xfaces.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@raeburn.org>2015-10-03 00:18:50 -0400
committerKen Raeburn <raeburn@raeburn.org>2015-10-08 01:44:42 -0400
commite23ed19ff933c35111f3a806b4104fee8ef42f55 (patch)
treedca1de3b389da477befb537c46a3a7992c02b1ea /src/xfaces.c
parentb8eea1d7b1485a147f112127c0ca58cb1a0a8ebb (diff)
downloademacs-e23ed19ff933c35111f3a806b4104fee8ef42f55.tar.gz
emacs-e23ed19ff933c35111f3a806b4104fee8ef42f55.tar.bz2
emacs-e23ed19ff933c35111f3a806b4104fee8ef42f55.zip
Reduce color allocation/query traffic in the TrueColor case.
When working with an X visual with TrueColor class, pixel values can be generated from the RGB values according to mask value provided by the server on connection. Some of the image-handling code was already doing this. * src/xterm.h (x_make_truecolor_pixel): New function; code taken from lookup_rgb_color. (x_mutable_colormap): New function. * src/image.c (lookup_rgb_color): Move pixel composition code to x_make_truecolor_pixel. (x_kill_gs_process): Call x_mutable_colormap. * src/xfaces.c (x_free_colors, x_free_dpy_colors): Call x_mutable_colormap. * src/xftfont.c (xftfont_get_colors): Call x_query_colors. * src/xterm.c (x_query_colors): For a TrueColor display, decompose the pixel value into RGB values directly, and don't send a request to the server. (x_alloc_nearest_color): For a TrueColor display, construct the pixel value with x_make_truecolor_pixel. (x_copy_color): For an immutable color map, just return the provided pixel value.
Diffstat (limited to 'src/xfaces.c')
-rw-r--r--src/xfaces.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 8cf0b427799..a3d122fbf46 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -454,11 +454,9 @@ DEFUN ("dump-colors", Fdump_colors, Sdump_colors, 0, 0, 0,
void
x_free_colors (struct frame *f, unsigned long *pixels, int npixels)
{
- int class = FRAME_DISPLAY_INFO (f)->visual->class;
-
/* If display has an immutable color map, freeing colors is not
necessary and some servers don't allow it. So don't do it. */
- if (class != StaticColor && class != StaticGray && class != TrueColor)
+ if (x_mutable_colormap (FRAME_X_VISUAL (f)))
{
#ifdef DEBUG_X_COLORS
unregister_colors (pixels, npixels);
@@ -471,7 +469,7 @@ x_free_colors (struct frame *f, unsigned long *pixels, int npixels)
#ifdef USE_X_TOOLKIT
-/* Free colors used on frame F. PIXELS is an array of NPIXELS pixel
+/* Free colors used on display DPY. PIXELS is an array of NPIXELS pixel
color values. Interrupt input must be blocked when this function
is called. */
@@ -480,11 +478,10 @@ x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
unsigned long *pixels, int npixels)
{
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
- int class = dpyinfo->visual->class;
/* If display has an immutable color map, freeing colors is not
necessary and some servers don't allow it. So don't do it. */
- if (class != StaticColor && class != StaticGray && class != TrueColor)
+ if (x_mutable_colormap (dpyinfo->visual))
{
#ifdef DEBUG_X_COLORS
unregister_colors (pixels, npixels);