From b23dfd55acdbeb9cb8cf387a2ae38f61352e7c12 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 7 Jun 2021 11:28:17 +0200 Subject: [PATCH] platforms/drm: optimize cursor setting --- src/plugins/platforms/drm/drm_pipeline.cpp | 11 +++++++++++ src/plugins/platforms/drm/drm_pipeline.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/plugins/platforms/drm/drm_pipeline.cpp b/src/plugins/platforms/drm/drm_pipeline.cpp index 8eeaf03227..5ce6f9f04b 100644 --- a/src/plugins/platforms/drm/drm_pipeline.cpp +++ b/src/plugins/platforms/drm/drm_pipeline.cpp @@ -307,21 +307,29 @@ bool DrmPipeline::checkTestBuffer() bool DrmPipeline::setCursor(const QSharedPointer &buffer) { + if (!m_cursor.dirty && m_cursor.buffer == buffer) { + return true; + } const QSize &s = buffer ? buffer->size() : QSize(64, 64); if (drmModeSetCursor(m_gpu->fd(), m_crtc->id(), buffer ? buffer->handle() : 0, s.width(), s.height()) != 0) { qCWarning(KWIN_DRM) << "Could not set cursor:" << strerror(errno); return false; } m_cursor.buffer = buffer; + m_cursor.dirty = false; return true; } bool DrmPipeline::moveCursor(QPoint pos) { + if (!m_cursor.dirty && m_cursor.pos == pos) { + return true; + } if (drmModeMoveCursor(m_gpu->fd(), m_crtc->id(), pos.x(), pos.y()) != 0) { m_cursor.pos = pos; return false; } + m_cursor.dirty = false; return true; } @@ -517,6 +525,9 @@ void DrmPipeline::updateProperties() for (const auto &obj : qAsConst(m_allObjects)) { obj->updateProperties(); } + // with legacy we don't know what happened to the cursor after VT switch + // so make sure it gets set again + m_cursor.dirty = true; } static void printProps(DrmObject *object) diff --git a/src/plugins/platforms/drm/drm_pipeline.h b/src/plugins/platforms/drm/drm_pipeline.h index 5baa75d2aa..03bcdd4f26 100644 --- a/src/plugins/platforms/drm/drm_pipeline.h +++ b/src/plugins/platforms/drm/drm_pipeline.h @@ -98,6 +98,7 @@ private: struct { QPoint pos = QPoint(100, 100); QSharedPointer buffer; + bool dirty = true;// we don't know what the current state is } m_cursor; QVector m_allObjects;