started memory cache server

This commit is contained in:
itsmattkc
2019-05-20 03:26:14 +10:00
parent 3d4f12cd8e
commit bdf513585f
11 changed files with 364 additions and 46 deletions
+5 -5
View File
@@ -38,16 +38,16 @@ int Node::ParameterCount()
return parameters_.size();
}
void Node::Process(rational time)
{
Q_UNUSED(time)
}
NodeGraph *Node::ParentGraph()
{
return static_cast<NodeGraph*>(parent());
}
double Node::Time()
{
return ParentGraph()->Time();
}
const QPointF &Node::pos()
{
return pos_;
+6 -3
View File
@@ -1,9 +1,8 @@
#ifndef NODE_H
#define NODE_H
#include <memory>
#include "nodes/nodeio.h"
#include "global/rational.h"
class NodeGraph;
@@ -16,16 +15,20 @@ public:
virtual QString name();
virtual QString id();
virtual void Process(rational time);
void AddParameter(NodeIO* row);
int IndexOfParameter(NodeIO* row);
NodeIO* Parameter(int i);
int ParameterCount();
NodeGraph* ParentGraph();
double Time();
const QPointF& pos();
protected:
virtual void GLContextChangeEvent();
public slots:
void SetPos(const QPointF& pos);
+44 -3
View File
@@ -3,11 +3,20 @@
#include <QChildEvent>
#include <QDebug>
NodeGraph::NodeGraph()
NodeGraph::NodeGraph() :
output_node_(nullptr),
ctx_(nullptr)
{
}
void NodeGraph::Process()
{
if (output_node_ != nullptr) {
output_node_->Process(Time());
}
}
void NodeGraph::childEvent(QChildEvent *event)
{
if (event->type() == QEvent::ChildAdded || event->type() == QEvent::ChildRemoved) {
@@ -25,13 +34,45 @@ Node *NodeGraph::OutputNode()
return output_node_;
}
double NodeGraph::Time()
const rational& NodeGraph::Time()
{
return time_;
}
void NodeGraph::SetTime(double d)
void NodeGraph::SetTime(const rational &d)
{
time_ = d;
emit TimeChanged();
}
MemoryCache *NodeGraph::memory_cache()
{
return &memory_cache_;
}
const int &NodeGraph::width()
{
return width_;
}
const int &NodeGraph::height()
{
return height_;
}
void NodeGraph::set_width(const int& w)
{
width_ = w;
emit ParametersChanged();
}
void NodeGraph::set_height(const int& h)
{
height_ = h;
emit ParametersChanged();
}
void NodeGraph::SetGLContext(QOpenGLContext *ctx)
{
memory_cache_.SetParameters(ctx, width_, height_);
}
+22 -3
View File
@@ -5,6 +5,7 @@
#include <QObject>
#include "nodes/node.h"
#include "rendering/memorycache.h"
class NodeGraph : public QObject
{
@@ -12,6 +13,12 @@ class NodeGraph : public QObject
public:
NodeGraph();
const int& width();
void set_width(const int& w);
const int& height();
void set_height(const int& h);
/**
* @brief Process the graph
*
@@ -41,12 +48,18 @@ public:
*/
Node* OutputNode();
double Time();
void SetTime(double d);
const rational &Time();
void SetTime(const rational& d);
MemoryCache* memory_cache();
QOpenGLContext* GLContext();
void SetGLContext(QOpenGLContext* ctx);
signals:
void NodeGraphChanged();
void TimeChanged();
void ParametersChanged();
protected:
virtual void childEvent(QChildEvent *event) override;
@@ -54,7 +67,13 @@ protected:
private:
Node* output_node_;
double time_;
MemoryCache memory_cache_;
QOpenGLContext* ctx_;
int width_;
int height_;
rational time_;
};
#endif // NODEGRAPH_H
+27 -21
View File
@@ -1,13 +1,16 @@
#include "nodemedia.h"
NodeMedia::NodeMedia(Clip* c) :
OldEffectNode(c)
{
NodeIO* matrix_input = new NodeIO(this, "matrix", tr("Matrix"), true, false);
matrix_input->AddAcceptedNodeInput(olive::nodes::kMatrix);
#include "nodes/nodegraph.h"
NodeIO* texture_output = new NodeIO(this, "texture", tr("Texture"), true, false);
texture_output->SetOutputDataType(olive::nodes::kTexture);
NodeMedia::NodeMedia(NodeGraph* c) :
Node(c),
buffer_(c->memory_cache())
{
matrix_input_ = new NodeIO(this, "matrix", tr("Matrix"), true, false);
matrix_input_->AddAcceptedNodeInput(olive::nodes::kMatrix);
texture_output_ = new NodeIO(this, "texture", tr("Texture"), true, false);
texture_output_->SetOutputDataType(olive::nodes::kTexture);
}
QString NodeMedia::name()
@@ -20,27 +23,30 @@ QString NodeMedia::id()
return "org.olivevideoeditor.Olive.media";
}
QString NodeMedia::category()
void NodeMedia::Process(rational time)
{
return tr("Inputs");
Q_UNUSED(time)
buffer_.buffer()->BindBuffer();
// DEBUG CODE - we should see a solid red color return from this function
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
// END DEBUG CODE
buffer_.buffer()->ReleaseBuffer();
texture_output_->SetValue(buffer_.buffer()->texture());
}
QString NodeMedia::description()
NodeIO *NodeMedia::matrix_input()
{
return tr("Retrieve frames from a media source.");
return matrix_input_;
}
EffectType NodeMedia::type()
NodeIO *NodeMedia::texture_output()
{
return EFFECT_TYPE_EFFECT;
return texture_output_;
}
olive::TrackType NodeMedia::subtype()
{
return olive::kTypeVideo;
}
OldEffectNodePtr NodeMedia::Create(Clip *c)
{
return std::make_shared<NodeMedia>(c);
}
+16 -8
View File
@@ -1,20 +1,28 @@
#ifndef MEDIANODE_H
#define MEDIANODE_H
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "rendering/memorycache.h"
class NodeMedia : public OldEffectNode
class NodeMedia : public Node
{
Q_OBJECT
public:
NodeMedia(Clip *c);
NodeMedia(NodeGraph *c);
virtual QString name() override;
virtual QString id() override;
virtual QString category() override;
virtual QString description() override;
virtual EffectType type() override;
virtual olive::TrackType subtype() override;
virtual OldEffectNodePtr Create(Clip *c) override;
virtual void Process(rational time) override;
NodeIO* matrix_input();
NodeIO* texture_output();
private:
NodeIO* matrix_input_;
NodeIO* texture_output_;
MemoryCache::Reference buffer_;
};
#endif // MEDIANODE_H