diff options
| author | Ken Raeburn | 2015-10-03 00:15:54 -0400 |
|---|---|---|
| committer | Ken Raeburn | 2015-10-08 01:19:49 -0400 |
| commit | b8eea1d7b1485a147f112127c0ca58cb1a0a8ebb (patch) | |
| tree | 215730e1b1fc26ea26a37f4b454c6da138be4c28 /src/image.c | |
| parent | 0360b7f2c4f0358106e229de4dfe91a67445a50c (diff) | |
| download | emacs-b8eea1d7b1485a147f112127c0ca58cb1a0a8ebb.tar.gz emacs-b8eea1d7b1485a147f112127c0ca58cb1a0a8ebb.zip | |
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.c | 16 |
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, | |||
| 1108 | XColor xbgcolor; | 1108 | XColor xbgcolor; |
| 1109 | Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL); | 1109 | Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL); |
| 1110 | 1110 | ||
| 1111 | if (STRINGP (bg) && XParseColor (FRAME_X_DISPLAY (f), | 1111 | if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor)) |
| 1112 | FRAME_X_COLORMAP (f), | ||
| 1113 | SSDATA (bg), | ||
| 1114 | &xbgcolor)) | ||
| 1115 | bgcolor = xcolor_to_argb32 (xbgcolor); | 1112 | bgcolor = xcolor_to_argb32 (xbgcolor); |
| 1116 | 1113 | ||
| 1117 | return bgcolor; | 1114 | return bgcolor; |
| @@ -3241,7 +3238,10 @@ static struct xpm_cached_color *xpm_cache_color (struct frame *, char *, | |||
| 3241 | /* An entry in a hash table used to cache color definitions of named | 3238 | /* An entry in a hash table used to cache color definitions of named |
| 3242 | colors. This cache is necessary to speed up XPM image loading in | 3239 | colors. This cache is necessary to speed up XPM image loading in |
| 3243 | case we do color allocations ourselves. Without it, we would need | 3240 | case we do color allocations ourselves. Without it, we would need |
| 3244 | a call to XParseColor per pixel in the image. */ | 3241 | a call to XParseColor per pixel in the image. |
| 3242 | |||
| 3243 | FIXME Now that we're using x_parse_color and its cache, reevaluate | ||
| 3244 | the need for this caching layer. */ | ||
| 3245 | 3245 | ||
| 3246 | struct xpm_cached_color | 3246 | struct xpm_cached_color |
| 3247 | { | 3247 | { |
| @@ -3276,8 +3276,7 @@ xpm_init_color_cache (struct frame *f, XpmAttributes *attrs) | |||
| 3276 | XColor color; | 3276 | XColor color; |
| 3277 | 3277 | ||
| 3278 | for (i = 0; i < attrs->numsymbols; ++i) | 3278 | for (i = 0; i < attrs->numsymbols; ++i) |
| 3279 | if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), | 3279 | if (x_parse_color (f, attrs->colorsymbols[i].value, &color)) |
| 3280 | attrs->colorsymbols[i].value, &color)) | ||
| 3281 | { | 3280 | { |
| 3282 | color.pixel = lookup_rgb_color (f, color.red, color.green, | 3281 | color.pixel = lookup_rgb_color (f, color.red, color.green, |
| 3283 | color.blue); | 3282 | color.blue); |
| @@ -3356,8 +3355,7 @@ xpm_lookup_color (struct frame *f, char *color_name, XColor *color) | |||
| 3356 | 3355 | ||
| 3357 | if (p != NULL) | 3356 | if (p != NULL) |
| 3358 | *color = p->color; | 3357 | *color = p->color; |
| 3359 | else if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), | 3358 | else if (x_parse_color (f, color_name, color)) |
| 3360 | color_name, color)) | ||
| 3361 | { | 3359 | { |
| 3362 | color->pixel = lookup_rgb_color (f, color->red, color->green, | 3360 | color->pixel = lookup_rgb_color (f, color->red, color->green, |
| 3363 | color->blue); | 3361 | color->blue); |