summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2019-04-05 21:14:40 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2019-04-09 04:26:27 +0000
commit6b41334b099dd39372b9309d543e7fa6c45a6dd0 (patch)
treeabfea7b22a721aaee767b7fd417eaf63ce95c507
parent381cf7475268f303983e1a91ec0a01d0dfe60f7a (diff)
BatchRenderer: handle QLOTTIE_RENDER_CACHE_SIZE env var
handling it in every LottieAnimation instance is a waste Change-Id: I4de7673d0de0fc5c3bab04b9db419a62ac8b5580 Reviewed-by: Rebecca Worledge <rebecca.worledge@theqtcompany.com>
-rw-r--r--src/imports/lottieanimation.cpp6
-rw-r--r--src/imports/rasterrenderer/batchrenderer.cpp20
-rw-r--r--src/imports/rasterrenderer/batchrenderer.h3
3 files changed, 12 insertions, 17 deletions
diff --git a/src/imports/lottieanimation.cpp b/src/imports/lottieanimation.cpp
index ea0c308..58e3043 100644
--- a/src/imports/lottieanimation.cpp
+++ b/src/imports/lottieanimation.cpp
@@ -198,12 +198,6 @@ LottieAnimation::LottieAnimation(QQuickItem *parent)
m_frameRenderThread = BatchRenderer::instance();
- QByteArray cacheStr = qgetenv("QLOTTIE_RENDER_CACHE_SIZE");
- bool ok = false;
- int cacheSize = cacheStr.toInt(&ok);
- if (ok)
- m_frameRenderThread->setCacheSize(cacheSize);
-
qRegisterMetaType<LottieAnimation*>();
}
diff --git a/src/imports/rasterrenderer/batchrenderer.cpp b/src/imports/rasterrenderer/batchrenderer.cpp
index 6b64e7a..eb0cc44 100644
--- a/src/imports/rasterrenderer/batchrenderer.cpp
+++ b/src/imports/rasterrenderer/batchrenderer.cpp
@@ -52,6 +52,17 @@ Q_LOGGING_CATEGORY(lcLottieQtBodymovinRenderThread, "qt.lottieqt.bodymovin.rende
BatchRenderer *BatchRenderer::m_rendererInstance = nullptr;
+BatchRenderer::BatchRenderer()
+ : QThread()
+{
+ const QByteArray cacheStr = qgetenv("QLOTTIE_RENDER_CACHE_SIZE");
+ int cacheSize = cacheStr.toInt();
+ if (cacheSize > 0) {
+ qCDebug(lcLottieQtBodymovinRenderThread) << "Setting frame cache size to" << cacheSize;
+ m_cacheSize = cacheSize;
+ }
+}
+
BatchRenderer::~BatchRenderer()
{
qDeleteAll(m_animData);
@@ -149,15 +160,6 @@ BMBase *BatchRenderer::getFrame(LottieAnimation *animator, int frameNumber)
return nullptr;
}
-void BatchRenderer::setCacheSize(int size)
-{
- if (size < 1 || isRunning())
- return;
-
- qCDebug(lcLottieQtBodymovinRenderThread) << "Setting frame cache size to" << size;
- m_cacheSize = size;
-}
-
void BatchRenderer::prerender(Entry *animEntry)
{
while (animEntry->frameCache.count() < m_cacheSize) {
diff --git a/src/imports/rasterrenderer/batchrenderer.h b/src/imports/rasterrenderer/batchrenderer.h
index 4ede260..7e5830e 100644
--- a/src/imports/rasterrenderer/batchrenderer.h
+++ b/src/imports/rasterrenderer/batchrenderer.h
@@ -77,7 +77,6 @@ public slots:
bool gotoFrame(LottieAnimation *animator, int frame);
void frameRendered(LottieAnimation *animator, int frameNumber);
- void setCacheSize(int size);
protected:
void run() override;
@@ -87,7 +86,7 @@ protected:
void prerender(Entry *animEntry);
private:
- BatchRenderer() = default;
+ BatchRenderer();
void pruneFrameCache(Entry* e);