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.186 by sf-exg, Wed Dec 28 11:11:25 2011 UTC vs.
Revision 1.190 by sf-exg, Thu Dec 29 20:35:37 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);
803 820
804#if XRENDER 821#if XRENDER
805 if (tr_flags) 822 if (tr_flags)
806 { 823 {
807 XRenderPictureAttributes pa; 824 XRenderPictureAttributes pa;
808
809 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 825 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
826
810 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 827 Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, &pa);
811 828
812 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
813 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 829 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, &pa);
814 830
815 pa.repeat = True; 831 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 832
821 XRenderColor mask_c; 833 XRenderColor mask_c;
822 834
823 mask_c.alpha = 0x8000; 835 mask_c.alpha = 0x8000;
824 mask_c.red = 0; 836 mask_c.red = 0;
960 rgba c; 972 rgba c;
961 bool has_shade = shade != 100; 973 bool has_shade = shade != 100;
962 974
963 bg_flags &= ~BG_TINT_FLAGS; 975 bg_flags &= ~BG_TINT_FLAGS;
964 976
965 if (bg_flags & BG_TINT_SET)
966 {
967 tint.get (c); 977 tint.get (c);
978
968 if (!has_shade 979 if (!has_shade
969 && (c.r <= 0x00ff || c.r >= 0xff00) 980 && (c.r <= 0x00ff || c.r >= 0xff00)
970 && (c.g <= 0x00ff || c.g >= 0xff00) 981 && (c.g <= 0x00ff || c.g >= 0xff00)
971 && (c.b <= 0x00ff || c.b >= 0xff00)) 982 && (c.b <= 0x00ff || c.b >= 0xff00))
972 bg_flags |= BG_TINT_BITAND; 983 bg_flags |= BG_TINT_BITAND;
973 }
974 984
975 if (has_shade || (bg_flags & BG_TINT_SET)) 985 if (has_shade
986 || c.r < 0xff00
987 || c.g < 0xff00
988 || c.b < 0xff00)
976 bg_flags |= BG_NEEDS_TINT; 989 bg_flags |= BG_NEEDS_TINT;
977} 990}
978 991
979bool 992bool
980rxvt_term::bg_set_tint (rxvt_color &new_tint) 993rxvt_term::bg_set_tint (rxvt_color &new_tint)
981{ 994{
982 if (!(bg_flags & BG_TINT_SET) || tint != new_tint) 995 if (tint != new_tint)
983 { 996 {
984 tint = new_tint; 997 tint = new_tint;
985 bg_flags |= BG_TINT_SET;
986 set_tint_shade_flags (); 998 set_tint_shade_flags ();
987 return true; 999 return true;
988 } 1000 }
989 1001
990 return false; 1002 return false;
1123 } 1135 }
1124 } 1136 }
1125# if XRENDER 1137# if XRENDER
1126 else if (bg_flags & BG_HAS_RENDER) 1138 else if (bg_flags & BG_HAS_RENDER)
1127 { 1139 {
1128 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1140 rgba c;
1129 1141
1130 if (bg_flags & BG_TINT_SET)
1131 tint.get (c); 1142 tint.get (c);
1132 1143
1133 if (shade <= 100) 1144 if (shade <= 100)
1134 { 1145 {
1135 c.r = c.r * shade / 100; 1146 c.r = c.r * shade / 100;
1136 c.g = c.g * shade / 100; 1147 c.g = c.g * shade / 100;
1141 c.r = c.r * (200 - shade) / 100; 1152 c.r = c.r * (200 - shade) / 100;
1142 c.g = c.g * (200 - shade) / 100; 1153 c.g = c.g * (200 - shade) / 100;
1143 c.b = c.b * (200 - shade) / 100; 1154 c.b = c.b * (200 - shade) / 100;
1144 } 1155 }
1145 1156
1146 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1147 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1157 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1148 XRenderPictureAttributes pa; 1158 XRenderPictureAttributes pa;
1149 1159
1150 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1160 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1151 1161
1152 pa.repeat = True; 1162 Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False);
1153 1163
1154 Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1164 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 1165
1163 XRenderColor mask_c; 1166 XRenderColor mask_c;
1164 1167
1165 mask_c.alpha = 0xffff; 1168 mask_c.alpha = 0xffff;
1166 mask_c.red = 1169 mask_c.red =
1295 1298
1296 if (gc) 1299 if (gc)
1297 { 1300 {
1298 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1301 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1299 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1302 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1300 XFreeGC (dpy, gc);
1301 1303
1302 if (!(bg_flags & BG_CLIENT_RENDER)) 1304 if (!(bg_flags & BG_CLIENT_RENDER))
1303 { 1305 {
1304 if (bg_flags & BG_NEEDS_BLUR) 1306 if (bg_flags & BG_NEEDS_BLUR)
1305 { 1307 {
1309 if (bg_flags & BG_NEEDS_TINT) 1311 if (bg_flags & BG_NEEDS_TINT)
1310 { 1312 {
1311 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1313 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1312 result &= ~BG_NEEDS_TINT; 1314 result &= ~BG_NEEDS_TINT;
1313 } 1315 }
1316# ifndef HAVE_AFTERIMAGE
1317 if (result & BG_NEEDS_TINT)
1318 {
1319 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1320 if (ximage)
1321 {
1322 /* our own client-side tinting */
1323 tint_ximage (DefaultVisual (dpy, display->screen), ximage);
1324
1325 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
1326 XDestroyImage (ximage);
1327 }
1328 }
1329# endif
1314 } /* server side rendering completed */ 1330 } /* server side rendering completed */
1331
1332 XFreeGC (dpy, gc);
1315 } 1333 }
1316 1334
1317 if (recoded_root_pmap != root_pixmap) 1335 if (recoded_root_pmap != root_pixmap)
1318 XFreePixmap (dpy, recoded_root_pmap); 1336 XFreePixmap (dpy, recoded_root_pmap);
1319 1337
1355 if (render_image (tr_flags)) 1373 if (render_image (tr_flags))
1356 bg_flags |= BG_IS_VALID; 1374 bg_flags |= BG_IS_VALID;
1357 } 1375 }
1358# endif 1376# endif
1359 1377
1360# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1361 XImage *result = NULL;
1362
1363 if (tr_flags & BG_NEEDS_TINT)
1364 {
1365 result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1366 }
1367
1368 if (result)
1369 {
1370 /* our own client-side tinting */
1371 //if (tr_flags & BG_NEEDS_TINT)
1372 if (1)
1373 tint_ximage (DefaultVisual (dpy, display->screen), result);
1374
1375 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1376
1377 if (gc)
1378 {
1379 XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1380
1381 XFreeGC (dpy, gc);
1382 }
1383
1384 XDestroyImage (result);
1385 }
1386# endif
1387
1388 if (!(bg_flags & BG_IS_VALID)) 1378 if (!(bg_flags & BG_IS_VALID))
1389 { 1379 {
1390 if (bg_pixmap != None) 1380 if (bg_pixmap != None)
1391 { 1381 {
1392 XFreePixmap (dpy, bg_pixmap); 1382 XFreePixmap (dpy, bg_pixmap);
1404 1394
1405void 1395void
1406rxvt_term::bg_init () 1396rxvt_term::bg_init ()
1407{ 1397{
1408#ifdef ENABLE_TRANSPARENCY 1398#ifdef ENABLE_TRANSPARENCY
1399 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1400 tint.set (this, c);
1409 shade = 100; 1401 shade = 100;
1410#endif 1402#endif
1411 1403
1412 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); 1404 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV);
1413#if XRENDER 1405#if XRENDER
1516 break; 1508 break;
1517 default: 1509 default:
1518 return; /* we do not support this color depth */ 1510 return; /* we do not support this color depth */
1519 } 1511 }
1520 1512
1521 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1513 rgba c;
1522 1514
1523 if (bg_flags & BG_TINT_SET)
1524 tint.get (c); 1515 tint.get (c);
1525 1516
1526 /* prepare limits for color transformation (each channel is handled separately) */ 1517 /* prepare limits for color transformation (each channel is handled separately) */
1527 if (shade > 100) 1518 if (shade > 100)
1528 { 1519 {
1529 c.r = c.r * (200 - shade) / 100; 1520 c.r = c.r * (200 - shade) / 100;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines