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.148 by root, Tue Apr 26 09:48:09 2011 UTC vs.
Revision 1.153 by sf-exg, Sun May 8 21:07:43 2011 UTC

723 result = gdk_pixbuf_scale_simple (pixbuf, 723 result = gdk_pixbuf_scale_simple (pixbuf,
724 w, h, 724 w, h,
725 GDK_INTERP_BILINEAR); 725 GDK_INTERP_BILINEAR);
726 } 726 }
727 727
728 if (!result)
729 return false;
730
728 bool ret = false; 731 bool ret = false;
729 732
730 if (result)
731 {
732 XGCValues gcv; 733 XGCValues gcv;
733 GC gc; 734 GC gc;
734 Pixmap root_pmap; 735 Pixmap root_pmap;
735 736
736 image_width = gdk_pixbuf_get_width (result); 737 image_width = gdk_pixbuf_get_width (result);
737 image_height = gdk_pixbuf_get_height (result); 738 image_height = gdk_pixbuf_get_height (result);
738 739
739 if (tr_flags) 740 if (tr_flags)
740 { 741 {
741 root_pmap = bg_pixmap; 742 root_pmap = bg_pixmap;
742 bg_pixmap = None; 743 bg_pixmap = None;
743 } 744 }
744 else 745 else
745 { 746 {
746 if (h_scale == 0 || v_scale == 0) 747 if (h_scale == 0 || v_scale == 0)
747 { 748 {
748 new_pmap_width = min (image_width, target_width); 749 new_pmap_width = min (image_width, target_width);
749 new_pmap_height = min (image_height, target_height); 750 new_pmap_height = min (image_height, target_height);
750 } 751 }
751 } 752 }
752 753
753 if (bg_pixmap == None 754 if (bg_pixmap == None
754 || bg_pmap_width != new_pmap_width 755 || bg_pmap_width != new_pmap_width
755 || bg_pmap_height != new_pmap_height) 756 || bg_pmap_height != new_pmap_height)
756 { 757 {
757 if (bg_pixmap) 758 if (bg_pixmap)
758 XFreePixmap (dpy, bg_pixmap); 759 XFreePixmap (dpy, bg_pixmap);
759 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);
760 bg_pmap_width = new_pmap_width; 761 bg_pmap_width = new_pmap_width;
761 bg_pmap_height = new_pmap_height; 762 bg_pmap_height = new_pmap_height;
762 } 763 }
763 764
765 if (bg_pixmap != None)
766 {
764 gcv.foreground = pix_colors[Color_bg]; 767 gcv.foreground = pix_colors[Color_bg];
765 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 768 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
766 769
770 if (gc)
771 {
767 if (h_scale == 0 || v_scale == 0) 772 if (h_scale == 0 || v_scale == 0)
768 { 773 {
769 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 {
770 pixbuf_to_pixmap (result, tile, gc, 778 pixbuf_to_pixmap (result, tile, gc,
771 0, 0, 779 0, 0,
772 0, 0, 780 0, 0,
773 image_width, image_height); 781 image_width, image_height);
774 782
775 gcv.tile = tile; 783 gcv.tile = tile;
776 gcv.fill_style = FillTiled; 784 gcv.fill_style = FillTiled;
777 gcv.ts_x_origin = x; 785 gcv.ts_x_origin = x;
778 gcv.ts_y_origin = y; 786 gcv.ts_y_origin = y;
779 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 787 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
780 788
781 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);
782 XFreePixmap (dpy, tile); 790 XFreePixmap (dpy, tile);
791 }
783 } 792 }
784 else 793 else
785 { 794 {
786 int src_x, src_y, dst_x, dst_y; 795 int src_x, src_y, dst_x, dst_y;
787 int dst_width, dst_height; 796 int dst_width, dst_height;
788 797
789 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 );
790 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);
791 800
792 if (dst_x > 0 || dst_y > 0 801 if (dst_x > 0 || dst_y > 0
793 || dst_x + dst_width < new_pmap_width 802 || dst_x + dst_width < new_pmap_width
794 || dst_y + dst_height < new_pmap_height) 803 || dst_y + dst_height < new_pmap_height)
795 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);
796 805
797 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 806 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
798 pixbuf_to_pixmap (result, bg_pixmap, gc, 807 pixbuf_to_pixmap (result, bg_pixmap, gc,
799 src_x, src_y, 808 src_x, src_y,
800 dst_x, dst_y, 809 dst_x, dst_y,
801 dst_width, dst_height); 810 dst_width, dst_height);
802 } 811 }
803 812
804#if XRENDER 813#if XRENDER
805 if (tr_flags) 814 if (tr_flags)
806 { 815 {
807 XRenderPictureAttributes pa; 816 XRenderPictureAttributes pa;
808 817
809 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 818 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
810 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 819 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
811 820
812 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 821 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
813 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 822 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
814 823
815 pa.repeat = True; 824 pa.repeat = True;
816 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 825 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
817 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 826 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
818 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 827 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
819 XFreePixmap (dpy, mask_pmap); 828 XFreePixmap (dpy, mask_pmap);
820 829
821 if (src && dst && mask) 830 if (src && dst && mask)
822 { 831 {
823 XRenderColor mask_c; 832 XRenderColor mask_c;
824 833
825 mask_c.alpha = 0x8000; 834 mask_c.alpha = 0x8000;
826 mask_c.red = 0; 835 mask_c.red = 0;
827 mask_c.green = 0; 836 mask_c.green = 0;
828 mask_c.blue = 0; 837 mask_c.blue = 0;
829 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 838 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
830 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);
831 } 840 }
832 841
833 XRenderFreePicture (dpy, src); 842 XRenderFreePicture (dpy, src);
834 XRenderFreePicture (dpy, dst); 843 XRenderFreePicture (dpy, dst);
835 XRenderFreePicture (dpy, mask); 844 XRenderFreePicture (dpy, mask);
836
837 XFreePixmap (dpy, root_pmap);
838 } 845 }
839#endif 846#endif
840 847
848 XFreeGC (dpy, gc);
849
850 ret = true;
851 }
852 }
853
841 if (result != pixbuf) 854 if (result != pixbuf)
842 g_object_unref (result); 855 g_object_unref (result);
843 856
844 XFreeGC (dpy, gc); 857 if (tr_flags)
845 858 XFreePixmap (dpy, root_pmap);
846 ret = true;
847 }
848 859
849 return ret; 860 return ret;
850} 861}
851# endif /* HAVE_PIXBUF */ 862# endif /* HAVE_PIXBUF */
852 863
1184 } 1195 }
1185 1196
1186 return ret; 1197 return ret;
1187} 1198}
1188 1199
1189/* make_transparency_pixmap() 1200/*
1190 * 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
1191 * 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
1192 * our window. 1203 * our window.
1193 */ 1204 */
1194unsigned long 1205unsigned long
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 root_pixmap = 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 root_pixmap = None; 1280 recoded_root_pmap = None;
1266 } 1281 }
1267 1282
1268 if (root_pixmap == None) 1283 if (recoded_root_pmap == None)
1269 return 0; 1284 return 0;
1270 1285
1271 if (bg_pixmap == None 1286 if (bg_pixmap == None
1272 || bg_pmap_width != window_width 1287 || bg_pmap_width != window_width
1273 || bg_pmap_height != window_height) 1288 || bg_pmap_height != window_height)
1277 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1292 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1278 bg_pmap_width = window_width; 1293 bg_pmap_width = window_width;
1279 bg_pmap_height = window_height; 1294 bg_pmap_height = window_height;
1280 } 1295 }
1281 1296
1282 if (bg_pixmap == None) 1297 if (bg_pixmap != None)
1283 return 0; 1298 {
1284
1285 /* straightforward pixmap copy */ 1299 /* straightforward pixmap copy */
1286 while (sx < 0) sx += (int)root_width; 1300 while (sx < 0) sx += root_width;
1287 while (sy < 0) sy += (int)root_height; 1301 while (sy < 0) sy += root_height;
1288 1302
1289 gcv.tile = recoded_root_pmap; 1303 gcv.tile = recoded_root_pmap;
1290 gcv.fill_style = FillTiled; 1304 gcv.fill_style = FillTiled;
1291 gcv.ts_x_origin = -sx; 1305 gcv.ts_x_origin = -sx;
1292 gcv.ts_y_origin = -sy; 1306 gcv.ts_y_origin = -sy;
1293 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1307 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1294 1308
1295 if (gc) 1309 if (gc)
1296 { 1310 {
1297 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1311 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1298 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1312 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1299 XFreeGC (dpy, gc); 1313 XFreeGC (dpy, gc);
1300 1314
1301 if (!(bg_flags & BG_CLIENT_RENDER)) 1315 if (!(bg_flags & BG_CLIENT_RENDER))
1302 { 1316 {
1303 if ((bg_flags & BG_NEEDS_BLUR) 1317 if ((bg_flags & BG_NEEDS_BLUR)
1304 && (bg_flags & BG_HAS_RENDER_CONV)) 1318 && (bg_flags & BG_HAS_RENDER_CONV))
1305 { 1319 {
1306 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1320 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1307 result &= ~BG_NEEDS_BLUR; 1321 result &= ~BG_NEEDS_BLUR;
1308 } 1322 }
1309 if ((bg_flags & BG_NEEDS_TINT) 1323 if ((bg_flags & BG_NEEDS_TINT)
1310 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) 1324 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1311 { 1325 {
1312 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1326 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1313 result &= ~BG_NEEDS_TINT; 1327 result &= ~BG_NEEDS_TINT;
1314 } 1328 }
1315 } /* server side rendering completed */ 1329 } /* server side rendering completed */
1330 }
1316 } 1331 }
1317 1332
1318 if (recoded_root_pmap != root_pixmap) 1333 if (recoded_root_pmap != root_pixmap)
1319 XFreePixmap (dpy, recoded_root_pmap); 1334 XFreePixmap (dpy, recoded_root_pmap);
1320 1335

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines