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.193 by sf-exg, Sun Jan 1 14:31:29 2012 UTC vs.
Revision 1.197 by sf-exg, Wed Jan 11 13:22:01 2012 UTC

32 32
33#ifndef FilterConvolution 33#ifndef FilterConvolution
34#define FilterConvolution "convolution" 34#define FilterConvolution "convolution"
35#endif 35#endif
36 36
37#ifndef RepeatPad
38#define RepeatPad True
39#endif
40
37#ifdef HAVE_BG_PIXMAP 41#ifdef HAVE_BG_PIXMAP
38# if XRENDER 42# if XRENDER
39static Picture 43static Picture
40create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha) 44create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha)
41{ 45{
187 src_pos = -pos; 191 src_pos = -pos;
188 dst_pos = 0; 192 dst_pos = 0;
189 dst_size += pos; 193 dst_size += pos;
190 } 194 }
191 195
192 if (dst_pos + dst_size > target_size)
193 dst_size = target_size - dst_pos; 196 min_it (dst_size, target_size - dst_pos);
194 return src_pos; 197 return src_pos;
195} 198}
196 199
197bool 200bool
198rxvt_term::bg_set_geometry (const char *geom, bool update) 201rxvt_term::bg_set_geometry (const char *geom, bool update)
392 if (tr_flags & BG_NEEDS_TINT) 395 if (tr_flags & BG_NEEDS_TINT)
393 { 396 {
394 ShadingInfo as_shade; 397 ShadingInfo as_shade;
395 as_shade.shading = shade; 398 as_shade.shading = shade;
396 399
397 rgba c; 400 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
401 if (bg_flags & BG_TINT_SET)
398 tint.get (c); 402 tint.get (c);
399 as_shade.tintColor.red = c.r; 403 as_shade.tintColor.red = c.r;
400 as_shade.tintColor.green = c.g; 404 as_shade.tintColor.green = c.g;
401 as_shade.tintColor.blue = c.b; 405 as_shade.tintColor.blue = c.b;
402 406
403 background_tint = shading2tint32 (&as_shade); 407 background_tint = shading2tint32 (&as_shade);
972 rgba c; 976 rgba c;
973 bool has_shade = shade != 100; 977 bool has_shade = shade != 100;
974 978
975 bg_flags &= ~BG_TINT_FLAGS; 979 bg_flags &= ~BG_TINT_FLAGS;
976 980
981 if (bg_flags & BG_TINT_SET)
982 {
977 tint.get (c); 983 tint.get (c);
978
979 if (!has_shade 984 if (!has_shade
980 && (c.r <= 0x00ff || c.r >= 0xff00) 985 && (c.r <= 0x00ff || c.r >= 0xff00)
981 && (c.g <= 0x00ff || c.g >= 0xff00) 986 && (c.g <= 0x00ff || c.g >= 0xff00)
982 && (c.b <= 0x00ff || c.b >= 0xff00)) 987 && (c.b <= 0x00ff || c.b >= 0xff00))
983 bg_flags |= BG_TINT_BITAND; 988 bg_flags |= BG_TINT_BITAND;
989 }
984 990
985 if (has_shade 991 if (has_shade || (bg_flags & BG_TINT_SET))
986 || c.r < 0xff00
987 || c.g < 0xff00
988 || c.b < 0xff00)
989 bg_flags |= BG_NEEDS_TINT; 992 bg_flags |= BG_NEEDS_TINT;
990} 993}
991 994
992bool 995bool
993rxvt_term::bg_set_tint (rxvt_color &new_tint) 996rxvt_term::bg_set_tint (rxvt_color &new_tint)
994{ 997{
995 if (tint != new_tint) 998 if (!(bg_flags & BG_TINT_SET) || tint != new_tint)
996 { 999 {
997 tint = new_tint; 1000 tint = new_tint;
1001 bg_flags |= BG_TINT_SET;
998 set_tint_shade_flags (); 1002 set_tint_shade_flags ();
999 return true; 1003 return true;
1000 } 1004 }
1001 1005
1002 return false; 1006 return false;
1043 params[i+2] = XDoubleToFixed (kernel[i] / sum); 1047 params[i+2] = XDoubleToFixed (kernel[i] / sum);
1044} 1048}
1045#endif 1049#endif
1046 1050
1047bool 1051bool
1048rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1052rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height, int depth)
1049{ 1053{
1050 bool ret = false; 1054 bool ret = false;
1051#if XRENDER 1055#if XRENDER
1052 if (!(bg_flags & BG_HAS_RENDER_CONV)) 1056 if (!(bg_flags & BG_HAS_RENDER_CONV))
1053 return false; 1057 return false;
1054 1058
1055 int size = max (h_blurRadius, v_blurRadius) * 2 + 1; 1059 int size = max (h_blurRadius, v_blurRadius) * 2 + 1;
1056 double *kernel = (double *)malloc (size * sizeof (double)); 1060 double *kernel = (double *)malloc (size * sizeof (double));
1057 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 1061 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
1058 1062
1063 XRenderPictureAttributes pa;
1059 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1064 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1060 1065
1066 pa.repeat = RepeatPad;
1061 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, 0); 1067 Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa);
1068 Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth);
1062 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, 0); 1069 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa);
1070 XFreePixmap (dpy, tmp);
1063 1071
1064 if (kernel && params) 1072 if (kernel && params)
1065 { 1073 {
1066 size = h_blurRadius * 2 + 1; 1074 size = h_blurRadius * 2 + 1;
1067 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1075 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1075 0, 0, 1083 0, 0,
1076 0, 0, 1084 0, 0,
1077 0, 0, 1085 0, 0,
1078 width, height); 1086 width, height);
1079 1087
1088 ::swap (src, dst);
1089
1080 size = v_blurRadius * 2 + 1; 1090 size = v_blurRadius * 2 + 1;
1081 get_gaussian_kernel (v_blurRadius, size, kernel, params); 1091 get_gaussian_kernel (v_blurRadius, size, kernel, params);
1082 ::swap (params[0], params[1]); 1092 ::swap (params[0], params[1]);
1083 1093
1084 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 1094 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
1128 } 1138 }
1129 } 1139 }
1130# if XRENDER 1140# if XRENDER
1131 else if (bg_flags & BG_HAS_RENDER) 1141 else if (bg_flags & BG_HAS_RENDER)
1132 { 1142 {
1133 rgba c; 1143 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1134 1144
1145 if (bg_flags & BG_TINT_SET)
1135 tint.get (c); 1146 tint.get (c);
1136 1147
1137 if (shade <= 100) 1148 if (shade <= 100)
1138 { 1149 {
1139 c.r = c.r * shade / 100; 1150 c.r = c.r * shade / 100;
1140 c.g = c.g * shade / 100; 1151 c.g = c.g * shade / 100;
1296 1307
1297 if (!(bg_flags & BG_CLIENT_RENDER)) 1308 if (!(bg_flags & BG_CLIENT_RENDER))
1298 { 1309 {
1299 if (bg_flags & BG_NEEDS_BLUR) 1310 if (bg_flags & BG_NEEDS_BLUR)
1300 { 1311 {
1301 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1312 if (blur_pixmap (bg_pixmap, visual, window_width, window_height, depth))
1302 result &= ~BG_NEEDS_BLUR; 1313 result &= ~BG_NEEDS_BLUR;
1303 } 1314 }
1304 if (bg_flags & BG_NEEDS_TINT) 1315 if (bg_flags & BG_NEEDS_TINT)
1305 { 1316 {
1306 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1317 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1387 1398
1388void 1399void
1389rxvt_term::bg_init () 1400rxvt_term::bg_init ()
1390{ 1401{
1391#ifdef ENABLE_TRANSPARENCY 1402#ifdef ENABLE_TRANSPARENCY
1392 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1393 tint.set (this, c);
1394 shade = 100; 1403 shade = 100;
1395#endif 1404#endif
1396 1405
1397 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); 1406 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV);
1398#if XRENDER 1407#if XRENDER
1501 break; 1510 break;
1502 default: 1511 default:
1503 return; /* we do not support this color depth */ 1512 return; /* we do not support this color depth */
1504 } 1513 }
1505 1514
1506 rgba c; 1515 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1507 1516
1517 if (bg_flags & BG_TINT_SET)
1508 tint.get (c); 1518 tint.get (c);
1509 1519
1510 /* prepare limits for color transformation (each channel is handled separately) */ 1520 /* prepare limits for color transformation (each channel is handled separately) */
1511 if (shade > 100) 1521 if (shade > 100)
1512 { 1522 {
1513 c.r = c.r * (200 - shade) / 100; 1523 c.r = c.r * (200 - shade) / 100;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines