Files
oak-editor/app/render/backend/videorenderframecache.h
T
itsmattkc e8fddc2d5b improved renderer reliability
The renderer backend can now distinguish between jobs. Previously if two jobs
of the same frame were started (which is legal if the user made a change while
frames were still being rendered), an earlier job in some situations could
finish AFTER a later job, and the backend would have no way of distinguishing
between them. This meant a frame could be erroneously set to an old value
rather than the newest. This commit introduces job identification so that old
jobs are automatically discarded.
2020-01-02 03:21:38 +11:00

54 lines
1.2 KiB
C++

#ifndef VIDEORENDERFRAMECACHE_H
#define VIDEORENDERFRAMECACHE_H
#include <QMutex>
#include "common/rational.h"
class VideoRenderFrameCache
{
public:
VideoRenderFrameCache();
/**
* @brief Return whether a frame with this hash already exists
*/
bool HasHash(const QByteArray& hash);
/**
* @brief Return whether a frame is currently being cached
*/
bool IsCaching(const QByteArray& hash);
/**
* @brief Check if a frame is currently being cached, and if not reserve it
*/
bool TryCache(const rational &time, const QByteArray& hash);
/**
* @brief Return the path of the cached image at this time
*/
QString CachePathName(const QByteArray &hash) const;
void SetCacheID(const QString& id);
QByteArray TimeToHash(const rational& time) const;
void SetHash(const rational& time, const QByteArray& hash);
void RemoveHash(const rational& time, const QByteArray &hash);
void Truncate(const rational& time);
private:
void RemoveHashFromCurrentlyCaching(const QByteArray& hash);
QMap<rational, QByteArray> time_hash_map_;
QMutex currently_caching_lock_;
QVector<QByteArray> currently_caching_list_;
QString cache_id_;
};
#endif // VIDEORENDERFRAMECACHE_H