mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Try to reduce CPU overhead of animated images a bit
This commit is contained in:
parent
459edcd71a
commit
c5f4865ee6
1 changed files with 8 additions and 4 deletions
|
@ -91,6 +91,10 @@ MxcAnimatedImage::startDownload()
|
||||||
"Playing movie with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
|
"Playing movie with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
|
||||||
movie.setFormat(mimeType);
|
movie.setFormat(mimeType);
|
||||||
movie.setDevice(&buffer);
|
movie.setDevice(&buffer);
|
||||||
|
movie.setScaledSize(this->size().toSize());
|
||||||
|
if (buffer.bytesAvailable() <
|
||||||
|
4LL * 1024 * 1024 * 1024) // cache images smaller than 4MB in RAM
|
||||||
|
movie.setCacheMode(QMovie::CacheAll);
|
||||||
if (play_)
|
if (play_)
|
||||||
movie.start();
|
movie.start();
|
||||||
else
|
else
|
||||||
|
@ -158,17 +162,17 @@ MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeD
|
||||||
|
|
||||||
// n->setTexture(nullptr);
|
// n->setTexture(nullptr);
|
||||||
auto img = movie.currentImage();
|
auto img = movie.currentImage();
|
||||||
|
n->setSourceRect(img.rect());
|
||||||
if (!img.isNull())
|
if (!img.isNull())
|
||||||
n->setTexture(window()->createTextureFromImage(img));
|
n->setTexture(window()->createTextureFromImage(std::move(img)));
|
||||||
else {
|
else {
|
||||||
delete n;
|
delete n;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
n->setSourceRect(img.rect());
|
|
||||||
n->setRect(QRect(0, 0, width(), height()));
|
n->setRect(QRect(0, 0, width(), height()));
|
||||||
n->setFiltering(QSGTexture::Linear);
|
n->setFiltering(QSGTexture::Nearest);
|
||||||
n->setMipmapFiltering(QSGTexture::Linear);
|
n->setMipmapFiltering(QSGTexture::None);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue