decoder/renderer: use memory cache and single decoder to optimize frames for

cycles
This commit is contained in:
itsmattkc
2020-02-20 15:32:12 +11:00
parent 71048f40a8
commit 2145efa2a0
19 changed files with 150 additions and 135 deletions
+3 -33
View File
@@ -18,41 +18,11 @@ public:
bool Has(K key) const {return values_.contains(key);}
private:
QHash<K, V> values_;
};
void Lock() { lock_.lock(); }
template<class K, class V>
class ThreadSafeRenderCache
{
public:
ThreadSafeRenderCache() = default;
void Unlock() { lock_.unlock(); }
void Clear() {
lock_.lock();
values_.clear();
lock_.unlock();
}
void Add(K key, V val) {
lock_.lock();
values_.insert(key, val);
lock_.unlock();
}
V Get(K key) {
lock_.lock();
V val = values_.value(key);
lock_.unlock();
return val;
}
bool Has(K key) {
lock_.lock();
bool has = values_.contains(key);
lock_.unlock();
return has;
}
QMutex* lock() { return &lock_; }
private:
QHash<K, V> values_;