mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-27 19:31:38 +00:00
(lookup_rgb_color): Handle TrueColor visuals specially.
This commit is contained in:
parent
17139abc07
commit
e019878d2c
@ -1,3 +1,7 @@
|
||||
2003-08-29 Gerd Moellmann <gerd@gnu.org>
|
||||
|
||||
* xfns.c (lookup_rgb_color): Handle TrueColor visuals specially.
|
||||
|
||||
2003-08-28 David Abrahams <dave@boost-consulting.com> (tiny change)
|
||||
|
||||
* coding.c (decode_coding_iso2022): Initialized local variable c2.
|
||||
|
36
src/xfns.c
36
src/xfns.c
@ -6755,7 +6755,43 @@ lookup_rgb_color (f, r, g, b)
|
||||
unsigned hash = CT_HASH_RGB (r, g, b);
|
||||
int i = hash % CT_SIZE;
|
||||
struct ct_color *p;
|
||||
Visual *visual;
|
||||
|
||||
/* Handle TrueColor visuals specially, which improves performance by
|
||||
two orders of magnitude. Freeing colors on TrueColor visuals is
|
||||
a nop, and pixel colors specify RGB values directly. See also
|
||||
the Xlib spec, chapter 3.1. */
|
||||
visual = FRAME_X_DISPLAY_INFO (f)->visual;
|
||||
if (visual->class == TrueColor)
|
||||
{
|
||||
int bits = visual->bits_per_rgb;
|
||||
unsigned long pr, pg, pb;
|
||||
|
||||
/* Apply gamma-correction like normal color allocation does. */
|
||||
if (f->gamma)
|
||||
{
|
||||
XColor color;
|
||||
color.red = r, color.green = g, color.blue = b;
|
||||
gamma_correct (f, &color);
|
||||
r = color.red, g = color.green, b = color.blue;
|
||||
}
|
||||
|
||||
/* Scale down RGB values to the visual's bits per RGB, and shift
|
||||
them to the right position in the pixel color. Note that the
|
||||
original RGB values are 16-bit values, as usual in X. */
|
||||
pr = (r >> (16 - bits)) << 2 * bits;
|
||||
pg = (g >> (16 - bits)) << 1 * bits;
|
||||
pb = (b >> (16 - bits)) << 0 * bits;
|
||||
|
||||
/* Apply RGB masks of the visual. */
|
||||
pr &= visual->red_mask;
|
||||
pg &= visual->green_mask;
|
||||
pb &= visual->blue_mask;
|
||||
|
||||
/* Assemble the pixel color. */
|
||||
return pr | pg | pb;
|
||||
}
|
||||
|
||||
for (p = ct_table[i]; p; p = p->next)
|
||||
if (p->r == r && p->g == g && p->b == b)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user