adjusted invalidatecache function

This commit is contained in:
itsmattkc
2019-09-02 20:11:42 +10:00
parent e87ed9dd3d
commit 3a9af58344
11 changed files with 68 additions and 30 deletions
+41 -11
View File
@@ -26,7 +26,8 @@
#include "node/graph.h"
TrackOutput::TrackOutput() :
current_block_(this)
current_block_(this),
block_invalidate_cache_stack_(0)
{
track_input_ = new NodeInput("track_in");
track_input_->add_data_input(NodeParam::kTrack);
@@ -148,7 +149,13 @@ NodeOutput* TrackOutput::track_output()
return track_output_;
}
#include "render/rendertexture.h"
void TrackOutput::InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from)
{
// We intercept IC signals from Blocks since we may be performing several options and they may over-signal
if (!block_invalidate_cache_stack_) {
Node::InvalidateCache(qMax(start_range, rational(0)), qMin(end_range, in()), from);
}
}
QVariant TrackOutput::Value(NodeOutput *output, const rational &time)
{
@@ -247,11 +254,18 @@ void TrackOutput::AppendBlock(Block *block)
{
AddBlockToGraph(block);
BlockInvalidateCache();
if (block_cache_.isEmpty()) {
ConnectBlockInternal(block);
} else {
InsertBlockBetweenBlocks(block, block_cache_.last(), this);
}
UnblockInvalidateCache();
// Invalidate area that block was added to
InvalidateCache(block->in(), in());
}
void TrackOutput::ConnectBlockInternal(Block *block)
@@ -289,6 +303,16 @@ void TrackOutput::ValidateCurrentBlock(const rational &time)
}
}
void TrackOutput::BlockInvalidateCache()
{
block_invalidate_cache_stack_++;
}
void TrackOutput::UnblockInvalidateCache()
{
block_invalidate_cache_stack_--;
}
void TrackOutput::PlaceBlock(Block *block, rational start)
{
if (block_cache_.contains(block) && block->in() == start) {
@@ -299,20 +323,14 @@ void TrackOutput::PlaceBlock(Block *block, rational start)
// Check if the placement location is past the end of the timeline
if (start >= in()) {
GapBlock* gap = nullptr;
if (start > in()) {
// If so, insert a gap here
gap = new GapBlock();
GapBlock* gap = new GapBlock();
gap->set_length(start - in());
AppendBlock(gap);
}
InsertBlockBefore(block, this);
if (gap != nullptr) {
// Insert gap if we made one before
InsertBlockBefore(gap, block);
}
AppendBlock(block);
return;
}
@@ -365,6 +383,8 @@ Block* TrackOutput::SplitBlock(Block *block, rational time)
return nullptr;
}
BlockInvalidateCache();
rational original_length = block->length();
block->set_length(time - block->in());
@@ -373,6 +393,8 @@ Block* TrackOutput::SplitBlock(Block *block, rational time)
copy->set_length(original_length - block->length());
InsertBlockAfter(copy, block);
UnblockInvalidateCache();
return copy;
}
@@ -477,9 +499,13 @@ void TrackOutput::RippleRemoveArea(rational in, rational out, Block *insert)
void TrackOutput::ReplaceBlock(Block *old, Block *replace)
{
Q_ASSERT(old->length() == replace->length());
Block* previous = old->previous();
Block* next = old->next();
BlockInvalidateCache();
AddBlockToGraph(replace);
// Disconnect old block from its surroundings
@@ -492,4 +518,8 @@ void TrackOutput::ReplaceBlock(Block *old, Block *replace)
Block::DisconnectBlocks(old, next);
Block::ConnectBlocks(replace, next);
}
UnblockInvalidateCache();
InvalidateCache(replace->in(), replace->out());
}
+8 -1
View File
@@ -61,6 +61,8 @@ public:
NodeOutput* track_output();
virtual void InvalidateCache(const rational& start_range, const rational& end_range, NodeInput* from = nullptr) override;
/**
* @brief Adds Block `block` at the very beginning of the Sequence before all other clips
*/
@@ -145,7 +147,7 @@ public:
/**
* @brief Replaces Block `old` with Block `replace`
*
* Makes no modification to the lengths of either Blocks
* Both blocks must have equal lengths.
*/
void ReplaceBlock(Block* old, Block* replace);
@@ -186,6 +188,9 @@ private:
*/
void ValidateCurrentBlock(const rational& time);
void BlockInvalidateCache();
void UnblockInvalidateCache();
Block* attached_block();
QVector<Block*> block_cache_;
@@ -196,6 +201,8 @@ private:
NodeOutput* track_output_;
int block_invalidate_cache_stack_;
private slots:
};
+2 -2
View File
@@ -78,12 +78,12 @@ void ViewerOutput::AttachViewer(ViewerPanel *viewer)
}
}
void ViewerOutput::InvalidateCache(NodeInput* from, const rational &start_range, const rational &end_range)
void ViewerOutput::InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from)
{
// Update any attached viewer
UpdateViewer();
Node::InvalidateCache(from, start_range, end_range);
Node::InvalidateCache(start_range, end_range, from);
}
void ViewerOutput::UpdateViewer()
+1 -1
View File
@@ -47,7 +47,7 @@ public:
void AttachViewer(ViewerPanel* viewer);
virtual void InvalidateCache(NodeInput* from, const rational &start_range, const rational &end_range) override;
virtual void InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from = nullptr) override;
protected:
virtual QVariant Value(NodeOutput* output, const rational& time) override;