ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.8 by ayin, Sat Oct 27 15:14:55 2007 UTC vs.
Revision 1.11 by sasha, Wed Nov 14 22:25:41 2007 UTC

31 31
32#if DO_TIMING_TEST 32#if DO_TIMING_TEST
33#define TIMING_TEST_START(id) \ 33#define TIMING_TEST_START(id) \
34 struct timeval timing_test_##id##_stv;\ 34 struct timeval timing_test_##id##_stv;\
35 gettimeofday (&timing_test_##id##_stv, NULL); 35 gettimeofday (&timing_test_##id##_stv, NULL);
36 36
37#define TIMING_TEST_PRINT_RESULT(id) \ 37#define TIMING_TEST_PRINT_RESULT(id) \
38 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ 38 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\
39 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ 39 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\
40 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) 40 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0)
41 41
100#endif 100#endif
101 flags = 0; 101 flags = 0;
102 pixmap = None; 102 pixmap = None;
103} 103}
104 104
105bgPixmap_t::~bgPixmap_t()
106{
107#ifdef HAVE_AFTERIMAGE
108 if (original_asim)
109 safe_asimage_destroy (original_asim);
110#endif
111 if (pixmap && target)
112 XFreePixmap (target->dpy, pixmap);
113}
105 114
106bool 115bool
107bgPixmap_t::window_size_sensitive () 116bgPixmap_t::window_size_sensitive ()
108{ 117{
109# ifdef BG_IMAGE_FROM_FILE 118# ifdef BG_IMAGE_FROM_FILE
318 else if (!(flags & geometrySet)) 327 else if (!(flags & geometrySet))
319 { /* default geometry - scaled and centered */ 328 { /* default geometry - scaled and centered */
320 x = y = defaultAlign; 329 x = y = defaultAlign;
321 w = h = defaultScale; 330 w = h = defaultScale;
322 } 331 }
323 332
324 if (!(flags & geometrySet)) 333 if (!(flags & geometrySet))
325 geom_flags |= WidthValue|HeightValue|XValue|YValue; 334 geom_flags |= WidthValue|HeightValue|XValue|YValue;
326 335
327 if (ops) 336 if (ops)
328 { 337 {
449 { 458 {
450 result = original_asim; 459 result = original_asim;
451 if ((w > 0 && w != original_asim->width) 460 if ((w > 0 && w != original_asim->width)
452 || (h > 0 && h != original_asim->height)) 461 || (h > 0 && h != original_asim->height))
453 { 462 {
454 result = scale_asimage (target->asv, original_asim, 463 result = scale_asimage (target->asv, original_asim,
455 w > 0 ? w : original_asim->width, 464 w > 0 ? w : original_asim->width,
456 h > 0 ? h : original_asim->height, 465 h > 0 ? h : original_asim->height,
457 background ? ASA_ASImage : ASA_XImage, 466 background ? ASA_ASImage : ASA_XImage,
458 100, ASIMAGE_QUALITY_DEFAULT); 467 100, ASIMAGE_QUALITY_DEFAULT);
459 } 468 }
460 if (background == NULL) 469 if (background == NULL)
465 new_pmap_height = result->height; 474 new_pmap_height = result->height;
466 /* we also need to tile our image in one or both directions */ 475 /* we also need to tile our image in one or both directions */
467 if (h_scale == 0 || v_scale == 0) 476 if (h_scale == 0 || v_scale == 0)
468 { 477 {
469 ASImage *tmp = tile_asimage (target->asv, result, 478 ASImage *tmp = tile_asimage (target->asv, result,
470 (h_scale > 0) ? 0 : (int)result->width - x, 479 (h_scale > 0) ? 0 : (int)result->width - x,
471 (v_scale > 0) ? 0 : (int)result->height - y, 480 (v_scale > 0) ? 0 : (int)result->height - y,
472 result->width, result->height, 481 result->width, result->height,
473 TINT_LEAVE_SAME, ASA_XImage, 482 TINT_LEAVE_SAME, ASA_XImage,
474 100, ASIMAGE_QUALITY_DEFAULT); 483 100, ASIMAGE_QUALITY_DEFAULT);
475 if (tmp) 484 if (tmp)
476 { 485 {
578 } 587 }
579 588
580 /* put result on pixmap */ 589 /* put result on pixmap */
581 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 590 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
582 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); 591 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True);
583 592
584 if (result != background && result != original_asim) 593 if (result != background && result != original_asim)
585 destroy_asimage (&result); 594 destroy_asimage (&result);
586 595
587 XFreeGC (target->dpy, gc); 596 XFreeGC (target->dpy, gc);
588 TIMING_TEST_PRINT_RESULT (asim); 597 TIMING_TEST_PRINT_RESULT (asim);
614 f[len] = '\0'; 623 f[len] = '\0';
615 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 624 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
616 free (f); 625 free (f);
617 } 626 }
618 return (original_asim != NULL); 627 return (original_asim != NULL);
619# endif 628# endif
620 } 629 }
621 return false; 630 return false;
622} 631}
623 632
624# endif /* BG_IMAGE_FROM_FILE */ 633# endif /* BG_IMAGE_FROM_FILE */
625 634
626# ifdef ENABLE_TRANSPARENCY 635# ifdef ENABLE_TRANSPARENCY
627bool 636bool
628bgPixmap_t::set_transparent () 637bgPixmap_t::set_transparent ()
629{ 638{
630 if (!(flags & isTransparent)) 639 if (!(flags & isTransparent))
631 { 640 {
632 flags |= isTransparent; 641 flags |= isTransparent;
657 if (v_blurRadius != vr) 666 if (v_blurRadius != vr)
658 { 667 {
659 ++changed; 668 ++changed;
660 v_blurRadius = vr; 669 v_blurRadius = vr;
661 } 670 }
662 671
663 if (v_blurRadius == 0 && h_blurRadius == 0) 672 if (v_blurRadius == 0 && h_blurRadius == 0)
664 flags &= ~blurNeeded; 673 flags &= ~blurNeeded;
665 else 674 else
666 flags |= blurNeeded; 675 flags |= blurNeeded;
667 676
694 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 703 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
695 { 704 {
696 flags |= bgPixmap_t::tintNeeded; 705 flags |= bgPixmap_t::tintNeeded;
697 } 706 }
698 } 707 }
699 708
700 if (flags & bgPixmap_t::tintNeeded) 709 if (flags & bgPixmap_t::tintNeeded)
701 { 710 {
702 if (flags & bgPixmap_t::tintWholesome) 711 if (flags & bgPixmap_t::tintWholesome)
703 flags |= bgPixmap_t::tintServerSide; 712 flags |= bgPixmap_t::tintServerSide;
704 else 713 else
741bool 750bool
742bgPixmap_t::set_shade (const char *shade_str) 751bgPixmap_t::set_shade (const char *shade_str)
743{ 752{
744 int new_shade = (shade_str) ? atoi (shade_str) : 0; 753 int new_shade = (shade_str) ? atoi (shade_str) : 0;
745 754
755 if (new_shade < 0 && new_shade > -100)
756 new_shade = 200 - (100 + new_shade);
746 if (new_shade == 100) 757 else if (new_shade == 100)
747 new_shade = 0; 758 new_shade = 0;
748 759
749 if (new_shade != shade) 760 if (new_shade != shade)
750 { 761 {
751 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); 762 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade);
754 return true; 765 return true;
755 } 766 }
756 return false; 767 return false;
757} 768}
758 769
759/* make_transparency_pixmap() 770/* make_transparency_pixmap()
760 * Builds a pixmap sized the same as terminal window, with depth same as the root window 771 * Builds a pixmap sized the same as terminal window, with depth same as the root window
761 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by 772 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by
762 * our window. 773 * our window.
763 */ 774 */
764unsigned long 775unsigned long
765bgPixmap_t::make_transparency_pixmap () 776bgPixmap_t::make_transparency_pixmap ()
766{ 777{
882 } 893 }
883 TIMING_TEST_PRINT_RESULT (tp); 894 TIMING_TEST_PRINT_RESULT (tp);
884 895
885 if (tiled_root_pmap != None) 896 if (tiled_root_pmap != None)
886 { 897 {
887 if (!need_client_side_rendering ()) 898 if (!need_client_side_rendering ())
888 { 899 {
889 if ((flags & tintNeeded)) 900 if ((flags & tintNeeded))
890 { 901 {
891 if (flags & tintWholesome) 902 if (flags & tintWholesome)
892 { 903 {
893 /* In this case we can tint image server-side getting significant 904 /* In this case we can tint image server-side getting significant
894 * performance improvements, as we eliminate XImage transfer 905 * performance improvements, as we eliminate XImage transfer
954 965
955 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 966 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
956 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 967 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
957 XFreePixmap (dpy, overlay_pmap); 968 XFreePixmap (dpy, overlay_pmap);
958 969
959 pa.component_alpha = True; 970 pa.component_alpha = True;
960 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 971 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
961 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 972 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
962 XFreePixmap (dpy, mask_pmap); 973 XFreePixmap (dpy, mask_pmap);
963 974
964 if (mask_pic && overlay_pic && back_pic) 975 if (mask_pic && overlay_pic && back_pic)
980 XRenderFreePicture (dpy, mask_pic); 991 XRenderFreePicture (dpy, mask_pic);
981 XRenderFreePicture (dpy, overlay_pic); 992 XRenderFreePicture (dpy, overlay_pic);
982 XRenderFreePicture (dpy, back_pic); 993 XRenderFreePicture (dpy, back_pic);
983# if DO_TIMING_TEST 994# if DO_TIMING_TEST
984 XSync (dpy, False); 995 XSync (dpy, False);
985# endif 996# endif
986# endif 997# endif
987 } 998 }
988 } 999 }
989 } /* server side rendering completed */ 1000 } /* server side rendering completed */
990 1001
994 pixmap = tiled_root_pmap; 1005 pixmap = tiled_root_pmap;
995 pmap_width = window_width; 1006 pmap_width = window_width;
996 pmap_height = window_height; 1007 pmap_height = window_height;
997 pmap_depth = root_depth; 1008 pmap_depth = root_depth;
998 } 1009 }
999 1010
1000 if (gc) 1011 if (gc)
1001 XFreeGC (dpy, gc); 1012 XFreeGC (dpy, gc);
1002 1013
1003 TIMING_TEST_PRINT_RESULT (tp); 1014 TIMING_TEST_PRINT_RESULT (tp);
1004 1015
1005 return result; 1016 return result;
1006} 1017}
1007 1018
1008bool 1019bool
1009bgPixmap_t::set_root_pixmap () 1020bgPixmap_t::set_root_pixmap ()
1010{ 1021{
1011 Pixmap new_root_pixmap = None; 1022 Pixmap new_root_pixmap = None;
1012 1023
1013 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1024 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1014 if (new_root_pixmap == None) 1025 if (new_root_pixmap == None)
1015 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1026 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1016 1027
1017 if (new_root_pixmap != root_pixmap) 1028 if (new_root_pixmap != root_pixmap)
1165 1176
1166 apply (); 1177 apply ();
1167 1178
1168 TIMING_TEST_PRINT_RESULT (tp); 1179 TIMING_TEST_PRINT_RESULT (tp);
1169 1180
1170 return true; 1181 return true;
1171} 1182}
1172 1183
1173bool 1184bool
1174bgPixmap_t::set_target (rxvt_term *new_target) 1185bgPixmap_t::set_target (rxvt_term *new_target)
1175{ 1186{
1176 if (new_target) 1187 if (new_target)
1177 if (target != new_target) 1188 if (target != new_target)
1178 { 1189 {
1225# if HAVE_SCROLLBARS 1236# if HAVE_SCROLLBARS
1226 if (target->scrollBar.win) 1237 if (target->scrollBar.win)
1227 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1238 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1228# endif 1239# endif
1229 } 1240 }
1230 /* don't want Expose on the parent or vt. It is better to use 1241 /* don't want Expose on the parent or vt. It is better to use
1231 scr_touch or we get a great deal of flicker otherwise: */ 1242 scr_touch or we get a great deal of flicker otherwise: */
1232 XClearWindow (target->dpy, target->parent[0]); 1243 XClearWindow (target->dpy, target->parent[0]);
1233 1244
1234# if HAVE_SCROLLBARS 1245# if HAVE_SCROLLBARS
1235 if (target->scrollBar.win) 1246 if (target->scrollBar.win)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines