summaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@raeburn.org>2015-10-03 00:15:54 -0400
committerKen Raeburn <raeburn@raeburn.org>2015-10-08 01:19:49 -0400
commitb8eea1d7b1485a147f112127c0ca58cb1a0a8ebb (patch)
tree215730e1b1fc26ea26a37f4b454c6da138be4c28 /src/image.c
parent0360b7f2c4f0358106e229de4dfe91a67445a50c (diff)
downloademacs-b8eea1d7b1485a147f112127c0ca58cb1a0a8ebb.tar.gz
Cache XParseColor results in the X display info structure.
With repeated lookups of foreground and background colors for multiple faces per frame, we issue a lot of redundant color name lookups to the X server, waiting every time for the response. On a remote network with, say, 30ms round-trip time, this can add nearly a full second to creation of a new frame. * src/gtkutil.c (xg_check_special_colors): Call x_parse_color. * src/image.c (get_spec_bg_or_alpha_as_argb): (xpm_init_color_cache, xpm_lookup_color): * src/xfns.c (x_defined_color): * src/xterm.c (x_parse_color): New function; caches color names not starting with "#" in the display-info structure. (x_delete_display): Delete the cache content. * src/xterm.h (struct color_name_cache_entry): New type. (x_parse_color): Declare. (struct x_display_info): Add a new field for the cache.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/image.c b/src/image.c
index 10b067f889c..79bf21e8865 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1108,10 +1108,7 @@ get_spec_bg_or_alpha_as_argb (struct image *img,
XColor xbgcolor;
Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL);
- if (STRINGP (bg) && XParseColor (FRAME_X_DISPLAY (f),
- FRAME_X_COLORMAP (f),
- SSDATA (bg),
- &xbgcolor))
+ if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor))
bgcolor = xcolor_to_argb32 (xbgcolor);
return bgcolor;
@@ -3241,7 +3238,10 @@ static struct xpm_cached_color *xpm_cache_color (struct frame *, char *,
/* An entry in a hash table used to cache color definitions of named
colors. This cache is necessary to speed up XPM image loading in
case we do color allocations ourselves. Without it, we would need
- a call to XParseColor per pixel in the image. */
+ a call to XParseColor per pixel in the image.
+
+ FIXME Now that we're using x_parse_color and its cache, reevaluate
+ the need for this caching layer. */
struct xpm_cached_color
{
@@ -3276,8 +3276,7 @@ xpm_init_color_cache (struct frame *f, XpmAttributes *attrs)
XColor color;
for (i = 0; i < attrs->numsymbols; ++i)
- if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
- attrs->colorsymbols[i].value, &color))
+ if (x_parse_color (f, attrs->colorsymbols[i].value, &color))
{
color.pixel = lookup_rgb_color (f, color.red, color.green,
color.blue);
@@ -3356,8 +3355,7 @@ xpm_lookup_color (struct frame *f, char *color_name, XColor *color)
if (p != NULL)
*color = p->color;
- else if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
- color_name, color))
+ else if (x_parse_color (f, color_name, color))
{
color->pixel = lookup_rgb_color (f, color->red, color->green,
color->blue);