From d1b537b58719bc4c7dd1b9e2990bcc4741d063cc Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sun, 4 Apr 2021 14:45:44 +0300 Subject: [PATCH] Move insertion of safety points to X11Compositor Safety points only work on X11. On Wayland, we gain nothing from them. --- src/composite.cpp | 35 +++++++++++++++++------------------ src/composite.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/composite.cpp b/src/composite.cpp index cea6a01407..6a90da11f2 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -145,9 +145,6 @@ Compositor::Compositor(QObject* workspace) }, Qt::QueuedConnection ); - if (qEnvironmentVariableIsSet("KWIN_MAX_FRAMES_TESTED")) - m_framesToTestForSafety = qEnvironmentVariableIntValue("KWIN_MAX_FRAMES_TESTED"); - // register DBus new CompositorDBusInterface(this); FTraceLogger::create(); @@ -629,26 +626,11 @@ void Compositor::composite(RenderLoop *renderLoop) } } - if (m_framesToTestForSafety > 0 && (m_scene->compositingType() & OpenGLCompositing)) { - kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PreFrame); - } - const QRegion repaints = m_scene->repaints(screenId); m_scene->resetRepaints(screenId); m_scene->paint(screenId, repaints, windows, renderLoop); - if (m_framesToTestForSafety > 0) { - if (m_scene->compositingType() & OpenGLCompositing) { - kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PostFrame); - } - m_framesToTestForSafety--; - if (m_framesToTestForSafety == 0 && (m_scene->compositingType() & OpenGLCompositing)) { - kwinApp()->platform()->createOpenGLSafePoint( - Platform::OpenGLSafePoint::PostLastGuardedFrame); - } - } - if (waylandServer()) { const std::chrono::milliseconds frameTime = std::chrono::duration_cast(renderLoop->lastPresentationTimestamp()); @@ -710,6 +692,9 @@ X11Compositor::X11Compositor(QObject *parent) : Compositor(parent) , m_suspended(options->isUseCompositing() ? NoReasonSuspend : UserSuspend) { + if (qEnvironmentVariableIsSet("KWIN_MAX_FRAMES_TESTED")) { + m_framesToTestForSafety = qEnvironmentVariableIntValue("KWIN_MAX_FRAMES_TESTED"); + } } void X11Compositor::toggleCompositing() @@ -822,7 +807,21 @@ void X11Compositor::composite(RenderLoop *renderLoop) item->waitForDamage(); } + if (m_framesToTestForSafety > 0 && (scene()->compositingType() & OpenGLCompositing)) { + kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PreFrame); + } + Compositor::composite(renderLoop); + + if (m_framesToTestForSafety > 0) { + if (scene()->compositingType() & OpenGLCompositing) { + kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PostFrame); + } + m_framesToTestForSafety--; + if (m_framesToTestForSafety == 0 && (scene()->compositingType() & OpenGLCompositing)) { + kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PostLastGuardedFrame); + } + } } bool X11Compositor::checkForOverlayWindow(WId w) const diff --git a/src/composite.h b/src/composite.h index 6484d051f0..f43a5254bc 100644 --- a/src/composite.h +++ b/src/composite.h @@ -140,7 +140,6 @@ private: QList m_unusedSupportProperties; QTimer m_unusedSupportPropertyTimer; Scene *m_scene; - int m_framesToTestForSafety = 3; QMap m_renderLoops; }; @@ -236,6 +235,7 @@ private: * Whether the Compositor is currently suspended, 8 bits encoding the reason */ SuspendReasons m_suspended; + int m_framesToTestForSafety = 3; }; }