implemented new block system

Fixes recurring design issue that the Blocks were a frequent exception to the
DAG concept. The Blocks connecting to each others inputs/outputs while not
necessarily being "dependent" on each other to produce an image continually
causes issues while trying to create a rendering code path. This redesign
should provide a more "directed" approach to the directed acyclic graph.
This commit is contained in:
itsmattkc
2019-12-02 00:37:03 +11:00
parent 6314c80cbc
commit 79ee3bc3df
13 changed files with 279 additions and 240 deletions
+25 -23
View File
@@ -31,9 +31,6 @@ Block::Block() :
buffer_output_ = new NodeOutput("buffer_out");
AddParameter(buffer_output_);
connect(this, SIGNAL(EdgeAdded(NodeEdgePtr)), this, SLOT(EdgeAddedSlot(NodeEdgePtr)), Qt::DirectConnection);
connect(this, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SLOT(EdgeRemovedSlot(NodeEdgePtr)), Qt::DirectConnection);
}
QString Block::Category()
@@ -51,6 +48,16 @@ const rational &Block::out()
return out_point_;
}
void Block::set_in(const rational &in)
{
in_point_ = in;
}
void Block::set_out(const rational &out)
{
out_point_ = out;
}
const rational& Block::length()
{
return length_;
@@ -60,13 +67,17 @@ void Block::set_length(const rational &length)
{
Q_ASSERT(length > 0);
if (length == length_) {
return;
}
LockUserInput();
length_ = length;
UnlockUserInput();
Refresh();
emit LengthChanged(length_);
}
void Block::set_length_and_media_in(const rational &length)
@@ -88,6 +99,16 @@ Block *Block::next()
return next_;
}
void Block::set_previous(Block *previous)
{
previous_ = previous;
}
void Block::set_next(Block *next)
{
next_ = next;
}
QVariant Block::Value(NodeOutput *output)
{
if (output == block_output_) {
@@ -98,25 +119,6 @@ QVariant Block::Value(NodeOutput *output)
return 0;
}
void Block::Refresh()
{
// Set in point to the out point of the previous Node
if (previous() != nullptr) {
in_point_ = previous()->out();
} else {
in_point_ = 0;
}
// Update out point by adding this clip's length to the just calculated in point
out_point_ = in_point_ + length();
emit Refreshed();
if (next() != nullptr) {
next()->Refresh();
}
}
NodeOutput *Block::buffer_output()
{
return buffer_output_;
+12 -20
View File
@@ -42,7 +42,7 @@ public:
enum Type {
kClip,
kGap,
kEnd
kTrack
};
virtual Type type() = 0;
@@ -51,6 +51,8 @@ public:
const rational& in();
const rational& out();
void set_in(const rational& in);
void set_out(const rational& out);
const rational &length();
void set_length(const rational &length);
@@ -58,6 +60,8 @@ public:
Block* previous();
Block* next();
void set_previous(Block* previous);
void set_next(Block* next);
NodeOutput* buffer_output();
NodeOutput* block_output();
@@ -80,20 +84,6 @@ public:
virtual QVariant Value(NodeOutput* output) override;
public slots:
/**
* @brief Refreshes internal cache of in/out points up to date
*
* A block can only know truly know its in point by adding all the lengths of the clips before it. Since this can
* become timeconsuming, blocks cache their in and out points for easy access, however this does mean their caches
* need to stay up to date to provide accurate results. Whenever this or any surrounding Block is changed, it's
* recommended to call Refresh().
*
* This function specifically sets the in point to the out point of the previous clip and sets its out point to the
* in point + this block's length. Therefore, before calling Refresh() on a Block, it's necessary that all the
* Blocks before it are accurate and up to date. You may need to traverse through the Block list (using previous())
* and run Refresh() on all Blocks sequentially.
*/
virtual void Refresh();
signals:
/**
@@ -103,6 +93,8 @@ signals:
*/
void Refreshed();
void LengthChanged(const rational& length);
protected:
rational SequenceToMediaTime(const rational& sequence_time);
@@ -110,18 +102,18 @@ protected:
static void CopyParameters(Block* source, Block* dest);
Block* previous_;
Block* next_;
private:
NodeOutput* block_output_;
NodeOutput* buffer_output_;
rational in_point_;
rational out_point_;
rational length_;
rational media_in_;
Block* previous_;
Block* next_;
rational in_point_;
rational out_point_;
QString block_name_;