ported crossdissolve to external shader

This commit is contained in:
itsmattkc
2019-12-17 15:58:16 +11:00
parent 6a4dcc673a
commit 4e6da87585
12 changed files with 33 additions and 88 deletions
+3
View File
@@ -43,6 +43,9 @@ Block::Block() :
media_out_input_->SetConnectable(false);
media_out_input_->set_data_type(NodeParam::kRational);
AddInput(media_out_input_);
// A block's length must be greater than 0
set_length(1);
}
QString Block::Category() const
-1
View File
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(crossdissolve)
add_subdirectory(diptoblack)
set(OLIVE_SOURCES
@@ -1,22 +0,0 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/block/transition/crossdissolve/crossdissolve.h
node/block/transition/crossdissolve/crossdissolve.cpp
PARENT_SCOPE
)
@@ -1,35 +0,0 @@
#include "crossdissolve.h"
Node *CrossDissolveTransition::copy() const
{
CrossDissolveTransition* c = new CrossDissolveTransition();
CopyParameters(this, c);
return c;
}
QString CrossDissolveTransition::Name() const
{
return tr("Cross Dissolve");
}
QString CrossDissolveTransition::id() const
{
return "org.olivevideoeditor.Olive.crossdissolve";
}
QString CrossDissolveTransition::Description() const
{
return tr("A smooth fade transition from one video clip to another.");
}
bool CrossDissolveTransition::IsAccelerated() const
{
return true;
}
QString CrossDissolveTransition::AcceleratedCodeFragment() const
{
return ReadFileAsString(":/shaders/crossdissolve.frag");
}
@@ -1,21 +0,0 @@
#ifndef CROSSDISSOLVETRANSITION_H
#define CROSSDISSOLVETRANSITION_H
#include "../transition.h"
class CrossDissolveTransition : public TransitionBlock
{
public:
CrossDissolveTransition() = default;
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Description() const override;
virtual bool IsAccelerated() const override;
virtual QString AcceleratedCodeFragment() const override;
};
#endif // CROSSDISSOLVETRANSITION_H
@@ -10,7 +10,11 @@ ExternalTransition::ExternalTransition(const QString &xml_meta_filename) :
Node *ExternalTransition::copy() const
{
return new ExternalTransition(meta_.filename());
ExternalTransition* t = new ExternalTransition(meta_.filename());
CopyParameters(this, t);
return t;
}
QString ExternalTransition::Name() const
+3
View File
@@ -9,6 +9,9 @@ TransitionBlock::TransitionBlock()
in_block_input_ = new NodeInput("in_block_in");
in_block_input_->set_data_type(NodeParam::kBuffer);
AddInput(in_block_input_);
// A block's length must be greater than 0
set_in_and_out_offset(1, 1);
}
Block::Type TransitionBlock::type() const
+2 -4
View File
@@ -2,7 +2,7 @@
#include "block/clip/clip.h"
#include "block/gap/gap.h"
#include "block/transition/crossdissolve/crossdissolve.h"
#include "block/transition/externaltransition.h"
#include "distort/transform/transform.h"
#include "input/media/video/video.h"
#include "input/media/audio/audio.h"
@@ -26,7 +26,7 @@ void NodeFactory::Initialize()
library_.append(new ExternalNode(":/shaders/boxblur.xml"));
library_.append(new ExternalNode(":/shaders/opacity.xml"));
library_.append(new ExternalNode(":/shaders/solid.xml"));
library_.append(new ExternalNode(":/shaders/alphaover.xml"));
library_.append(new ExternalTransition(":/shaders/crossdissolve.xml"));
}
void NodeFactory::Destroy()
@@ -116,8 +116,6 @@ Node *NodeFactory::CreateInternal(const NodeFactory::InternalID &id)
return new ClipBlock();
case kGapBlock:
return new GapBlock();
case kTransitionBlock:
return new CrossDissolveTransition();
case kTransformDistort:
return new TransformDistort();
case kVideoInput:
-1
View File
@@ -15,7 +15,6 @@ public:
kGapBlock,
kAudioInput,
kTransformDistort,
kTransitionBlock,
kVideoInput,
kTimelineOutput,
kTrackOutput,
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.crossdissolve">
<!-- Effect Name -->
<name lang="en_US">Cross Dissolve</name>
<!-- Effect Category -->
<category lang="en_US">Transition</category>
<!-- Effect Description -->
<description lang="en_US">
A smooth fade transition from one video clip to another.
</description>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/crossdissolve.frag"/>
</effect>
+1
View File
@@ -5,6 +5,7 @@
<file>boxblur.frag</file>
<file>boxblur.xml</file>
<file>crossdissolve.frag</file>
<file>crossdissolve.xml</file>
<file>diptoblack.frag</file>
<file>gaussianblur.frag</file>
<file>gaussianblur.xml</file>
@@ -1,7 +1,7 @@
#include "widget/timelinewidget/timelinewidget.h"
#include "node/block/transition/crossdissolve/crossdissolve.h"
#include "node/block/transition/diptoblack/diptoblack.h"
#include "node/block/transition/transition.h"
#include "node/factory.h"
#include "widget/nodeview/nodeviewundo.h"
TimelineWidget::TransitionTool::TransitionTool(TimelineWidget *parent) :
@@ -89,7 +89,7 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
if (ghost_) {
if (!ghost_->AdjustedLength().isNull()) {
CrossDissolveTransition* transition = new CrossDissolveTransition();
TransitionBlock* transition = static_cast<TransitionBlock*>(NodeFactory::CreateFromID("org.olivevideoeditor.Olive.crossdissolve"));
QUndoCommand* command = new QUndoCommand();