plugins/screencast: Rename "_damagedRegion" parameter

This commit is contained in:
Vlad Zahorodnii 2024-04-23 13:26:26 +03:00
parent ce9531d549
commit 55cccf3779
2 changed files with 9 additions and 13 deletions

View file

@ -276,7 +276,7 @@ ScreenCastStream::ScreenCastStream(ScreenCastSource *source, std::shared_ptr<Pip
m_pendingFrame.setSingleShot(true);
connect(&m_pendingFrame, &QTimer::timeout, this, [this] {
recordFrame(m_pendingDamages, m_pendingContents);
recordFrame(m_pendingDamage, m_pendingContents);
});
}
@ -401,9 +401,8 @@ void ScreenCastStream::close()
Q_EMIT closed();
}
void ScreenCastStream::recordFrame(const QRegion &_damagedRegion, Contents contents)
void ScreenCastStream::recordFrame(const QRegion &damage, Contents contents)
{
QRegion damagedRegion = _damagedRegion;
Q_ASSERT(!m_closed);
const char *error = "";
@ -426,7 +425,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion, Contents conte
const auto frameInterval = std::chrono::milliseconds(1000 * m_videoFormat.max_framerate.denom / m_videoFormat.max_framerate.num);
const auto lastSentAgo = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastSent.value());
if (lastSentAgo < frameInterval) {
m_pendingDamages += damagedRegion;
m_pendingDamage += damage;
m_pendingContents |= contents;
if (!m_pendingFrame.isActive()) {
m_pendingFrame.start(frameInterval - lastSentAgo);
@ -435,7 +434,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion, Contents conte
}
}
m_pendingDamages = {};
m_pendingDamage = {};
m_pendingContents = {};
struct pw_buffer *pwBuffer = pw_stream_dequeue_buffer(m_pwStream);
@ -473,13 +472,14 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion, Contents conte
}
}
QRegion effectiveDamage = damage;
if (effectiveContents & Content::Cursor) {
Cursor *cursor = Cursors::self()->currentCursor();
switch (m_cursor.mode) {
case ScreencastV1Interface::Hidden:
break;
case ScreencastV1Interface::Embedded:
damagedRegion += addCursorEmbedded(buffer, cursor);
effectiveDamage += addCursorEmbedded(buffer, cursor);
break;
case ScreencastV1Interface::Metadata:
addCursorMetadata(spa_buffer, cursor);
@ -494,7 +494,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion, Contents conte
glFlush();
}
addDamage(spa_buffer, damagedRegion);
addDamage(spa_buffer, effectiveDamage);
addHeader(spa_buffer);
if (effectiveContents & Content::Video) {

View file

@ -66,11 +66,7 @@ public:
void close();
/**
* Renders @p frame into the current framebuffer into the stream
* @p timestamp
*/
void recordFrame(const QRegion &damagedRegion, Contents contents = Content::Video);
void recordFrame(const QRegion &damage, Contents contents = Content::Video);
void setCursorMode(ScreencastV1Interface::CursorMode mode, qreal scale, const QRectF &viewport);
@ -140,7 +136,7 @@ private:
quint32 m_drmFormat = 0;
std::optional<std::chrono::steady_clock::time_point> m_lastSent;
QRegion m_pendingDamages;
QRegion m_pendingDamage;
QTimer m_pendingFrame;
Contents m_pendingContents = Content::None;
};