Files
oak-editor/app/render/stillimagecache.h
T
itsmattkc 4827782331 moved sequence params into node graph too
Reduces code by reusing more of the existing node infrastructure
to synchronize sequence parameters the render backend.
2021-02-18 13:20:23 +11:00

85 lines
1.5 KiB
C++

#ifndef STILLIMAGECACHE_H
#define STILLIMAGECACHE_H
#include <QHash>
#include <QWaitCondition>
#include "codec/decoder.h"
#include "common/rational.h"
#include "project/item/footage/footage.h"
#include "render/texture.h"
namespace olive {
class StillImageCache
{
public:
struct Entry {
Entry(TexturePtr t, const Decoder::CodecStream& s, const QString& cs, bool a, int d, const rational& i, bool w)
{
texture = t;
stream = s;
colorspace = cs;
alpha_is_associated = a;
divider = d;
time = i;
working = w;
}
TexturePtr texture;
Decoder::CodecStream stream;
QString colorspace;
bool alpha_is_associated;
int divider;
rational time;
bool working;
};
using EntryPtr = std::shared_ptr<Entry>;
QMutex* mutex()
{
return &mutex_;
}
QWaitCondition* wait_cond()
{
return &wait_cond_;
}
const QVector<EntryPtr>& entries() const
{
return entries_;
}
static bool CompareEntryMetadata(EntryPtr a, EntryPtr b)
{
return (a->stream == b->stream
&& a->colorspace == b->colorspace
&& a->alpha_is_associated == b->alpha_is_associated
&& a->divider == b->divider
&& a->time == b->time);
}
void PushEntry(EntryPtr e)
{
entries_.prepend(e);
if (entries_.size() > 8) {
entries_.removeLast();
}
}
private:
QMutex mutex_;
QWaitCondition wait_cond_;
QVector<EntryPtr> entries_;
};
}
#endif // STILLIMAGECACHE_H