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.93 by sf-exg, Tue Oct 19 14:44:30 2010 UTC vs.
Revision 1.98 by sf-exg, Sat Oct 30 10:57:52 2010 UTC

428 { 428 {
429 flags = new_flags; 429 flags = new_flags;
430 changed++; 430 changed++;
431 } 431 }
432 432
433 //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
434 // flags, h_scale, v_scale, h_align, v_align);
435 return (changed > 0); 433 return (changed > 0);
436} 434}
437 435
438void 436void
439bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) 437bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y)
529 527
530 int x = 0; 528 int x = 0;
531 int y = 0; 529 int y = 0;
532 int w = 0; 530 int w = 0;
533 int h = 0; 531 int h = 0;
534
535 TIMING_TEST_START (asim);
536 532
537 if (original_asim) 533 if (original_asim)
538 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); 534 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y);
539 535
540 if (!original_asim 536 if (!original_asim
657 } 653 }
658 654
659 free (layers); 655 free (layers);
660 } 656 }
661 } 657 }
662 TIMING_TEST_PRINT_RESULT (asim);
663 658
664 bool ret = false; 659 bool ret = false;
665 660
666 if (result) 661 if (result)
667 { 662 {
713 708
714 if (result != background && result != original_asim) 709 if (result != background && result != original_asim)
715 destroy_asimage (&result); 710 destroy_asimage (&result);
716 711
717 XFreeGC (target->dpy, gc); 712 XFreeGC (target->dpy, gc);
718 TIMING_TEST_PRINT_RESULT (asim);
719 713
720 ret = true; 714 ret = true;
721 } 715 }
722 716
723 if (background) 717 if (background)
1283 } 1277 }
1284 1278
1285 XRenderFreePicture (dpy, mask_pic); 1279 XRenderFreePicture (dpy, mask_pic);
1286 XRenderFreePicture (dpy, overlay_pic); 1280 XRenderFreePicture (dpy, overlay_pic);
1287 XRenderFreePicture (dpy, back_pic); 1281 XRenderFreePicture (dpy, back_pic);
1288# if DO_TIMING_TEST
1289 XSync (dpy, False);
1290# endif
1291# endif 1282# endif
1292 } 1283 }
1293 1284
1294 return ret; 1285 return ret;
1295} 1286}
1320 int window_height = target->szHint.height; 1311 int window_height = target->szHint.height;
1321 int sx, sy; 1312 int sx, sy;
1322 XGCValues gcv; 1313 XGCValues gcv;
1323 GC gc; 1314 GC gc;
1324 1315
1325 TIMING_TEST_START (tp);
1326 target->get_window_origin (sx, sy); 1316 target->get_window_origin (sx, sy);
1327 1317
1328 /* check if we are outside of the visible part of the virtual screen : */ 1318 /* check if we are outside of the visible part of the virtual screen : */
1329 if (sx + window_width <= 0 || sy + window_height <= 0 1319 if (sx + window_width <= 0 || sy + window_height <= 0
1330 || sx >= root_width || sy >= root_height) 1320 || sx >= root_width || sy >= root_height)
1367 { 1357 {
1368 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1358 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1369 result |= transpPmapTiled; 1359 result |= transpPmapTiled;
1370 XFreeGC (dpy, gc); 1360 XFreeGC (dpy, gc);
1371 } 1361 }
1372 TIMING_TEST_PRINT_RESULT (tp);
1373 1362
1374 if (tiled_root_pmap != None) 1363 if (tiled_root_pmap != None)
1375 { 1364 {
1376 if (!need_client_side_rendering ()) 1365 if (!need_client_side_rendering ())
1377 { 1366 {
1394 pmap_width = window_width; 1383 pmap_width = window_width;
1395 pmap_height = window_height; 1384 pmap_height = window_height;
1396 pmap_depth = root_depth; 1385 pmap_depth = root_depth;
1397 } 1386 }
1398 1387
1399 TIMING_TEST_PRINT_RESULT (tp);
1400
1401 return result; 1388 return result;
1402} 1389}
1403 1390
1404bool 1391void
1405bgPixmap_t::set_root_pixmap () 1392bgPixmap_t::set_root_pixmap ()
1406{ 1393{
1407 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1394 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1408 if (new_root_pixmap == None) 1395 if (new_root_pixmap == None)
1409 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1396 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1410 1397
1411 if (new_root_pixmap != root_pixmap)
1412 {
1413 root_pixmap = new_root_pixmap; 1398 root_pixmap = new_root_pixmap;
1414 return true;
1415 }
1416
1417 return false;
1418} 1399}
1419# endif /* ENABLE_TRANSPARENCY */ 1400# endif /* ENABLE_TRANSPARENCY */
1420 1401
1421# ifndef HAVE_AFTERIMAGE 1402# ifndef HAVE_AFTERIMAGE
1422static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1403static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm);
1427{ 1408{
1428 unsigned long background_flags = 0; 1409 unsigned long background_flags = 0;
1429 1410
1430 if (target == NULL) 1411 if (target == NULL)
1431 return false; 1412 return false;
1432
1433 TIMING_TEST_START (tp);
1434 1413
1435 invalidate (); 1414 invalidate ();
1436# ifdef ENABLE_TRANSPARENCY 1415# ifdef ENABLE_TRANSPARENCY
1437 if (flags & isTransparent) 1416 if (flags & isTransparent)
1438 { 1417 {
1527 } 1506 }
1528 } 1507 }
1529 1508
1530 apply (); 1509 apply ();
1531 1510
1532 XSync (target->dpy, False);
1533 valid_since = ev::now (); 1511 valid_since = ev::now ();
1534
1535 TIMING_TEST_PRINT_RESULT (tp);
1536 1512
1537 return true; 1513 return true;
1538} 1514}
1539 1515
1540bool 1516bool
1556void 1532void
1557bgPixmap_t::apply () 1533bgPixmap_t::apply ()
1558{ 1534{
1559 if (target) 1535 if (target)
1560 { 1536 {
1561 flags &= ~isVtOrigin;
1562
1563 if (pixmap != None) 1537 if (pixmap != None)
1564 { 1538 {
1565 /* set target's background to pixmap */ 1539 /* set target's background to pixmap */
1566# ifdef ENABLE_TRANSPARENCY 1540# ifdef ENABLE_TRANSPARENCY
1567 if (flags & isTransparent) 1541 if (flags & isTransparent)
1573 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); 1547 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative);
1574 } 1548 }
1575 else 1549 else
1576# endif 1550# endif
1577 { 1551 {
1578 flags |= isVtOrigin;
1579 /* force old pixmap dereference in case it was transparent before :*/ 1552 /* force old pixmap dereference in case it was transparent before :*/
1580 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1553 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1581 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); 1554 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap);
1582 /* do we also need to set scrollbar's background here ? */ 1555 /* do we also need to set scrollbar's background here ? */
1583 1556
1613#endif /* HAVE_BG_PIXMAP */ 1586#endif /* HAVE_BG_PIXMAP */
1614 1587
1615#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT 1588#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT
1616/* taken from aterm-0.4.2 */ 1589/* taken from aterm-0.4.2 */
1617 1590
1618typedef uint32_t RUINT32T;
1619
1620static void 1591static void
1621ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) 1592ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm)
1622{ 1593{
1623 int sh_r, sh_g, sh_b; 1594 int sh_r, sh_g, sh_b;
1624 RUINT32T mask_r, mask_g, mask_b; 1595 uint32_t mask_r, mask_g, mask_b;
1625 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; 1596 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1626 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1597 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
1627 unsigned int upper_lim_r, upper_lim_g, upper_lim_b; 1598 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
1628 int i; 1599 int i;
1629 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; 1600 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst;
1630 1601
1641 case 15: 1612 case 15:
1642 if ((mask_r != 0x7c00) || 1613 if ((mask_r != 0x7c00) ||
1643 (mask_g != 0x03e0) || 1614 (mask_g != 0x03e0) ||
1644 (mask_b != 0x001f)) 1615 (mask_b != 0x001f))
1645 return; 1616 return;
1646 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); 1617 lookup = (uint32_t *) malloc (sizeof (uint32_t)*(32+32+32));
1647 lookup_r = lookup; 1618 lookup_r = lookup;
1648 lookup_g = lookup+32; 1619 lookup_g = lookup+32;
1649 lookup_b = lookup+32+32; 1620 lookup_b = lookup+32+32;
1650 sh_r = 10; 1621 sh_r = 10;
1651 sh_g = 5; 1622 sh_g = 5;
1654 case 16: 1625 case 16:
1655 if ((mask_r != 0xf800) || 1626 if ((mask_r != 0xf800) ||
1656 (mask_g != 0x07e0) || 1627 (mask_g != 0x07e0) ||
1657 (mask_b != 0x001f)) 1628 (mask_b != 0x001f))
1658 return; 1629 return;
1659 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); 1630 lookup = (uint32_t *) malloc (sizeof (uint32_t)*(32+64+32));
1660 lookup_r = lookup; 1631 lookup_r = lookup;
1661 lookup_g = lookup+32; 1632 lookup_g = lookup+32;
1662 lookup_b = lookup+32+64; 1633 lookup_b = lookup+32+64;
1663 sh_r = 11; 1634 sh_r = 11;
1664 sh_g = 5; 1635 sh_g = 5;
1667 case 24: 1638 case 24:
1668 if ((mask_r != 0xff0000) || 1639 if ((mask_r != 0xff0000) ||
1669 (mask_g != 0x00ff00) || 1640 (mask_g != 0x00ff00) ||
1670 (mask_b != 0x0000ff)) 1641 (mask_b != 0x0000ff))
1671 return; 1642 return;
1672 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); 1643 lookup = (uint32_t *) malloc (sizeof (uint32_t)*(256+256+256));
1673 lookup_r = lookup; 1644 lookup_r = lookup;
1674 lookup_g = lookup+256; 1645 lookup_g = lookup+256;
1675 lookup_b = lookup+256+256; 1646 lookup_b = lookup+256+256;
1676 sh_r = 16; 1647 sh_r = 16;
1677 sh_g = 8; 1648 sh_g = 8;
1680 case 32: 1651 case 32:
1681 if ((mask_r != 0xff0000) || 1652 if ((mask_r != 0xff0000) ||
1682 (mask_g != 0x00ff00) || 1653 (mask_g != 0x00ff00) ||
1683 (mask_b != 0x0000ff)) 1654 (mask_b != 0x0000ff))
1684 return; 1655 return;
1685 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); 1656 lookup = (uint32_t *) malloc (sizeof (uint32_t)*(256+256+256));
1686 lookup_r = lookup; 1657 lookup_r = lookup;
1687 lookup_g = lookup+256; 1658 lookup_g = lookup+256;
1688 lookup_b = lookup+256+256; 1659 lookup_b = lookup+256+256;
1689 sh_r = 16; 1660 sh_r = 16;
1690 sh_g = 8; 1661 sh_g = 8;
1701 1672
1702 lower_lim_r = 65535-rm; 1673 lower_lim_r = 65535-rm;
1703 lower_lim_g = 65535-gm; 1674 lower_lim_g = 65535-gm;
1704 lower_lim_b = 65535-bm; 1675 lower_lim_b = 65535-bm;
1705 1676
1706 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); 1677 lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100);
1707 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); 1678 lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100);
1708 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); 1679 lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100);
1709 1680
1710 upper_lim_r = upper_lim_g = upper_lim_b = 65535; 1681 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1711 } 1682 }
1712 else 1683 else
1713 { 1684 {
1714 1685
1715 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1686 lower_lim_r = lower_lim_g = lower_lim_b = 0;
1716 1687
1717 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); 1688 upper_lim_r = (unsigned int)((((uint32_t)rm)*((uint32_t)shade))/100);
1718 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); 1689 upper_lim_g = (unsigned int)((((uint32_t)gm)*((uint32_t)shade))/100);
1719 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); 1690 upper_lim_b = (unsigned int)((((uint32_t)bm)*((uint32_t)shade))/100);
1720 } 1691 }
1721 1692
1722 /* fill our lookup tables */ 1693 /* fill our lookup tables */
1723 for (i = 0; i <= mask_r>>sh_r; i++) 1694 for (i = 0; i <= mask_r>>sh_r; i++)
1724 { 1695 {
1725 RUINT32T tmp; 1696 uint32_t tmp;
1726 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); 1697 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r));
1727 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); 1698 tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r);
1728 lookup_r[i] = (tmp/65535)<<sh_r; 1699 lookup_r[i] = (tmp/65535)<<sh_r;
1729 } 1700 }
1730 for (i = 0; i <= mask_g>>sh_g; i++) 1701 for (i = 0; i <= mask_g>>sh_g; i++)
1731 { 1702 {
1732 RUINT32T tmp; 1703 uint32_t tmp;
1733 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); 1704 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g));
1734 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); 1705 tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g);
1735 lookup_g[i] = (tmp/65535)<<sh_g; 1706 lookup_g[i] = (tmp/65535)<<sh_g;
1736 } 1707 }
1737 for (i = 0; i <= mask_b>>sh_b; i++) 1708 for (i = 0; i <= mask_b>>sh_b; i++)
1738 { 1709 {
1739 RUINT32T tmp; 1710 uint32_t tmp;
1740 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); 1711 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b));
1741 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); 1712 tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b);
1742 lookup_b[i] = (tmp/65535)<<sh_b; 1713 lookup_b[i] = (tmp/65535)<<sh_b;
1743 } 1714 }
1744 1715
1745 /* apply table to input image (replacing colors by newly calculated ones) */ 1716 /* apply table to input image (replacing colors by newly calculated ones) */
1746 if (srcImage->bits_per_pixel == 32 1717 if (srcImage->bits_per_pixel == 32
1747 && (srcImage->depth == 24 || srcImage->depth == 32) 1718 && (srcImage->depth == 24 || srcImage->depth == 32)
1748 && srcImage->byte_order == host_byte_order) 1719 && srcImage->byte_order == host_byte_order)
1749 { 1720 {
1750 RUINT32T *p1, *pf, *p, *pl; 1721 uint32_t *p1, *pf, *p, *pl;
1751 p1 = (RUINT32T *) srcImage->data; 1722 p1 = (uint32_t *) srcImage->data;
1752 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); 1723 pf = (uint32_t *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1753 1724
1754 while (p1 < pf) 1725 while (p1 < pf)
1755 { 1726 {
1756 p = p1; 1727 p = p1;
1757 pl = p1 + srcImage->width; 1728 pl = p1 + srcImage->width;
1760 *p = lookup_r[(*p & 0xff0000) >> 16] | 1731 *p = lookup_r[(*p & 0xff0000) >> 16] |
1761 lookup_g[(*p & 0x00ff00) >> 8] | 1732 lookup_g[(*p & 0x00ff00) >> 8] |
1762 lookup_b[(*p & 0x0000ff)] | 1733 lookup_b[(*p & 0x0000ff)] |
1763 (*p & 0xff000000); 1734 (*p & 0xff000000);
1764 } 1735 }
1765 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); 1736 p1 = (uint32_t *) ((char *) p1 + srcImage->bytes_per_line);
1766 } 1737 }
1767 } 1738 }
1768 else 1739 else
1769 { 1740 {
1770 for (int y = 0; y < srcImage->height; y++) 1741 for (int y = 0; y < srcImage->height; y++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines