… | |
… | |
620 | else if (depth == 15 || depth == 16) |
620 | else if (depth == 15 || depth == 16) |
621 | bytes_per_pixel = 2; |
621 | bytes_per_pixel = 2; |
622 | else |
622 | else |
623 | return false; |
623 | return false; |
624 | |
624 | |
625 | width_r = rxvt_popcount (visual->red_mask); |
625 | width_r = ecb_popcount32 (visual->red_mask); |
626 | width_g = rxvt_popcount (visual->green_mask); |
626 | width_g = ecb_popcount32 (visual->green_mask); |
627 | width_b = rxvt_popcount (visual->blue_mask); |
627 | width_b = ecb_popcount32 (visual->blue_mask); |
628 | |
628 | |
629 | if (width_r > 8 || width_g > 8 || width_b > 8) |
629 | if (width_r > 8 || width_g > 8 || width_b > 8) |
630 | return false; |
630 | return false; |
631 | |
631 | |
632 | sh_r = rxvt_ctz (visual->red_mask); |
632 | sh_r = ecb_ctz32 (visual->red_mask); |
633 | sh_g = rxvt_ctz (visual->green_mask); |
633 | sh_g = ecb_ctz32 (visual->green_mask); |
634 | sh_b = rxvt_ctz (visual->blue_mask); |
634 | sh_b = ecb_ctz32 (visual->blue_mask); |
635 | |
635 | |
636 | if (width > INT_MAX / height / bytes_per_pixel) |
636 | if (width > INT_MAX / height / bytes_per_pixel) |
637 | return false; |
637 | return false; |
638 | |
638 | |
639 | data = (char *)malloc (width * height * bytes_per_pixel); |
639 | data = (char *)malloc (width * height * bytes_per_pixel); |
… | |
… | |
646 | { |
646 | { |
647 | free (data); |
647 | free (data); |
648 | return false; |
648 | return false; |
649 | } |
649 | } |
650 | |
650 | |
651 | ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; |
651 | ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
652 | |
652 | |
653 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
653 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
654 | channels = gdk_pixbuf_get_n_channels (pixbuf); |
654 | channels = gdk_pixbuf_get_n_channels (pixbuf); |
655 | row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; |
655 | row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; |
656 | line = data; |
656 | line = data; |
… | |
… | |
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 | |
764 | gcv.foreground = pix_colors[Color_bg]; |
765 | gcv.foreground = pix_colors[Color_bg]; |
765 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
766 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
766 | |
767 | |
|
|
768 | if (gc) |
|
|
769 | { |
767 | if (h_scale == 0 || v_scale == 0) |
770 | if (h_scale == 0 || v_scale == 0) |
768 | { |
771 | { |
769 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
772 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
770 | pixbuf_to_pixmap (result, tile, gc, |
773 | pixbuf_to_pixmap (result, tile, gc, |
771 | 0, 0, |
774 | 0, 0, |
… | |
… | |
816 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
819 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
817 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
820 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
818 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
821 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
819 | XFreePixmap (dpy, mask_pmap); |
822 | XFreePixmap (dpy, mask_pmap); |
820 | |
823 | |
821 | if (src && dst && mask) |
|
|
822 | { |
|
|
823 | XRenderColor mask_c; |
824 | XRenderColor mask_c; |
824 | |
825 | |
825 | mask_c.alpha = 0x8000; |
826 | mask_c.alpha = 0x8000; |
826 | mask_c.red = 0; |
827 | mask_c.red = 0; |
827 | mask_c.green = 0; |
828 | mask_c.green = 0; |
828 | mask_c.blue = 0; |
829 | mask_c.blue = 0; |
829 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
830 | 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); |
831 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
831 | } |
|
|
832 | |
832 | |
833 | XRenderFreePicture (dpy, src); |
833 | XRenderFreePicture (dpy, src); |
834 | XRenderFreePicture (dpy, dst); |
834 | XRenderFreePicture (dpy, dst); |
835 | XRenderFreePicture (dpy, mask); |
835 | XRenderFreePicture (dpy, mask); |
836 | |
|
|
837 | XFreePixmap (dpy, root_pmap); |
|
|
838 | } |
836 | } |
839 | #endif |
837 | #endif |
840 | |
838 | |
841 | if (result != pixbuf) |
|
|
842 | g_object_unref (result); |
|
|
843 | |
|
|
844 | XFreeGC (dpy, gc); |
839 | XFreeGC (dpy, gc); |
845 | |
840 | |
846 | ret = true; |
841 | ret = true; |
847 | } |
842 | } |
|
|
843 | |
|
|
844 | if (result != pixbuf) |
|
|
845 | g_object_unref (result); |
|
|
846 | |
|
|
847 | if (tr_flags) |
|
|
848 | XFreePixmap (dpy, root_pmap); |
848 | |
849 | |
849 | return ret; |
850 | return ret; |
850 | } |
851 | } |
851 | # endif /* HAVE_PIXBUF */ |
852 | # endif /* HAVE_PIXBUF */ |
852 | |
853 | |
… | |
… | |
1036 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1037 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1037 | |
1038 | |
1038 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1040 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1040 | |
1041 | |
1041 | if (kernel && params && src && dst) |
1042 | if (kernel && params) |
1042 | { |
1043 | { |
1043 | if (h_blurRadius) |
1044 | if (h_blurRadius) |
1044 | { |
1045 | { |
1045 | size = h_blurRadius * 2 + 1; |
1046 | size = h_blurRadius * 2 + 1; |
1046 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1047 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
… | |
… | |
1146 | pa.component_alpha = True; |
1147 | pa.component_alpha = True; |
1147 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1148 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1148 | 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); |
1149 | XFreePixmap (dpy, mask_pmap); |
1150 | XFreePixmap (dpy, mask_pmap); |
1150 | |
1151 | |
1151 | if (mask_pic && overlay_pic && back_pic) |
|
|
1152 | { |
|
|
1153 | XRenderColor mask_c; |
1152 | XRenderColor mask_c; |
1154 | |
1153 | |
1155 | mask_c.alpha = 0xffff; |
1154 | mask_c.alpha = 0xffff; |
1156 | mask_c.red = |
1155 | mask_c.red = |
1157 | mask_c.green = |
1156 | mask_c.green = |
1158 | 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; |
1159 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1171 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1160 | |
1172 | |
1161 | mask_c.alpha = 0; |
|
|
1162 | mask_c.red = 0xffff - c.r; |
|
|
1163 | mask_c.green = 0xffff - c.g; |
|
|
1164 | mask_c.blue = 0xffff - c.b; |
|
|
1165 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1166 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1167 | |
|
|
1168 | if (shade > 100) |
|
|
1169 | { |
|
|
1170 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1171 | mask_c.alpha = 0; |
|
|
1172 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1173 | |
|
|
1174 | 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); |
1175 | } |
1174 | } |
1176 | |
1175 | |
1177 | ret = true; |
1176 | ret = true; |
1178 | } |
|
|
1179 | |
1177 | |
1180 | XRenderFreePicture (dpy, mask_pic); |
1178 | XRenderFreePicture (dpy, mask_pic); |
1181 | XRenderFreePicture (dpy, overlay_pic); |
1179 | XRenderFreePicture (dpy, overlay_pic); |
1182 | XRenderFreePicture (dpy, back_pic); |
1180 | XRenderFreePicture (dpy, back_pic); |
1183 | # endif |
1181 | # endif |
… | |
… | |
1238 | if (root_pixmap != None && root_depth != depth) |
1236 | if (root_pixmap != None && root_depth != depth) |
1239 | { |
1237 | { |
1240 | #if XRENDER |
1238 | #if XRENDER |
1241 | if (bg_flags & BG_HAS_RENDER) |
1239 | if (bg_flags & BG_HAS_RENDER) |
1242 | { |
1240 | { |
|
|
1241 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1242 | |
1243 | XRenderPictureAttributes pa; |
1243 | XRenderPictureAttributes pa; |
1244 | |
1244 | |
1245 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1245 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1246 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1246 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1247 | |
1247 | |
1248 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1249 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1248 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1250 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1249 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1251 | |
1250 | |
1252 | if (src && dst) |
|
|
1253 | 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); |
1254 | else |
|
|
1255 | { |
|
|
1256 | XFreePixmap (dpy, recoded_root_pmap); |
|
|
1257 | root_pixmap = None; |
|
|
1258 | } |
|
|
1259 | |
1252 | |
1260 | XRenderFreePicture (dpy, src); |
1253 | XRenderFreePicture (dpy, src); |
1261 | XRenderFreePicture (dpy, dst); |
1254 | XRenderFreePicture (dpy, dst); |
1262 | } |
1255 | } |
1263 | else |
1256 | else |
1264 | #endif |
1257 | #endif |
1265 | root_pixmap = None; |
1258 | recoded_root_pmap = None; |
1266 | } |
1259 | } |
1267 | |
1260 | |
1268 | if (root_pixmap == None) |
1261 | if (recoded_root_pmap == None) |
1269 | return 0; |
1262 | return 0; |
1270 | |
1263 | |
1271 | if (bg_pixmap == None |
1264 | if (bg_pixmap == None |
1272 | || bg_pmap_width != window_width |
1265 | || bg_pmap_width != window_width |
1273 | || bg_pmap_height != window_height) |
1266 | || bg_pmap_height != window_height) |
… | |
… | |
1277 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1270 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1278 | bg_pmap_width = window_width; |
1271 | bg_pmap_width = window_width; |
1279 | bg_pmap_height = window_height; |
1272 | bg_pmap_height = window_height; |
1280 | } |
1273 | } |
1281 | |
1274 | |
1282 | if (bg_pixmap == None) |
|
|
1283 | return 0; |
|
|
1284 | |
|
|
1285 | /* straightforward pixmap copy */ |
1275 | /* straightforward pixmap copy */ |
1286 | while (sx < 0) sx += (int)root_width; |
1276 | while (sx < 0) sx += root_width; |
1287 | while (sy < 0) sy += (int)root_height; |
1277 | while (sy < 0) sy += root_height; |
1288 | |
1278 | |
1289 | gcv.tile = recoded_root_pmap; |
1279 | gcv.tile = recoded_root_pmap; |
1290 | gcv.fill_style = FillTiled; |
1280 | gcv.fill_style = FillTiled; |
1291 | gcv.ts_x_origin = -sx; |
1281 | gcv.ts_x_origin = -sx; |
1292 | gcv.ts_y_origin = -sy; |
1282 | gcv.ts_y_origin = -sy; |
… | |
… | |
1449 | uint32_t mask_r, mask_g, mask_b; |
1439 | uint32_t mask_r, mask_g, mask_b; |
1450 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1440 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1451 | rgba low; |
1441 | rgba low; |
1452 | rgba high; |
1442 | rgba high; |
1453 | int i; |
1443 | int i; |
1454 | int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; |
1444 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1455 | |
1445 | |
1456 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1446 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1457 | |
1447 | |
1458 | /* for convenience */ |
1448 | /* for convenience */ |
1459 | mask_r = visual->red_mask; |
1449 | mask_r = visual->red_mask; |