ported opacity node to external file format

The plan is to port all nodes that can be external to the external file format.
This should help keep things maintainable.
This commit is contained in:
itsmattkc
2019-12-15 02:51:28 +11:00
parent 845a197c99
commit 965519e9cf
11 changed files with 34 additions and 187 deletions
-1
View File
@@ -16,7 +16,6 @@
add_subdirectory(blend)
add_subdirectory(block)
add_subdirectory(color)
add_subdirectory(distort)
add_subdirectory(generator)
add_subdirectory(input)
-22
View File
@@ -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/>.
add_subdirectory(opacity)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
-22
View File
@@ -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/color/opacity/opacity.h
node/color/opacity/opacity.cpp
PARENT_SCOPE
)
-81
View File
@@ -1,81 +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/>.
***/
#include "opacity.h"
OpacityNode::OpacityNode()
{
opacity_input_ = new NodeInput("opacity_in");
opacity_input_->set_data_type(NodeParam::kFloat);
opacity_input_->set_value_at_time(0, 100);
opacity_input_->set_minimum(0);
opacity_input_->set_maximum(100);
AddInput(opacity_input_);
texture_input_ = new NodeInput("tex_in");
texture_input_->set_data_type(NodeParam::kTexture);
AddInput(texture_input_);
}
Node *OpacityNode::copy() const
{
return new OpacityNode();
}
QString OpacityNode::Name() const
{
return tr("Opacity");
}
QString OpacityNode::Category() const
{
return tr("Color");
}
QString OpacityNode::Description() const
{
return tr("Adjust an image's opacity.");
}
QString OpacityNode::id() const
{
return "org.olivevideoeditor.Olive.opacity";
}
void OpacityNode::Retranslate()
{
opacity_input_->set_name(tr("Opacity"));
texture_input_->set_name(tr("Texture"));
}
bool OpacityNode::IsAccelerated() const
{
return true;
}
QString OpacityNode::AcceleratedCodeFragment() const
{
return ReadFileAsString(":/shaders/opacity.frag");
}
NodeInput *OpacityNode::texture_input() const
{
return texture_input_;
}
-54
View File
@@ -1,54 +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/>.
***/
#ifndef OPACITYNODE_H
#define OPACITYNODE_H
#include "node/node.h"
class OpacityNode : public Node
{
Q_OBJECT
public:
OpacityNode();
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString Category() const override;
virtual QString Description() const override;
virtual QString id() const override;
virtual void Retranslate() override;
virtual bool IsAccelerated() const override;
virtual QString AcceleratedCodeFragment() const override;
NodeInput* texture_input() const;
private:
NodeInput* opacity_input_;
NodeInput* texture_input_;
};
#endif // OPACITYNODE_H
+1 -3
View File
@@ -4,7 +4,6 @@
#include "block/clip/clip.h"
#include "block/gap/gap.h"
#include "block/transition/crossdissolve/crossdissolve.h"
#include "color/opacity/opacity.h"
#include "distort/transform/transform.h"
#include "generator/solid/solid.h"
#include "input/media/video/video.h"
@@ -27,6 +26,7 @@ void NodeFactory::Initialize()
library_.append(new ExternalNode(":/shaders/gaussianblur.xml"));
library_.append(new ExternalNode(":/shaders/boxblur.xml"));
library_.append(new ExternalNode(":/shaders/opacity.xml"));
}
void NodeFactory::Destroy()
@@ -109,8 +109,6 @@ Node *NodeFactory::CreateInternal(const NodeFactory::InternalID &id)
return new GapBlock();
case kTransitionBlock:
return new CrossDissolveTransition();
case kOpacity:
return new OpacityNode();
case kTransformDistort:
return new TransformDistort();
case kSolidGenerator:
-1
View File
@@ -18,7 +18,6 @@ public:
kAudioInput,
kTransformDistort,
kTransitionBlock,
kOpacity,
kVideoInput,
kTimelineOutput,
kTrackOutput,
+2 -2
View File
@@ -1,10 +1,10 @@
#version 110
varying vec2 ove_tex_coord;
varying vec2 ove_texcoord;
uniform sampler2D tex_in;
uniform float opacity_in;
void main(void) {
gl_FragColor = texture2D(tex_in, ove_tex_coord) * (opacity_in * 0.01);
gl_FragColor = texture2D(tex_in, ove_texcoord) * (opacity_in * 0.01);
}
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.opacity">
<!-- Effect Name -->
<name lang="en_US">Opacity</name>
<!-- Effect Category -->
<category lang="en_US">Color</category>
<category lang="en_GB">Colour</category>
<!-- Effect Description -->
<description lang="en_US">
Adjust an image's opacity (transparency).
</description>
<!-- Parameter: Texture Input -->
<param id="tex_in" type="texture">
<name lang="en_US">Texture</name>
</param>
<!-- Parameter: Opacity Value -->
<param id="opacity_in" type="float">
<name lang="en_US">Opacity</name>
<min>0</min>
<max>100</max>
<default>100</default>
</param>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/opacity.frag" />
</effect>
+1
View File
@@ -8,6 +8,7 @@
<file>gaussianblur.frag</file>
<file>gaussianblur.xml</file>
<file>opacity.frag</file>
<file>opacity.xml</file>
<file>solid.frag</file>
<file>videoinput.frag</file>
<file>videoinput.vert</file>
@@ -27,7 +27,6 @@
#include "common/qtversionabstraction.h"
#include "core.h"
#include "node/distort/transform/transform.h"
#include "node/color/opacity/opacity.h"
#include "node/input/media/audio/audio.h"
#include "node/input/media/video/video.h"
#include "widget/nodeview/nodeviewundo.h"