… | |
… | |
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 */ |
… | |
… | |
573 | if (!(flags & isTransparent)) |
611 | if (!(flags & isTransparent)) |
574 | { |
612 | { |
575 | flags |= isTransparent; |
613 | flags |= isTransparent; |
576 | return true; |
614 | return true; |
577 | } |
615 | } |
|
|
616 | return false; |
578 | } |
617 | } |
579 | |
618 | |
580 | bool |
619 | bool |
581 | bgPixmap_t::set_blur_radius (const char *geom) |
620 | bgPixmap_t::set_blur_radius (const char *geom) |
582 | { |
621 | { |
… | |
… | |
597 | if (v_blurRadius != vr) |
636 | if (v_blurRadius != vr) |
598 | { |
637 | { |
599 | ++changed; |
638 | ++changed; |
600 | v_blurRadius = vr; |
639 | v_blurRadius = vr; |
601 | } |
640 | } |
|
|
641 | if (v_blurRadius == 0 && h_blurRadius == 0) |
|
|
642 | flags &= ~blurNeeded; |
|
|
643 | else |
|
|
644 | flags |= blurNeeded; |
602 | return (changed>0); |
645 | return (changed>0); |
603 | } |
646 | } |
604 | |
647 | |
605 | static inline unsigned long |
648 | static inline unsigned long |
606 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
649 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
607 | { |
650 | { |
608 | unsigned long flags = 0; |
651 | unsigned long flags = 0; |
|
|
652 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
609 | |
653 | |
610 | if (shade > 0 && shade <100) |
654 | if (tint) |
|
|
655 | { |
|
|
656 | tint->get (c); |
|
|
657 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
|
|
658 | if (IS_COMPONENT_WHOLESOME (c.r) |
|
|
659 | && IS_COMPONENT_WHOLESOME (c.g) |
|
|
660 | && IS_COMPONENT_WHOLESOME (c.b)) |
|
|
661 | flags |= bgPixmap_t::tintWholesome; |
|
|
662 | # undef IS_COMPONENT_WHOLESOME |
|
|
663 | } |
|
|
664 | |
|
|
665 | if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200)) |
611 | flags |= bgPixmap_t::tintNeeded; |
666 | flags |= bgPixmap_t::tintNeeded; |
612 | else if (tint) |
667 | else if (tint) |
613 | { |
668 | { |
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) |
669 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
619 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
670 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
620 | { |
671 | { |
621 | flags |= bgPixmap_t::tintNeeded; |
672 | 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 | } |
673 | } |
629 | } |
674 | } |
|
|
675 | |
|
|
676 | if (flags & bgPixmap_t::tintNeeded) |
|
|
677 | { |
|
|
678 | if (flags & bgPixmap_t::tintWholesome) |
|
|
679 | flags |= bgPixmap_t::tintServerSide; |
|
|
680 | #if XFT |
|
|
681 | /* TODO: add logic for XRENDER tinting */ |
|
|
682 | flags |= bgPixmap_t::tintServerSide; |
|
|
683 | #endif |
|
|
684 | } |
|
|
685 | |
630 | return flags; |
686 | return flags; |
631 | } |
687 | } |
632 | |
688 | |
633 | bool |
689 | bool |
634 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
690 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
… | |
… | |
664 | if (new_shade == 100) |
720 | if (new_shade == 100) |
665 | new_shade = 0; |
721 | new_shade = 0; |
666 | |
722 | |
667 | if (new_shade != shade) |
723 | if (new_shade != shade) |
668 | { |
724 | { |
669 | unsigned long new_flags = compute_tint_shade_flags (&tint, new_shade); |
725 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
670 | shade = new_shade; |
726 | shade = new_shade; |
671 | flags = (flags & ~tintFlags) | new_flags; |
727 | flags = (flags & ~tintFlags) | new_flags; |
672 | return true; |
728 | return true; |
673 | } |
729 | } |
674 | return false; |
730 | return false; |
… | |
… | |
700 | int window_width = target->szHint.width; |
756 | int window_width = target->szHint.width; |
701 | int window_height = target->szHint.height; |
757 | int window_height = target->szHint.height; |
702 | int sx, sy; |
758 | int sx, sy; |
703 | XGCValues gcv; |
759 | XGCValues gcv; |
704 | |
760 | |
|
|
761 | TIMING_TEST_START (tp); |
705 | target->get_window_origin (sx, sy); |
762 | target->get_window_origin (sx, sy); |
706 | |
763 | |
707 | /* check if we are outside of the visible part of the virtual screen : */ |
764 | /* check if we are outside of the visible part of the virtual screen : */ |
708 | if (sx + window_width <= 0 || sy + window_height <= 0 |
765 | if (sx + window_width <= 0 || sy + window_height <= 0 |
709 | || sx >= root_width || sy >= root_height) |
766 | || sx >= root_width || sy >= root_height) |
… | |
… | |
788 | { |
845 | { |
789 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
846 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
790 | result |= transpPmapTiled; |
847 | result |= transpPmapTiled; |
791 | } |
848 | } |
792 | } |
849 | } |
|
|
850 | TIMING_TEST_PRINT_RESULT (tp); |
793 | |
851 | |
794 | if (tiled_root_pmap != None) |
852 | if (tiled_root_pmap != None) |
|
|
853 | { |
|
|
854 | if ((flags & tintNeeded) && !need_client_side_rendering ()) |
795 | { |
855 | { |
796 | if (flags & tintNeeded) |
856 | if (flags & tintWholesome) |
797 | { |
857 | { |
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 |
858 | /* In this case we can tint image server-side getting significant |
805 | * performance improvements, as we eliminate XImage transfer |
859 | * performance improvements, as we eliminate XImage transfer |
806 | */ |
860 | */ |
807 | gcv.foreground = Pixel (tint); |
861 | gcv.foreground = Pixel (tint); |
808 | gcv.function = GXand; |
862 | gcv.function = GXand; |
809 | gcv.fill_style = FillSolid; |
863 | gcv.fill_style = FillSolid; |
810 | if (gc) |
864 | if (gc) |
811 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
865 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
812 | else |
866 | else |
813 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
867 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
814 | if (gc) |
868 | if (gc) |
815 | { |
869 | { |
816 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
870 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
871 | result |= transpPmapTinted; |
|
|
872 | } |
|
|
873 | } |
|
|
874 | else |
|
|
875 | { |
|
|
876 | #if XFT /* TODO : implement proper detection of XRENDER, as XFT may be present without XRENDER ! */ |
|
|
877 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
878 | if (flags & tintSet) |
|
|
879 | tint.get (c); |
|
|
880 | if (shade > 0 && shade < 100) |
|
|
881 | { |
|
|
882 | c.r = (c.r * shade) / 100; |
|
|
883 | c.g = (c.g * shade) / 100; |
|
|
884 | c.b = (c.b * shade) / 100; |
|
|
885 | } |
|
|
886 | else if( shade > 100 && shade < 200) |
|
|
887 | { |
|
|
888 | c.r = (c.r * (200 - shade)) / 100; |
|
|
889 | c.g = (c.g * (200 - shade)) / 100; |
|
|
890 | c.b = (c.b * (200 - shade)) / 100; |
|
|
891 | } |
|
|
892 | |
|
|
893 | XRenderPictFormat pf; |
|
|
894 | pf.type = PictTypeDirect; |
|
|
895 | pf.depth = 32; |
|
|
896 | pf.direct.redMask = 0xff; |
|
|
897 | pf.direct.greenMask = 0xff; |
|
|
898 | pf.direct.blueMask = 0xff; |
|
|
899 | pf.direct.alphaMask = 0xff; |
|
|
900 | |
|
|
901 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
902 | (PictFormatType| |
|
|
903 | PictFormatDepth| |
|
|
904 | PictFormatRedMask| |
|
|
905 | PictFormatGreenMask| |
|
|
906 | PictFormatBlueMask| |
|
|
907 | PictFormatAlphaMask), |
|
|
908 | &pf, |
|
|
909 | 0); |
|
|
910 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
911 | XRenderPictureAttributes pa ; |
|
|
912 | |
|
|
913 | Picture back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
|
|
914 | |
|
|
915 | pa.repeat = True; |
|
|
916 | |
|
|
917 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
918 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
919 | XFreePixmap (dpy, overlay_pmap); |
|
|
920 | |
|
|
921 | pa.component_alpha = True; |
|
|
922 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
923 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
924 | XFreePixmap (dpy, mask_pmap); |
|
|
925 | |
|
|
926 | if (mask_pic && overlay_pic && back_pic) |
|
|
927 | { |
|
|
928 | XRenderColor mask_c; |
|
|
929 | |
|
|
930 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof(mask_c)); |
|
|
931 | mask_c.alpha = 0xffff; |
|
|
932 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
933 | memset (&mask_c, 0x0, sizeof(mask_c)); |
|
|
934 | mask_c.alpha = 0; |
|
|
935 | if (c.r == c.b && c.b == c.g) /* pure shading */ |
|
|
936 | { |
|
|
937 | mask_c.red = mask_c.green = mask_c.blue = 0xffff-c.r; |
|
|
938 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
939 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
940 | } |
|
|
941 | else |
|
|
942 | { |
|
|
943 | mask_c.red = 0xffff-c.r; |
|
|
944 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
945 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
946 | mask_c.red = 0; |
|
|
947 | mask_c.green = 0xffff-c.g; |
|
|
948 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
949 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
950 | mask_c.green = 0; |
|
|
951 | mask_c.blue = 0xffff-c.b; |
|
|
952 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
953 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
954 | } |
817 | result |= transpPmapTinted; |
955 | result |= transpPmapTinted; |
818 | } |
956 | } |
819 | } |
957 | XRenderFreePicture (dpy, mask_pic); |
|
|
958 | XRenderFreePicture (dpy, overlay_pic); |
|
|
959 | XRenderFreePicture (dpy, back_pic); |
|
|
960 | #endif |
820 | } |
961 | } |
|
|
962 | } |
821 | if (pixmap) |
963 | if (pixmap) |
822 | XFreePixmap (dpy, pixmap); |
964 | XFreePixmap (dpy, pixmap); |
823 | pixmap = tiled_root_pmap; |
965 | pixmap = tiled_root_pmap; |
824 | pmap_width = window_width; |
966 | pmap_width = window_width; |
825 | pmap_height = window_height; |
967 | pmap_height = window_height; |
826 | pmap_depth = root_depth; |
968 | pmap_depth = root_depth; |
827 | } |
969 | } |
828 | |
970 | |
829 | if (gc) |
971 | if (gc) |
830 | XFreeGC (dpy, gc); |
972 | XFreeGC (dpy, gc); |
|
|
973 | |
|
|
974 | TIMING_TEST_PRINT_RESULT (tp); |
831 | |
975 | |
832 | return result; |
976 | return result; |
833 | } |
977 | } |
834 | |
978 | |
835 | bool |
979 | bool |
836 | bgPixmap_t::set_root_pixmap () |
980 | bgPixmap_t::set_root_pixmap () |
837 | { |
981 | { |
… | |
… | |
848 | } |
992 | } |
849 | return false; |
993 | return false; |
850 | } |
994 | } |
851 | # endif /* ENABLE_TRANSPARENCY */ |
995 | # endif /* ENABLE_TRANSPARENCY */ |
852 | |
996 | |
|
|
997 | # ifndef HAVE_AFTERIMAGE |
|
|
998 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
|
|
999 | # endif |
|
|
1000 | |
|
|
1001 | |
853 | bool |
1002 | bool |
854 | bgPixmap_t::render () |
1003 | bgPixmap_t::render () |
855 | { |
1004 | { |
856 | unsigned long background_flags = 0; |
1005 | unsigned long background_flags = 0; |
857 | |
1006 | |
… | |
… | |
864 | { |
1013 | { |
865 | /* we need to re-generate transparency pixmap in that case ! */ |
1014 | /* we need to re-generate transparency pixmap in that case ! */ |
866 | background_flags = make_transparency_pixmap (); |
1015 | background_flags = make_transparency_pixmap (); |
867 | if (background_flags == 0) |
1016 | if (background_flags == 0) |
868 | return false; |
1017 | return false; |
|
|
1018 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
|
|
1019 | && pmap_depth == target->depth) |
|
|
1020 | flags = flags & ~isInvalid; |
869 | } |
1021 | } |
870 | # endif |
1022 | # endif |
871 | |
1023 | |
872 | XImage *result = NULL; |
1024 | XImage *result = NULL; |
873 | # ifdef HAVE_AFTERIMAGE |
1025 | # ifdef HAVE_AFTERIMAGE |
… | |
… | |
877 | ASImage *background = NULL; |
1029 | ASImage *background = NULL; |
878 | ARGB32 as_tint = TINT_LEAVE_SAME; |
1030 | ARGB32 as_tint = TINT_LEAVE_SAME; |
879 | if (background_flags) |
1031 | if (background_flags) |
880 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
1032 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
881 | |
1033 | |
|
|
1034 | # ifdef ENABLE_TRANSPARENCY |
882 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1035 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
883 | { |
1036 | { |
884 | ShadingInfo as_shade; |
1037 | ShadingInfo as_shade; |
885 | as_shade.shading = (shade == 0) ? 100 : shade; |
1038 | as_shade.shading = (shade == 0) ? 100 : shade; |
886 | |
1039 | |
887 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1040 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1041 | if (flags & tintSet) |
888 | tint.get (c); |
1042 | tint.get (c); |
889 | as_shade.tintColor.red = c.r; |
1043 | as_shade.tintColor.red = c.r; |
890 | as_shade.tintColor.green = c.g; |
1044 | as_shade.tintColor.green = c.g; |
891 | as_shade.tintColor.blue = c.b; |
1045 | as_shade.tintColor.blue = c.b; |
892 | |
1046 | |
893 | as_tint = shading2tint32 (&as_shade); |
1047 | as_tint = shading2tint32 (&as_shade); |
894 | } |
1048 | } |
|
|
1049 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
1050 | { |
|
|
1051 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
1052 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1053 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1054 | if (tmp) |
|
|
1055 | { |
|
|
1056 | destroy_asimage (&background); |
|
|
1057 | background = tmp; |
|
|
1058 | } |
|
|
1059 | } |
|
|
1060 | # endif |
|
|
1061 | |
895 | if (render_asim (background, as_tint)) |
1062 | if (render_asim (background, as_tint)) |
896 | flags = flags & ~isInvalid; |
1063 | flags = flags & ~isInvalid; |
897 | if (background) |
1064 | if (background) |
898 | destroy_asimage (&background); |
1065 | destroy_asimage (&background); |
899 | } |
1066 | } |
900 | else if (background_flags && pmap_depth != target->depth) |
1067 | else if (background_flags && pmap_depth != target->depth) |
901 | { |
1068 | { |
902 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1069 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
903 | } |
1070 | } |
904 | # else /* our own client-side tinting */ |
1071 | # else /* our own client-side tinting */ |
905 | if (background_flags && |
1072 | if (background_flags && (flags & isInvalid)) |
906 | (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) || pmap_depth != target->depth) |
|
|
907 | { |
1073 | { |
908 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1074 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
909 | success = False; |
|
|
910 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1075 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
911 | { |
1076 | { |
912 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1077 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1078 | if (flags & tintSet) |
913 | tint.get (c); |
1079 | tint.get (c); |
914 | ShadeXImage (this, result, shade, c.r, c.g, c.b); |
1080 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
915 | } |
1081 | } |
916 | } |
1082 | } |
917 | # endif |
1083 | # endif /* HAVE_AFTERIMAGE */ |
918 | if (result != NULL) |
1084 | if (result != NULL) |
919 | { |
1085 | { |
920 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1086 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
921 | if (gc) |
1087 | if (gc) |
922 | { |
1088 | { |
923 | if (pmap_depth != target->depth && pixmap != None) |
1089 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
924 | { |
1090 | { |
925 | XFreePixmap (target->dpy, pixmap); |
1091 | XFreePixmap (target->dpy, pixmap); |
926 | pixmap = None; |
1092 | pixmap = None; |
927 | } |
1093 | } |
928 | if (pixmap == None) |
1094 | if (pixmap == None) |
… | |
… | |
930 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
1096 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
931 | pmap_width = result->width; |
1097 | pmap_width = result->width; |
932 | pmap_height = result->height; |
1098 | pmap_height = result->height; |
933 | pmap_depth = target->depth; |
1099 | pmap_depth = target->depth; |
934 | } |
1100 | } |
|
|
1101 | if (pmap_depth != result->depth) |
|
|
1102 | { /* Bad Match error will ensue ! stupid X !!!! */ |
|
|
1103 | if( result->depth == 24 && pmap_depth == 32) |
|
|
1104 | result->depth = 32; |
|
|
1105 | else if( result->depth == 32 && pmap_depth == 24) |
|
|
1106 | result->depth = 24; |
|
|
1107 | else |
|
|
1108 | { |
|
|
1109 | /* TODO: implement image recoding */ |
|
|
1110 | } |
|
|
1111 | } |
|
|
1112 | if (pmap_depth == result->depth) |
935 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1113 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
936 | XFreeGC (target->dpy, gc); |
1114 | XFreeGC (target->dpy, gc); |
937 | flags = flags & ~isInvalid; |
1115 | flags = flags & ~isInvalid; |
938 | } |
1116 | } |
939 | XDestroyImage (result); |
1117 | XDestroyImage (result); |
940 | } |
1118 | } |
… | |
… | |
944 | if (pixmap != None) |
1122 | if (pixmap != None) |
945 | { |
1123 | { |
946 | XFreePixmap (target->dpy, pixmap); |
1124 | XFreePixmap (target->dpy, pixmap); |
947 | pixmap = None; |
1125 | pixmap = None; |
948 | } |
1126 | } |
949 | // TODO : we need to get rid of that garbadge : |
|
|
950 | target->am_transparent = target->am_pixmap_trans = 0; |
|
|
951 | } |
1127 | } |
952 | else |
|
|
953 | target->am_transparent = target->am_pixmap_trans = 1; |
|
|
954 | |
1128 | |
955 | apply (); |
1129 | apply (); |
956 | |
1130 | |
957 | return true; |
1131 | return true; |
958 | } |
1132 | } |
… | |
… | |
1014 | } |
1188 | } |
1015 | /* don't want Expose on the parent */ |
1189 | /* don't want Expose on the parent */ |
1016 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1190 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1017 | /* do want Expose on the vt */ |
1191 | /* do want Expose on the vt */ |
1018 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
1192 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
1019 | #if HAVE_SCROLLBARS |
1193 | # if HAVE_SCROLLBARS |
1020 | if (target->scrollBar.win) |
1194 | if (target->scrollBar.win) |
1021 | { |
1195 | { |
1022 | target->scrollBar.setIdle (); |
1196 | target->scrollBar.setIdle (); |
1023 | target->scrollbar_show (0); |
1197 | target->scrollbar_show (0); |
1024 | } |
1198 | } |
1025 | #endif |
1199 | # endif |
|
|
1200 | /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */ |
|
|
1201 | target->want_refresh = 1; |
|
|
1202 | # ifdef ENABLE_TRANSPARENCY |
1026 | target->want_refresh = target->want_full_refresh = 1; |
1203 | target->want_full_refresh = 1; |
|
|
1204 | # endif |
|
|
1205 | /* TODO: why do we need a flush here ??? It causes segfault on resize ! */ |
1027 | target->flush (); |
1206 | // target->flush (); |
1028 | } |
1207 | } |
1029 | } |
1208 | } |
1030 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1031 | |
|
|
1032 | |
1209 | |
1033 | void |
1210 | void |
1034 | rxvt_term::get_window_origin (int &x, int &y) |
1211 | rxvt_term::get_window_origin (int &x, int &y) |
1035 | { |
1212 | { |
1036 | Window cr; |
1213 | Window cr; |
1037 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
1214 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
|
|
1215 | /* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ |
1038 | } |
1216 | } |
1039 | |
1217 | |
1040 | Pixmap |
1218 | Pixmap |
1041 | rxvt_term::get_pixmap_property (int prop_id) |
1219 | rxvt_term::get_pixmap_property (int prop_id) |
1042 | { |
1220 | { |
1043 | if (prop_id > 0 && prop_id < NUM_XA) |
1221 | if (prop_id > 0 && prop_id < NUM_XA) |
1044 | if (xa[prop_id]) |
1222 | if (xa[prop_id]) |
1045 | { |
1223 | { |
1046 | int aformat, rootdepth; |
1224 | int aformat; |
1047 | unsigned long nitems, bytes_after; |
1225 | unsigned long nitems, bytes_after; |
1048 | Atom atype; |
1226 | Atom atype; |
1049 | unsigned char *prop = NULL; |
1227 | unsigned char *prop = NULL; |
1050 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
1228 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
1051 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
1229 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
… | |
… | |
1056 | } |
1234 | } |
1057 | } |
1235 | } |
1058 | return None; |
1236 | return None; |
1059 | } |
1237 | } |
1060 | |
1238 | |
|
|
1239 | /* |
|
|
1240 | * Check our parents are still who we think they are. |
|
|
1241 | * Do transparency updates if required |
|
|
1242 | */ |
|
|
1243 | int |
|
|
1244 | rxvt_term::update_background () |
|
|
1245 | { |
|
|
1246 | bgPixmap.invalidate(); |
|
|
1247 | /* no chance of real time refresh if we are blurring ! */ |
|
|
1248 | if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
|
|
1249 | bgPixmap.render(); |
|
|
1250 | else |
|
|
1251 | { |
|
|
1252 | update_background_ev.stop (); |
|
|
1253 | if (!bgPixmap.need_client_side_rendering()) |
|
|
1254 | update_background_ev.start (NOW + .05); |
|
|
1255 | else if (bgPixmap.flags & bgPixmap_t::blurNeeded) |
|
|
1256 | update_background_ev.start (NOW + .2); /* very slow !!! */ |
|
|
1257 | else |
|
|
1258 | update_background_ev.start (NOW + .07); |
|
|
1259 | } |
|
|
1260 | return 0; |
|
|
1261 | } |
1061 | |
1262 | |
1062 | #ifdef ENABLE_TRANSPARENCY |
1263 | void |
1063 | #ifndef HAVE_AFTERIMAGE |
1264 | rxvt_term::update_background_cb (time_watcher &w) |
|
|
1265 | { |
|
|
1266 | bgPixmap.render (); |
|
|
1267 | } |
|
|
1268 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1269 | |
|
|
1270 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1064 | /* taken from aterm-0.4.2 */ |
1271 | /* taken from aterm-0.4.2 */ |
1065 | |
1272 | |
1066 | typedef uint32_t RUINT32T; |
1273 | typedef uint32_t RUINT32T; |
1067 | |
1274 | |
1068 | static void |
1275 | static void |
… | |
… | |
1075 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
1282 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
1076 | int i; |
1283 | int i; |
1077 | |
1284 | |
1078 | Visual *visual = term->visual; |
1285 | Visual *visual = term->visual; |
1079 | |
1286 | |
1080 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
1287 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
|
|
1288 | |
|
|
1289 | if (shade == 0) |
|
|
1290 | shade = 100; |
1081 | |
1291 | |
1082 | /* for convenience */ |
1292 | /* for convenience */ |
1083 | mask_r = visual->red_mask; |
1293 | mask_r = visual->red_mask; |
1084 | mask_g = visual->green_mask; |
1294 | mask_g = visual->green_mask; |
1085 | mask_b = visual->blue_mask; |
1295 | mask_b = visual->blue_mask; |
… | |
… | |
1288 | } |
1498 | } |
1289 | } |
1499 | } |
1290 | |
1500 | |
1291 | free (lookup); |
1501 | free (lookup); |
1292 | } |
1502 | } |
1293 | #endif |
1503 | #endif /* defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) */ |
1294 | |
1504 | |
1295 | /* |
1505 | #if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ |
1296 | * Check our parents are still who we think they are. |
|
|
1297 | * Do transparency updates if required |
|
|
1298 | */ |
|
|
1299 | int |
|
|
1300 | rxvt_term::check_our_parents () |
|
|
1301 | { |
|
|
1302 | check_our_parents_ev.stop (); |
|
|
1303 | check_our_parents_ev.start (NOW + .1); |
|
|
1304 | return 0; |
|
|
1305 | } |
|
|
1306 | |
|
|
1307 | void |
1506 | void |
1308 | rxvt_term::check_our_parents_cb (time_watcher &w) |
1507 | rxvt_term::check_our_parents_cb (time_watcher &w) |
1309 | { |
1508 | { |
1310 | #if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ |
|
|
1311 | |
1509 | |
1312 | int i, aformat, rootdepth; |
1510 | int i, aformat, rootdepth; |
1313 | unsigned long nitems, bytes_after; |
1511 | unsigned long nitems, bytes_after; |
1314 | Atom atype; |
1512 | Atom atype; |
1315 | unsigned char *prop = NULL; |
1513 | unsigned char *prop = NULL; |
… | |
… | |
1320 | Window cr; |
1518 | Window cr; |
1321 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1519 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1322 | |
1520 | |
1323 | if (!option (Opt_transparent)) |
1521 | if (!option (Opt_transparent)) |
1324 | return; /* Don't try any more */ |
1522 | return; /* Don't try any more */ |
1325 | #if 0 |
|
|
1326 | struct timeval stv; |
|
|
1327 | gettimeofday (&stv,NULL); |
|
|
1328 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
|
|
1329 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
|
|
1330 | tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0) |
|
|
1331 | #else |
|
|
1332 | #define PRINT_BACKGROUND_OP_TIME do{}while(0) |
|
|
1333 | #endif |
|
|
1334 | |
|
|
1335 | |
1523 | |
1336 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
1524 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
1337 | rootdepth = wrootattr.depth; |
1525 | rootdepth = wrootattr.depth; |
1338 | |
1526 | |
1339 | XGetWindowAttributes (dpy, parent[0], &wattr); |
1527 | XGetWindowAttributes (dpy, parent[0], &wattr); |
… | |
… | |
1473 | { |
1661 | { |
1474 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
1662 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
1475 | success = False; |
1663 | success = False; |
1476 | if (image != NULL) |
1664 | if (image != NULL) |
1477 | { |
1665 | { |
1478 | PRINT_BACKGROUND_OP_TIME; |
|
|
1479 | if (gc == NULL) |
1666 | if (gc == NULL) |
1480 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
1667 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
1481 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
1668 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
1482 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
1669 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
1483 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
1670 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
1484 | XDestroyImage (image); |
1671 | XDestroyImage (image); |
1485 | success = True; |
1672 | success = True; |
1486 | } |
1673 | } |
1487 | } |
1674 | } |
1488 | #endif /* HAVE_AFTERIMAGE */ |
1675 | #endif /* HAVE_AFTERIMAGE */ |
1489 | PRINT_BACKGROUND_OP_TIME; |
|
|
1490 | |
1676 | |
1491 | if (gc != NULL) |
1677 | if (gc != NULL) |
1492 | XFreeGC (dpy, gc); |
1678 | XFreeGC (dpy, gc); |
1493 | |
1679 | |
1494 | bgPixmap.apply(); |
1680 | bgPixmap.apply(); |
… | |
… | |
1513 | want_refresh = want_full_refresh = 1; |
1699 | want_refresh = want_full_refresh = 1; |
1514 | if (am_pixmap_trans) |
1700 | if (am_pixmap_trans) |
1515 | flush (); |
1701 | flush (); |
1516 | } |
1702 | } |
1517 | } |
1703 | } |
|
|
1704 | } |
1518 | #endif |
1705 | #endif |
1519 | } |
|
|
1520 | #endif |
|
|