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.185 by sf-exg, Mon Dec 26 14:53:56 2011 UTC vs.
Revision 1.188 by sf-exg, Thu Dec 29 12:25:50 2011 UTC

33#ifndef FilterConvolution 33#ifndef FilterConvolution
34#define FilterConvolution "convolution" 34#define FilterConvolution "convolution"
35#endif 35#endif
36 36
37#ifdef HAVE_BG_PIXMAP 37#ifdef HAVE_BG_PIXMAP
38# if XRENDER
39static Picture
40create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha)
41{
42 Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8);
43
44 XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8);
45 XRenderPictureAttributes pa;
46 pa.repeat = True;
47 pa.component_alpha = component_alpha;
48 Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat | CPComponentAlpha, &pa);
49
50 XFreePixmap (dpy, pixmap);
51
52 return mask;
53}
54# endif
55
38void 56void
39rxvt_term::bg_destroy () 57rxvt_term::bg_destroy ()
40{ 58{
41#ifdef HAVE_AFTERIMAGE 59#ifdef HAVE_AFTERIMAGE
42 if (original_asim) 60 if (original_asim)
374 if (tr_flags & BG_NEEDS_TINT) 392 if (tr_flags & BG_NEEDS_TINT)
375 { 393 {
376 ShadingInfo as_shade; 394 ShadingInfo as_shade;
377 as_shade.shading = shade; 395 as_shade.shading = shade;
378 396
379 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 397 rgba c;
380 if (bg_flags & BG_TINT_SET)
381 tint.get (c); 398 tint.get (c);
382 as_shade.tintColor.red = c.r; 399 as_shade.tintColor.red = c.r;
383 as_shade.tintColor.green = c.g; 400 as_shade.tintColor.green = c.g;
384 as_shade.tintColor.blue = c.b; 401 as_shade.tintColor.blue = c.b;
385 402
386 background_tint = shading2tint32 (&as_shade); 403 background_tint = shading2tint32 (&as_shade);
810 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 827 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
811 828
812 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 829 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
813 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 830 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
814 831
815 pa.repeat = True; 832 Picture mask = create_xrender_mask (dpy, vt, False, False);
816 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
817 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
818 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
819 XFreePixmap (dpy, mask_pmap);
820 833
821 XRenderColor mask_c; 834 XRenderColor mask_c;
822 835
823 mask_c.alpha = 0x8000; 836 mask_c.alpha = 0x8000;
824 mask_c.red = 0; 837 mask_c.red = 0;
960 rgba c; 973 rgba c;
961 bool has_shade = shade != 100; 974 bool has_shade = shade != 100;
962 975
963 bg_flags &= ~BG_TINT_FLAGS; 976 bg_flags &= ~BG_TINT_FLAGS;
964 977
965 if (bg_flags & BG_TINT_SET)
966 {
967 tint.get (c); 978 tint.get (c);
979
968 if (!has_shade 980 if (!has_shade
969 && (c.r <= 0x00ff || c.r >= 0xff00) 981 && (c.r <= 0x00ff || c.r >= 0xff00)
970 && (c.g <= 0x00ff || c.g >= 0xff00) 982 && (c.g <= 0x00ff || c.g >= 0xff00)
971 && (c.b <= 0x00ff || c.b >= 0xff00)) 983 && (c.b <= 0x00ff || c.b >= 0xff00))
972 bg_flags |= BG_TINT_BITAND; 984 bg_flags |= BG_TINT_BITAND;
973 }
974 985
975 if (has_shade || (bg_flags & BG_TINT_SET)) 986 if (has_shade
987 || c.r < 0xff00
988 || c.g < 0xff00
989 || c.b < 0xff00)
976 bg_flags |= BG_NEEDS_TINT; 990 bg_flags |= BG_NEEDS_TINT;
977} 991}
978 992
979bool 993bool
980rxvt_term::bg_set_tint (rxvt_color &new_tint) 994rxvt_term::bg_set_tint (rxvt_color &new_tint)
981{ 995{
982 if (!(bg_flags & BG_TINT_SET) || tint != new_tint) 996 if (tint != new_tint)
983 { 997 {
984 tint = new_tint; 998 tint = new_tint;
985 bg_flags |= BG_TINT_SET;
986 set_tint_shade_flags (); 999 set_tint_shade_flags ();
987 return true; 1000 return true;
988 } 1001 }
989 1002
990 return false; 1003 return false;
991} 1004}
992 1005
993bool 1006bool
994rxvt_term::bg_set_shade (const char *shade_str) 1007rxvt_term::bg_set_shade (const char *shade_str)
995{ 1008{
996 int new_shade = (shade_str) ? atoi (shade_str) : 100; 1009 int new_shade = atoi (shade_str);
997 1010
998 clamp_it (new_shade, -100, 200); 1011 clamp_it (new_shade, -100, 200);
999 if (new_shade < 0) 1012 if (new_shade < 0)
1000 new_shade = 200 - (100 + new_shade); 1013 new_shade = 200 - (100 + new_shade);
1001 1014
1123 } 1136 }
1124 } 1137 }
1125# if XRENDER 1138# if XRENDER
1126 else if (bg_flags & BG_HAS_RENDER) 1139 else if (bg_flags & BG_HAS_RENDER)
1127 { 1140 {
1128 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1141 rgba c;
1129 1142
1130 if (bg_flags & BG_TINT_SET)
1131 tint.get (c); 1143 tint.get (c);
1132 1144
1133 if (shade <= 100) 1145 if (shade <= 100)
1134 { 1146 {
1135 c.r = c.r * shade / 100; 1147 c.r = c.r * shade / 100;
1136 c.g = c.g * shade / 100; 1148 c.g = c.g * shade / 100;
1141 c.r = c.r * (200 - shade) / 100; 1153 c.r = c.r * (200 - shade) / 100;
1142 c.g = c.g * (200 - shade) / 100; 1154 c.g = c.g * (200 - shade) / 100;
1143 c.b = c.b * (200 - shade) / 100; 1155 c.b = c.b * (200 - shade) / 100;
1144 } 1156 }
1145 1157
1146 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1147 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1158 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1148 XRenderPictureAttributes pa; 1159 XRenderPictureAttributes pa;
1149 1160
1150 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1161 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1151 1162
1152 pa.repeat = True; 1163 Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False);
1153 1164
1154 Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1165 Picture mask_pic = create_xrender_mask (dpy, pixmap, True, True);
1155 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1156 XFreePixmap (dpy, overlay_pmap);
1157
1158 pa.component_alpha = True;
1159 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1160 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1161 XFreePixmap (dpy, mask_pmap);
1162 1166
1163 XRenderColor mask_c; 1167 XRenderColor mask_c;
1164 1168
1165 mask_c.alpha = 0xffff; 1169 mask_c.alpha = 0xffff;
1166 mask_c.red = 1170 mask_c.red =
1404 1408
1405void 1409void
1406rxvt_term::bg_init () 1410rxvt_term::bg_init ()
1407{ 1411{
1408#ifdef ENABLE_TRANSPARENCY 1412#ifdef ENABLE_TRANSPARENCY
1413 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1414 tint.set (this, c);
1409 shade = 100; 1415 shade = 100;
1410#endif 1416#endif
1411 1417
1412 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); 1418 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV);
1413#if XRENDER 1419#if XRENDER
1516 break; 1522 break;
1517 default: 1523 default:
1518 return; /* we do not support this color depth */ 1524 return; /* we do not support this color depth */
1519 } 1525 }
1520 1526
1521 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1527 rgba c;
1522 1528
1523 if (bg_flags & BG_TINT_SET)
1524 tint.get (c); 1529 tint.get (c);
1525 1530
1526 /* prepare limits for color transformation (each channel is handled separately) */ 1531 /* prepare limits for color transformation (each channel is handled separately) */
1527 if (shade > 100) 1532 if (shade > 100)
1528 { 1533 {
1529 c.r = c.r * (200 - shade) / 100; 1534 c.r = c.r * (200 - shade) / 100;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines