Commit 07c994fb authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

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.
parent bf5155f8
......@@ -73,7 +73,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,
......@@ -497,11 +497,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()) {
QPainter painter(&dest);
painter.drawImage(QPoint(), image);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment