several adjustments to node caching system
This commit is contained in:
@@ -127,8 +127,6 @@ void Block::Refresh()
|
||||
// Update out point by adding this clip's length to the just calculated in point
|
||||
out_point_ = in_point_ + length();
|
||||
|
||||
InvalidateCache(in_point_, out_point_);
|
||||
|
||||
emit Refreshed();
|
||||
}
|
||||
|
||||
@@ -176,7 +174,7 @@ void Block::set_media_in(const rational &media_in)
|
||||
media_in_ = media_in;
|
||||
|
||||
// Signal that this clips contents have changed
|
||||
InvalidateCache(in(), out());
|
||||
InvalidateCache(nullptr, in(), out());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,3 +187,23 @@ QList<NodeDependency> Block::RunDependencies(NodeOutput* param, const rational &
|
||||
|
||||
return QList<NodeDependency>();
|
||||
}
|
||||
|
||||
rational Block::SequenceToMediaTime(const rational &sequence_time)
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
if (sequence_time == RATIONAL_MIN || sequence_time == RATIONAL_MAX) {
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
return sequence_time - in() + media_in();
|
||||
}
|
||||
|
||||
rational Block::MediaToSequenceTime(const rational &media_time)
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
if (media_time == RATIONAL_MIN || media_time == RATIONAL_MAX) {
|
||||
return media_time;
|
||||
}
|
||||
|
||||
return media_time - media_in() + in();
|
||||
}
|
||||
|
||||
@@ -104,6 +104,10 @@ signals:
|
||||
protected:
|
||||
virtual QVariant Value(NodeOutput* output, const rational& time) override;
|
||||
|
||||
rational SequenceToMediaTime(const rational& sequence_time);
|
||||
|
||||
rational MediaToSequenceTime(const rational& media_time);
|
||||
|
||||
private:
|
||||
NodeInput* previous_input_;
|
||||
NodeOutput* block_output_;
|
||||
|
||||
@@ -67,11 +67,6 @@ NodeInput *ClipBlock::texture_input()
|
||||
return texture_input_;
|
||||
}
|
||||
|
||||
rational ClipBlock::SequenceToMediaTime(const rational &sequence_time)
|
||||
{
|
||||
return sequence_time - in() + media_in();
|
||||
}
|
||||
|
||||
QVariant ClipBlock::Value(NodeOutput* param, const rational& time)
|
||||
{
|
||||
QVariant value = Block::Value(param, time);
|
||||
@@ -80,7 +75,7 @@ QVariant ClipBlock::Value(NodeOutput* param, const rational& time)
|
||||
// If the time retrieved is within this block, get texture information
|
||||
if (time >= in() && time < out()) {
|
||||
// We convert the time given (timeline time) to media time
|
||||
rational media_time = SequenceToMediaTime(time - in() + media_in());
|
||||
rational media_time = SequenceToMediaTime(time);
|
||||
|
||||
// Retrieve texture
|
||||
return texture_input_->get_value(media_time);
|
||||
@@ -90,3 +85,21 @@ QVariant ClipBlock::Value(NodeOutput* param, const rational& time)
|
||||
|
||||
return Block::Value(param, time);
|
||||
}
|
||||
|
||||
void ClipBlock::InvalidateCache(NodeInput *from, const rational &start_range, const rational &end_range)
|
||||
{
|
||||
// If signal is from texture input, transform all times from media time to sequence time
|
||||
if (from == texture_input_) {
|
||||
rational start = MediaToSequenceTime(start_range);
|
||||
rational end = MediaToSequenceTime(end_range);
|
||||
|
||||
// Limit cache invalidation to clip lengths
|
||||
start = qMax(start, in());
|
||||
end = qMin(end, out());
|
||||
|
||||
Node::InvalidateCache(from, start, end);
|
||||
} else {
|
||||
// Otherwise, pass signal along normally
|
||||
Node::InvalidateCache(from, start_range, end_range);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ public:
|
||||
|
||||
NodeInput* texture_input();
|
||||
|
||||
virtual void InvalidateCache(NodeInput *from, const rational &start_range, const rational &end_range) override;
|
||||
|
||||
protected:
|
||||
virtual QVariant Value(NodeOutput* output, const rational& time) override;
|
||||
|
||||
private:
|
||||
rational SequenceToMediaTime(const rational& sequence_time);
|
||||
|
||||
NodeInput* texture_input_;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user