screencasting: don't crash if the cursor is too big for our buffer
Make sure we stay within our bounds.
Also initialise the background to transparent so there's no data from
past renders.
(cherry picked from commit 07c994fb82
)
icc-effect-5.20.5
parent
2a4fb12f8f
commit
233df87c2c
|
@ -72,7 +72,7 @@ void PipeWireStream::newStreamParams()
|
|||
spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT (paramsBuffer, sizeof (paramsBuffer));
|
||||
|
||||
spa_rectangle resolution = SPA_RECTANGLE(uint32_t(m_resolution.width()), uint32_t(m_resolution.height()));
|
||||
const auto cursorSize = Cursors::self()->currentCursor()->themeSize();
|
||||
const int cursorSize = Cursors::self()->currentCursor()->themeSize() * m_cursor.scale;
|
||||
const spa_pod *params[] = {
|
||||
(spa_pod*) spa_pod_builder_add_object(&pod_builder,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
|
||||
|
@ -449,11 +449,17 @@ void PipeWireStream::sendCursorData(Cursor *cursor, spa_meta_cursor *spa_meta_cu
|
|||
spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
|
||||
|
||||
uint8_t *bitmap_data = SPA_MEMBER (spa_meta_bitmap, spa_meta_bitmap->offset, uint8_t);
|
||||
QImage dest(bitmap_data, image.width(), image.height(), QImage::Format_RGBA8888_Premultiplied);
|
||||
spa_meta_bitmap->size.width = image.width();
|
||||
spa_meta_bitmap->size.height = image.height();
|
||||
const int bufferSideSize = Cursors::self()->currentCursor()->themeSize() * m_cursor.scale;
|
||||
QImage dest(bitmap_data, std::min(bufferSideSize, image.width()), std::min(bufferSideSize, image.height()), QImage::Format_RGBA8888_Premultiplied);
|
||||
spa_meta_bitmap->size.width = dest.width();
|
||||
spa_meta_bitmap->size.height = dest.height();
|
||||
spa_meta_bitmap->stride = dest.bytesPerLine();
|
||||
|
||||
if (image.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dest.fill(Qt::transparent);
|
||||
QPainter painter(&dest);
|
||||
painter.drawImage(QPoint(), image);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue