nodes: optimize blocks so they don't unnecessarily change the hash
This commit is contained in:
@@ -365,4 +365,9 @@ void Block::InvalidateCache(const TimeRange &range, NodeInput *from, NodeInput *
|
||||
Node::InvalidateCache(range, from, source);
|
||||
}
|
||||
|
||||
void Block::Hash(QCryptographicHash &, const rational &) const
|
||||
{
|
||||
// A block does nothing by default
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -99,6 +99,8 @@ public:
|
||||
|
||||
virtual void InvalidateCache(const TimeRange& range, NodeInput* from, NodeInput* source) override;
|
||||
|
||||
virtual void Hash(QCryptographicHash &hash, const rational &time) const override;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
|
||||
@@ -119,4 +119,13 @@ void ClipBlock::Retranslate()
|
||||
texture_input_->set_name(tr("Buffer"));
|
||||
}
|
||||
|
||||
void ClipBlock::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
{
|
||||
if (texture_input_->IsConnected()) {
|
||||
rational t = InputTimeAdjustment(texture_input_, TimeRange(time, time)).in();
|
||||
|
||||
texture_input_->get_connected_node()->Hash(hash, t);
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void Hash(QCryptographicHash &hash, const rational &time) const override;
|
||||
|
||||
signals:
|
||||
void PreviewUpdated();
|
||||
|
||||
|
||||
@@ -131,8 +131,6 @@ double TransitionBlock::GetInProgress(const rational &time) const
|
||||
|
||||
void TransitionBlock::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
{
|
||||
Block::Hash(hash, time);
|
||||
|
||||
double all_prog = GetTotalProgress(time);
|
||||
double in_prog = GetInProgress(time);
|
||||
double out_prog = GetOutProgress(time);
|
||||
@@ -140,6 +138,14 @@ void TransitionBlock::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
hash.addData(reinterpret_cast<const char*>(&all_prog), sizeof(double));
|
||||
hash.addData(reinterpret_cast<const char*>(&in_prog), sizeof(double));
|
||||
hash.addData(reinterpret_cast<const char*>(&out_prog), sizeof(double));
|
||||
|
||||
if (out_block_input_->IsConnected()) {
|
||||
out_block_input_->get_connected_node()->Hash(hash, time);
|
||||
}
|
||||
|
||||
if (in_block_input_->IsConnected()) {
|
||||
in_block_input_->get_connected_node()->Hash(hash, time);
|
||||
}
|
||||
}
|
||||
|
||||
double TransitionBlock::GetInternalTransitionTime(const rational &time) const
|
||||
|
||||
@@ -420,11 +420,11 @@ NodeInputArray *TrackOutput::block_input() const
|
||||
|
||||
void TrackOutput::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
{
|
||||
// Resolve block list
|
||||
Block* b = BlockAtTime(time);
|
||||
|
||||
// Defer to block at this time, don't add any of our own information to the hash
|
||||
if (b) {
|
||||
return b->Hash(hash, time);
|
||||
b->Hash(hash, time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user