Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/standalone/glxbackend.cpp
Show All 35 Lines | |||||
36 | #include "xcbutils.h" | 36 | #include "xcbutils.h" | ||
37 | #include "texture.h" | 37 | #include "texture.h" | ||
38 | // kwin libs | 38 | // kwin libs | ||
39 | #include <kwinglplatform.h> | 39 | #include <kwinglplatform.h> | ||
40 | #include <kwinglutils.h> | 40 | #include <kwinglutils.h> | ||
41 | #include <kwineffectquickview.h> | 41 | #include <kwineffectquickview.h> | ||
42 | #include <kwinxrenderutils.h> | 42 | #include <kwinxrenderutils.h> | ||
43 | // Qt | 43 | // Qt | ||
44 | #include <QDebug> | | |||
45 | #include <QOpenGLContext> | 44 | #include <QOpenGLContext> | ||
46 | #include <QX11Info> | 45 | #include <QX11Info> | ||
47 | #include <QtPlatformHeaders/QGLXNativeContext> | 46 | #include <QtPlatformHeaders/QGLXNativeContext> | ||
48 | // system | 47 | // system | ||
49 | #include <unistd.h> | 48 | #include <unistd.h> | ||
50 | 49 | | |||
51 | #include <deque> | 50 | #include <deque> | ||
52 | #include <algorithm> | 51 | #include <algorithm> | ||
▲ Show 20 Lines • Show All 607 Lines • ▼ Show 20 Line(s) | |||||
660 | 659 | | |||
661 | void GlxBackend::present() | 660 | void GlxBackend::present() | ||
662 | { | 661 | { | ||
663 | if (lastDamage().isEmpty()) | 662 | if (lastDamage().isEmpty()) | ||
664 | return; | 663 | return; | ||
665 | 664 | | |||
666 | const QSize &screenSize = screens()->size(); | 665 | const QSize &screenSize = screens()->size(); | ||
667 | const QRegion displayRegion(0, 0, screenSize.width(), screenSize.height()); | 666 | const QRegion displayRegion(0, 0, screenSize.width(), screenSize.height()); | ||
668 | const bool fullRepaint = supportsBufferAge() || (lastDamage() == displayRegion); | 667 | const bool canSwapBuffers = supportsBufferAge() || (lastDamage() == displayRegion); | ||
668 | m_needsCompositeTimerStart = true; | ||||
669 | 669 | | |||
670 | if (fullRepaint) { | 670 | if (canSwapBuffers) { | ||
671 | if (hasSwapEvent()) { | 671 | if (supportsSwapEvents()) { | ||
672 | m_needsCompositeTimerStart = false; | ||||
672 | Compositor::self()->aboutToSwapBuffers(); | 673 | Compositor::self()->aboutToSwapBuffers(); | ||
673 | } | 674 | } | ||
674 | 675 | | |||
675 | glXSwapBuffers(display(), glxWindow); | 676 | glXSwapBuffers(display(), glxWindow); | ||
676 | 677 | | |||
677 | if (supportsBufferAge()) { | 678 | if (supportsBufferAge()) { | ||
678 | glXQueryDrawable(display(), glxWindow, GLX_BACK_BUFFER_AGE_EXT, (GLuint *) &m_bufferAge); | 679 | glXQueryDrawable(display(), glxWindow, GLX_BACK_BUFFER_AGE_EXT, (GLuint *) &m_bufferAge); | ||
679 | } | 680 | } | ||
680 | } else if (m_haveMESACopySubBuffer) { | 681 | } else if (m_haveMESACopySubBuffer) { | ||
681 | for (const QRect &r : lastDamage()) { | 682 | for (const QRect &r : lastDamage()) { | ||
682 | // convert to OpenGL coordinates | 683 | // convert to OpenGL coordinates | ||
683 | int y = screenSize.height() - r.y() - r.height(); | 684 | int y = screenSize.height() - r.y() - r.height(); | ||
684 | glXCopySubBufferMESA(display(), glxWindow, r.x(), y, r.width(), r.height()); | 685 | glXCopySubBufferMESA(display(), glxWindow, r.x(), y, r.width(), r.height()); | ||
685 | } | 686 | } | ||
686 | } else { // Copy Pixels (horribly slow on Mesa) | 687 | } else { | ||
688 | // Copy Pixels (horribly slow on Mesa). | ||||
687 | glDrawBuffer(GL_FRONT); | 689 | glDrawBuffer(GL_FRONT); | ||
688 | copyPixels(lastDamage()); | 690 | copyPixels(lastDamage()); | ||
689 | glDrawBuffer(GL_BACK); | 691 | glDrawBuffer(GL_BACK); | ||
690 | } | 692 | } | ||
691 | 693 | | |||
692 | setLastDamage(QRegion()); | 694 | setLastDamage(QRegion()); | ||
693 | if (!supportsBufferAge()) { | 695 | if (!supportsBufferAge()) { | ||
694 | glXWaitGL(); | 696 | glXWaitGL(); | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 779 | { | |||
778 | return m_overlayWindow; | 780 | return m_overlayWindow; | ||
779 | } | 781 | } | ||
780 | 782 | | |||
781 | bool GlxBackend::usesOverlayWindow() const | 783 | bool GlxBackend::usesOverlayWindow() const | ||
782 | { | 784 | { | ||
783 | return true; | 785 | return true; | ||
784 | } | 786 | } | ||
785 | 787 | | |||
786 | bool GlxBackend::hasSwapEvent() const | 788 | bool GlxBackend::supportsSwapEvents() const | ||
787 | { | 789 | { | ||
788 | return m_swapEventFilter != nullptr; | 790 | return m_swapEventFilter != nullptr; | ||
789 | } | 791 | } | ||
790 | 792 | | |||
793 | bool GlxBackend::hasSwapEvent() const | ||||
794 | { | ||||
795 | return !m_needsCompositeTimerStart; | ||||
796 | } | ||||
797 | | ||||
791 | /******************************************************** | 798 | /******************************************************** | ||
792 | * GlxTexture | 799 | * GlxTexture | ||
793 | *******************************************************/ | 800 | *******************************************************/ | ||
794 | GlxTexture::GlxTexture(SceneOpenGLTexture *texture, GlxBackend *backend) | 801 | GlxTexture::GlxTexture(SceneOpenGLTexture *texture, GlxBackend *backend) | ||
795 | : SceneOpenGLTexturePrivate() | 802 | : SceneOpenGLTexturePrivate() | ||
796 | , q(texture) | 803 | , q(texture) | ||
797 | , m_backend(backend) | 804 | , m_backend(backend) | ||
798 | , m_glxpixmap(None) | 805 | , m_glxpixmap(None) | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |