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.179 by sf-exg, Sat Dec 24 09:44:10 2011 UTC vs.
Revision 1.184 by sf-exg, Sun Dec 25 17:07:00 2011 UTC

953} 953}
954 954
955void 955void
956rxvt_term::set_tint_shade_flags () 956rxvt_term::set_tint_shade_flags ()
957{ 957{
958 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 958 rgba c;
959 bool has_shade = shade != 100; 959 bool has_shade = shade != 100;
960 960
961 bg_flags &= ~BG_TINT_FLAGS; 961 bg_flags &= ~BG_TINT_FLAGS;
962 962
963 if (bg_flags & BG_TINT_SET) 963 if (bg_flags & BG_TINT_SET)
1033bool 1033bool
1034rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1034rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height)
1035{ 1035{
1036 bool ret = false; 1036 bool ret = false;
1037#if XRENDER 1037#if XRENDER
1038 if (!(bg_flags & BG_HAS_RENDER_CONV))
1039 return false;
1040
1038 int size = max (h_blurRadius, v_blurRadius) * 2 + 1; 1041 int size = max (h_blurRadius, v_blurRadius) * 2 + 1;
1039 double *kernel = (double *)malloc (size * sizeof (double)); 1042 double *kernel = (double *)malloc (size * sizeof (double));
1040 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 1043 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
1041 1044
1042 XRenderPictureAttributes pa; 1045 XRenderPictureAttributes pa;
1115 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); 1118 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height);
1116 ret = true; 1119 ret = true;
1117 XFreeGC (dpy, gc); 1120 XFreeGC (dpy, gc);
1118 } 1121 }
1119 } 1122 }
1120 else
1121 {
1122# if XRENDER 1123# if XRENDER
1124 else if (bg_flags & BG_HAS_RENDER)
1125 {
1123 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1126 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1124 1127
1125 if (bg_flags & BG_TINT_SET) 1128 if (bg_flags & BG_TINT_SET)
1126 tint.get (c); 1129 tint.get (c);
1127 1130
1182 ret = true; 1185 ret = true;
1183 1186
1184 XRenderFreePicture (dpy, mask_pic); 1187 XRenderFreePicture (dpy, mask_pic);
1185 XRenderFreePicture (dpy, overlay_pic); 1188 XRenderFreePicture (dpy, overlay_pic);
1186 XRenderFreePicture (dpy, back_pic); 1189 XRenderFreePicture (dpy, back_pic);
1190 }
1187# endif 1191# endif
1188 }
1189 1192
1190 return ret; 1193 return ret;
1191} 1194}
1192 1195
1193/* 1196/*
1294 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1297 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1295 XFreeGC (dpy, gc); 1298 XFreeGC (dpy, gc);
1296 1299
1297 if (!(bg_flags & BG_CLIENT_RENDER)) 1300 if (!(bg_flags & BG_CLIENT_RENDER))
1298 { 1301 {
1299 if ((bg_flags & BG_NEEDS_BLUR) 1302 if (bg_flags & BG_NEEDS_BLUR)
1300 && (bg_flags & BG_HAS_RENDER_CONV))
1301 { 1303 {
1302 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1304 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1303 result &= ~BG_NEEDS_BLUR; 1305 result &= ~BG_NEEDS_BLUR;
1304 } 1306 }
1305 if ((bg_flags & BG_NEEDS_TINT) 1307 if (bg_flags & BG_NEEDS_TINT)
1306 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1307 { 1308 {
1308 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1309 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1309 result &= ~BG_NEEDS_TINT; 1310 result &= ~BG_NEEDS_TINT;
1310 } 1311 }
1311 } /* server side rendering completed */ 1312 } /* server side rendering completed */
1325 new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); 1326 new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]);
1326 1327
1327 root_pixmap = new_root_pixmap; 1328 root_pixmap = new_root_pixmap;
1328} 1329}
1329# endif /* ENABLE_TRANSPARENCY */ 1330# endif /* ENABLE_TRANSPARENCY */
1330
1331#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1332static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c);
1333# endif
1334 1331
1335bool 1332bool
1336rxvt_term::bg_render () 1333rxvt_term::bg_render ()
1337{ 1334{
1338 unsigned long tr_flags = 0; 1335 unsigned long tr_flags = 0;
1369 if (result) 1366 if (result)
1370 { 1367 {
1371 /* our own client-side tinting */ 1368 /* our own client-side tinting */
1372 //if (tr_flags & BG_NEEDS_TINT) 1369 //if (tr_flags & BG_NEEDS_TINT)
1373 if (1) 1370 if (1)
1374 {
1375 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1376 if (bg_flags & BG_TINT_SET)
1377 tint.get (c);
1378 shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); 1371 tint_ximage (DefaultVisual (dpy, display->screen), result);
1379 }
1380 1372
1381 GC gc = XCreateGC (dpy, vt, 0UL, NULL); 1373 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1382 1374
1383 if (gc) 1375 if (gc)
1384 { 1376 {
1447 tmp += (mask >> sh) * low; 1439 tmp += (mask >> sh) * low;
1448 lookup[i] = (tmp / 0xffff) << sh; 1440 lookup[i] = (tmp / 0xffff) << sh;
1449 } 1441 }
1450} 1442}
1451 1443
1452static void 1444void
1453shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) 1445rxvt_term::tint_ximage (Visual *visual, XImage *ximage)
1454{ 1446{
1455 int sh_r, sh_g, sh_b; 1447 int sh_r, sh_g, sh_b;
1456 uint32_t mask_r, mask_g, mask_b; 1448 uint32_t mask_r, mask_g, mask_b;
1457 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1449 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1458 rgba low; 1450 unsigned short low;
1459 rgba high;
1460 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; 1451 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1461 1452
1462 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1453 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1463 1454
1464 /* for convenience */ 1455 /* for convenience */
1523 break; 1514 break;
1524 default: 1515 default:
1525 return; /* we do not support this color depth */ 1516 return; /* we do not support this color depth */
1526 } 1517 }
1527 1518
1519 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1520
1521 if (bg_flags & BG_TINT_SET)
1522 tint.get (c);
1523
1528 /* prepare limits for color transformation (each channel is handled separately) */ 1524 /* prepare limits for color transformation (each channel is handled separately) */
1529 if (shade > 100) 1525 if (shade > 100)
1530 { 1526 {
1531 shade = 200 - shade;
1532
1533 high.r = c.r * shade / 100;
1534 high.g = c.g * shade / 100;
1535 high.b = c.b * shade / 100;
1536
1537 low.r = 65535 * (100 - shade) / 100; 1527 c.r = c.r * (200 - shade) / 100;
1538 low.g = 65535 * (100 - shade) / 100; 1528 c.g = c.g * (200 - shade) / 100;
1539 low.b = 65535 * (100 - shade) / 100; 1529 c.b = c.b * (200 - shade) / 100;
1530
1531 low = 0xffff * (shade - 100) / 100;
1540 } 1532 }
1541 else 1533 else
1542 { 1534 {
1543 high.r = c.r * shade / 100; 1535 c.r = c.r * shade / 100;
1544 high.g = c.g * shade / 100; 1536 c.g = c.g * shade / 100;
1545 high.b = c.b * shade / 100; 1537 c.b = c.b * shade / 100;
1546 1538
1547 low.r = low.g = low.b = 0; 1539 low = 0;
1548 } 1540 }
1549 1541
1550 /* fill our lookup tables */ 1542 /* fill our lookup tables */
1551 fill_lut (lookup_r, mask_r, sh_r, low.r, high.r); 1543 fill_lut (lookup_r, mask_r, sh_r, low, c.r);
1552 fill_lut (lookup_g, mask_g, sh_g, low.g, high.g); 1544 fill_lut (lookup_g, mask_g, sh_g, low, c.g);
1553 fill_lut (lookup_b, mask_b, sh_b, low.b, high.b); 1545 fill_lut (lookup_b, mask_b, sh_b, low, c.b);
1554 1546
1555 /* apply table to input image (replacing colors by newly calculated ones) */ 1547 /* apply table to input image (replacing colors by newly calculated ones) */
1556 if (ximage->bits_per_pixel == 32 1548 if (ximage->bits_per_pixel == 32
1557 && (ximage->depth == 24 || ximage->depth == 32) 1549 && (ximage->depth == 24 || ximage->depth == 32)
1558 && ximage->byte_order == host_byte_order) 1550 && ximage->byte_order == host_byte_order)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines