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
This commit is contained in:
parent
7eafab7304
commit
a55dee3bd3
7 changed files with 24 additions and 6 deletions
|
@ -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;
|
||||
|
|
1
scene.h
1
scene.h
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue