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.153 by sf-exg, Sun May 8 21:07:43 2011 UTC vs.
Revision 1.154 by sf-exg, Mon May 9 16:35:37 2011 UTC

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 {
767 gcv.foreground = pix_colors[Color_bg]; 765 gcv.foreground = pix_colors[Color_bg];
768 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 766 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
769 767
770 if (gc) 768 if (gc)
771 { 769 {
772 if (h_scale == 0 || v_scale == 0) 770 if (h_scale == 0 || v_scale == 0)
773 { 771 {
774 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 772 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
775
776 if (tile != None)
777 {
778 pixbuf_to_pixmap (result, tile, gc, 773 pixbuf_to_pixmap (result, tile, gc,
779 0, 0, 774 0, 0,
780 0, 0, 775 0, 0,
781 image_width, image_height); 776 image_width, image_height);
782 777
783 gcv.tile = tile; 778 gcv.tile = tile;
784 gcv.fill_style = FillTiled; 779 gcv.fill_style = FillTiled;
785 gcv.ts_x_origin = x; 780 gcv.ts_x_origin = x;
786 gcv.ts_y_origin = y; 781 gcv.ts_y_origin = y;
787 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 782 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
788 783
789 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 784 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
790 XFreePixmap (dpy, tile); 785 XFreePixmap (dpy, tile);
791 }
792 } 786 }
793 else 787 else
794 { 788 {
795 int src_x, src_y, dst_x, dst_y; 789 int src_x, src_y, dst_x, dst_y;
796 int dst_width, dst_height; 790 int dst_width, dst_height;
797 791
798 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width ); 792 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width );
799 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); 793 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
800 794
801 if (dst_x > 0 || dst_y > 0 795 if (dst_x > 0 || dst_y > 0
802 || dst_x + dst_width < new_pmap_width 796 || dst_x + dst_width < new_pmap_width
803 || dst_y + dst_height < new_pmap_height) 797 || dst_y + dst_height < new_pmap_height)
804 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 798 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
805 799
806 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 800 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
807 pixbuf_to_pixmap (result, bg_pixmap, gc, 801 pixbuf_to_pixmap (result, bg_pixmap, gc,
808 src_x, src_y, 802 src_x, src_y,
809 dst_x, dst_y, 803 dst_x, dst_y,
810 dst_width, dst_height); 804 dst_width, dst_height);
811 } 805 }
812 806
813#if XRENDER 807#if XRENDER
814 if (tr_flags) 808 if (tr_flags)
815 { 809 {
816 XRenderPictureAttributes pa; 810 XRenderPictureAttributes pa;
817 811
818 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 812 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
819 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 813 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
820 814
821 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 815 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
822 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 816 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
823 817
824 pa.repeat = True; 818 pa.repeat = True;
825 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 819 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
826 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 820 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
827 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 821 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
828 XFreePixmap (dpy, mask_pmap); 822 XFreePixmap (dpy, mask_pmap);
829 823
830 if (src && dst && mask)
831 {
832 XRenderColor mask_c; 824 XRenderColor mask_c;
833 825
834 mask_c.alpha = 0x8000; 826 mask_c.alpha = 0x8000;
835 mask_c.red = 0; 827 mask_c.red = 0;
836 mask_c.green = 0; 828 mask_c.green = 0;
837 mask_c.blue = 0; 829 mask_c.blue = 0;
838 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 830 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
839 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); 831 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height);
840 }
841 832
842 XRenderFreePicture (dpy, src); 833 XRenderFreePicture (dpy, src);
843 XRenderFreePicture (dpy, dst); 834 XRenderFreePicture (dpy, dst);
844 XRenderFreePicture (dpy, mask); 835 XRenderFreePicture (dpy, mask);
845 } 836 }
846#endif 837#endif
847 838
848 XFreeGC (dpy, gc); 839 XFreeGC (dpy, gc);
849 840
850 ret = true; 841 ret = true;
851 }
852 } 842 }
853 843
854 if (result != pixbuf) 844 if (result != pixbuf)
855 g_object_unref (result); 845 g_object_unref (result);
856 846
1047 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1037 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1048 1038
1049 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1039 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1050 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1040 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1051 1041
1052 if (kernel && params && src && dst) 1042 if (kernel && params)
1053 { 1043 {
1054 if (h_blurRadius) 1044 if (h_blurRadius)
1055 { 1045 {
1056 size = h_blurRadius * 2 + 1; 1046 size = h_blurRadius * 2 + 1;
1057 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1047 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1157 pa.component_alpha = True; 1147 pa.component_alpha = True;
1158 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1148 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1159 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); 1149 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1160 XFreePixmap (dpy, mask_pmap); 1150 XFreePixmap (dpy, mask_pmap);
1161 1151
1162 if (mask_pic && overlay_pic && back_pic)
1163 {
1164 XRenderColor mask_c; 1152 XRenderColor mask_c;
1165 1153
1166 mask_c.alpha = 0xffff; 1154 mask_c.alpha = 0xffff;
1167 mask_c.red = 1155 mask_c.red =
1168 mask_c.green = 1156 mask_c.green =
1169 mask_c.blue = 0; 1157 mask_c.blue = 0;
1158 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1159
1160 mask_c.alpha = 0;
1161 mask_c.red = 0xffff - c.r;
1162 mask_c.green = 0xffff - c.g;
1163 mask_c.blue = 0xffff - c.b;
1164 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1165 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1166
1167 if (shade > 100)
1168 {
1169 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1170 mask_c.alpha = 0;
1170 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1171 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1171 1172
1172 mask_c.alpha = 0;
1173 mask_c.red = 0xffff - c.r;
1174 mask_c.green = 0xffff - c.g;
1175 mask_c.blue = 0xffff - c.b;
1176 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1177 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1178
1179 if (shade > 100)
1180 {
1181 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1182 mask_c.alpha = 0;
1183 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1184
1185 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1173 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1186 } 1174 }
1187 1175
1188 ret = true; 1176 ret = true;
1189 }
1190 1177
1191 XRenderFreePicture (dpy, mask_pic); 1178 XRenderFreePicture (dpy, mask_pic);
1192 XRenderFreePicture (dpy, overlay_pic); 1179 XRenderFreePicture (dpy, overlay_pic);
1193 XRenderFreePicture (dpy, back_pic); 1180 XRenderFreePicture (dpy, back_pic);
1194# endif 1181# endif
1251#if XRENDER 1238#if XRENDER
1252 if (bg_flags & BG_HAS_RENDER) 1239 if (bg_flags & BG_HAS_RENDER)
1253 { 1240 {
1254 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); 1241 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1255 1242
1256 if (recoded_root_pmap != None)
1257 {
1258 XRenderPictureAttributes pa; 1243 XRenderPictureAttributes pa;
1259 1244
1260 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1245 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1261 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1246 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1262 1247
1263 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1248 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1264 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1249 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1265 1250
1266 if (src && dst)
1267 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1251 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1268 else
1269 {
1270 XFreePixmap (dpy, recoded_root_pmap);
1271 recoded_root_pmap = None;
1272 }
1273 1252
1274 XRenderFreePicture (dpy, src); 1253 XRenderFreePicture (dpy, src);
1275 XRenderFreePicture (dpy, dst); 1254 XRenderFreePicture (dpy, dst);
1276 }
1277 } 1255 }
1278 else 1256 else
1279#endif 1257#endif
1280 recoded_root_pmap = None; 1258 recoded_root_pmap = None;
1281 } 1259 }
1292 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1270 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1293 bg_pmap_width = window_width; 1271 bg_pmap_width = window_width;
1294 bg_pmap_height = window_height; 1272 bg_pmap_height = window_height;
1295 } 1273 }
1296 1274
1297 if (bg_pixmap != None)
1298 {
1299 /* straightforward pixmap copy */ 1275 /* straightforward pixmap copy */
1300 while (sx < 0) sx += root_width; 1276 while (sx < 0) sx += root_width;
1301 while (sy < 0) sy += root_height; 1277 while (sy < 0) sy += root_height;
1302 1278
1303 gcv.tile = recoded_root_pmap; 1279 gcv.tile = recoded_root_pmap;
1304 gcv.fill_style = FillTiled; 1280 gcv.fill_style = FillTiled;
1305 gcv.ts_x_origin = -sx; 1281 gcv.ts_x_origin = -sx;
1306 gcv.ts_y_origin = -sy; 1282 gcv.ts_y_origin = -sy;
1307 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1283 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1308 1284
1309 if (gc) 1285 if (gc)
1310 { 1286 {
1311 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1287 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1312 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1288 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1313 XFreeGC (dpy, gc); 1289 XFreeGC (dpy, gc);
1314 1290
1315 if (!(bg_flags & BG_CLIENT_RENDER)) 1291 if (!(bg_flags & BG_CLIENT_RENDER))
1316 { 1292 {
1317 if ((bg_flags & BG_NEEDS_BLUR) 1293 if ((bg_flags & BG_NEEDS_BLUR)
1318 && (bg_flags & BG_HAS_RENDER_CONV)) 1294 && (bg_flags & BG_HAS_RENDER_CONV))
1319 { 1295 {
1320 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1296 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1321 result &= ~BG_NEEDS_BLUR; 1297 result &= ~BG_NEEDS_BLUR;
1322 } 1298 }
1323 if ((bg_flags & BG_NEEDS_TINT) 1299 if ((bg_flags & BG_NEEDS_TINT)
1324 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) 1300 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1325 { 1301 {
1326 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1302 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1327 result &= ~BG_NEEDS_TINT; 1303 result &= ~BG_NEEDS_TINT;
1328 } 1304 }
1329 } /* server side rendering completed */ 1305 } /* server side rendering completed */
1330 }
1331 } 1306 }
1332 1307
1333 if (recoded_root_pmap != root_pixmap) 1308 if (recoded_root_pmap != root_pixmap)
1334 XFreePixmap (dpy, recoded_root_pmap); 1309 XFreePixmap (dpy, recoded_root_pmap);
1335 1310

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines