From 838d7e7a14e32f29f22e32b26aae02ed347ffbf5 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 26 Oct 2020 10:02:17 +0200 Subject: [PATCH] Mark the cursor as rendered after performing compositing If a cursor animation is driven purely by frame callbacks and kwin uses hardware cursors, the cpu usage may spike to 100%. This change addresses that issue by sending frame callbacks after a compositing cycle has been performed. (cherry picked from commit 9b09f0399fee4e46fe9cbc4291434e4908b170cf) --- composite.cpp | 3 +++ plugins/platforms/drm/drm_backend.cpp | 2 -- plugins/platforms/x11/windowed/x11windowed_backend.cpp | 1 - plugins/scenes/opengl/scene_opengl.cpp | 3 --- plugins/scenes/qpainter/scene_qpainter.cpp | 1 - 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/composite.cpp b/composite.cpp index 6d00e948f7..9a261b4964 100644 --- a/composite.cpp +++ b/composite.cpp @@ -705,6 +705,9 @@ void Compositor::performCompositing() surface->frameRendered(currentTime); } } + if (!kwinApp()->platform()->isCursorHidden()) { + Cursors::self()->currentCursor()->markAsRendered(); + } } // Stop here to ensure *we* cause the next repaint schedule - not some effect diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp index d6a282beb7..03902bee22 100644 --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -680,8 +680,6 @@ void DrmBackend::setCursor() } } } - - Cursors::self()->currentCursor()->markAsRendered(); } void DrmBackend::updateCursor() diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp index 267bdd271b..9b24c03d26 100644 --- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp @@ -481,7 +481,6 @@ void X11WindowedBackend::createCursor(const QImage &srcImage, const QPoint &hots } m_cursor = cid; xcb_flush(m_connection); - Cursors::self()->currentCursor()->markAsRendered(); } xcb_window_t X11WindowedBackend::rootWindow() const diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp index 7916a42e34..63cb8260be 100644 --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -601,9 +601,6 @@ void SceneOpenGL2::paintCursor() binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); m_cursorTexture->render(QRegion(cursorRect), cursorRect); m_cursorTexture->unbind(); - - cursor->markAsRendered(); - glDisable(GL_BLEND); } diff --git a/plugins/scenes/qpainter/scene_qpainter.cpp b/plugins/scenes/qpainter/scene_qpainter.cpp index 9bc4d4e289..8e680f3c66 100644 --- a/plugins/scenes/qpainter/scene_qpainter.cpp +++ b/plugins/scenes/qpainter/scene_qpainter.cpp @@ -163,7 +163,6 @@ void SceneQPainter::paintCursor() const QPoint cursorPos = cursor->pos(); const QPoint hotspot = cursor->hotspot(); m_painter->drawImage(cursorPos - hotspot, img); - cursor->markAsRendered(); } void SceneQPainter::paintEffectQuickView(EffectQuickView *w)