aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorKen Raeburn2015-10-03 00:18:50 -0400
committerKen Raeburn2015-10-08 01:44:42 -0400
commite23ed19ff933c35111f3a806b4104fee8ef42f55 (patch)
treedca1de3b389da477befb537c46a3a7992c02b1ea /src/image.c
parentb8eea1d7b1485a147f112127c0ca58cb1a0a8ebb (diff)
downloademacs-e23ed19ff933c35111f3a806b4104fee8ef42f55.tar.gz
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/image.c')
-rw-r--r--src/image.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/image.c b/src/image.c
index 79bf21e8865..401689e940a 100644
--- a/src/image.c
+++ b/src/image.c
@@ -4442,15 +4442,7 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
4442 r = color.red, g = color.green, b = color.blue; 4442 r = color.red, g = color.green, b = color.blue;
4443 } 4443 }
4444 4444
4445 /* Scale down RGB values to the visual's bits per RGB, and shift 4445 return x_make_truecolor_pixel (dpyinfo, r, g, b);
4446 them to the right position in the pixel color. Note that the
4447 original RGB values are 16-bit values, as usual in X. */
4448 pr = (r >> (16 - dpyinfo->red_bits)) << dpyinfo->red_offset;
4449 pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
4450 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset;
4451
4452 /* Assemble the pixel color. */
4453 return pr | pg | pb;
4454 } 4446 }
4455 4447
4456 for (p = ct_table[i]; p; p = p->next) 4448 for (p = ct_table[i]; p; p = p->next)
@@ -9542,7 +9534,6 @@ void
9542x_kill_gs_process (Pixmap pixmap, struct frame *f) 9534x_kill_gs_process (Pixmap pixmap, struct frame *f)
9543{ 9535{
9544 struct image_cache *c = FRAME_IMAGE_CACHE (f); 9536 struct image_cache *c = FRAME_IMAGE_CACHE (f);
9545 int class;
9546 ptrdiff_t i; 9537 ptrdiff_t i;
9547 struct image *img; 9538 struct image *img;
9548 9539
@@ -9568,8 +9559,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9568 /* On displays with a mutable colormap, figure out the colors 9559 /* On displays with a mutable colormap, figure out the colors
9569 allocated for the image by looking at the pixels of an XImage for 9560 allocated for the image by looking at the pixels of an XImage for
9570 img->pixmap. */ 9561 img->pixmap. */
9571 class = FRAME_X_VISUAL (f)->class; 9562 if (x_mutable_colormap (FRAME_X_VISUAL (f)))
9572 if (class != StaticColor && class != StaticGray && class != TrueColor)
9573 { 9563 {
9574 XImagePtr ximg; 9564 XImagePtr ximg;
9575 9565