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.151 by sf-exg, Sun May 8 21:02:28 2011 UTC vs.
Revision 1.152 by sf-exg, Sun May 8 21:03:03 2011 UTC

728 if (!result) 728 if (!result)
729 return false; 729 return false;
730 730
731 bool ret = false; 731 bool ret = false;
732 732
733 XGCValues gcv; 733 XGCValues gcv;
734 GC gc; 734 GC gc;
735 Pixmap root_pmap; 735 Pixmap root_pmap;
736 736
737 image_width = gdk_pixbuf_get_width (result); 737 image_width = gdk_pixbuf_get_width (result);
738 image_height = gdk_pixbuf_get_height (result); 738 image_height = gdk_pixbuf_get_height (result);
739 739
740 if (tr_flags) 740 if (tr_flags)
741 { 741 {
742 root_pmap = bg_pixmap; 742 root_pmap = bg_pixmap;
743 bg_pixmap = None; 743 bg_pixmap = None;
744 } 744 }
745 else 745 else
746 { 746 {
747 if (h_scale == 0 || v_scale == 0) 747 if (h_scale == 0 || v_scale == 0)
748 { 748 {
749 new_pmap_width = min (image_width, target_width); 749 new_pmap_width = min (image_width, target_width);
750 new_pmap_height = min (image_height, target_height); 750 new_pmap_height = min (image_height, target_height);
751 } 751 }
752 } 752 }
753 753
754 if (bg_pixmap == None 754 if (bg_pixmap == None
755 || bg_pmap_width != new_pmap_width 755 || bg_pmap_width != new_pmap_width
756 || bg_pmap_height != new_pmap_height) 756 || bg_pmap_height != new_pmap_height)
757 { 757 {
758 if (bg_pixmap) 758 if (bg_pixmap)
759 XFreePixmap (dpy, bg_pixmap); 759 XFreePixmap (dpy, bg_pixmap);
760 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);
761 bg_pmap_width = new_pmap_width; 761 bg_pmap_width = new_pmap_width;
762 bg_pmap_height = new_pmap_height; 762 bg_pmap_height = new_pmap_height;
763 } 763 }
764 764
765 if (bg_pixmap != None)
766 {
765 gcv.foreground = pix_colors[Color_bg]; 767 gcv.foreground = pix_colors[Color_bg];
766 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 768 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
767 769
770 if (gc)
771 {
768 if (h_scale == 0 || v_scale == 0) 772 if (h_scale == 0 || v_scale == 0)
769 { 773 {
770 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 {
771 pixbuf_to_pixmap (result, tile, gc, 778 pixbuf_to_pixmap (result, tile, gc,
772 0, 0, 779 0, 0,
773 0, 0, 780 0, 0,
774 image_width, image_height); 781 image_width, image_height);
775 782
776 gcv.tile = tile; 783 gcv.tile = tile;
777 gcv.fill_style = FillTiled; 784 gcv.fill_style = FillTiled;
778 gcv.ts_x_origin = x; 785 gcv.ts_x_origin = x;
779 gcv.ts_y_origin = y; 786 gcv.ts_y_origin = y;
780 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 787 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
781 788
782 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);
783 XFreePixmap (dpy, tile); 790 XFreePixmap (dpy, tile);
791 }
784 } 792 }
785 else 793 else
786 { 794 {
787 int src_x, src_y, dst_x, dst_y; 795 int src_x, src_y, dst_x, dst_y;
788 int dst_width, dst_height; 796 int dst_width, dst_height;
789 797
790 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 );
791 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);
792 800
793 if (dst_x > 0 || dst_y > 0 801 if (dst_x > 0 || dst_y > 0
794 || dst_x + dst_width < new_pmap_width 802 || dst_x + dst_width < new_pmap_width
795 || dst_y + dst_height < new_pmap_height) 803 || dst_y + dst_height < new_pmap_height)
796 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);
797 805
798 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 806 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
799 pixbuf_to_pixmap (result, bg_pixmap, gc, 807 pixbuf_to_pixmap (result, bg_pixmap, gc,
800 src_x, src_y, 808 src_x, src_y,
801 dst_x, dst_y, 809 dst_x, dst_y,
802 dst_width, dst_height); 810 dst_width, dst_height);
803 } 811 }
804 812
805#if XRENDER 813#if XRENDER
806 if (tr_flags) 814 if (tr_flags)
807 { 815 {
808 XRenderPictureAttributes pa; 816 XRenderPictureAttributes pa;
809 817
810 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 818 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
811 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 819 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
812 820
813 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 821 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
814 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 822 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
815 823
816 pa.repeat = True; 824 pa.repeat = True;
817 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 825 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
818 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 826 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
819 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 827 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
820 XFreePixmap (dpy, mask_pmap); 828 XFreePixmap (dpy, mask_pmap);
821 829
822 if (src && dst && mask) 830 if (src && dst && mask)
823 { 831 {
824 XRenderColor mask_c; 832 XRenderColor mask_c;
825 833
826 mask_c.alpha = 0x8000; 834 mask_c.alpha = 0x8000;
827 mask_c.red = 0; 835 mask_c.red = 0;
828 mask_c.green = 0; 836 mask_c.green = 0;
829 mask_c.blue = 0; 837 mask_c.blue = 0;
830 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 838 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
831 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);
832 } 840 }
833 841
834 XRenderFreePicture (dpy, src); 842 XRenderFreePicture (dpy, src);
835 XRenderFreePicture (dpy, dst); 843 XRenderFreePicture (dpy, dst);
836 XRenderFreePicture (dpy, mask); 844 XRenderFreePicture (dpy, mask);
837
838 XFreePixmap (dpy, root_pmap);
839 } 845 }
840#endif 846#endif
841 847
848 XFreeGC (dpy, gc);
849
850 ret = true;
851 }
852 }
853
842 if (result != pixbuf) 854 if (result != pixbuf)
843 g_object_unref (result); 855 g_object_unref (result);
844 856
845 XFreeGC (dpy, gc); 857 if (tr_flags)
846 858 XFreePixmap (dpy, root_pmap);
847 ret = true;
848 859
849 return ret; 860 return ret;
850} 861}
851# endif /* HAVE_PIXBUF */ 862# endif /* HAVE_PIXBUF */
852 863
1238 if (root_pixmap != None && root_depth != depth) 1249 if (root_pixmap != None && root_depth != depth)
1239 { 1250 {
1240#if XRENDER 1251#if XRENDER
1241 if (bg_flags & BG_HAS_RENDER) 1252 if (bg_flags & BG_HAS_RENDER)
1242 { 1253 {
1243 XRenderPictureAttributes pa;
1244
1245 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1246 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1247
1248 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
1249 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1263 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1250 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1264 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1251 1265
1252 if (src && dst) 1266 if (src && dst)
1253 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);
1254 else 1268 else
1255 { 1269 {
1256 XFreePixmap (dpy, recoded_root_pmap); 1270 XFreePixmap (dpy, recoded_root_pmap);
1257 recoded_root_pmap = None; 1271 recoded_root_pmap = None;
1258 } 1272 }
1259 1273
1260 XRenderFreePicture (dpy, src); 1274 XRenderFreePicture (dpy, src);
1261 XRenderFreePicture (dpy, dst); 1275 XRenderFreePicture (dpy, dst);
1276 }
1262 } 1277 }
1263 else 1278 else
1264#endif 1279#endif
1265 recoded_root_pmap = None; 1280 recoded_root_pmap = None;
1266 } 1281 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines