… | |
… | |
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | *---------------------------------------------------------------------*/ |
24 | *---------------------------------------------------------------------*/ |
25 | |
25 | |
26 | #include "../config.h" /* NECESSARY */ |
26 | #include "../config.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
|
|
28 | |
|
|
29 | #define DO_TIMING_TEST 0 |
|
|
30 | |
|
|
31 | #if DO_TIMING_TEST |
|
|
32 | #define TIMING_TEST_START(id) \ |
|
|
33 | struct timeval timing_test_##id##_stv;\ |
|
|
34 | gettimeofday (&timing_test_##id##_stv, NULL); |
|
|
35 | |
|
|
36 | #define TIMING_TEST_PRINT_RESULT(id) \ |
|
|
37 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
|
|
38 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ |
|
|
39 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
|
|
40 | |
|
|
41 | #else |
|
|
42 | #define TIMING_TEST_START(id) do{}while (0) |
|
|
43 | #define TIMING_TEST_PRINT_RESULT(id) do{}while (0) |
|
|
44 | #endif |
28 | |
45 | |
29 | /* |
46 | /* |
30 | * Pixmap geometry string interpretation : |
47 | * Pixmap geometry string interpretation : |
31 | * Each geometry string contains zero or one scale/position |
48 | * Each geometry string contains zero or one scale/position |
32 | * adjustment and may optionally be followed by a colon and one or more |
49 | * adjustment and may optionally be followed by a colon and one or more |
… | |
… | |
88 | return true; |
105 | return true; |
89 | # endif |
106 | # endif |
90 | return false; |
107 | return false; |
91 | } |
108 | } |
92 | |
109 | |
|
|
110 | bool bgPixmap_t::need_client_side_rendering () |
|
|
111 | { |
|
|
112 | # ifdef HAVE_AFTERIMAGE |
|
|
113 | if (original_asim != NULL) |
|
|
114 | return true; |
|
|
115 | # endif |
|
|
116 | # ifdef ENABLE_TRANSPARENCY |
|
|
117 | if (flags & isTransparent) |
|
|
118 | { |
|
|
119 | if ((flags & blurNeeded) |
|
|
120 | || ((flags & tintNeeded) && !(flags & tintServerSide))) |
|
|
121 | return true; |
|
|
122 | } |
|
|
123 | # endif |
|
|
124 | return false; |
|
|
125 | } |
|
|
126 | |
93 | # ifdef XPM_BACKGROUND |
127 | # ifdef XPM_BACKGROUND |
94 | static inline bool |
128 | static inline bool |
95 | check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) |
129 | check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) |
96 | { |
130 | { |
97 | if (geom_flags & flag) |
131 | if (geom_flags & flag) |
… | |
… | |
359 | int x = 0; |
393 | int x = 0; |
360 | int y = 0; |
394 | int y = 0; |
361 | int w = h_scale * target_width / 100; |
395 | int w = h_scale * target_width / 100; |
362 | int h = v_scale * target_height / 100; |
396 | int h = v_scale * target_height / 100; |
363 | |
397 | |
|
|
398 | TIMING_TEST_START (asim); |
|
|
399 | |
364 | if (original_asim) |
400 | if (original_asim) |
365 | { |
401 | { |
366 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
402 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
367 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
403 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
368 | } |
404 | } |
… | |
… | |
472 | result = tmp; |
508 | result = tmp; |
473 | } |
509 | } |
474 | free (layers); |
510 | free (layers); |
475 | } |
511 | } |
476 | } |
512 | } |
|
|
513 | TIMING_TEST_PRINT_RESULT (asim); |
477 | |
514 | |
478 | if (pixmap) |
515 | if (pixmap) |
479 | { |
516 | { |
480 | if (result == NULL |
517 | if (result == NULL |
481 | || pmap_width != new_pmap_width |
518 | || pmap_width != new_pmap_width |
… | |
… | |
527 | |
564 | |
528 | if (result != background && result != original_asim) |
565 | if (result != background && result != original_asim) |
529 | destroy_asimage (&result); |
566 | destroy_asimage (&result); |
530 | |
567 | |
531 | XFreeGC (target->dpy, gc); |
568 | XFreeGC (target->dpy, gc); |
|
|
569 | TIMING_TEST_PRINT_RESULT (asim); |
532 | } |
570 | } |
533 | |
571 | |
534 | return true; |
572 | return true; |
535 | } |
573 | } |
536 | # endif /* HAVE_AFTERIMAGE */ |
574 | # endif /* HAVE_AFTERIMAGE */ |
… | |
… | |
597 | if (v_blurRadius != vr) |
635 | if (v_blurRadius != vr) |
598 | { |
636 | { |
599 | ++changed; |
637 | ++changed; |
600 | v_blurRadius = vr; |
638 | v_blurRadius = vr; |
601 | } |
639 | } |
|
|
640 | if (v_blurRadius == 0 && h_blurRadius == 0) |
|
|
641 | flags &= ~blurNeeded; |
|
|
642 | else |
|
|
643 | flags |= blurNeeded; |
602 | return (changed>0); |
644 | return (changed>0); |
603 | } |
645 | } |
604 | |
646 | |
605 | static inline unsigned long |
647 | static inline unsigned long |
606 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
648 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
607 | { |
649 | { |
608 | unsigned long flags = 0; |
650 | unsigned long flags = 0; |
|
|
651 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
609 | |
652 | |
610 | if (shade > 0 && shade <100) |
653 | if (tint) |
|
|
654 | { |
|
|
655 | tint->get (c); |
|
|
656 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
|
|
657 | if (IS_COMPONENT_WHOLESOME (c.r) |
|
|
658 | && IS_COMPONENT_WHOLESOME (c.g) |
|
|
659 | && IS_COMPONENT_WHOLESOME (c.b)) |
|
|
660 | flags |= bgPixmap_t::tintWholesome; |
|
|
661 | # undef IS_COMPONENT_WHOLESOME |
|
|
662 | } |
|
|
663 | |
|
|
664 | if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200)) |
611 | flags |= bgPixmap_t::tintNeeded; |
665 | flags |= bgPixmap_t::tintNeeded; |
612 | else if (tint) |
666 | else if (tint) |
613 | { |
667 | { |
614 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
615 | tint->get (c); |
|
|
616 | |
|
|
617 | flags |= bgPixmap_t::tintNeeded; |
|
|
618 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
668 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
619 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
669 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
620 | { |
670 | { |
621 | flags |= bgPixmap_t::tintNeeded; |
671 | flags |= bgPixmap_t::tintNeeded; |
622 | #define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
|
|
623 | if (IS_COMPONENT_WHOLESOME (c.r) |
|
|
624 | && IS_COMPONENT_WHOLESOME (c.g) |
|
|
625 | && IS_COMPONENT_WHOLESOME (c.b)) |
|
|
626 | flags |= bgPixmap_t::tintServerSide; |
|
|
627 | #undef IS_COMPONENT_WHOLESOME |
|
|
628 | } |
672 | } |
629 | } |
673 | } |
|
|
674 | |
|
|
675 | if (flags & bgPixmap_t::tintNeeded) |
|
|
676 | { |
|
|
677 | if (flags & bgPixmap_t::tintWholesome) |
|
|
678 | flags |= bgPixmap_t::tintServerSide; |
|
|
679 | #if XFT |
|
|
680 | /* TODO: add logic for XRENDER tinting */ |
|
|
681 | flags |= bgPixmap_t::tintServerSide; |
|
|
682 | #endif |
|
|
683 | } |
|
|
684 | |
630 | return flags; |
685 | return flags; |
631 | } |
686 | } |
632 | |
687 | |
633 | bool |
688 | bool |
634 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
689 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
… | |
… | |
664 | if (new_shade == 100) |
719 | if (new_shade == 100) |
665 | new_shade = 0; |
720 | new_shade = 0; |
666 | |
721 | |
667 | if (new_shade != shade) |
722 | if (new_shade != shade) |
668 | { |
723 | { |
669 | unsigned long new_flags = compute_tint_shade_flags (&tint, new_shade); |
724 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
670 | shade = new_shade; |
725 | shade = new_shade; |
671 | flags = (flags & ~tintFlags) | new_flags; |
726 | flags = (flags & ~tintFlags) | new_flags; |
672 | return true; |
727 | return true; |
673 | } |
728 | } |
674 | return false; |
729 | return false; |
… | |
… | |
700 | int window_width = target->szHint.width; |
755 | int window_width = target->szHint.width; |
701 | int window_height = target->szHint.height; |
756 | int window_height = target->szHint.height; |
702 | int sx, sy; |
757 | int sx, sy; |
703 | XGCValues gcv; |
758 | XGCValues gcv; |
704 | |
759 | |
|
|
760 | TIMING_TEST_START (tp); |
705 | target->get_window_origin (sx, sy); |
761 | target->get_window_origin (sx, sy); |
706 | |
762 | |
707 | /* check if we are outside of the visible part of the virtual screen : */ |
763 | /* check if we are outside of the visible part of the virtual screen : */ |
708 | if (sx + window_width <= 0 || sy + window_height <= 0 |
764 | if (sx + window_width <= 0 || sy + window_height <= 0 |
709 | || sx >= root_width || sy >= root_height) |
765 | || sx >= root_width || sy >= root_height) |
… | |
… | |
788 | { |
844 | { |
789 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
845 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
790 | result |= transpPmapTiled; |
846 | result |= transpPmapTiled; |
791 | } |
847 | } |
792 | } |
848 | } |
|
|
849 | TIMING_TEST_PRINT_RESULT (tp); |
793 | |
850 | |
794 | if (tiled_root_pmap != None) |
851 | if (tiled_root_pmap != None) |
|
|
852 | { |
|
|
853 | if ((flags & tintNeeded) && !need_client_side_rendering ()) |
795 | { |
854 | { |
796 | if (flags & tintNeeded) |
855 | if (flags & tintWholesome) |
797 | { |
856 | { |
798 | if ((flags & tintServerSide) |
|
|
799 | && h_blurRadius <= 1 && v_blurRadius <= 1 |
|
|
800 | # ifdef HAVE_AFTERIMAGE |
|
|
801 | && original_asim == NULL |
|
|
802 | # endif |
|
|
803 | ) |
|
|
804 | { /* In this case we can tint image server-side getting significant |
857 | /* In this case we can tint image server-side getting significant |
805 | * performance improvements, as we eliminate XImage transfer |
858 | * performance improvements, as we eliminate XImage transfer |
806 | */ |
859 | */ |
807 | gcv.foreground = Pixel (tint); |
860 | gcv.foreground = Pixel (tint); |
808 | gcv.function = GXand; |
861 | gcv.function = GXand; |
809 | gcv.fill_style = FillSolid; |
862 | gcv.fill_style = FillSolid; |
810 | if (gc) |
863 | if (gc) |
811 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
864 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
812 | else |
865 | else |
813 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
866 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
814 | if (gc) |
867 | if (gc) |
815 | { |
868 | { |
816 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
869 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
870 | result |= transpPmapTinted; |
|
|
871 | } |
|
|
872 | } |
|
|
873 | else |
|
|
874 | { |
|
|
875 | #if XFT /* TODO : implement proper detection of XRENDER, as XFT may be present without XRENDER ! */ |
|
|
876 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
877 | if (flags & tintSet) |
|
|
878 | tint.get (c); |
|
|
879 | if (shade > 0 && shade < 100) |
|
|
880 | { |
|
|
881 | c.r = (c.r * shade) / 100; |
|
|
882 | c.g = (c.g * shade) / 100; |
|
|
883 | c.b = (c.b * shade) / 100; |
|
|
884 | } |
|
|
885 | else if( shade > 100 && shade < 200) |
|
|
886 | { |
|
|
887 | c.r = (c.r * (200 - shade)) / 100; |
|
|
888 | c.g = (c.g * (200 - shade)) / 100; |
|
|
889 | c.b = (c.b * (200 - shade)) / 100; |
|
|
890 | } |
|
|
891 | |
|
|
892 | XRenderPictFormat pf; |
|
|
893 | pf.type = PictTypeDirect; |
|
|
894 | pf.depth = 32; |
|
|
895 | pf.direct.redMask = 0xff; |
|
|
896 | pf.direct.greenMask = 0xff; |
|
|
897 | pf.direct.blueMask = 0xff; |
|
|
898 | pf.direct.alphaMask = 0xff; |
|
|
899 | |
|
|
900 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
901 | (PictFormatType| |
|
|
902 | PictFormatDepth| |
|
|
903 | PictFormatRedMask| |
|
|
904 | PictFormatGreenMask| |
|
|
905 | PictFormatBlueMask| |
|
|
906 | PictFormatAlphaMask), |
|
|
907 | &pf, |
|
|
908 | 0); |
|
|
909 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
910 | XRenderPictureAttributes pa ; |
|
|
911 | |
|
|
912 | Picture back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
|
|
913 | |
|
|
914 | pa.repeat = True; |
|
|
915 | |
|
|
916 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
917 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
918 | XFreePixmap (dpy, overlay_pmap); |
|
|
919 | |
|
|
920 | pa.component_alpha = True; |
|
|
921 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
922 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
923 | XFreePixmap (dpy, mask_pmap); |
|
|
924 | |
|
|
925 | if (mask_pic && overlay_pic && back_pic) |
|
|
926 | { |
|
|
927 | XRenderColor mask_c; |
|
|
928 | |
|
|
929 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof(mask_c)); |
|
|
930 | mask_c.alpha = 0xffff; |
|
|
931 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
932 | memset (&mask_c, 0x0, sizeof(mask_c)); |
|
|
933 | mask_c.alpha = 0; |
|
|
934 | if (c.r == c.b && c.b == c.g) /* pure shading */ |
|
|
935 | { |
|
|
936 | mask_c.red = mask_c.green = mask_c.blue = 0xffff-c.r; |
|
|
937 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
938 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
939 | } |
|
|
940 | else |
|
|
941 | { |
|
|
942 | mask_c.red = 0xffff-c.r; |
|
|
943 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
944 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
945 | mask_c.red = 0; |
|
|
946 | mask_c.green = 0xffff-c.g; |
|
|
947 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
948 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
949 | mask_c.green = 0; |
|
|
950 | mask_c.blue = 0xffff-c.b; |
|
|
951 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
952 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
953 | } |
817 | result |= transpPmapTinted; |
954 | result |= transpPmapTinted; |
818 | } |
955 | } |
819 | } |
956 | XRenderFreePicture (dpy, mask_pic); |
|
|
957 | XRenderFreePicture (dpy, overlay_pic); |
|
|
958 | XRenderFreePicture (dpy, back_pic); |
|
|
959 | #endif |
820 | } |
960 | } |
|
|
961 | } |
821 | if (pixmap) |
962 | if (pixmap) |
822 | XFreePixmap (dpy, pixmap); |
963 | XFreePixmap (dpy, pixmap); |
823 | pixmap = tiled_root_pmap; |
964 | pixmap = tiled_root_pmap; |
824 | pmap_width = window_width; |
965 | pmap_width = window_width; |
825 | pmap_height = window_height; |
966 | pmap_height = window_height; |
826 | pmap_depth = root_depth; |
967 | pmap_depth = root_depth; |
827 | } |
968 | } |
828 | |
969 | |
829 | if (gc) |
970 | if (gc) |
830 | XFreeGC (dpy, gc); |
971 | XFreeGC (dpy, gc); |
|
|
972 | |
|
|
973 | TIMING_TEST_PRINT_RESULT (tp); |
831 | |
974 | |
832 | return result; |
975 | return result; |
833 | } |
976 | } |
834 | |
977 | |
835 | bool |
978 | bool |
836 | bgPixmap_t::set_root_pixmap () |
979 | bgPixmap_t::set_root_pixmap () |
837 | { |
980 | { |
… | |
… | |
850 | } |
993 | } |
851 | # endif /* ENABLE_TRANSPARENCY */ |
994 | # endif /* ENABLE_TRANSPARENCY */ |
852 | |
995 | |
853 | # ifndef HAVE_AFTERIMAGE |
996 | # ifndef HAVE_AFTERIMAGE |
854 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
997 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
855 | #endif |
998 | # endif |
856 | |
999 | |
857 | |
1000 | |
858 | bool |
1001 | bool |
859 | bgPixmap_t::render () |
1002 | bgPixmap_t::render () |
860 | { |
1003 | { |
… | |
… | |
885 | ASImage *background = NULL; |
1028 | ASImage *background = NULL; |
886 | ARGB32 as_tint = TINT_LEAVE_SAME; |
1029 | ARGB32 as_tint = TINT_LEAVE_SAME; |
887 | if (background_flags) |
1030 | if (background_flags) |
888 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
1031 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
889 | |
1032 | |
|
|
1033 | # ifdef ENABLE_TRANSPARENCY |
890 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1034 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
891 | { |
1035 | { |
892 | ShadingInfo as_shade; |
1036 | ShadingInfo as_shade; |
893 | as_shade.shading = (shade == 0) ? 100 : shade; |
1037 | as_shade.shading = (shade == 0) ? 100 : shade; |
894 | |
1038 | |
… | |
… | |
899 | as_shade.tintColor.green = c.g; |
1043 | as_shade.tintColor.green = c.g; |
900 | as_shade.tintColor.blue = c.b; |
1044 | as_shade.tintColor.blue = c.b; |
901 | |
1045 | |
902 | as_tint = shading2tint32 (&as_shade); |
1046 | as_tint = shading2tint32 (&as_shade); |
903 | } |
1047 | } |
|
|
1048 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
1049 | { |
|
|
1050 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
1051 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1052 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1053 | if (tmp) |
|
|
1054 | { |
|
|
1055 | destroy_asimage (&background); |
|
|
1056 | background = tmp; |
|
|
1057 | } |
|
|
1058 | } |
|
|
1059 | # endif |
|
|
1060 | |
904 | if (render_asim (background, as_tint)) |
1061 | if (render_asim (background, as_tint)) |
905 | flags = flags & ~isInvalid; |
1062 | flags = flags & ~isInvalid; |
906 | if (background) |
1063 | if (background) |
907 | destroy_asimage (&background); |
1064 | destroy_asimage (&background); |
908 | } |
1065 | } |
… | |
… | |
920 | if (flags & tintSet) |
1077 | if (flags & tintSet) |
921 | tint.get (c); |
1078 | tint.get (c); |
922 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1079 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
923 | } |
1080 | } |
924 | } |
1081 | } |
925 | # endif |
1082 | # endif /* HAVE_AFTERIMAGE */ |
926 | if (result != NULL) |
1083 | if (result != NULL) |
927 | { |
1084 | { |
928 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1085 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
929 | if (gc) |
1086 | if (gc) |
930 | { |
1087 | { |
931 | if (pmap_depth != target->depth && pixmap != None) |
1088 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
932 | { |
1089 | { |
933 | XFreePixmap (target->dpy, pixmap); |
1090 | XFreePixmap (target->dpy, pixmap); |
934 | pixmap = None; |
1091 | pixmap = None; |
935 | } |
1092 | } |
936 | if (pixmap == None) |
1093 | if (pixmap == None) |
… | |
… | |
938 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
1095 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
939 | pmap_width = result->width; |
1096 | pmap_width = result->width; |
940 | pmap_height = result->height; |
1097 | pmap_height = result->height; |
941 | pmap_depth = target->depth; |
1098 | pmap_depth = target->depth; |
942 | } |
1099 | } |
|
|
1100 | if (pmap_depth != result->depth) |
|
|
1101 | { /* Bad Match error will ensue ! stupid X !!!! */ |
|
|
1102 | if( result->depth == 24 && pmap_depth == 32) |
|
|
1103 | result->depth = 32; |
|
|
1104 | else if( result->depth == 32 && pmap_depth == 24) |
|
|
1105 | result->depth = 24; |
|
|
1106 | else |
|
|
1107 | { |
|
|
1108 | /* TODO: implement image recoding */ |
|
|
1109 | } |
|
|
1110 | } |
|
|
1111 | if (pmap_depth == result->depth) |
943 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1112 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
944 | XFreeGC (target->dpy, gc); |
1113 | XFreeGC (target->dpy, gc); |
945 | flags = flags & ~isInvalid; |
1114 | flags = flags & ~isInvalid; |
946 | } |
1115 | } |
947 | XDestroyImage (result); |
1116 | XDestroyImage (result); |
948 | } |
1117 | } |
… | |
… | |
952 | if (pixmap != None) |
1121 | if (pixmap != None) |
953 | { |
1122 | { |
954 | XFreePixmap (target->dpy, pixmap); |
1123 | XFreePixmap (target->dpy, pixmap); |
955 | pixmap = None; |
1124 | pixmap = None; |
956 | } |
1125 | } |
957 | // TODO : we need to get rid of that garbadge : |
|
|
958 | target->am_transparent = target->am_pixmap_trans = 0; |
|
|
959 | } |
1126 | } |
960 | else |
|
|
961 | target->am_transparent = target->am_pixmap_trans = 1; |
|
|
962 | |
1127 | |
963 | apply (); |
1128 | apply (); |
964 | |
1129 | |
965 | return true; |
1130 | return true; |
966 | } |
1131 | } |
… | |
… | |
1022 | } |
1187 | } |
1023 | /* don't want Expose on the parent */ |
1188 | /* don't want Expose on the parent */ |
1024 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1189 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1025 | /* do want Expose on the vt */ |
1190 | /* do want Expose on the vt */ |
1026 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
1191 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
1027 | #if HAVE_SCROLLBARS |
1192 | # if HAVE_SCROLLBARS |
1028 | if (target->scrollBar.win) |
1193 | if (target->scrollBar.win) |
1029 | { |
1194 | { |
1030 | target->scrollBar.setIdle (); |
1195 | target->scrollBar.setIdle (); |
1031 | target->scrollbar_show (0); |
1196 | target->scrollbar_show (0); |
1032 | } |
1197 | } |
1033 | #endif |
1198 | # endif |
1034 | /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */ |
1199 | /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */ |
|
|
1200 | target->want_refresh = 1; |
|
|
1201 | # ifdef ENABLE_TRANSPARENCY |
1035 | target->want_refresh = target->want_full_refresh = 1; |
1202 | target->want_full_refresh = 1; |
|
|
1203 | # endif |
1036 | /* TODO: why do we need a flush here ??? It causes segfault on resize ! */ |
1204 | /* TODO: why do we need a flush here ??? It causes segfault on resize ! */ |
1037 | // target->flush (); |
1205 | // target->flush (); |
1038 | } |
1206 | } |
1039 | } |
1207 | } |
1040 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1041 | |
|
|
1042 | |
1208 | |
1043 | void |
1209 | void |
1044 | rxvt_term::get_window_origin (int &x, int &y) |
1210 | rxvt_term::get_window_origin (int &x, int &y) |
1045 | { |
1211 | { |
1046 | Window cr; |
1212 | Window cr; |
1047 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
1213 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
|
|
1214 | /* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ |
1048 | } |
1215 | } |
1049 | |
1216 | |
1050 | Pixmap |
1217 | Pixmap |
1051 | rxvt_term::get_pixmap_property (int prop_id) |
1218 | rxvt_term::get_pixmap_property (int prop_id) |
1052 | { |
1219 | { |
… | |
… | |
1066 | } |
1233 | } |
1067 | } |
1234 | } |
1068 | return None; |
1235 | return None; |
1069 | } |
1236 | } |
1070 | |
1237 | |
|
|
1238 | /* |
|
|
1239 | * Check our parents are still who we think they are. |
|
|
1240 | * Do transparency updates if required |
|
|
1241 | */ |
|
|
1242 | int |
|
|
1243 | rxvt_term::update_background () |
|
|
1244 | { |
|
|
1245 | bgPixmap.invalidate(); |
|
|
1246 | /* no chance of real time refresh if we are blurring ! */ |
|
|
1247 | if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
|
|
1248 | bgPixmap.render(); |
|
|
1249 | else |
|
|
1250 | { |
|
|
1251 | update_background_ev.stop (); |
|
|
1252 | if (!bgPixmap.need_client_side_rendering()) |
|
|
1253 | update_background_ev.start (NOW + .05); |
|
|
1254 | else if (bgPixmap.flags & bgPixmap_t::blurNeeded) |
|
|
1255 | update_background_ev.start (NOW + .2); /* very slow !!! */ |
|
|
1256 | else |
|
|
1257 | update_background_ev.start (NOW + .07); |
|
|
1258 | } |
|
|
1259 | return 0; |
|
|
1260 | } |
1071 | |
1261 | |
1072 | #ifdef ENABLE_TRANSPARENCY |
1262 | void |
1073 | #ifndef HAVE_AFTERIMAGE |
1263 | rxvt_term::update_background_cb (time_watcher &w) |
|
|
1264 | { |
|
|
1265 | bgPixmap.render (); |
|
|
1266 | } |
|
|
1267 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1268 | |
|
|
1269 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1074 | /* taken from aterm-0.4.2 */ |
1270 | /* taken from aterm-0.4.2 */ |
1075 | |
1271 | |
1076 | typedef uint32_t RUINT32T; |
1272 | typedef uint32_t RUINT32T; |
1077 | |
1273 | |
1078 | static void |
1274 | static void |
… | |
… | |
1089 | |
1285 | |
1090 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
1286 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
1091 | |
1287 | |
1092 | if (shade == 0) |
1288 | if (shade == 0) |
1093 | shade = 100; |
1289 | shade = 100; |
1094 | |
1290 | |
1095 | /* for convenience */ |
1291 | /* for convenience */ |
1096 | mask_r = visual->red_mask; |
1292 | mask_r = visual->red_mask; |
1097 | mask_g = visual->green_mask; |
1293 | mask_g = visual->green_mask; |
1098 | mask_b = visual->blue_mask; |
1294 | mask_b = visual->blue_mask; |
1099 | |
1295 | |
… | |
… | |
1301 | } |
1497 | } |
1302 | } |
1498 | } |
1303 | |
1499 | |
1304 | free (lookup); |
1500 | free (lookup); |
1305 | } |
1501 | } |
1306 | #endif |
1502 | #endif /* defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) */ |
1307 | |
1503 | |
1308 | /* |
1504 | #if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ |
1309 | * Check our parents are still who we think they are. |
|
|
1310 | * Do transparency updates if required |
|
|
1311 | */ |
|
|
1312 | int |
|
|
1313 | rxvt_term::check_our_parents () |
|
|
1314 | { |
|
|
1315 | check_our_parents_ev.stop (); |
|
|
1316 | check_our_parents_ev.start (NOW + .1); |
|
|
1317 | return 0; |
|
|
1318 | } |
|
|
1319 | |
|
|
1320 | void |
1505 | void |
1321 | rxvt_term::check_our_parents_cb (time_watcher &w) |
1506 | rxvt_term::check_our_parents_cb (time_watcher &w) |
1322 | { |
1507 | { |
1323 | #if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ |
|
|
1324 | |
1508 | |
1325 | int i, aformat, rootdepth; |
1509 | int i, aformat, rootdepth; |
1326 | unsigned long nitems, bytes_after; |
1510 | unsigned long nitems, bytes_after; |
1327 | Atom atype; |
1511 | Atom atype; |
1328 | unsigned char *prop = NULL; |
1512 | unsigned char *prop = NULL; |
… | |
… | |
1333 | Window cr; |
1517 | Window cr; |
1334 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1518 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1335 | |
1519 | |
1336 | if (!option (Opt_transparent)) |
1520 | if (!option (Opt_transparent)) |
1337 | return; /* Don't try any more */ |
1521 | return; /* Don't try any more */ |
1338 | #if 0 |
|
|
1339 | struct timeval stv; |
|
|
1340 | gettimeofday (&stv,NULL); |
|
|
1341 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
|
|
1342 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
|
|
1343 | tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0) |
|
|
1344 | #else |
|
|
1345 | #define PRINT_BACKGROUND_OP_TIME do{}while(0) |
|
|
1346 | #endif |
|
|
1347 | |
|
|
1348 | |
1522 | |
1349 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
1523 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
1350 | rootdepth = wrootattr.depth; |
1524 | rootdepth = wrootattr.depth; |
1351 | |
1525 | |
1352 | XGetWindowAttributes (dpy, parent[0], &wattr); |
1526 | XGetWindowAttributes (dpy, parent[0], &wattr); |
… | |
… | |
1486 | { |
1660 | { |
1487 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
1661 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
1488 | success = False; |
1662 | success = False; |
1489 | if (image != NULL) |
1663 | if (image != NULL) |
1490 | { |
1664 | { |
1491 | PRINT_BACKGROUND_OP_TIME; |
|
|
1492 | if (gc == NULL) |
1665 | if (gc == NULL) |
1493 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
1666 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
1494 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
1667 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
1495 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
1668 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
1496 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
1669 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
1497 | XDestroyImage (image); |
1670 | XDestroyImage (image); |
1498 | success = True; |
1671 | success = True; |
1499 | } |
1672 | } |
1500 | } |
1673 | } |
1501 | #endif /* HAVE_AFTERIMAGE */ |
1674 | #endif /* HAVE_AFTERIMAGE */ |
1502 | PRINT_BACKGROUND_OP_TIME; |
|
|
1503 | |
1675 | |
1504 | if (gc != NULL) |
1676 | if (gc != NULL) |
1505 | XFreeGC (dpy, gc); |
1677 | XFreeGC (dpy, gc); |
1506 | |
1678 | |
1507 | bgPixmap.apply(); |
1679 | bgPixmap.apply(); |
… | |
… | |
1526 | want_refresh = want_full_refresh = 1; |
1698 | want_refresh = want_full_refresh = 1; |
1527 | if (am_pixmap_trans) |
1699 | if (am_pixmap_trans) |
1528 | flush (); |
1700 | flush (); |
1529 | } |
1701 | } |
1530 | } |
1702 | } |
|
|
1703 | } |
1531 | #endif |
1704 | #endif |
1532 | } |
|
|
1533 | #endif |
|
|