ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.C
(Generate patch)

Comparing rxvt-unicode/src/rxvttoolkit.C (file contents):
Revision 1.146 by root, Sun Dec 14 04:52:10 2014 UTC vs.
Revision 1.149 by root, Wed Dec 17 16:03:51 2014 UTC

755 unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a; 755 unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a;
756 756
757#if XFT 757#if XFT
758 XRenderPictFormat *format; 758 XRenderPictFormat *format;
759 759
760 // not needed by XftColorAlloc, but by the other paths (ours
761 // and fallback), so just set all components here.
762 c.color.red = color.r;
763 c.color.green = color.g;
764 c.color.blue = color.b;
765 c.color.alpha = alpha;
766
760 // FUCKING Xft gets it wrong, of course, so work around it. 767 // FUCKING Xft gets it wrong, of course, so work around it.
761 // Transparency users should eat shit and die, and then 768 // Transparency users should eat shit and die, and then
762 // XRenderQueryPictIndexValues themselves plenty. 769 // XRenderQueryPictIndexValues themselves plenty.
763 if ((screen->visual->c_class == TrueColor) 770 if ((screen->visual->c_class == TrueColor)
764 && (format = XRenderFindVisualFormat (screen->dpy, screen->visual))) 771 && (format = XRenderFindVisualFormat (screen->dpy, screen->visual)))
765 { 772 {
766 // the fun lies in doing everything manually... 773 // the fun lies in doing everything manually...
767 c.color.red = color.r;
768 c.color.green = color.g;
769 c.color.blue = color.b;
770 c.color.alpha = alpha;
771 774
772 // Xft wants premultiplied alpha, but abuses the alpha channel 775 // Xft wants premultiplied alpha, but abuses the alpha channel
773 // as blend factor, and doesn't allow us to set the alpha channel 776 // as blend factor, and doesn't allow us to set the alpha channel
774 c.color.red = c.color.red * alpha / 0xffff; 777 c.color.red = c.color.red * alpha / 0xffff;
775 c.color.green = c.color.green * alpha / 0xffff; 778 c.color.green = c.color.green * alpha / 0xffff;
789 d.red = color.r; 792 d.red = color.r;
790 d.green = color.g; 793 d.green = color.g;
791 d.blue = color.b; 794 d.blue = color.b;
792 d.alpha = alpha; 795 d.alpha = alpha;
793 796
797 // XftColorAlloc always returns 100% transparent pixels(!)
794 if (XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c)) 798 if (XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c))
795 return true; 799 return true;
796 } 800 }
797#else 801#else
798 c.red = color.r; 802 c.red = color.r;
809 } 813 }
810 else if (XAllocColor (screen->dpy, screen->cmap, &c)) 814 else if (XAllocColor (screen->dpy, screen->cmap, &c))
811 return true; 815 return true;
812#endif 816#endif
813 817
814 //TODO: set c.color* or c.*
815 c.pixel = (color.r * 2 + color.g * 3 + color.b) >= 0x8000 * 6 818 c.pixel = (color.r * 2 + color.g * 3 + color.b) >= 0x8000 * 6
816 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) 819 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy))
817 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); 820 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy));
818 821
819 return false; 822 return false;
919 922
920void 923void
921rxvt_color::get (rgba &color) const 924rxvt_color::get (rgba &color) const
922{ 925{
923#if XFT 926#if XFT
924 //TODO premultiplied alpha?? 927
925 color.r = c.color.red; 928 color.r = c.color.red;
926 color.g = c.color.green; 929 color.g = c.color.green;
927 color.b = c.color.blue; 930 color.b = c.color.blue;
928 color.a = c.color.alpha; 931 color.a = c.color.alpha;
932
933 if (IN_RANGE_INC (color.a, 0x0001, 0xfffe))
934 {
935 color.r = color.r * 0xffff / color.a;
936 color.g = color.g * 0xffff / color.a;
937 color.b = color.b * 0xffff / color.a;
938 }
939
929#else 940#else
941
930 color.r = c.red; 942 color.r = c.red;
931 color.g = c.green; 943 color.g = c.green;
932 color.b = c.blue; 944 color.b = c.blue;
933 color.a = rgba::MAX_CC; 945 color.a = rgba::MAX_CC;
946
934#endif 947#endif
935} 948}
936 949
937void 950void
938rxvt_color::get (XColor &color) const 951rxvt_color::get (XColor &color) const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines