platforms/drm: optimize cursor setting
This commit is contained in:
parent
5ad0d18476
commit
b23dfd55ac
2 changed files with 12 additions and 0 deletions
|
@ -307,21 +307,29 @@ bool DrmPipeline::checkTestBuffer()
|
||||||
|
|
||||||
bool DrmPipeline::setCursor(const QSharedPointer<DrmDumbBuffer> &buffer)
|
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);
|
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) {
|
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);
|
qCWarning(KWIN_DRM) << "Could not set cursor:" << strerror(errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_cursor.buffer = buffer;
|
m_cursor.buffer = buffer;
|
||||||
|
m_cursor.dirty = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmPipeline::moveCursor(QPoint pos)
|
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) {
|
if (drmModeMoveCursor(m_gpu->fd(), m_crtc->id(), pos.x(), pos.y()) != 0) {
|
||||||
m_cursor.pos = pos;
|
m_cursor.pos = pos;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
m_cursor.dirty = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +525,9 @@ void DrmPipeline::updateProperties()
|
||||||
for (const auto &obj : qAsConst(m_allObjects)) {
|
for (const auto &obj : qAsConst(m_allObjects)) {
|
||||||
obj->updateProperties();
|
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)
|
static void printProps(DrmObject *object)
|
||||||
|
|
|
@ -98,6 +98,7 @@ private:
|
||||||
struct {
|
struct {
|
||||||
QPoint pos = QPoint(100, 100);
|
QPoint pos = QPoint(100, 100);
|
||||||
QSharedPointer<DrmDumbBuffer> buffer;
|
QSharedPointer<DrmDumbBuffer> buffer;
|
||||||
|
bool dirty = true;// we don't know what the current state is
|
||||||
} m_cursor;
|
} m_cursor;
|
||||||
|
|
||||||
QVector<DrmObject*> m_allObjects;
|
QVector<DrmObject*> m_allObjects;
|
||||||
|
|
Loading…
Reference in a new issue