Commit a55dee3b authored by Roman Gilg's avatar Roman Gilg
Browse files

Add hasSwapEvent getter

Summary:
Add a small getter to query information internally if the backend supports
swap events. Defaults to true as it is the default in the GBM Wayland backend.

Test Plan: i915

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T11071

Differential Revision: https://phabricator.kde.org/D25298
parent 7eafab73
......@@ -85,6 +85,7 @@ public:
virtual bool makeCurrent() = 0;
virtual void doneCurrent() = 0;
virtual bool usesOverlayWindow() const = 0;
virtual bool hasSwapEvent() const { return true; }
/**
* Whether the rendering needs to be split per screen.
* Default implementation returns @c false.
......
......@@ -206,11 +206,10 @@ void GlxBackend::init()
m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));
m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"));
m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control"));
// only enable Intel swap event if env variable is set, see BUG 342582
m_haveINTELSwapEvent = hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event"))
&& qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1");
if (m_haveINTELSwapEvent) {
// only enable Intel swap event if env variable is set, see BUG 342582
if (hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event")) &&
qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1")) {
m_swapEventFilter = std::make_unique<SwapEventFilter>(window, glxWindow);
glXSelectEvent(display(), glxWindow, GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK);
}
......@@ -668,8 +667,9 @@ void GlxBackend::present()
const bool fullRepaint = supportsBufferAge() || (lastDamage() == displayRegion);
if (fullRepaint) {
if (m_haveINTELSwapEvent)
if (hasSwapEvent()) {
Compositor::self()->aboutToSwapBuffers();
}
glXSwapBuffers(display(), glxWindow);
......@@ -782,6 +782,11 @@ bool GlxBackend::usesOverlayWindow() const
return true;
}
bool GlxBackend::hasSwapEvent() const
{
return m_swapEventFilter != nullptr;
}
/********************************************************
* GlxTexture
*******************************************************/
......
......@@ -77,6 +77,7 @@ public:
void doneCurrent() override;
OverlayWindow* overlayWindow() const override;
bool usesOverlayWindow() const override;
bool hasSwapEvent() const override;
void init() override;
protected:
......@@ -111,7 +112,6 @@ private:
bool m_haveMESACopySubBuffer = false;
bool m_haveMESASwapControl = false;
bool m_haveEXTSwapControl = false;
bool m_haveINTELSwapEvent = false;
Display *m_x11Display;
friend class GlxTexture;
};
......
......@@ -522,6 +522,11 @@ OverlayWindow *SceneOpenGL::overlayWindow() const
return m_backend->overlayWindow();
}
bool SceneOpenGL::hasSwapEvent() const
{
return m_backend->hasSwapEvent();
}
void SceneOpenGL::idle()
{
m_backend->idle();
......
......@@ -53,6 +53,7 @@ public:
void screenGeometryChanged(const QSize &size) override;
OverlayWindow *overlayWindow() const override;
bool usesOverlayWindow() const override;
bool hasSwapEvent() const override;
bool makeOpenGLContextCurrent() override;
void doneOpenGLContextCurrent() override;
Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override;
......
......@@ -629,6 +629,11 @@ void Scene::screenGeometryChanged(const QSize &size)
overlayWindow()->resize(size);
}
bool Scene::hasSwapEvent() const
{
return false;
}
bool Scene::makeOpenGLContextCurrent()
{
return false;
......
......@@ -146,6 +146,7 @@ public:
// there's nothing to paint (adjust time_diff later)
virtual void idle();
virtual OverlayWindow* overlayWindow() const = 0;
virtual bool hasSwapEvent() const;
virtual bool makeOpenGLContextCurrent();
virtual void doneOpenGLContextCurrent();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment