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.110 by sf-exg, Wed Nov 3 11:58:03 2010 UTC vs.
Revision 1.114 by sf-exg, Wed Nov 10 13:15:08 2010 UTC

1367 if (gc) 1367 if (gc)
1368 { 1368 {
1369 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1369 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1370 result |= transpPmapTiled; 1370 result |= transpPmapTiled;
1371 XFreeGC (dpy, gc); 1371 XFreeGC (dpy, gc);
1372 }
1373 1372
1374 if (tiled_root_pmap != None)
1375 {
1376 if (!need_client_side_rendering ()) 1373 if (!need_client_side_rendering ())
1377 { 1374 {
1378 if ((flags & blurNeeded) 1375 if ((flags & blurNeeded)
1379 && (flags & HAS_RENDER_CONV)) 1376 && (flags & HAS_RENDER_CONV))
1380 { 1377 {
1395 pixmap = tiled_root_pmap; 1392 pixmap = tiled_root_pmap;
1396 pmap_width = window_width; 1393 pmap_width = window_width;
1397 pmap_height = window_height; 1394 pmap_height = window_height;
1398 pmap_depth = target->depth; 1395 pmap_depth = target->depth;
1399 } 1396 }
1397 else
1398 XFreePixmap (dpy, tiled_root_pmap);
1400 1399
1401 if (recoded_root_pmap != root_pixmap) 1400 if (recoded_root_pmap != root_pixmap)
1402 XFreePixmap (dpy, recoded_root_pmap); 1401 XFreePixmap (dpy, recoded_root_pmap);
1403 1402
1404 return result; 1403 return result;
1413 1412
1414 root_pixmap = new_root_pixmap; 1413 root_pixmap = new_root_pixmap;
1415} 1414}
1416# endif /* ENABLE_TRANSPARENCY */ 1415# endif /* ENABLE_TRANSPARENCY */
1417 1416
1418# ifndef HAVE_AFTERIMAGE 1417#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1419static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1418static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c);
1420# endif 1419# endif
1421 1420
1422bool 1421bool
1423bgPixmap_t::render () 1422bgPixmap_t::render ()
1424{ 1423{
1447 if (render_image (background_flags)) 1446 if (render_image (background_flags))
1448 flags = flags & ~isInvalid; 1447 flags = flags & ~isInvalid;
1449 } 1448 }
1450# endif 1449# endif
1451 1450
1451# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1452 XImage *result = NULL; 1452 XImage *result = NULL;
1453 1453
1454 if (background_flags && (flags & isInvalid)) 1454 if (background_flags && (flags & isInvalid))
1455 { 1455 {
1456 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1456 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1457 } 1457 }
1458 1458
1459 if (result) 1459 if (result)
1460 { 1460 {
1461# if !defined(HAVE_AFTERIMAGE) && !XRENDER
1462 /* our own client-side tinting */ 1461 /* our own client-side tinting */
1463 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1462 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1464 { 1463 {
1465 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1464 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1466 if (flags & tintSet) 1465 if (flags & tintSet)
1467 tint.get (c); 1466 tint.get (c);
1468 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c.r, c.g, c.b); 1467 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c);
1469 } 1468 }
1470# endif
1471 1469
1472 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1470 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1473 1471
1474 if (gc) 1472 if (gc)
1475 { 1473 {
1479 flags = flags & ~isInvalid; 1477 flags = flags & ~isInvalid;
1480 } 1478 }
1481 1479
1482 XDestroyImage (result); 1480 XDestroyImage (result);
1483 } 1481 }
1482# endif
1484 1483
1485 if (flags & isInvalid) 1484 if (flags & isInvalid)
1486 { 1485 {
1487 if (pixmap != None) 1486 if (pixmap != None)
1488 { 1487 {
1574 flags |= hasChanged; 1573 flags |= hasChanged;
1575} 1574}
1576 1575
1577#endif /* HAVE_BG_PIXMAP */ 1576#endif /* HAVE_BG_PIXMAP */
1578 1577
1579#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER 1578#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1580/* taken from aterm-0.4.2 */ 1579/* taken from aterm-0.4.2 */
1581 1580
1582static void 1581static void
1583ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) 1582ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c)
1584{ 1583{
1585 int sh_r, sh_g, sh_b; 1584 int sh_r, sh_g, sh_b;
1586 uint32_t mask_r, mask_g, mask_b; 1585 uint32_t mask_r, mask_g, mask_b;
1587 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1586 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1588 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1587 rgba low;
1589 unsigned int upper_lim_r, upper_lim_g, upper_lim_b; 1588 rgba high;
1590 int i; 1589 int i;
1591 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; 1590 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst;
1592 1591
1593 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; 1592 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return;
1594 1593
1659 /* prepare limits for color transformation (each channel is handled separately) */ 1658 /* prepare limits for color transformation (each channel is handled separately) */
1660 if (shade > 100) 1659 if (shade > 100)
1661 { 1660 {
1662 shade = 200 - shade; 1661 shade = 200 - shade;
1663 1662
1664 lower_lim_r = 65535-rm; 1663 high.r = (65535 - c.r) * shade / 100;
1665 lower_lim_g = 65535-gm; 1664 high.g = (65535 - c.g) * shade / 100;
1666 lower_lim_b = 65535-bm; 1665 high.b = (65535 - c.b) * shade / 100;
1667 1666
1668 lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100); 1667 low.r = 65535 - high.r;
1669 lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100); 1668 low.g = 65535 - high.g;
1670 lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100); 1669 low.b = 65535 - high.b;
1671
1672 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1673 } 1670 }
1674 else 1671 else
1675 { 1672 {
1673 high.r = c.r * shade / 100;
1674 high.g = c.g * shade / 100;
1675 high.b = c.b * shade / 100;
1676 1676
1677 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1677 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 } 1678 }
1683 1679
1684 /* fill our lookup tables */ 1680 /* fill our lookup tables */
1685 for (i = 0; i <= mask_r>>sh_r; i++) 1681 for (i = 0; i <= mask_r>>sh_r; i++)
1686 { 1682 {
1687 uint32_t tmp; 1683 uint32_t tmp;
1688 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r)); 1684 tmp = i * high.r;
1689 tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r); 1685 tmp += (mask_r>>sh_r) * low.r;
1690 lookup_r[i] = (tmp/65535)<<sh_r; 1686 lookup_r[i] = (tmp/65535)<<sh_r;
1691 } 1687 }
1692 for (i = 0; i <= mask_g>>sh_g; i++) 1688 for (i = 0; i <= mask_g>>sh_g; i++)
1693 { 1689 {
1694 uint32_t tmp; 1690 uint32_t tmp;
1695 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g)); 1691 tmp = i * high.g;
1696 tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g); 1692 tmp += (mask_g>>sh_g) * low.g;
1697 lookup_g[i] = (tmp/65535)<<sh_g; 1693 lookup_g[i] = (tmp/65535)<<sh_g;
1698 } 1694 }
1699 for (i = 0; i <= mask_b>>sh_b; i++) 1695 for (i = 0; i <= mask_b>>sh_b; i++)
1700 { 1696 {
1701 uint32_t tmp; 1697 uint32_t tmp;
1702 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b)); 1698 tmp = i * high.b;
1703 tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b); 1699 tmp += (mask_b>>sh_b) * low.b;
1704 lookup_b[i] = (tmp/65535)<<sh_b; 1700 lookup_b[i] = (tmp/65535)<<sh_b;
1705 } 1701 }
1706 1702
1707 /* apply table to input image (replacing colors by newly calculated ones) */ 1703 /* apply table to input image (replacing colors by newly calculated ones) */
1708 if (srcImage->bits_per_pixel == 32 1704 if (srcImage->bits_per_pixel == 32

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines