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

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.220 by sf-exg, Fri May 25 08:27:47 2012 UTC vs.
Revision 1.235 by sf-exg, Thu Jun 7 09:34:51 2012 UTC

58# endif 58# endif
59 59
60void 60void
61rxvt_term::bg_destroy () 61rxvt_term::bg_destroy ()
62{ 62{
63# if BG_IMAGE_FROM_FILE
64 fimage.destroy ();
65# endif
66
63 if (bg_pixmap) 67 if (bg_pixmap)
64 XFreePixmap (dpy, bg_pixmap); 68 XFreePixmap (dpy, bg_pixmap);
65} 69}
66 70
67bool 71bool
79} 83}
80 84
81bool 85bool
82rxvt_term::bg_window_size_sensitive () 86rxvt_term::bg_window_size_sensitive ()
83{ 87{
84# ifdef ENABLE_TRANSPARENCY 88# if ENABLE_TRANSPARENCY
85 if (bg_flags & BG_IS_TRANSPARENT) 89 if (bg_flags & BG_IS_TRANSPARENT)
86 return true; 90 return true;
87# endif 91# endif
88 92
89# ifdef BG_IMAGE_FROM_FILE 93# if BG_IMAGE_FROM_FILE
90 for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) 94 if (fimage.flags & IM_IS_SET)
91 { 95 {
92 if ((bg_image->flags & IM_IS_SIZE_SENSITIVE) 96 if ((fimage.flags & IM_IS_SIZE_SENSITIVE)
93 || bg_image->width () > szHint.width 97 || fimage.width () > szHint.width
94 || bg_image->height () > szHint.height) 98 || fimage.height () > szHint.height)
95 return true; 99 return true;
96 } 100 }
97# endif 101# endif
98 102
99 return false; 103 return false;
100} 104}
101 105
102bool 106bool
103rxvt_term::bg_window_position_sensitive () 107rxvt_term::bg_window_position_sensitive ()
104{ 108{
105# ifdef ENABLE_TRANSPARENCY 109# if ENABLE_TRANSPARENCY
106 if (bg_flags & BG_IS_TRANSPARENT) 110 if (bg_flags & BG_IS_TRANSPARENT)
107 return true; 111 return true;
108# endif 112# endif
109 113
110# ifdef BG_IMAGE_FROM_FILE 114# if BG_IMAGE_FROM_FILE
111 for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) 115 if (fimage.flags & IM_IS_SET)
112 { 116 {
113 if (bg_image->flags & IM_ROOT_ALIGN) 117 if (fimage.flags & IM_ROOT_ALIGN)
114 return true; 118 return true;
115 } 119 }
116# endif 120# endif
117 121
118 return false; 122 return false;
119} 123}
120 124
121# ifdef BG_IMAGE_FROM_FILE 125# if BG_IMAGE_FROM_FILE
122static inline int 126static inline int
123make_align_position (int align, int window_size, int image_size) 127make_align_position (int align, int window_size, int image_size)
124{ 128{
125 if (align >= 0 && align <= 100) 129 if (align >= 0 && align <= 100)
126 return lerp (0, window_size - image_size, align); 130 return lerp (0, window_size - image_size, align);
298 h_align = x; 302 h_align = x;
299 v_align = y; 303 v_align = y;
300 changed = true; 304 changed = true;
301 } 305 }
302 306
303 if (!(flags & IM_TILE) 307 if (is_size_sensitive ())
304 || h_scale || v_scale
305 || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align)))
306 flags |= IM_IS_SIZE_SENSITIVE; 308 flags |= IM_IS_SIZE_SENSITIVE;
307 else 309 else
308 flags &= ~IM_IS_SIZE_SENSITIVE; 310 flags &= ~IM_IS_SIZE_SENSITIVE;
309 311
310 return changed; 312 return changed;
344 x = make_align_position (image.h_align, target_width, w); 346 x = make_align_position (image.h_align, target_width, w);
345 y = make_align_position (image.v_align, target_height, h); 347 y = make_align_position (image.v_align, target_height, h);
346 } 348 }
347} 349}
348 350
349# ifdef HAVE_PIXBUF 351# if HAVE_PIXBUF
350bool 352bool
351rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, 353rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
352 int src_x, int src_y, int dst_x, int dst_y, 354 int src_x, int src_y, int dst_x, int dst_y,
353 unsigned int width, unsigned int height, bool argb) 355 unsigned int width, unsigned int height, bool argb)
354{ 356{
481 return false; 483 return false;
482 484
483 bool need_blend = bg_flags & BG_IS_VALID; 485 bool need_blend = bg_flags & BG_IS_VALID;
484 486
485 if (need_blend 487 if (need_blend
486 && !(bg_flags & BG_HAS_RENDER)) 488 && !(display->flags & DISPLAY_HAS_RENDER))
487 return false; 489 return false;
488 490
489 GdkPixbuf *result; 491 GdkPixbuf *result;
490 492
491 int image_width = gdk_pixbuf_get_width (pixbuf); 493 int image_width = gdk_pixbuf_get_width (pixbuf);
534 536
535 if (need_blend) 537 if (need_blend)
536 tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32); 538 tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32);
537 else 539 else
538 { 540 {
539 // optimise bg pixmap size when tiling, but only if there are no
540 // other pixbufs to render. Otherwise, the bg pixmap size must
541 // be equal to the window size.
542 if ((image.flags & IM_TILE) 541 if (image.flags & IM_TILE)
543 && image_vec.size () == 1)
544 { 542 {
545 new_pmap_width = min (image_width, target_width); 543 new_pmap_width = min (image_width, target_width);
546 new_pmap_height = min (image_height, target_height); 544 new_pmap_height = min (image_height, target_height);
547 } 545 }
548 546
600 src_x, src_y, 598 src_x, src_y,
601 dst_x, dst_y, 599 dst_x, dst_y,
602 dst_width, dst_height, need_blend); 600 dst_width, dst_height, need_blend);
603 } 601 }
604 602
603 if (image.need_blur ())
604 blur_pixmap (tmp_pixmap, new_pmap_width, new_pmap_height, need_blend, image.h_blurRadius, image.v_blurRadius);
605 if (image.need_tint ())
606 tint_pixmap (tmp_pixmap, new_pmap_width, new_pmap_height, need_blend, image.tint, image.tint_set, image.shade);
607
605#if XRENDER 608#if XRENDER
606 if (need_blend) 609 if (need_blend)
607 { 610 {
608 XRenderPictFormat *argb_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); 611 XRenderPictFormat *argb_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
609 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 612 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
614 617
615 Picture mask = create_xrender_mask (dpy, vt, False, False); 618 Picture mask = create_xrender_mask (dpy, vt, False, False);
616 619
617 XRenderColor mask_c; 620 XRenderColor mask_c;
618 621
619 mask_c.alpha = gdk_pixbuf_get_has_alpha (image.pixbuf) ? 0xffff : image.alpha; 622 mask_c.alpha = image.alpha;
620 mask_c.red = 623 mask_c.red =
621 mask_c.green = 624 mask_c.green =
622 mask_c.blue = 0; 625 mask_c.blue = 0;
623 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 626 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
624 627
643 646
644 return ret; 647 return ret;
645} 648}
646# endif /* HAVE_PIXBUF */ 649# endif /* HAVE_PIXBUF */
647 650
648# ifndef NO_RESOURCES
649static int
650rxvt_define_image (XrmDatabase *database ecb_unused,
651 XrmBindingList bindings ecb_unused,
652 XrmQuarkList quarks,
653 XrmRepresentation *type ecb_unused,
654 XrmValue *value,
655 XPointer closure ecb_unused)
656{
657 int size;
658
659 for (size = 0; quarks[size] != NULLQUARK; size++)
660 ;
661
662 if (size >= 2)
663 {
664 int id = strtol (XrmQuarkToString (quarks[size-2]), 0, 0);
665 if (id >= 1)
666 GET_R->parse_image (id, XrmQuarkToString (quarks[size-1]), (char *)value->addr);
667 }
668 return False;
669}
670
671void
672rxvt_term::parse_image (int id, const char *type, const char *arg)
673{
674 rxvt_image *image;
675
676 for (image = image_vec.begin (); image < image_vec.end (); image++)
677 if (image->id == id)
678 break;
679
680 if (image == image_vec.end ())
681 {
682 image = new_image ();
683 image->id = id;
684 }
685}
686# endif
687
688rxvt_image::rxvt_image () 651rxvt_image::rxvt_image ()
689{ 652{
690 id = 653 alpha = 0xffff;
691 alpha =
692 flags = 654 flags = 0;
693 h_scale = 655 h_scale =
694 v_scale = 656 v_scale = defaultScale;
695 h_align = 657 h_align =
696 v_align = 0; 658 v_align = defaultAlign;
697 659
698# ifdef HAVE_PIXBUF 660# if HAVE_PIXBUF
699 pixbuf.reset (0); 661 pixbuf = 0;
700# endif 662# endif
701} 663}
702 664
703bool 665bool
704rxvt_image::set_file_geometry (const char *file) 666rxvt_image::set_file_geometry (const char *file)
717 file = f; 679 file = f;
718 } 680 }
719 681
720 bool ret = set_file (file); 682 bool ret = set_file (file);
721 alpha = 0x8000; 683 alpha = 0x8000;
722 if (ret && p) 684 if (ret)
723 set_geometry (p + 1); 685 set_geometry (p ? p + 1 : "");
724 return ret; 686 return ret;
725} 687}
726 688
727bool 689bool
728rxvt_image::set_file (const char *file) 690rxvt_image::set_file (const char *file)
729{ 691{
730 bool ret = false; 692 bool ret = false;
731 693
732# ifdef HAVE_PIXBUF 694# if HAVE_PIXBUF
733 GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); 695 GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL);
734 if (image) 696 if (image)
735 { 697 {
736 if (pixbuf) 698 if (pixbuf)
737 g_object_unref (pixbuf); 699 g_object_unref (pixbuf);
738 pixbuf.reset (image); 700 pixbuf = image;
739 ret = true; 701 ret = true;
740 } 702 }
741# endif 703# endif
742 704
743 if (ret) 705 if (ret)
744 { 706 flags |= IM_IS_SET;
745 alpha = 0xffff;
746 flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE;
747 h_scale = v_scale = defaultScale;
748 h_align = v_align = defaultAlign;
749 }
750 707
751 return ret; 708 return ret;
752} 709}
753 710
754# endif /* BG_IMAGE_FROM_FILE */ 711# endif /* BG_IMAGE_FROM_FILE */
755 712
756# ifdef ENABLE_TRANSPARENCY
757bool 713bool
758rxvt_term::bg_set_blur (const char *geom) 714image_effects::set_blur (const char *geom)
759{ 715{
760 bool changed = false; 716 bool changed = false;
761 unsigned int hr, vr; 717 unsigned int hr, vr;
762 int junk; 718 int junk;
763 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); 719 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr);
784 740
785 return changed; 741 return changed;
786} 742}
787 743
788bool 744bool
789rxvt_term::bg_set_tint (rxvt_color &new_tint) 745image_effects::set_tint (const rxvt_color &new_tint)
790{ 746{
791 if (!(bg_flags & BG_TINT_SET) || tint != new_tint) 747 if (!tint_set || tint != new_tint)
792 { 748 {
793 tint = new_tint; 749 tint = new_tint;
794 bg_flags |= BG_TINT_SET; 750 tint_set = true;
795
796 rgba c;
797 tint.get (c);
798 if ((c.r <= 0x00ff || c.r >= 0xff00)
799 && (c.g <= 0x00ff || c.g >= 0xff00)
800 && (c.b <= 0x00ff || c.b >= 0xff00))
801 bg_flags |= BG_TINT_BITAND;
802 else
803 bg_flags &= ~BG_TINT_BITAND;
804 751
805 return true; 752 return true;
806 } 753 }
807 754
808 return false; 755 return false;
809} 756}
810 757
811bool 758bool
812rxvt_term::bg_set_shade (const char *shade_str) 759image_effects::set_shade (const char *shade_str)
813{ 760{
814 int new_shade = atoi (shade_str); 761 int new_shade = atoi (shade_str);
815 762
816 clamp_it (new_shade, -100, 200); 763 clamp_it (new_shade, -100, 200);
817 if (new_shade < 0) 764 if (new_shade < 0)
848 params[i+2] = XDoubleToFixed (kernel[i] / sum); 795 params[i+2] = XDoubleToFixed (kernel[i] / sum);
849} 796}
850#endif 797#endif
851 798
852bool 799bool
853rxvt_term::blur_pixmap (Pixmap pixmap, int width, int height) 800rxvt_term::blur_pixmap (Pixmap pixmap, int width, int height, bool argb, int h_blurRadius, int v_blurRadius)
854{ 801{
855 bool ret = false; 802 bool ret = false;
856#if XRENDER 803#if XRENDER
857 if (!(bg_flags & BG_HAS_RENDER_CONV)) 804 if (!(display->flags & DISPLAY_HAS_RENDER_CONV))
858 return false; 805 return false;
859 806
860 int size = max (h_blurRadius, v_blurRadius) * 2 + 1; 807 int size = max (h_blurRadius, v_blurRadius) * 2 + 1;
861 double *kernel = (double *)malloc (size * sizeof (double)); 808 double *kernel = (double *)malloc (size * sizeof (double));
862 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 809 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
863 810
864 XRenderPictureAttributes pa; 811 XRenderPictureAttributes pa;
865 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 812 XRenderPictFormat *format = argb ? XRenderFindStandardFormat (dpy, PictStandardARGB32)
813 : XRenderFindVisualFormat (dpy, visual);
866 814
867 pa.repeat = RepeatPad; 815 pa.repeat = RepeatPad;
868 Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa); 816 Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa);
869 Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth); 817 Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth);
870 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); 818 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa);
913#endif 861#endif
914 return ret; 862 return ret;
915} 863}
916 864
917bool 865bool
918rxvt_term::tint_pixmap (Pixmap pixmap, int width, int height) 866rxvt_term::tint_pixmap (Pixmap pixmap, int width, int height, bool argb, rxvt_color &tint, bool tint_set, int shade)
919{ 867{
920 bool ret = false; 868 bool ret = false;
921 869
922 if (shade == 100 && (bg_flags & BG_TINT_BITAND)) 870 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
871
872 if (tint_set)
873 tint.get (c);
874
875 if (shade == 100
876 && (c.r <= 0x00ff || c.r >= 0xff00)
877 && (c.g <= 0x00ff || c.g >= 0xff00)
878 && (c.b <= 0x00ff || c.b >= 0xff00))
923 { 879 {
924 XGCValues gcv; 880 XGCValues gcv;
925 GC gc; 881 GC gc;
926 882
927 /* In this case we can tint image server-side getting significant 883 /* In this case we can tint image server-side getting significant
937 ret = true; 893 ret = true;
938 XFreeGC (dpy, gc); 894 XFreeGC (dpy, gc);
939 } 895 }
940 } 896 }
941# if XRENDER 897# if XRENDER
942 else if (bg_flags & BG_HAS_RENDER) 898 else if (display->flags & DISPLAY_HAS_RENDER)
943 { 899 {
944 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
945
946 if (bg_flags & BG_TINT_SET)
947 tint.get (c);
948
949 if (shade <= 100) 900 if (shade <= 100)
950 { 901 {
951 c.r = c.r * shade / 100; 902 c.r = c.r * shade / 100;
952 c.g = c.g * shade / 100; 903 c.g = c.g * shade / 100;
953 c.b = c.b * shade / 100; 904 c.b = c.b * shade / 100;
957 c.r = c.r * (200 - shade) / 100; 908 c.r = c.r * (200 - shade) / 100;
958 c.g = c.g * (200 - shade) / 100; 909 c.g = c.g * (200 - shade) / 100;
959 c.b = c.b * (200 - shade) / 100; 910 c.b = c.b * (200 - shade) / 100;
960 } 911 }
961 912
962 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 913 XRenderPictFormat *format = argb ? XRenderFindStandardFormat (dpy, PictStandardARGB32)
914 : XRenderFindVisualFormat (dpy, visual);
963 915
964 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); 916 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0);
965 917
966 Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); 918 Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False);
967 919
1003# endif 955# endif
1004 956
1005 return ret; 957 return ret;
1006} 958}
1007 959
960# if ENABLE_TRANSPARENCY
1008/* 961/*
1009 * Builds a pixmap of the same size as the terminal window that contains 962 * Builds a pixmap of the same size as the terminal window that contains
1010 * the tiled portion of the root pixmap that is supposed to be covered by 963 * the tiled portion of the root pixmap that is supposed to be covered by
1011 * our window. 964 * our window.
1012 */ 965 */
1013bool 966bool
1014rxvt_term::make_transparency_pixmap () 967rxvt_term::render_root_image ()
1015{ 968{
1016 bool ret = false; 969 bool ret = false;
1017 970
1018 /* root dimensions may change from call to call - but Display structure should 971 /* root dimensions may change from call to call - but Display structure should
1019 * be always up-to-date, so let's use it : 972 * be always up-to-date, so let's use it :
1055 Pixmap recoded_root_pmap = root_pixmap; 1008 Pixmap recoded_root_pmap = root_pixmap;
1056 1009
1057 if (root_pixmap != None && root_depth != depth) 1010 if (root_pixmap != None && root_depth != depth)
1058 { 1011 {
1059#if XRENDER 1012#if XRENDER
1060 if (bg_flags & BG_HAS_RENDER) 1013 if (display->flags & DISPLAY_HAS_RENDER)
1061 { 1014 {
1062 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); 1015 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1063 1016
1064 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1017 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1065 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); 1018 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0);
1103 1056
1104 if (gc) 1057 if (gc)
1105 { 1058 {
1106 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1059 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1107 ret = true; 1060 ret = true;
1108 bool need_blur = h_blurRadius && v_blurRadius; 1061 bool need_blur = root_effects.need_blur ();
1109 bool need_tint = shade != 100 || (bg_flags & BG_TINT_SET); 1062 bool need_tint = root_effects.need_tint ();
1110 1063
1111 if (!(bg_flags & BG_CLIENT_RENDER))
1112 {
1113 if (need_blur) 1064 if (need_blur)
1065 {
1066 if (blur_pixmap (bg_pixmap, window_width, window_height, false,
1067 root_effects.h_blurRadius, root_effects.v_blurRadius))
1068 need_blur = false;
1069 }
1070 if (need_tint)
1071 {
1072 if (tint_pixmap (bg_pixmap, window_width, window_height, false,
1073 root_effects.tint, root_effects.tint_set, root_effects.shade))
1074 need_tint = false;
1075 }
1076 if (need_tint)
1077 {
1078 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1079 if (ximage)
1114 { 1080 {
1115 if (blur_pixmap (bg_pixmap, window_width, window_height)) 1081 /* our own client-side tinting */
1116 need_blur = false; 1082 tint_ximage (ximage, root_effects.tint, root_effects.tint_set, root_effects.shade);
1083
1084 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
1085 XDestroyImage (ximage);
1117 } 1086 }
1118 if (need_tint)
1119 {
1120 if (tint_pixmap (bg_pixmap, window_width, window_height))
1121 need_tint = false;
1122 } 1087 }
1123 if (need_tint)
1124 {
1125 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1126 if (ximage)
1127 {
1128 /* our own client-side tinting */
1129 tint_ximage (ximage);
1130
1131 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
1132 XDestroyImage (ximage);
1133 }
1134 }
1135 } /* server side rendering completed */
1136 1088
1137 XFreeGC (dpy, gc); 1089 XFreeGC (dpy, gc);
1138 } 1090 }
1139 1091
1140 if (recoded_root_pmap != root_pixmap) 1092 if (recoded_root_pmap != root_pixmap)
1144} 1096}
1145 1097
1146void 1098void
1147rxvt_term::bg_set_root_pixmap () 1099rxvt_term::bg_set_root_pixmap ()
1148{ 1100{
1149 Pixmap new_root_pixmap = get_pixmap_property (xa[XA_XROOTPMAP_ID]); 1101 Pixmap new_root_pixmap = display->get_pixmap_property (xa[XA_XROOTPMAP_ID]);
1150 if (new_root_pixmap == None) 1102 if (new_root_pixmap == None)
1151 new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); 1103 new_root_pixmap = display->get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]);
1152 1104
1153 root_pixmap = new_root_pixmap; 1105 root_pixmap = new_root_pixmap;
1154} 1106}
1155# endif /* ENABLE_TRANSPARENCY */ 1107# endif /* ENABLE_TRANSPARENCY */
1156 1108
1157bool 1109void
1158rxvt_term::bg_render () 1110rxvt_term::bg_render ()
1159{ 1111{
1112 if (bg_flags & BG_INHIBIT_RENDER)
1113 return;
1114
1160 bg_invalidate (); 1115 bg_invalidate ();
1161# ifdef ENABLE_TRANSPARENCY 1116# if ENABLE_TRANSPARENCY
1162 if (bg_flags & BG_IS_TRANSPARENT) 1117 if (bg_flags & BG_IS_TRANSPARENT)
1163 { 1118 {
1164 /* we need to re-generate transparency pixmap in that case ! */ 1119 /* we need to re-generate transparency pixmap in that case ! */
1165 if (make_transparency_pixmap ()) 1120 if (render_root_image ())
1166 bg_flags |= BG_IS_VALID; 1121 bg_flags |= BG_IS_VALID;
1167 } 1122 }
1168# endif 1123# endif
1169 1124
1170# ifdef BG_IMAGE_FROM_FILE 1125# if BG_IMAGE_FROM_FILE
1171 for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) 1126 if (fimage.flags & IM_IS_SET)
1172 { 1127 {
1173 if (render_image (*bg_image)) 1128 if (render_image (fimage))
1174 bg_flags |= BG_IS_VALID; 1129 bg_flags |= BG_IS_VALID;
1175 } 1130 }
1176# endif 1131# endif
1177 1132
1178 if (!(bg_flags & BG_IS_VALID)) 1133 if (!(bg_flags & BG_IS_VALID))
1186 1141
1187 scr_recolour (false); 1142 scr_recolour (false);
1188 bg_flags |= BG_NEEDS_REFRESH; 1143 bg_flags |= BG_NEEDS_REFRESH;
1189 1144
1190 bg_valid_since = ev::now (); 1145 bg_valid_since = ev::now ();
1191
1192 return true;
1193} 1146}
1194 1147
1195void 1148void
1196rxvt_term::bg_init () 1149rxvt_term::bg_init ()
1197{ 1150{
1198#ifdef ENABLE_TRANSPARENCY 1151#if BG_IMAGE_FROM_FILE
1199 shade = 100; 1152 if (rs[Rs_backgroundPixmap])
1153 {
1154 if (fimage.set_file_geometry (rs[Rs_backgroundPixmap])
1155 && !bg_window_position_sensitive ())
1156 update_background ();
1157 }
1200#endif 1158#endif
1201
1202 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV);
1203#if XRENDER
1204 int major, minor;
1205 if (XRenderQueryVersion (dpy, &major, &minor))
1206 bg_flags |= BG_HAS_RENDER;
1207 XFilters *filters = XRenderQueryFilters (dpy, vt);
1208 if (filters)
1209 {
1210 for (int i = 0; i < filters->nfilter; i++)
1211 if (!strcmp (filters->filter[i], FilterConvolution))
1212 bg_flags |= BG_HAS_RENDER_CONV;
1213
1214 XFree (filters);
1215 }
1216#endif
1217
1218#ifdef BG_IMAGE_FROM_FILE
1219 if (rs[Rs_backgroundPixmap])
1220 {
1221 rxvt_image *image = new_image ();
1222 if (!image->set_file_geometry (rs[Rs_backgroundPixmap]))
1223 image_vec.pop_back ();
1224 }
1225
1226# ifndef NO_RESOURCES
1227 find_resources ("image", "Image", XrmEnumAllLevels, rxvt_define_image);
1228 vector<rxvt_image>::iterator bg_image = image_vec.begin ();
1229 while (bg_image != image_vec.end ())
1230 {
1231 if (!(bg_image->flags & IM_IS_SET))
1232 bg_image = image_vec.erase (bg_image);
1233 else
1234 bg_image++;
1235 }
1236# endif
1237
1238 if (image_vec.size () > 0
1239 && !bg_window_position_sensitive ())
1240 update_background ();
1241#endif
1242} 1159}
1243 1160
1244#endif /* HAVE_BG_PIXMAP */
1245
1246#ifdef ENABLE_TRANSPARENCY
1247/* based on code from aterm-0.4.2 */ 1161/* based on code from aterm-0.4.2 */
1248 1162
1249static inline void 1163static inline void
1250fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) 1164fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high)
1251{ 1165{
1257 lookup[i] = (tmp / 0xffff) << sh; 1171 lookup[i] = (tmp / 0xffff) << sh;
1258 } 1172 }
1259} 1173}
1260 1174
1261void 1175void
1262rxvt_term::tint_ximage (XImage *ximage) 1176rxvt_term::tint_ximage (XImage *ximage, rxvt_color &tint, bool tint_set, int shade)
1263{ 1177{
1264 unsigned int size_r, size_g, size_b; 1178 unsigned int size_r, size_g, size_b;
1265 int sh_r, sh_g, sh_b; 1179 int sh_r, sh_g, sh_b;
1266 uint32_t mask_r, mask_g, mask_b; 1180 uint32_t mask_r, mask_g, mask_b;
1267 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1181 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1292 lookup_g = lookup + size_r; 1206 lookup_g = lookup + size_r;
1293 lookup_b = lookup + size_r + size_g; 1207 lookup_b = lookup + size_r + size_g;
1294 1208
1295 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1209 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1296 1210
1297 if (bg_flags & BG_TINT_SET) 1211 if (tint_set)
1298 tint.get (c); 1212 tint.get (c);
1299 1213
1300 /* prepare limits for color transformation (each channel is handled separately) */ 1214 /* prepare limits for color transformation (each channel is handled separately) */
1301 if (shade > 100) 1215 if (shade > 100)
1302 { 1216 {
1352 } 1266 }
1353 } 1267 }
1354 1268
1355 free (lookup); 1269 free (lookup);
1356} 1270}
1357#endif /* ENABLE_TRANSPARENCY */ 1271
1272#endif /* HAVE_BG_PIXMAP */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines