… | |
… | |
666 | static unsigned int |
666 | static unsigned int |
667 | insert_component (unsigned int value, unsigned int mask, unsigned int shift) |
667 | insert_component (unsigned int value, unsigned int mask, unsigned int shift) |
668 | { |
668 | { |
669 | return (value * (mask + 1) >> 16) << shift; |
669 | return (value * (mask + 1) >> 16) << shift; |
670 | } |
670 | } |
671 | |
671 | |
672 | bool |
672 | bool |
673 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
673 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
674 | { |
674 | { |
675 | #if XFT |
675 | #if XFT |
676 | XRenderPictFormat *format; |
676 | XRenderPictFormat *format; |
… | |
… | |
795 | { |
795 | { |
796 | XColor *colors = new XColor [screen->visual->map_entries]; |
796 | XColor *colors = new XColor [screen->visual->map_entries]; |
797 | |
797 | |
798 | for (int i = 0; i < cmap_size; i++) |
798 | for (int i = 0; i < cmap_size; i++) |
799 | colors [i].pixel = i; |
799 | colors [i].pixel = i; |
800 | |
800 | |
801 | // many kilobytes transfer per colour, but pseudocolor isn't worth |
801 | // many kilobytes transfer per colour, but pseudocolor isn't worth |
802 | // many extra optimisations. |
802 | // many extra optimisations. |
803 | XQueryColors (screen->dpy, screen->cmap, colors, cmap_size); |
803 | XQueryColors (screen->dpy, screen->cmap, colors, cmap_size); |
804 | |
804 | |
805 | int diff = 0x7fffffffUL; |
805 | int diff = 0x7fffffffUL; |
… | |
… | |
818 | } |
818 | } |
819 | } |
819 | } |
820 | |
820 | |
821 | //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", |
821 | //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", |
822 | // color.r, color.g, color.b, best->red, best->green, best->blue, diff); |
822 | // color.r, color.g, color.b, best->red, best->green, best->blue, diff); |
823 | |
823 | |
824 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
824 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
825 | |
825 | |
826 | delete [] colors; |
826 | delete [] colors; |
827 | } |
827 | } |
828 | #endif |
828 | #endif |
… | |
… | |
856 | color.green = c.g; |
856 | color.green = c.g; |
857 | color.blue = c.b; |
857 | color.blue = c.b; |
858 | color.pixel = (Pixel)*this; |
858 | color.pixel = (Pixel)*this; |
859 | } |
859 | } |
860 | |
860 | |
861 | void |
861 | void |
862 | rxvt_color::free (rxvt_screen *screen) |
862 | rxvt_color::free (rxvt_screen *screen) |
863 | { |
863 | { |
864 | if (screen->visual->c_class == TrueColor) |
864 | if (screen->visual->c_class == TrueColor) |
865 | return; // nothing to do |
865 | return; // nothing to do |
866 | |
866 | |