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.143 by sf-exg, Fri Jan 28 00:08:57 2011 UTC vs.
Revision 1.152 by sf-exg, Sun May 8 21:03:03 2011 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.C - former xpm.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it> 8 * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
65rxvt_term::bg_destroy () 65rxvt_term::bg_destroy ()
66{ 66{
67#ifdef HAVE_AFTERIMAGE 67#ifdef HAVE_AFTERIMAGE
68 if (original_asim) 68 if (original_asim)
69 safe_asimage_destroy (original_asim); 69 safe_asimage_destroy (original_asim);
70 if (asv)
71 destroy_asvisual (asv, 0);
72 if (asimman)
73 destroy_image_manager (asimman, 0);
70#endif 74#endif
71 75
72#ifdef HAVE_PIXBUF 76#ifdef HAVE_PIXBUF
73 if (pixbuf) 77 if (pixbuf)
74 g_object_unref (pixbuf); 78 g_object_unref (pixbuf);
99 if (bg_flags & BG_IS_TRANSPARENT) 103 if (bg_flags & BG_IS_TRANSPARENT)
100 return true; 104 return true;
101# endif 105# endif
102 106
103# ifdef BG_IMAGE_FROM_FILE 107# ifdef BG_IMAGE_FROM_FILE
104 if (have_image) 108 if (bg_flags & BG_IS_FROM_FILE)
105 { 109 {
106 if (bg_flags & BG_IS_SIZE_SENSITIVE) 110 if (bg_flags & BG_IS_SIZE_SENSITIVE)
107 return true; 111 return true;
108 } 112 }
109# endif 113# endif
118 if (bg_flags & BG_IS_TRANSPARENT) 122 if (bg_flags & BG_IS_TRANSPARENT)
119 return true; 123 return true;
120# endif 124# endif
121 125
122# ifdef BG_IMAGE_FROM_FILE 126# ifdef BG_IMAGE_FROM_FILE
123 if (have_image) 127 if (bg_flags & BG_IS_FROM_FILE)
124 { 128 {
125 if (bg_flags & BG_ROOT_ALIGN) 129 if (bg_flags & BG_ROOT_ALIGN)
126 return true; 130 return true;
127 } 131 }
128# endif 132# endif
719 result = gdk_pixbuf_scale_simple (pixbuf, 723 result = gdk_pixbuf_scale_simple (pixbuf,
720 w, h, 724 w, h,
721 GDK_INTERP_BILINEAR); 725 GDK_INTERP_BILINEAR);
722 } 726 }
723 727
728 if (!result)
729 return false;
730
724 bool ret = false; 731 bool ret = false;
725 732
726 if (result)
727 {
728 XGCValues gcv; 733 XGCValues gcv;
729 GC gc; 734 GC gc;
730 Pixmap root_pmap; 735 Pixmap root_pmap;
731 736
732 image_width = gdk_pixbuf_get_width (result); 737 image_width = gdk_pixbuf_get_width (result);
733 image_height = gdk_pixbuf_get_height (result); 738 image_height = gdk_pixbuf_get_height (result);
734 739
735 if (tr_flags) 740 if (tr_flags)
736 { 741 {
737 root_pmap = bg_pixmap; 742 root_pmap = bg_pixmap;
738 bg_pixmap = None; 743 bg_pixmap = None;
739 } 744 }
740 else 745 else
741 { 746 {
742 if (h_scale == 0 || v_scale == 0) 747 if (h_scale == 0 || v_scale == 0)
743 { 748 {
744 new_pmap_width = min (image_width, target_width); 749 new_pmap_width = min (image_width, target_width);
745 new_pmap_height = min (image_height, target_height); 750 new_pmap_height = min (image_height, target_height);
746 } 751 }
747 } 752 }
748 753
749 if (bg_pixmap == None 754 if (bg_pixmap == None
750 || bg_pmap_width != new_pmap_width 755 || bg_pmap_width != new_pmap_width
751 || bg_pmap_height != new_pmap_height) 756 || bg_pmap_height != new_pmap_height)
752 { 757 {
753 if (bg_pixmap) 758 if (bg_pixmap)
754 XFreePixmap (dpy, bg_pixmap); 759 XFreePixmap (dpy, bg_pixmap);
755 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); 760 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
756 bg_pmap_width = new_pmap_width; 761 bg_pmap_width = new_pmap_width;
757 bg_pmap_height = new_pmap_height; 762 bg_pmap_height = new_pmap_height;
758 } 763 }
759 764
765 if (bg_pixmap != None)
766 {
760 gcv.foreground = pix_colors[Color_bg]; 767 gcv.foreground = pix_colors[Color_bg];
761 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 768 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
762 769
770 if (gc)
771 {
763 if (h_scale == 0 || v_scale == 0) 772 if (h_scale == 0 || v_scale == 0)
764 { 773 {
765 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 774 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
775
776 if (tile != None)
777 {
766 pixbuf_to_pixmap (result, tile, gc, 778 pixbuf_to_pixmap (result, tile, gc,
767 0, 0, 779 0, 0,
768 0, 0, 780 0, 0,
769 image_width, image_height); 781 image_width, image_height);
770 782
771 gcv.tile = tile; 783 gcv.tile = tile;
772 gcv.fill_style = FillTiled; 784 gcv.fill_style = FillTiled;
773 gcv.ts_x_origin = x; 785 gcv.ts_x_origin = x;
774 gcv.ts_y_origin = y; 786 gcv.ts_y_origin = y;
775 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 787 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
776 788
777 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 789 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
778 XFreePixmap (dpy, tile); 790 XFreePixmap (dpy, tile);
791 }
779 } 792 }
780 else 793 else
781 { 794 {
782 int src_x, src_y, dst_x, dst_y; 795 int src_x, src_y, dst_x, dst_y;
783 int dst_width, dst_height; 796 int dst_width, dst_height;
784 797
785 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width ); 798 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width );
786 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); 799 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
787 800
788 if (dst_x > 0 || dst_y > 0 801 if (dst_x > 0 || dst_y > 0
789 || dst_x + dst_width < new_pmap_width 802 || dst_x + dst_width < new_pmap_width
790 || dst_y + dst_height < new_pmap_height) 803 || dst_y + dst_height < new_pmap_height)
791 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 804 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
792 805
793 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 806 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
794 pixbuf_to_pixmap (result, bg_pixmap, gc, 807 pixbuf_to_pixmap (result, bg_pixmap, gc,
795 src_x, src_y, 808 src_x, src_y,
796 dst_x, dst_y, 809 dst_x, dst_y,
797 dst_width, dst_height); 810 dst_width, dst_height);
798 } 811 }
799 812
800#if XRENDER 813#if XRENDER
801 if (tr_flags) 814 if (tr_flags)
802 { 815 {
803 XRenderPictureAttributes pa; 816 XRenderPictureAttributes pa;
804 817
805 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 818 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
806 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 819 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
807 820
808 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 821 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
809 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 822 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
810 823
811 pa.repeat = True; 824 pa.repeat = True;
812 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 825 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
813 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 826 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
814 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 827 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
815 XFreePixmap (dpy, mask_pmap); 828 XFreePixmap (dpy, mask_pmap);
816 829
817 if (src && dst && mask) 830 if (src && dst && mask)
818 { 831 {
819 XRenderColor mask_c; 832 XRenderColor mask_c;
820 833
821 mask_c.alpha = 0x8000; 834 mask_c.alpha = 0x8000;
822 mask_c.red = 0; 835 mask_c.red = 0;
823 mask_c.green = 0; 836 mask_c.green = 0;
824 mask_c.blue = 0; 837 mask_c.blue = 0;
825 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 838 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
826 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); 839 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height);
827 } 840 }
828 841
829 XRenderFreePicture (dpy, src); 842 XRenderFreePicture (dpy, src);
830 XRenderFreePicture (dpy, dst); 843 XRenderFreePicture (dpy, dst);
831 XRenderFreePicture (dpy, mask); 844 XRenderFreePicture (dpy, mask);
832
833 XFreePixmap (dpy, root_pmap);
834 } 845 }
835#endif 846#endif
836 847
848 XFreeGC (dpy, gc);
849
850 ret = true;
851 }
852 }
853
837 if (result != pixbuf) 854 if (result != pixbuf)
838 g_object_unref (result); 855 g_object_unref (result);
839 856
840 XFreeGC (dpy, gc); 857 if (tr_flags)
841 858 XFreePixmap (dpy, root_pmap);
842 ret = true;
843 }
844 859
845 return ret; 860 return ret;
846} 861}
847# endif /* HAVE_PIXBUF */ 862# endif /* HAVE_PIXBUF */
848 863
868 if (image) 883 if (image)
869 { 884 {
870 if (original_asim) 885 if (original_asim)
871 safe_asimage_destroy (original_asim); 886 safe_asimage_destroy (original_asim);
872 original_asim = image; 887 original_asim = image;
873 bg_flags |= BG_CLIENT_RENDER; 888 bg_flags |= BG_IS_FROM_FILE | BG_CLIENT_RENDER;
874 have_image = true;
875 return true; 889 return true;
876 } 890 }
877# endif 891# endif
878 892
879# ifdef HAVE_PIXBUF 893# ifdef HAVE_PIXBUF
881 if (image) 895 if (image)
882 { 896 {
883 if (pixbuf) 897 if (pixbuf)
884 g_object_unref (pixbuf); 898 g_object_unref (pixbuf);
885 pixbuf = image; 899 pixbuf = image;
886 have_image = true; 900 bg_flags |= BG_IS_FROM_FILE;
887 return true; 901 return true;
888 } 902 }
889# endif 903# endif
890 904
891 return false; 905 return false;
940 bg_flags |= BG_NEEDS_BLUR; 954 bg_flags |= BG_NEEDS_BLUR;
941 955
942 return changed; 956 return changed;
943} 957}
944 958
945static inline unsigned long 959void
946compute_tint_shade_flags (rxvt_color *tint, int shade) 960rxvt_term::set_tint_shade_flags ()
947{ 961{
948 unsigned long flags = 0;
949 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 962 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
950 bool has_shade = shade != 100; 963 bool has_shade = shade != 100;
951 964
952 if (tint) 965 bg_flags &= ~BG_TINT_FLAGS;
966
967 if (bg_flags & BG_TINT_SET)
953 { 968 {
954 tint->get (c); 969 tint.get (c);
955 if (!has_shade 970 if (!has_shade
956 && (c.r <= 0x00ff || c.r >= 0xff00) 971 && (c.r <= 0x00ff || c.r >= 0xff00)
957 && (c.g <= 0x00ff || c.g >= 0xff00) 972 && (c.g <= 0x00ff || c.g >= 0xff00)
958 && (c.b <= 0x00ff || c.b >= 0xff00)) 973 && (c.b <= 0x00ff || c.b >= 0xff00))
959 flags |= rxvt_term::BG_TINT_BITAND; 974 bg_flags |= BG_TINT_BITAND;
960 } 975 }
961 976
962 if (has_shade || tint) 977 if (has_shade || (bg_flags & BG_TINT_SET))
963 flags |= rxvt_term::BG_NEEDS_TINT; 978 bg_flags |= BG_NEEDS_TINT;
964
965 return flags;
966} 979}
967 980
968bool 981bool
969rxvt_term::bg_set_tint (rxvt_color &new_tint) 982rxvt_term::bg_set_tint (rxvt_color &new_tint)
970{ 983{
971 if (!(bg_flags & BG_TINT_SET) || tint != new_tint) 984 if (!(bg_flags & BG_TINT_SET) || tint != new_tint)
972 { 985 {
973 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
974 tint = new_tint; 986 tint = new_tint;
975 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET; 987 bg_flags |= BG_TINT_SET;
988 set_tint_shade_flags ();
976 return true; 989 return true;
977 } 990 }
978 991
979 return false; 992 return false;
980} 993}
988 if (new_shade < 0) 1001 if (new_shade < 0)
989 new_shade = 200 - (100 + new_shade); 1002 new_shade = 200 - (100 + new_shade);
990 1003
991 if (new_shade != shade) 1004 if (new_shade != shade)
992 { 1005 {
993 unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade);
994 shade = new_shade; 1006 shade = new_shade;
995 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags; 1007 set_tint_shade_flags ();
996 return true; 1008 return true;
997 } 1009 }
998 1010
999 return false; 1011 return false;
1000} 1012}
1110 } 1122 }
1111 } 1123 }
1112 else 1124 else
1113 { 1125 {
1114# if XRENDER 1126# if XRENDER
1115 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1127 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1116 1128
1117 if (bg_flags & BG_TINT_SET) 1129 if (bg_flags & BG_TINT_SET)
1118 tint.get (c); 1130 tint.get (c);
1119 1131
1120 if (shade <= 100) 1132 if (shade <= 100)
1121 { 1133 {
1122 c.r = (c.r * shade) / 100; 1134 c.r = c.r * shade / 100;
1123 c.g = (c.g * shade) / 100; 1135 c.g = c.g * shade / 100;
1124 c.b = (c.b * shade) / 100; 1136 c.b = c.b * shade / 100;
1125 } 1137 }
1126 else 1138 else
1127 { 1139 {
1128 c.r = (c.r * (200 - shade)) / 100; 1140 c.r = c.r * (200 - shade) / 100;
1129 c.g = (c.g * (200 - shade)) / 100; 1141 c.g = c.g * (200 - shade) / 100;
1130 c.b = (c.b * (200 - shade)) / 100; 1142 c.b = c.b * (200 - shade) / 100;
1131 } 1143 }
1132 1144
1133 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); 1145 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1134 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1146 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1135 XRenderPictureAttributes pa; 1147 XRenderPictureAttributes pa;
1142 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 1154 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1143 XFreePixmap (dpy, overlay_pmap); 1155 XFreePixmap (dpy, overlay_pmap);
1144 1156
1145 pa.component_alpha = True; 1157 pa.component_alpha = True;
1146 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1158 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1147 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 1159 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1148 XFreePixmap (dpy, mask_pmap); 1160 XFreePixmap (dpy, mask_pmap);
1149 1161
1150 if (mask_pic && overlay_pic && back_pic) 1162 if (mask_pic && overlay_pic && back_pic)
1151 { 1163 {
1152 XRenderColor mask_c; 1164 XRenderColor mask_c;
1153 1165
1154 mask_c.red = mask_c.green = mask_c.blue = 0;
1155 mask_c.alpha = 0xffff; 1166 mask_c.alpha = 0xffff;
1167 mask_c.red =
1168 mask_c.green =
1169 mask_c.blue = 0;
1156 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1170 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1157 1171
1158 mask_c.alpha = 0; 1172 mask_c.alpha = 0;
1159 mask_c.red = 0xffff - c.r; 1173 mask_c.red = 0xffff - c.r;
1160 mask_c.green = 0xffff - c.g; 1174 mask_c.green = 0xffff - c.g;
1161 mask_c.blue = 0xffff - c.b; 1175 mask_c.blue = 0xffff - c.b;
1162 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); 1176 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1163 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1177 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1164 1178
1165 if (shade > 100) 1179 if (shade > 100)
1166 { 1180 {
1181 } 1195 }
1182 1196
1183 return ret; 1197 return ret;
1184} 1198}
1185 1199
1186/* make_transparency_pixmap() 1200/*
1187 * Builds a pixmap of the same size as the terminal window that contains 1201 * Builds a pixmap of the same size as the terminal window that contains
1188 * the tiled portion of the root pixmap that is supposed to be covered by 1202 * the tiled portion of the root pixmap that is supposed to be covered by
1189 * our window. 1203 * our window.
1190 */ 1204 */
1191unsigned long 1205unsigned long
1235 if (root_pixmap != None && root_depth != depth) 1249 if (root_pixmap != None && root_depth != depth)
1236 { 1250 {
1237#if XRENDER 1251#if XRENDER
1238 if (bg_flags & BG_HAS_RENDER) 1252 if (bg_flags & BG_HAS_RENDER)
1239 { 1253 {
1240 XRenderPictureAttributes pa;
1241
1242 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1243 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1244
1245 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); 1254 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1255
1256 if (recoded_root_pmap != None)
1257 {
1258 XRenderPictureAttributes pa;
1259
1260 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1261 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1262
1246 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1263 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1247 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1264 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1248 1265
1249 if (src && dst) 1266 if (src && dst)
1250 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1267 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1251 else 1268 else
1252 { 1269 {
1253 XFreePixmap (dpy, recoded_root_pmap); 1270 XFreePixmap (dpy, recoded_root_pmap);
1254 root_pixmap = None; 1271 recoded_root_pmap = None;
1255 } 1272 }
1256 1273
1257 XRenderFreePicture (dpy, src); 1274 XRenderFreePicture (dpy, src);
1258 XRenderFreePicture (dpy, dst); 1275 XRenderFreePicture (dpy, dst);
1276 }
1259 } 1277 }
1260 else 1278 else
1261#endif 1279#endif
1262 root_pixmap = None; 1280 recoded_root_pmap = None;
1263 } 1281 }
1264 1282
1265 if (root_pixmap == None) 1283 if (recoded_root_pmap == None)
1266 return 0; 1284 return 0;
1267 1285
1268 if (bg_pixmap == None 1286 if (bg_pixmap == None
1269 || bg_pmap_width != window_width 1287 || bg_pmap_width != window_width
1270 || bg_pmap_height != window_height) 1288 || bg_pmap_height != window_height)
1274 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1292 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1275 bg_pmap_width = window_width; 1293 bg_pmap_width = window_width;
1276 bg_pmap_height = window_height; 1294 bg_pmap_height = window_height;
1277 } 1295 }
1278 1296
1279 if (bg_pixmap == None) 1297 if (bg_pixmap != None)
1280 return 0; 1298 {
1281
1282 /* straightforward pixmap copy */ 1299 /* straightforward pixmap copy */
1283 while (sx < 0) sx += (int)root_width; 1300 while (sx < 0) sx += (int)root_width;
1284 while (sy < 0) sy += (int)root_height; 1301 while (sy < 0) sy += (int)root_height;
1285 1302
1286 gcv.tile = recoded_root_pmap; 1303 gcv.tile = recoded_root_pmap;
1287 gcv.fill_style = FillTiled; 1304 gcv.fill_style = FillTiled;
1288 gcv.ts_x_origin = -sx; 1305 gcv.ts_x_origin = -sx;
1289 gcv.ts_y_origin = -sy; 1306 gcv.ts_y_origin = -sy;
1290 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1307 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1291 1308
1292 if (gc) 1309 if (gc)
1293 { 1310 {
1294 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1311 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1295 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1312 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1296 XFreeGC (dpy, gc); 1313 XFreeGC (dpy, gc);
1297 1314
1298 if (!(bg_flags & BG_CLIENT_RENDER)) 1315 if (!(bg_flags & BG_CLIENT_RENDER))
1299 { 1316 {
1300 if ((bg_flags & BG_NEEDS_BLUR) 1317 if ((bg_flags & BG_NEEDS_BLUR)
1301 && (bg_flags & BG_HAS_RENDER_CONV)) 1318 && (bg_flags & BG_HAS_RENDER_CONV))
1302 { 1319 {
1303 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1320 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1304 result &= ~BG_NEEDS_BLUR; 1321 result &= ~BG_NEEDS_BLUR;
1305 } 1322 }
1306 if ((bg_flags & BG_NEEDS_TINT) 1323 if ((bg_flags & BG_NEEDS_TINT)
1307 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) 1324 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1308 { 1325 {
1309 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1326 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1310 result &= ~BG_NEEDS_TINT; 1327 result &= ~BG_NEEDS_TINT;
1311 } 1328 }
1312 } /* server side rendering completed */ 1329 } /* server side rendering completed */
1330 }
1313 } 1331 }
1314 1332
1315 if (recoded_root_pmap != root_pixmap) 1333 if (recoded_root_pmap != root_pixmap)
1316 XFreePixmap (dpy, recoded_root_pmap); 1334 XFreePixmap (dpy, recoded_root_pmap);
1317 1335
1350 bg_flags |= BG_IS_VALID; 1368 bg_flags |= BG_IS_VALID;
1351 } 1369 }
1352# endif 1370# endif
1353 1371
1354# ifdef BG_IMAGE_FROM_FILE 1372# ifdef BG_IMAGE_FROM_FILE
1355 if (have_image 1373 if ((bg_flags & BG_IS_FROM_FILE)
1356 || (tr_flags & BG_EFFECTS_FLAGS)) 1374 || (tr_flags & BG_EFFECTS_FLAGS))
1357 { 1375 {
1358 if (render_image (tr_flags)) 1376 if (render_image (tr_flags))
1359 bg_flags |= BG_IS_VALID; 1377 bg_flags |= BG_IS_VALID;
1360 } 1378 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines