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 |
… | |
… | |
65 | rxvt_term::bg_destroy () |
65 | rxvt_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 |
… | |
… | |
616 | else if (depth == 15 || depth == 16) |
620 | else if (depth == 15 || depth == 16) |
617 | bytes_per_pixel = 2; |
621 | bytes_per_pixel = 2; |
618 | else |
622 | else |
619 | return false; |
623 | return false; |
620 | |
624 | |
621 | width_r = rxvt_popcount (visual->red_mask); |
625 | width_r = ecb_popcount32 (visual->red_mask); |
622 | width_g = rxvt_popcount (visual->green_mask); |
626 | width_g = ecb_popcount32 (visual->green_mask); |
623 | width_b = rxvt_popcount (visual->blue_mask); |
627 | width_b = ecb_popcount32 (visual->blue_mask); |
624 | |
628 | |
625 | if (width_r > 8 || width_g > 8 || width_b > 8) |
629 | if (width_r > 8 || width_g > 8 || width_b > 8) |
626 | return false; |
630 | return false; |
627 | |
631 | |
628 | sh_r = rxvt_ctz (visual->red_mask); |
632 | sh_r = ecb_ctz32 (visual->red_mask); |
629 | sh_g = rxvt_ctz (visual->green_mask); |
633 | sh_g = ecb_ctz32 (visual->green_mask); |
630 | sh_b = rxvt_ctz (visual->blue_mask); |
634 | sh_b = ecb_ctz32 (visual->blue_mask); |
631 | |
635 | |
632 | if (width > INT_MAX / height / bytes_per_pixel) |
636 | if (width > INT_MAX / height / bytes_per_pixel) |
633 | return false; |
637 | return false; |
634 | |
638 | |
635 | data = (char *)malloc (width * height * bytes_per_pixel); |
639 | data = (char *)malloc (width * height * bytes_per_pixel); |
… | |
… | |
642 | { |
646 | { |
643 | free (data); |
647 | free (data); |
644 | return false; |
648 | return false; |
645 | } |
649 | } |
646 | |
650 | |
647 | ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; |
651 | ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
648 | |
652 | |
649 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
653 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
650 | channels = gdk_pixbuf_get_n_channels (pixbuf); |
654 | channels = gdk_pixbuf_get_n_channels (pixbuf); |
651 | 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; |
652 | line = data; |
656 | line = data; |
… | |
… | |
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 | |
760 | gcv.foreground = pix_colors[Color_bg]; |
765 | gcv.foreground = pix_colors[Color_bg]; |
761 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
766 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
762 | |
767 | |
|
|
768 | if (gc) |
|
|
769 | { |
763 | if (h_scale == 0 || v_scale == 0) |
770 | if (h_scale == 0 || v_scale == 0) |
764 | { |
771 | { |
765 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
772 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
766 | pixbuf_to_pixmap (result, tile, gc, |
773 | pixbuf_to_pixmap (result, tile, gc, |
767 | 0, 0, |
774 | 0, 0, |
… | |
… | |
812 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
819 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
813 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
820 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
814 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
821 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
815 | XFreePixmap (dpy, mask_pmap); |
822 | XFreePixmap (dpy, mask_pmap); |
816 | |
823 | |
817 | if (src && dst && mask) |
|
|
818 | { |
|
|
819 | XRenderColor mask_c; |
824 | XRenderColor mask_c; |
820 | |
825 | |
821 | mask_c.alpha = 0x8000; |
826 | mask_c.alpha = 0x8000; |
822 | mask_c.red = 0; |
827 | mask_c.red = 0; |
823 | mask_c.green = 0; |
828 | mask_c.green = 0; |
824 | mask_c.blue = 0; |
829 | mask_c.blue = 0; |
825 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
830 | 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); |
831 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
827 | } |
|
|
828 | |
832 | |
829 | XRenderFreePicture (dpy, src); |
833 | XRenderFreePicture (dpy, src); |
830 | XRenderFreePicture (dpy, dst); |
834 | XRenderFreePicture (dpy, dst); |
831 | XRenderFreePicture (dpy, mask); |
835 | XRenderFreePicture (dpy, mask); |
832 | |
|
|
833 | XFreePixmap (dpy, root_pmap); |
|
|
834 | } |
836 | } |
835 | #endif |
837 | #endif |
836 | |
838 | |
837 | if (result != pixbuf) |
|
|
838 | g_object_unref (result); |
|
|
839 | |
|
|
840 | XFreeGC (dpy, gc); |
839 | XFreeGC (dpy, gc); |
841 | |
840 | |
842 | ret = true; |
841 | ret = true; |
843 | } |
842 | } |
|
|
843 | |
|
|
844 | if (result != pixbuf) |
|
|
845 | g_object_unref (result); |
|
|
846 | |
|
|
847 | if (tr_flags) |
|
|
848 | XFreePixmap (dpy, root_pmap); |
844 | |
849 | |
845 | return ret; |
850 | return ret; |
846 | } |
851 | } |
847 | # endif /* HAVE_PIXBUF */ |
852 | # endif /* HAVE_PIXBUF */ |
848 | |
853 | |
… | |
… | |
868 | if (image) |
873 | if (image) |
869 | { |
874 | { |
870 | if (original_asim) |
875 | if (original_asim) |
871 | safe_asimage_destroy (original_asim); |
876 | safe_asimage_destroy (original_asim); |
872 | original_asim = image; |
877 | original_asim = image; |
873 | bg_flags |= BG_CLIENT_RENDER; |
878 | bg_flags |= BG_IS_FROM_FILE | BG_CLIENT_RENDER; |
874 | have_image = true; |
|
|
875 | return true; |
879 | return true; |
876 | } |
880 | } |
877 | # endif |
881 | # endif |
878 | |
882 | |
879 | # ifdef HAVE_PIXBUF |
883 | # ifdef HAVE_PIXBUF |
… | |
… | |
881 | if (image) |
885 | if (image) |
882 | { |
886 | { |
883 | if (pixbuf) |
887 | if (pixbuf) |
884 | g_object_unref (pixbuf); |
888 | g_object_unref (pixbuf); |
885 | pixbuf = image; |
889 | pixbuf = image; |
886 | have_image = true; |
890 | bg_flags |= BG_IS_FROM_FILE; |
887 | return true; |
891 | return true; |
888 | } |
892 | } |
889 | # endif |
893 | # endif |
890 | |
894 | |
891 | return false; |
895 | return false; |
… | |
… | |
940 | bg_flags |= BG_NEEDS_BLUR; |
944 | bg_flags |= BG_NEEDS_BLUR; |
941 | |
945 | |
942 | return changed; |
946 | return changed; |
943 | } |
947 | } |
944 | |
948 | |
945 | static inline unsigned long |
949 | void |
946 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
950 | rxvt_term::set_tint_shade_flags () |
947 | { |
951 | { |
948 | unsigned long flags = 0; |
|
|
949 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
952 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
950 | bool has_shade = shade != 100; |
953 | bool has_shade = shade != 100; |
951 | |
954 | |
952 | if (tint) |
955 | bg_flags &= ~BG_TINT_FLAGS; |
|
|
956 | |
|
|
957 | if (bg_flags & BG_TINT_SET) |
953 | { |
958 | { |
954 | tint->get (c); |
959 | tint.get (c); |
955 | if (!has_shade |
960 | if (!has_shade |
956 | && (c.r <= 0x00ff || c.r >= 0xff00) |
961 | && (c.r <= 0x00ff || c.r >= 0xff00) |
957 | && (c.g <= 0x00ff || c.g >= 0xff00) |
962 | && (c.g <= 0x00ff || c.g >= 0xff00) |
958 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
963 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
959 | flags |= rxvt_term::BG_TINT_BITAND; |
964 | bg_flags |= BG_TINT_BITAND; |
960 | } |
965 | } |
961 | |
966 | |
962 | if (has_shade || tint) |
967 | if (has_shade || (bg_flags & BG_TINT_SET)) |
963 | flags |= rxvt_term::BG_NEEDS_TINT; |
968 | bg_flags |= BG_NEEDS_TINT; |
964 | |
|
|
965 | return flags; |
|
|
966 | } |
969 | } |
967 | |
970 | |
968 | bool |
971 | bool |
969 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
972 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
970 | { |
973 | { |
971 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
974 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
972 | { |
975 | { |
973 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
|
|
974 | tint = new_tint; |
976 | tint = new_tint; |
975 | bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET; |
977 | bg_flags |= BG_TINT_SET; |
|
|
978 | set_tint_shade_flags (); |
976 | return true; |
979 | return true; |
977 | } |
980 | } |
978 | |
981 | |
979 | return false; |
982 | return false; |
980 | } |
983 | } |
… | |
… | |
988 | if (new_shade < 0) |
991 | if (new_shade < 0) |
989 | new_shade = 200 - (100 + new_shade); |
992 | new_shade = 200 - (100 + new_shade); |
990 | |
993 | |
991 | if (new_shade != shade) |
994 | if (new_shade != shade) |
992 | { |
995 | { |
993 | unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade); |
|
|
994 | shade = new_shade; |
996 | shade = new_shade; |
995 | bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags; |
997 | set_tint_shade_flags (); |
996 | return true; |
998 | return true; |
997 | } |
999 | } |
998 | |
1000 | |
999 | return false; |
1001 | return false; |
1000 | } |
1002 | } |
… | |
… | |
1035 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1037 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1036 | |
1038 | |
1037 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1038 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1040 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | |
1041 | |
1040 | if (kernel && params && src && dst) |
1042 | if (kernel && params) |
1041 | { |
1043 | { |
1042 | if (h_blurRadius) |
1044 | if (h_blurRadius) |
1043 | { |
1045 | { |
1044 | size = h_blurRadius * 2 + 1; |
1046 | size = h_blurRadius * 2 + 1; |
1045 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1047 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
… | |
… | |
1110 | } |
1112 | } |
1111 | } |
1113 | } |
1112 | else |
1114 | else |
1113 | { |
1115 | { |
1114 | # if XRENDER |
1116 | # if XRENDER |
1115 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1117 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1116 | |
1118 | |
1117 | if (bg_flags & BG_TINT_SET) |
1119 | if (bg_flags & BG_TINT_SET) |
1118 | tint.get (c); |
1120 | tint.get (c); |
1119 | |
1121 | |
1120 | if (shade <= 100) |
1122 | if (shade <= 100) |
1121 | { |
1123 | { |
1122 | c.r = (c.r * shade) / 100; |
1124 | c.r = c.r * shade / 100; |
1123 | c.g = (c.g * shade) / 100; |
1125 | c.g = c.g * shade / 100; |
1124 | c.b = (c.b * shade) / 100; |
1126 | c.b = c.b * shade / 100; |
1125 | } |
1127 | } |
1126 | else |
1128 | else |
1127 | { |
1129 | { |
1128 | c.r = (c.r * (200 - shade)) / 100; |
1130 | c.r = c.r * (200 - shade) / 100; |
1129 | c.g = (c.g * (200 - shade)) / 100; |
1131 | c.g = c.g * (200 - shade) / 100; |
1130 | c.b = (c.b * (200 - shade)) / 100; |
1132 | c.b = c.b * (200 - shade) / 100; |
1131 | } |
1133 | } |
1132 | |
1134 | |
1133 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1135 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1134 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1136 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1135 | XRenderPictureAttributes pa; |
1137 | XRenderPictureAttributes pa; |
… | |
… | |
1142 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1144 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1143 | XFreePixmap (dpy, overlay_pmap); |
1145 | XFreePixmap (dpy, overlay_pmap); |
1144 | |
1146 | |
1145 | pa.component_alpha = True; |
1147 | pa.component_alpha = True; |
1146 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1148 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1147 | 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); |
1148 | XFreePixmap (dpy, mask_pmap); |
1150 | XFreePixmap (dpy, mask_pmap); |
1149 | |
1151 | |
1150 | if (mask_pic && overlay_pic && back_pic) |
|
|
1151 | { |
|
|
1152 | XRenderColor mask_c; |
1152 | XRenderColor mask_c; |
1153 | |
1153 | |
1154 | mask_c.red = mask_c.green = mask_c.blue = 0; |
|
|
1155 | mask_c.alpha = 0xffff; |
1154 | mask_c.alpha = 0xffff; |
|
|
1155 | mask_c.red = |
|
|
1156 | mask_c.green = |
|
|
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; |
1156 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1171 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1157 | |
1172 | |
1158 | mask_c.alpha = 0; |
|
|
1159 | mask_c.red = 0xffff - c.r; |
|
|
1160 | mask_c.green = 0xffff - c.g; |
|
|
1161 | mask_c.blue = 0xffff - c.b; |
|
|
1162 | 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); |
|
|
1164 | |
|
|
1165 | if (shade > 100) |
|
|
1166 | { |
|
|
1167 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1168 | mask_c.alpha = 0; |
|
|
1169 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1170 | |
|
|
1171 | 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); |
1172 | } |
1174 | } |
1173 | |
1175 | |
1174 | ret = true; |
1176 | ret = true; |
1175 | } |
|
|
1176 | |
1177 | |
1177 | XRenderFreePicture (dpy, mask_pic); |
1178 | XRenderFreePicture (dpy, mask_pic); |
1178 | XRenderFreePicture (dpy, overlay_pic); |
1179 | XRenderFreePicture (dpy, overlay_pic); |
1179 | XRenderFreePicture (dpy, back_pic); |
1180 | XRenderFreePicture (dpy, back_pic); |
1180 | # endif |
1181 | # endif |
1181 | } |
1182 | } |
1182 | |
1183 | |
1183 | return ret; |
1184 | return ret; |
1184 | } |
1185 | } |
1185 | |
1186 | |
1186 | /* make_transparency_pixmap() |
1187 | /* |
1187 | * Builds a pixmap of the same size as the terminal window that contains |
1188 | * 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 |
1189 | * the tiled portion of the root pixmap that is supposed to be covered by |
1189 | * our window. |
1190 | * our window. |
1190 | */ |
1191 | */ |
1191 | unsigned long |
1192 | unsigned long |
… | |
… | |
1235 | if (root_pixmap != None && root_depth != depth) |
1236 | if (root_pixmap != None && root_depth != depth) |
1236 | { |
1237 | { |
1237 | #if XRENDER |
1238 | #if XRENDER |
1238 | if (bg_flags & BG_HAS_RENDER) |
1239 | if (bg_flags & BG_HAS_RENDER) |
1239 | { |
1240 | { |
|
|
1241 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1242 | |
1240 | XRenderPictureAttributes pa; |
1243 | XRenderPictureAttributes pa; |
1241 | |
1244 | |
1242 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1245 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1243 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1246 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1244 | |
1247 | |
1245 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1246 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1248 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1247 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1249 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1248 | |
1250 | |
1249 | if (src && dst) |
|
|
1250 | 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); |
1251 | else |
|
|
1252 | { |
|
|
1253 | XFreePixmap (dpy, recoded_root_pmap); |
|
|
1254 | root_pixmap = None; |
|
|
1255 | } |
|
|
1256 | |
1252 | |
1257 | XRenderFreePicture (dpy, src); |
1253 | XRenderFreePicture (dpy, src); |
1258 | XRenderFreePicture (dpy, dst); |
1254 | XRenderFreePicture (dpy, dst); |
1259 | } |
1255 | } |
1260 | else |
1256 | else |
1261 | #endif |
1257 | #endif |
1262 | root_pixmap = None; |
1258 | recoded_root_pmap = None; |
1263 | } |
1259 | } |
1264 | |
1260 | |
1265 | if (root_pixmap == None) |
1261 | if (recoded_root_pmap == None) |
1266 | return 0; |
1262 | return 0; |
1267 | |
1263 | |
1268 | if (bg_pixmap == None |
1264 | if (bg_pixmap == None |
1269 | || bg_pmap_width != window_width |
1265 | || bg_pmap_width != window_width |
1270 | || bg_pmap_height != window_height) |
1266 | || bg_pmap_height != window_height) |
… | |
… | |
1274 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1270 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1275 | bg_pmap_width = window_width; |
1271 | bg_pmap_width = window_width; |
1276 | bg_pmap_height = window_height; |
1272 | bg_pmap_height = window_height; |
1277 | } |
1273 | } |
1278 | |
1274 | |
1279 | if (bg_pixmap == None) |
|
|
1280 | return 0; |
|
|
1281 | |
|
|
1282 | /* straightforward pixmap copy */ |
1275 | /* straightforward pixmap copy */ |
1283 | while (sx < 0) sx += (int)root_width; |
1276 | while (sx < 0) sx += root_width; |
1284 | while (sy < 0) sy += (int)root_height; |
1277 | while (sy < 0) sy += root_height; |
1285 | |
1278 | |
1286 | gcv.tile = recoded_root_pmap; |
1279 | gcv.tile = recoded_root_pmap; |
1287 | gcv.fill_style = FillTiled; |
1280 | gcv.fill_style = FillTiled; |
1288 | gcv.ts_x_origin = -sx; |
1281 | gcv.ts_x_origin = -sx; |
1289 | gcv.ts_y_origin = -sy; |
1282 | gcv.ts_y_origin = -sy; |
… | |
… | |
1350 | bg_flags |= BG_IS_VALID; |
1343 | bg_flags |= BG_IS_VALID; |
1351 | } |
1344 | } |
1352 | # endif |
1345 | # endif |
1353 | |
1346 | |
1354 | # ifdef BG_IMAGE_FROM_FILE |
1347 | # ifdef BG_IMAGE_FROM_FILE |
1355 | if (have_image |
1348 | if ((bg_flags & BG_IS_FROM_FILE) |
1356 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1349 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1357 | { |
1350 | { |
1358 | if (render_image (tr_flags)) |
1351 | if (render_image (tr_flags)) |
1359 | bg_flags |= BG_IS_VALID; |
1352 | bg_flags |= BG_IS_VALID; |
1360 | } |
1353 | } |
… | |
… | |
1446 | uint32_t mask_r, mask_g, mask_b; |
1439 | uint32_t mask_r, mask_g, mask_b; |
1447 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1440 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1448 | rgba low; |
1441 | rgba low; |
1449 | rgba high; |
1442 | rgba high; |
1450 | int i; |
1443 | int i; |
1451 | int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; |
1444 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1452 | |
1445 | |
1453 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1446 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1454 | |
1447 | |
1455 | /* for convenience */ |
1448 | /* for convenience */ |
1456 | mask_r = visual->red_mask; |
1449 | mask_r = visual->red_mask; |