platform/drm: Fix clipped HiDPI hardware cursors

If an output is rotated, we will compute a transform matrix for the
cursor plane to rotate its contents.

In order to compute that matrix we need the rect of the cursor in the
device-independent pixels, the scale factor and the output transform.

The problem is that we provide a rect of the cursor in the native
pixels. This may result in the cursor being partially or fully clipped.

CCBUG: 424589
master
Vlad Zahorodnii 4 years ago
parent 3d80665c0a
commit c8eeefbd7d

@ -147,6 +147,11 @@ QRect Cursor::geometry() const
return QRect(m_pos - hotspot(), image().size());
}
QRect Cursor::rect() const
{
return QRect(QPoint(0, 0), image().size() / image().devicePixelRatio());
}
QPoint Cursor::pos()
{
doGetPos();

@ -163,6 +163,7 @@ public:
QImage image() const { return m_image; }
QPoint hotspot() const { return m_hotspot; }
QRect geometry() const;
QRect rect() const;
void updateCursor(const QImage &image, const QPoint &hotspot);
void markAsRendered() {

@ -136,7 +136,8 @@ void DrmOutput::updateCursor()
if (m_deleted) {
return;
}
QImage cursorImage = Cursors::self()->currentCursor()->image();
const Cursor *cursor = Cursors::self()->currentCursor();
const QImage cursorImage = cursor->image();
if (cursorImage.isNull()) {
return;
}
@ -146,14 +147,14 @@ void DrmOutput::updateCursor()
QPainter p;
p.begin(c);
p.setWorldTransform(logicalToNativeMatrix(cursorImage.rect(), scale(), transform()).toTransform());
p.setWorldTransform(logicalToNativeMatrix(cursor->rect(), scale(), transform()).toTransform());
p.drawImage(QPoint(0, 0), cursorImage);
p.end();
}
void DrmOutput::moveCursor(Cursor *cursor, const QPoint &globalPos)
{
const QMatrix4x4 hotspotMatrix = logicalToNativeMatrix(cursor->image().rect(), scale(), transform());
const QMatrix4x4 hotspotMatrix = logicalToNativeMatrix(cursor->rect(), scale(), transform());
const QMatrix4x4 monitorMatrix = logicalToNativeMatrix(geometry(), scale(), transform());
QPoint pos = monitorMatrix.map(globalPos);

@ -568,8 +568,7 @@ void SceneOpenGL2::paintCursor(const QRegion &rendered)
// figure out which part of the cursor needs to be repainted
const QPoint cursorPos = cursor->pos() - cursor->hotspot();
const qreal scale = cursor->image().devicePixelRatio();
const QRect cursorRect(QPoint(0, 0), cursor->image().size() / scale);
const QRect cursorRect = cursor->rect();
QRegion region;
for (const QRect &rect : rendered) {
region |= rect.translated(-cursorPos).intersected(cursorRect);

Loading…
Cancel
Save