plugins/screencast: Make embedded cursor position handling simpler

If the position of the cursor changes, let the screen cast source to
repaint memfd or dmabuf buffer.
This commit is contained in:
Vlad Zahorodnii 2021-11-14 17:39:32 +02:00
parent c3c87ed8fa
commit 10032e99e3
2 changed files with 1 additions and 23 deletions

View file

@ -301,11 +301,7 @@ bool PipeWireStream::createStream()
if (m_cursor.mode == KWaylandServer::ScreencastV1Interface::Embedded) {
connect(Cursors::self(), &Cursors::positionChanged, this, [this] {
if (m_cursor.lastFrameTexture) {
m_repainting = true;
recordFrame(QRegion{m_cursor.lastRect} | cursorGeometry(Cursors::self()->currentCursor()));
m_repainting = false;
}
recordFrame(QRegion{m_cursor.lastRect} | cursorGeometry(Cursors::self()->currentCursor()));
});
}
@ -323,19 +319,6 @@ void PipeWireStream::stop()
delete this;
}
static GLTexture *copyTexture(GLTexture *texture)
{
const QSize size = texture->size();
GLTexture *copy = new GLTexture(texture->internalFormat(), size);
copy->setFilter(GL_LINEAR);
copy->setWrapMode(GL_CLAMP_TO_EDGE);
copy->bind();
glCopyTextureSubImage2D(copy->texture(), 0, 0, 0, 0, 0, size.width(), size.height());
copy->unbind();
return copy;
}
// in-place vertical mirroring
static void mirrorVertically(uchar *data, int height, int stride)
{
@ -461,9 +444,6 @@ void PipeWireStream::recordFrame(const QRegion &damagedRegion)
mvp.ortho(r);
shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
if (!m_repainting) //We need to copy the last version of the stream to render the moved cursor on top
m_cursor.lastFrameTexture.reset(copyTexture(buf->texture()));
if (!m_cursor.texture || m_cursor.lastKey != cursor->image().cacheKey())
m_cursor.texture.reset(new GLTexture(cursor->image()));

View file

@ -99,9 +99,7 @@ private:
qint64 lastKey = 0;
QRect lastRect;
QScopedPointer<GLTexture> texture;
QScopedPointer<GLTexture> lastFrameTexture;
} m_cursor;
bool m_repainting = false;
QRect cursorGeometry(Cursor *cursor) const;
QHash<struct pw_buffer *, QSharedPointer<DmaBufTexture>> m_dmabufDataForPwBuffer;