1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-09-10 12:03:18 +02:00

rendermanager: fix rendering on GNU/Linux

use directRenderer storage if libwrap is enabled.
Avoid potential crashes by replacing reserve by resize

GitLab: #580
Change-Id: I5b8d83a6be2157164b755156bb16a424b38c70ad
This commit is contained in:
Sébastien Blin 2021-10-28 16:02:43 -04:00
parent 39c029da6e
commit 641730c425

View file

@ -144,24 +144,28 @@ FrameWrapper::slotFrameUpdated(const QString& id)
unsigned int width = renderer_->size().width();
unsigned int height = renderer_->size().height();
#ifndef Q_OS_LINUX
unsigned int size = frame_.storage.size();
auto imageFormat = QImage::Format_ARGB32_Premultiplied;
#else
unsigned int size = frame_.size;
auto imageFormat = QImage::Format_ARGB32;
#endif
unsigned int size;
QImage::Format imageFormat;
if (renderer_->useDirectRenderer()) {
size = frame_.storage.size();
imageFormat = QImage::Format_ARGB32_Premultiplied;
} else {
size = frame_.size;
imageFormat = QImage::Format_ARGB32;
}
/*
* If the frame is empty or not the expected size,
* do nothing and keep the last rendered QImage.
*/
if (size != 0 && size == width * height * 4) {
#ifndef Q_OS_LINUX
buffer_ = std::move(frame_.storage);
#else
buffer_.reserve(size);
std::move(frame_.ptr, frame_.ptr + size, buffer_.begin());
#endif
if (renderer_->useDirectRenderer()) {
buffer_ = std::move(frame_.storage);
} else {
// TODO remove this path. storage should work everywhere
// https://git.jami.net/savoirfairelinux/jami-libclient/-/issues/492
buffer_.resize(size);
std::move(frame_.ptr, frame_.ptr + size, buffer_.begin());
}
image_.reset(new QImage((uchar*) buffer_.data(), width, height, imageFormat));
}
}