platforms/drm: optimize cursor setting

This commit is contained in:
Xaver Hugl 2021-06-07 11:28:17 +02:00
parent 5ad0d18476
commit b23dfd55ac
2 changed files with 12 additions and 0 deletions

View file

@ -307,21 +307,29 @@ bool DrmPipeline::checkTestBuffer()
bool DrmPipeline::setCursor(const QSharedPointer<DrmDumbBuffer> &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)

View file

@ -98,6 +98,7 @@ private:
struct {
QPoint pos = QPoint(100, 100);
QSharedPointer<DrmDumbBuffer> buffer;
bool dirty = true;// we don't know what the current state is
} m_cursor;
QVector<DrmObject*> m_allObjects;