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.182 by sf-exg, Sun Dec 25 17:01:21 2011 UTC vs.
Revision 1.184 by sf-exg, Sun Dec 25 17:07:00 2011 UTC

1327 1327
1328 root_pixmap = new_root_pixmap; 1328 root_pixmap = new_root_pixmap;
1329} 1329}
1330# endif /* ENABLE_TRANSPARENCY */ 1330# endif /* ENABLE_TRANSPARENCY */
1331 1331
1332#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1333static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c);
1334# endif
1335
1336bool 1332bool
1337rxvt_term::bg_render () 1333rxvt_term::bg_render ()
1338{ 1334{
1339 unsigned long tr_flags = 0; 1335 unsigned long tr_flags = 0;
1340 1336
1370 if (result) 1366 if (result)
1371 { 1367 {
1372 /* our own client-side tinting */ 1368 /* our own client-side tinting */
1373 //if (tr_flags & BG_NEEDS_TINT) 1369 //if (tr_flags & BG_NEEDS_TINT)
1374 if (1) 1370 if (1)
1375 {
1376 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1377 if (bg_flags & BG_TINT_SET)
1378 tint.get (c);
1379 shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); 1371 tint_ximage (DefaultVisual (dpy, display->screen), result);
1380 }
1381 1372
1382 GC gc = XCreateGC (dpy, vt, 0UL, NULL); 1373 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1383 1374
1384 if (gc) 1375 if (gc)
1385 { 1376 {
1448 tmp += (mask >> sh) * low; 1439 tmp += (mask >> sh) * low;
1449 lookup[i] = (tmp / 0xffff) << sh; 1440 lookup[i] = (tmp / 0xffff) << sh;
1450 } 1441 }
1451} 1442}
1452 1443
1453static void 1444void
1454shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) 1445rxvt_term::tint_ximage (Visual *visual, XImage *ximage)
1455{ 1446{
1456 int sh_r, sh_g, sh_b; 1447 int sh_r, sh_g, sh_b;
1457 uint32_t mask_r, mask_g, mask_b; 1448 uint32_t mask_r, mask_g, mask_b;
1458 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1449 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1459 unsigned short low; 1450 unsigned short low;
1460 rgba high;
1461 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; 1451 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1462 1452
1463 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1453 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1464 1454
1465 /* for convenience */ 1455 /* for convenience */
1524 break; 1514 break;
1525 default: 1515 default:
1526 return; /* we do not support this color depth */ 1516 return; /* we do not support this color depth */
1527 } 1517 }
1528 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
1529 /* prepare limits for color transformation (each channel is handled separately) */ 1524 /* prepare limits for color transformation (each channel is handled separately) */
1530 if (shade > 100) 1525 if (shade > 100)
1531 { 1526 {
1532 shade = 200 - shade; 1527 c.r = c.r * (200 - shade) / 100;
1528 c.g = c.g * (200 - shade) / 100;
1529 c.b = c.b * (200 - shade) / 100;
1533 1530
1534 high.r = c.r * shade / 100;
1535 high.g = c.g * shade / 100;
1536 high.b = c.b * shade / 100;
1537
1538 low = 0xffff * (100 - shade) / 100; 1531 low = 0xffff * (shade - 100) / 100;
1539 } 1532 }
1540 else 1533 else
1541 { 1534 {
1542 high.r = c.r * shade / 100; 1535 c.r = c.r * shade / 100;
1543 high.g = c.g * shade / 100; 1536 c.g = c.g * shade / 100;
1544 high.b = c.b * shade / 100; 1537 c.b = c.b * shade / 100;
1545 1538
1546 low = 0; 1539 low = 0;
1547 } 1540 }
1548 1541
1549 /* fill our lookup tables */ 1542 /* fill our lookup tables */
1550 fill_lut (lookup_r, mask_r, sh_r, low, high.r); 1543 fill_lut (lookup_r, mask_r, sh_r, low, c.r);
1551 fill_lut (lookup_g, mask_g, sh_g, low, high.g); 1544 fill_lut (lookup_g, mask_g, sh_g, low, c.g);
1552 fill_lut (lookup_b, mask_b, sh_b, low, high.b); 1545 fill_lut (lookup_b, mask_b, sh_b, low, c.b);
1553 1546
1554 /* apply table to input image (replacing colors by newly calculated ones) */ 1547 /* apply table to input image (replacing colors by newly calculated ones) */
1555 if (ximage->bits_per_pixel == 32 1548 if (ximage->bits_per_pixel == 32
1556 && (ximage->depth == 24 || ximage->depth == 32) 1549 && (ximage->depth == 24 || ximage->depth == 32)
1557 && ximage->byte_order == host_byte_order) 1550 && ximage->byte_order == host_byte_order)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines