Changeset 561 for trunk/src/opengl/qgl_x11.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/opengl/qgl_x11.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtOpenGL module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 53 53 #include <private/qfontengine_ft_p.h> 54 54 #include <private/qt_x11_p.h> 55 56 55 57 #ifdef Q_OS_HPUX 56 58 // for GLXPBuffer 57 59 #include <private/qglpixelbuffer_p.h> 58 60 #endif 61 62 63 64 59 65 60 66 #define INT8 dummy_INT8 … … 63 69 #undef INT8 64 70 #undef INT32 71 65 72 #include <X11/Xlib.h> 66 73 #include <X11/Xutil.h> 67 74 #include <X11/Xos.h> 75 76 77 78 79 80 81 82 68 83 #include <X11/Xatom.h> 69 84 … … 80 95 #define GLX_SAMPLE_BUFFERS_ARB 100000 81 96 #define GLX_SAMPLES_ARB 100001 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 82 116 #endif 83 117 … … 130 164 GLCMapHash *qglcmap_hash; 131 165 }; 132 Q_GLOBAL_STATIC(QGLCMapCleanupHandler, cmap_handler) ;166 Q_GLOBAL_STATIC(QGLCMapCleanupHandler, cmap_handler) 133 167 134 168 static void cleanup_cmaps() … … 298 332 QGLFormat UNIX/GLX-specific code 299 333 *****************************************************************************/ 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 300 390 301 391 bool QGLFormat::hasOpenGL() … … 434 524 return false; 435 525 } 436 Q String glxExt = QString(QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)));437 if ( glxExt.contains(QLatin1String("GLX_SGI_video_sync"))) {526 Q))); 527 if ()) { 438 528 if (d->glFormat.swapInterval() == -1) 439 529 d->glFormat.setSwapInterval(0); … … 444 534 } 445 535 446 447 /*! 448 \bold{X11 only:} This virtual function tries to find a 449 visual that matches the format, reducing the demands if the original 450 request cannot be met. 451 452 The algorithm for reducing the demands of the format is quite 453 simple-minded, so override this method in your subclass if your 454 application has spcific requirements on visual selection. 455 456 \sa chooseContext() 457 */ 458 536 /* 537 See qgl.cpp for qdoc comment. 538 */ 459 539 void *QGLContext::chooseVisual() 460 540 { … … 520 600 } 521 601 522 523 /*! 524 \internal 525 526 \bold{X11 only:} This virtual function chooses a visual 527 that matches the OpenGL \link format() format\endlink. Reimplement this 528 function in a subclass if you need a custom visual. 529 530 \sa chooseContext() 531 */ 532 602 /* 603 See qgl.cpp for qdoc comment. 604 */ 533 605 void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) 534 606 { 535 607 Q_D(QGLContext); 536 int spec[4 0];608 int spec[4]; 537 609 int i = 0; 538 610 spec[i++] = GLX_LEVEL; 539 611 spec[i++] = f.plane(); 540 612 const QX11Info *xinfo = qt_x11Info(d->paintDevice); 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 541 628 542 629 #if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info) … … 544 631 static bool useTranspExtChecked = false; 545 632 if (f.plane() && !useTranspExtChecked && d->paintDevice) { 546 Q ByteArray estr(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));547 useTranspExt = e str.contains("GLX_EXT_visual_info");633 Q(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); 634 useTranspExt = e("GLX_EXT_visual_info"); 548 635 //# (A bit simplistic; that could theoretically be a substring) 549 636 if (useTranspExt) { … … 566 653 useTranspExtChecked = true; 567 654 } 568 if (f.plane() && useTranspExt ) {655 if (f.plane() && useTranspExt) { 569 656 // Required to avoid non-transparent overlay visual(!) on some systems 570 657 spec[i++] = GLX_TRANSPARENT_TYPE_EXT; … … 573 660 #endif 574 661 662 663 664 665 666 667 668 669 575 670 if (f.doubleBuffer()) 576 671 spec[i++] = GLX_DOUBLEBUFFER; 672 673 577 674 if (f.depth()) { 578 675 spec[i++] = GLX_DEPTH_SIZE; … … 581 678 if (f.stereo()) { 582 679 spec[i++] = GLX_STEREO; 680 681 583 682 } 584 683 if (f.stencil()) { … … 587 686 } 588 687 if (f.rgba()) { 589 spec[i++] = GLX_RGBA; 688 if (!useFBConfig) 689 spec[i++] = GLX_RGBA; 590 690 spec[i++] = GLX_RED_SIZE; 591 691 spec[i++] = f.redBufferSize() == -1 ? 1 : f.redBufferSize(); … … 622 722 } 623 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 624 744 spec[i] = XNone; 625 return glXChooseVisual(xinfo->display(), xinfo->screen(), spec); 745 746 747 XVisualInfo* chosenVisualInfo = 0; 748 749 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) 750 while (useFBConfig) { 751 GLXFBConfig *configs; 752 int configCount = 0; 753 configs = glXChooseFBConfig(xinfo->display(), xinfo->screen(), spec, &configCount); 754 755 if (!configs) 756 break; // fallback to trying glXChooseVisual 757 758 for (i = 0; i < configCount; ++i) { 759 XVisualInfo* vi; 760 vi = glXGetVisualFromFBConfig(xinfo->display(), configs[i]); 761 if (!vi) 762 continue; 763 764 #if !defined(QT_NO_XRENDER) 765 QWidget* w = 0; 766 if (d->paintDevice->devType() == QInternal::Widget) 767 w = static_cast<QWidget*>(d->paintDevice); 768 769 if (w && w->testAttribute(Qt::WA_TranslucentBackground) && f.alpha()) { 770 // Attempt to find a config who's visual has a proper alpha channel 771 XRenderPictFormat *pictFormat; 772 pictFormat = XRenderFindVisualFormat(xinfo->display(), vi->visual); 773 774 if (pictFormat && (pictFormat->type == PictTypeDirect) && pictFormat->direct.alphaMask) { 775 // The pict format for the visual matching the FBConfig indicates ARGB 776 if (chosenVisualInfo) 777 XFree(chosenVisualInfo); 778 chosenVisualInfo = vi; 779 break; 780 } 781 } else 782 #endif //QT_NO_XRENDER 783 if (chosenVisualInfo) { 784 // If we've got a visual we can use and we're not trying to find one with a 785 // real alpha channel, we might as well just use the one we've got 786 break; 787 } 788 789 if (!chosenVisualInfo) 790 chosenVisualInfo = vi; // Have something to fall back to 791 else 792 XFree(vi); 793 } 794 795 XFree(configs); 796 break; 797 } 798 #endif // defined(GLX_VERSION_1_3) 799 800 if (!chosenVisualInfo) 801 chosenVisualInfo = glXChooseVisual(xinfo->display(), xinfo->screen(), spec); 802 803 return chosenVisualInfo; 626 804 } 627 805 … … 671 849 qWarning("QGLContext::makeCurrent(): Failed."); 672 850 673 if (ok) { 674 if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) 675 qgl_context_storage.setLocalData(new QGLThreadContext); 676 if (qgl_context_storage.hasLocalData()) 677 qgl_context_storage.localData()->context = this; 678 currentCtx = this; 679 } 851 if (ok) 852 QGLContextPrivate::setCurrentContext(this); 680 853 } 681 854 … … 684 857 Q_D(QGLContext); 685 858 glXMakeCurrent(qt_x11Info(d->paintDevice)->display(), 0, 0); 686 if (qgl_context_storage.hasLocalData()) 687 qgl_context_storage.localData()->context = 0; 688 currentCtx = 0; 859 QGLContextPrivate::setCurrentContext(0); 689 860 } 690 861 … … 704 875 static bool resolved = false; 705 876 if (!resolved) { 706 QString glxExt = QString(QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS))); 707 if (glxExt.contains(QLatin1String("GLX_SGI_video_sync"))) { 708 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) 709 void *handle = dlopen(NULL, RTLD_LAZY); 710 if (handle) { 711 glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI) dlsym(handle, "glXGetVideoSyncSGI"); 712 glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI) dlsym(handle, "glXWaitVideoSyncSGI"); 713 dlclose(handle); 714 } 715 if (!glXGetVideoSyncSGI) 716 #endif 717 { 718 extern const QString qt_gl_library_name(); 719 QLibrary lib(qt_gl_library_name()); 720 glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI) lib.resolve("glXGetVideoSyncSGI"); 721 glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI) lib.resolve("glXWaitVideoSyncSGI"); 722 } 877 const QX11Info *xinfo = qt_x11Info(d->paintDevice); 878 QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); 879 if (extensions.match("GLX_SGI_video_sync")) { 880 glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI"); 881 glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI"); 723 882 } 724 883 resolved = true; … … 949 1108 return 0; 950 1109 if (!glXGetProcAddressARB) { 951 Q String glxExt = QString(QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)));952 if ( glxExt.contains(QLatin1String("GLX_ARB_get_proc_address"))) {1110 Q)); 1111 if ()) { 953 1112 #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) 954 1113 void *handle = dlopen(NULL, RTLD_LAZY); … … 960 1119 #endif 961 1120 { 1121 962 1122 extern const QString qt_gl_library_name(); 963 1123 QLibrary lib(qt_gl_library_name()); 964 1124 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); 1125 965 1126 } 966 1127 } … … 1184 1345 d->glcx = context; 1185 1346 1186 1187 1347 if (parentWidget()) { 1188 1348 // force creation of delay-created widgets … … 1191 1351 d_func()->xinfo = parentWidget()->d_func()->xinfo; 1192 1352 } 1353 1354 1355 1356 1357 1358 1193 1359 1194 1360 bool createFailed = false; … … 1423 1589 } 1424 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1425 1757 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.