Move insertion of safety points to X11Compositor

Safety points only work on X11. On Wayland, we gain nothing from them.
This commit is contained in:
Vlad Zahorodnii 2021-04-04 14:45:44 +03:00
parent dcdca9be6a
commit d1b537b587
2 changed files with 18 additions and 19 deletions

View file

@ -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<std::chrono::milliseconds>(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

View file

@ -140,7 +140,6 @@ private:
QList<xcb_atom_t> m_unusedSupportProperties;
QTimer m_unusedSupportPropertyTimer;
Scene *m_scene;
int m_framesToTestForSafety = 3;
QMap<RenderLoop *, AbstractOutput *> 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;
};
}