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.112 by sf-exg, Sat Nov 6 17:16:15 2010 UTC vs.
Revision 1.113 by sf-exg, Sat Nov 6 17:51:11 2010 UTC

1414 root_pixmap = new_root_pixmap; 1414 root_pixmap = new_root_pixmap;
1415} 1415}
1416# endif /* ENABLE_TRANSPARENCY */ 1416# endif /* ENABLE_TRANSPARENCY */
1417 1417
1418#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1418#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1419static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1419static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c);
1420# endif 1420# endif
1421 1421
1422bool 1422bool
1423bgPixmap_t::render () 1423bgPixmap_t::render ()
1424{ 1424{
1463 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1463 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1464 { 1464 {
1465 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1465 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1466 if (flags & tintSet) 1466 if (flags & tintSet)
1467 tint.get (c); 1467 tint.get (c);
1468 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c.r, c.g, c.b); 1468 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c);
1469 } 1469 }
1470 1470
1471 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1471 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1472 1472
1473 if (gc) 1473 if (gc)
1578 1578
1579#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1579#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1580/* taken from aterm-0.4.2 */ 1580/* taken from aterm-0.4.2 */
1581 1581
1582static void 1582static void
1583ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) 1583ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c)
1584{ 1584{
1585 int sh_r, sh_g, sh_b; 1585 int sh_r, sh_g, sh_b;
1586 uint32_t mask_r, mask_g, mask_b; 1586 uint32_t mask_r, mask_g, mask_b;
1587 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1587 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1588 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1588 rgba low;
1589 unsigned int upper_lim_r, upper_lim_g, upper_lim_b; 1589 rgba high;
1590 int i; 1590 int i;
1591 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; 1591 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst;
1592 1592
1593 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; 1593 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return;
1594 1594
1659 /* prepare limits for color transformation (each channel is handled separately) */ 1659 /* prepare limits for color transformation (each channel is handled separately) */
1660 if (shade > 100) 1660 if (shade > 100)
1661 { 1661 {
1662 shade = 200 - shade; 1662 shade = 200 - shade;
1663 1663
1664 lower_lim_r = 65535-rm; 1664 high.r = (65535 - c.r) * shade / 100;
1665 lower_lim_g = 65535-gm; 1665 high.g = (65535 - c.g) * shade / 100;
1666 lower_lim_b = 65535-bm; 1666 high.b = (65535 - c.b) * shade / 100;
1667 1667
1668 lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100); 1668 low.r = 65535 - high.r;
1669 lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100); 1669 low.g = 65535 - high.g;
1670 lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100); 1670 low.b = 65535 - high.b;
1671
1672 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1673 } 1671 }
1674 else 1672 else
1675 { 1673 {
1674 high.r = c.r * shade / 100;
1675 high.g = c.g * shade / 100;
1676 high.b = c.b * shade / 100;
1676 1677
1677 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1678 low.r = low.g = low.b = 0;
1678
1679 upper_lim_r = (unsigned int)((((uint32_t)rm)*((uint32_t)shade))/100);
1680 upper_lim_g = (unsigned int)((((uint32_t)gm)*((uint32_t)shade))/100);
1681 upper_lim_b = (unsigned int)((((uint32_t)bm)*((uint32_t)shade))/100);
1682 } 1679 }
1683 1680
1684 /* fill our lookup tables */ 1681 /* fill our lookup tables */
1685 for (i = 0; i <= mask_r>>sh_r; i++) 1682 for (i = 0; i <= mask_r>>sh_r; i++)
1686 { 1683 {
1687 uint32_t tmp; 1684 uint32_t tmp;
1688 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r)); 1685 tmp = i * high.r;
1689 tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r); 1686 tmp += (mask_r>>sh_r) * low.r;
1690 lookup_r[i] = (tmp/65535)<<sh_r; 1687 lookup_r[i] = (tmp/65535)<<sh_r;
1691 } 1688 }
1692 for (i = 0; i <= mask_g>>sh_g; i++) 1689 for (i = 0; i <= mask_g>>sh_g; i++)
1693 { 1690 {
1694 uint32_t tmp; 1691 uint32_t tmp;
1695 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g)); 1692 tmp = i * high.g;
1696 tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g); 1693 tmp += (mask_g>>sh_g) * low.g;
1697 lookup_g[i] = (tmp/65535)<<sh_g; 1694 lookup_g[i] = (tmp/65535)<<sh_g;
1698 } 1695 }
1699 for (i = 0; i <= mask_b>>sh_b; i++) 1696 for (i = 0; i <= mask_b>>sh_b; i++)
1700 { 1697 {
1701 uint32_t tmp; 1698 uint32_t tmp;
1702 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b)); 1699 tmp = i * high.b;
1703 tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b); 1700 tmp += (mask_b>>sh_b) * low.b;
1704 lookup_b[i] = (tmp/65535)<<sh_b; 1701 lookup_b[i] = (tmp/65535)<<sh_b;
1705 } 1702 }
1706 1703
1707 /* apply table to input image (replacing colors by newly calculated ones) */ 1704 /* apply table to input image (replacing colors by newly calculated ones) */
1708 if (srcImage->bits_per_pixel == 32 1705 if (srcImage->bits_per_pixel == 32

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines