Make Scene::qpainterRenderBuffer() take a screen id

This commit is contained in:
Vlad Zahorodnii 2020-11-09 15:39:36 +02:00
parent 94b731c196
commit 7cab8cf8bb
5 changed files with 13 additions and 12 deletions

View file

@ -105,7 +105,7 @@ void SceneQPainterTest::testStartFrame()
const QImage cursorImage = cursor->image(); const QImage cursorImage = cursor->image();
QVERIFY(!cursorImage.isNull()); QVERIFY(!cursorImage.isNull());
p.drawImage(cursor->pos() - cursor->hotspot(), cursorImage); p.drawImage(cursor->pos() - cursor->hotspot(), cursorImage);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
} }
void SceneQPainterTest::testCursorMoving() void SceneQPainterTest::testCursorMoving()
@ -136,7 +136,7 @@ void SceneQPainterTest::testCursorMoving()
const QImage cursorImage = cursor->image(); const QImage cursorImage = cursor->image();
QVERIFY(!cursorImage.isNull()); QVERIFY(!cursorImage.isNull());
p.drawImage(QPoint(45, 45) - cursor->hotspot(), cursorImage); p.drawImage(QPoint(45, 45) - cursor->hotspot(), cursorImage);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
} }
void SceneQPainterTest::testWindow() void SceneQPainterTest::testWindow()
@ -174,13 +174,13 @@ void SceneQPainterTest::testWindow()
p->setCursor(cs.data(), QPoint(5, 5)); p->setCursor(cs.data(), QPoint(5, 5));
QVERIFY(frameRenderedSpy.wait()); QVERIFY(frameRenderedSpy.wait());
painter.fillRect(KWin::Cursors::self()->mouse()->pos().x() - 5, KWin::Cursors::self()->mouse()->pos().y() - 5, 10, 10, Qt::red); painter.fillRect(KWin::Cursors::self()->mouse()->pos().x() - 5, KWin::Cursors::self()->mouse()->pos().y() - 5, 10, 10, Qt::red);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
// let's move the cursor again // let's move the cursor again
KWin::Cursors::self()->mouse()->setPos(10, 10); KWin::Cursors::self()->mouse()->setPos(10, 10);
QVERIFY(frameRenderedSpy.wait()); QVERIFY(frameRenderedSpy.wait());
painter.fillRect(0, 0, 200, 300, Qt::blue); painter.fillRect(0, 0, 200, 300, Qt::blue);
painter.fillRect(5, 5, 10, 10, Qt::red); painter.fillRect(5, 5, 10, 10, Qt::red);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
} }
void SceneQPainterTest::testWindowScaled() void SceneQPainterTest::testWindowScaled()
@ -230,7 +230,7 @@ void SceneQPainterTest::testWindowScaled()
painter.fillRect(100, 150, 100, 100, Qt::red); painter.fillRect(100, 150, 100, 100, Qt::red);
painter.fillRect(5, 5, 10, 10, Qt::red); //cursor painter.fillRect(5, 5, 10, 10, Qt::red); //cursor
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
} }
void SceneQPainterTest::testCompositorRestart() void SceneQPainterTest::testCompositorRestart()
@ -274,7 +274,7 @@ void SceneQPainterTest::testCompositorRestart()
const QImage cursorImage = cursor->image(); const QImage cursorImage = cursor->image();
QVERIFY(!cursorImage.isNull()); QVERIFY(!cursorImage.isNull());
painter.drawImage(QPoint(400, 400) - cursor->hotspot(), cursorImage); painter.drawImage(QPoint(400, 400) - cursor->hotspot(), cursorImage);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
} }
struct XcbConnectionDeleter struct XcbConnectionDeleter
@ -348,7 +348,7 @@ void SceneQPainterTest::testX11Window()
QVERIFY(frameRenderedSpy.wait()); QVERIFY(frameRenderedSpy.wait());
const QPoint startPos = client->pos() + client->clientPos(); const QPoint startPos = client->pos() + client->clientPos();
auto image = scene->qpainterRenderBuffer(); auto image = scene->qpainterRenderBuffer(0);
QCOMPARE(image->copy(QRect(startPos, client->clientSize())), compareImage); QCOMPARE(image->copy(QRect(startPos, client->clientSize())), compareImage);
// and destroy the window again // and destroy the window again

View file

@ -179,9 +179,9 @@ void SceneQPainter::screenGeometryChanged(const QSize &size)
m_backend->screenGeometryChanged(size); m_backend->screenGeometryChanged(size);
} }
QImage *SceneQPainter::qpainterRenderBuffer() const QImage *SceneQPainter::qpainterRenderBuffer(int screenId) const
{ {
return m_backend->bufferForScreen(0); return m_backend->bufferForScreen(screenId);
} }
//**************************************** //****************************************

View file

@ -39,7 +39,7 @@ public:
} }
QPainter *scenePainter() const override; QPainter *scenePainter() const override;
QImage *qpainterRenderBuffer() const override; QImage *qpainterRenderBuffer(int screenId) const override;
QPainterBackend *backend() const { QPainterBackend *backend() const {
return m_backend.data(); return m_backend.data();

View file

@ -692,8 +692,9 @@ QPainter *Scene::scenePainter() const
return nullptr; return nullptr;
} }
QImage *Scene::qpainterRenderBuffer() const QImage *Scene::qpainterRenderBuffer(int screenId) const
{ {
Q_UNUSED(screenId)
return nullptr; return nullptr;
} }

View file

@ -179,7 +179,7 @@ public:
* The render buffer used by a QPainter based compositor. * The render buffer used by a QPainter based compositor.
* Default implementation returns @c nullptr. * Default implementation returns @c nullptr.
*/ */
virtual QImage *qpainterRenderBuffer() const; virtual QImage *qpainterRenderBuffer(int screenId) const;
/** /**
* The backend specific extensions (e.g. EGL/GLX extensions). * The backend specific extensions (e.g. EGL/GLX extensions).