From 46b3f9db489029906ae24c0858a2ea6539bba6e5 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 15 Dec 2019 03:41:37 +1100 Subject: [PATCH] moved alphaover to external file format --- app/node/CMakeLists.txt | 1 - app/node/blend/CMakeLists.txt | 24 ----------- app/node/blend/alphaover/CMakeLists.txt | 22 ---------- app/node/blend/alphaover/alphaover.cpp | 56 ------------------------- app/node/blend/alphaover/alphaover.h | 45 -------------------- app/node/blend/blend.cpp | 53 ----------------------- app/node/blend/blend.h | 46 -------------------- app/node/factory.cpp | 4 +- app/node/factory.h | 1 - app/node/output/timeline/tracklist.cpp | 8 ++-- app/shaders/alphaover.xml | 24 +++++++++++ app/shaders/shaders.qrc | 1 + 12 files changed, 30 insertions(+), 255 deletions(-) delete mode 100644 app/node/blend/CMakeLists.txt delete mode 100644 app/node/blend/alphaover/CMakeLists.txt delete mode 100644 app/node/blend/alphaover/alphaover.cpp delete mode 100644 app/node/blend/alphaover/alphaover.h delete mode 100644 app/node/blend/blend.cpp delete mode 100644 app/node/blend/blend.h create mode 100644 app/shaders/alphaover.xml diff --git a/app/node/CMakeLists.txt b/app/node/CMakeLists.txt index cdd553e3f..d301deca5 100644 --- a/app/node/CMakeLists.txt +++ b/app/node/CMakeLists.txt @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -add_subdirectory(blend) add_subdirectory(block) add_subdirectory(distort) add_subdirectory(input) diff --git a/app/node/blend/CMakeLists.txt b/app/node/blend/CMakeLists.txt deleted file mode 100644 index 645e6b7a9..000000000 --- a/app/node/blend/CMakeLists.txt +++ /dev/null @@ -1,24 +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 . - -add_subdirectory(alphaover) - -set(OLIVE_SOURCES - ${OLIVE_SOURCES} - node/blend/blend.h - node/blend/blend.cpp - PARENT_SCOPE -) diff --git a/app/node/blend/alphaover/CMakeLists.txt b/app/node/blend/alphaover/CMakeLists.txt deleted file mode 100644 index e2af3e24d..000000000 --- a/app/node/blend/alphaover/CMakeLists.txt +++ /dev/null @@ -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 . - -set(OLIVE_SOURCES - ${OLIVE_SOURCES} - node/blend/alphaover/alphaover.h - node/blend/alphaover/alphaover.cpp - PARENT_SCOPE -) diff --git a/app/node/blend/alphaover/alphaover.cpp b/app/node/blend/alphaover/alphaover.cpp deleted file mode 100644 index e21d09f44..000000000 --- a/app/node/blend/alphaover/alphaover.cpp +++ /dev/null @@ -1,56 +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 . - -***/ - -#include "alphaover.h" - -AlphaOverBlend::AlphaOverBlend() -{ - -} - -Node *AlphaOverBlend::copy() const -{ - return new AlphaOverBlend(); -} - -QString AlphaOverBlend::Name() const -{ - return tr("Alpha Over"); -} - -QString AlphaOverBlend::id() const -{ - return "org.olivevideoeditor.Olive.alphaoverblend"; -} - -QString AlphaOverBlend::Description() const -{ - return tr("A blending node that composites one texture over another using its alpha channel."); -} - -bool AlphaOverBlend::IsAccelerated() const -{ - return true; -} - -QString AlphaOverBlend::AcceleratedCodeFragment() const -{ - return ReadFileAsString(":/shaders/alphaover.frag"); -} diff --git a/app/node/blend/alphaover/alphaover.h b/app/node/blend/alphaover/alphaover.h deleted file mode 100644 index 9667c08ec..000000000 --- a/app/node/blend/alphaover/alphaover.h +++ /dev/null @@ -1,45 +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 . - -***/ - -#ifndef ALPHAOVER_H -#define ALPHAOVER_H - -#include "node/blend/blend.h" - -class AlphaOverBlend : public BlendNode -{ -public: - AlphaOverBlend(); - - 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; - -protected: - -private: -}; - -#endif // ALPHAOVER_H diff --git a/app/node/blend/blend.cpp b/app/node/blend/blend.cpp deleted file mode 100644 index 1d18439fd..000000000 --- a/app/node/blend/blend.cpp +++ /dev/null @@ -1,53 +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 . - -***/ - -#include "blend.h" - -BlendNode::BlendNode() -{ - base_input_ = new NodeInput("base_in"); - base_input_->set_data_type(NodeParam::kTexture); - AddInput(base_input_); - - blend_input_ = new NodeInput("blend_in"); - blend_input_->set_data_type(NodeParam::kTexture); - AddInput(blend_input_); -} - -QString BlendNode::Category() const -{ - return tr("Blend"); -} - -NodeInput *BlendNode::base_input() const -{ - return base_input_; -} - -NodeInput *BlendNode::blend_input() const -{ - return blend_input_; -} - -void BlendNode::Retranslate() -{ - base_input_->set_name(tr("Base")); - blend_input_->set_name(tr("Blend")); -} diff --git a/app/node/blend/blend.h b/app/node/blend/blend.h deleted file mode 100644 index 5dc84b834..000000000 --- a/app/node/blend/blend.h +++ /dev/null @@ -1,46 +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 . - -***/ - -#ifndef BLEND_H -#define BLEND_H - -#include "node/node.h" - -class BlendNode : public Node -{ -public: - BlendNode(); - - virtual QString Category() const override; - - NodeInput* base_input() const; - - NodeInput* blend_input() const; - - virtual void Retranslate() override; - -private: - NodeInput* base_input_; - - NodeInput* blend_input_; - -}; - -#endif // BLEND_H diff --git a/app/node/factory.cpp b/app/node/factory.cpp index c63603975..4583951bd 100644 --- a/app/node/factory.cpp +++ b/app/node/factory.cpp @@ -1,6 +1,5 @@ #include "factory.h" -#include "blend/alphaover/alphaover.h" #include "block/clip/clip.h" #include "block/gap/gap.h" #include "block/transition/crossdissolve/crossdissolve.h" @@ -27,6 +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")); } void NodeFactory::Destroy() @@ -112,8 +112,6 @@ Node *NodeFactory::CreateFromID(const QString &id) Node *NodeFactory::CreateInternal(const NodeFactory::InternalID &id) { switch (id) { - case kAlphaOverBlend: - return new AlphaOverBlend(); case kClipBlock: return new ClipBlock(); case kGapBlock: diff --git a/app/node/factory.h b/app/node/factory.h index 6ffb17585..adea970d1 100644 --- a/app/node/factory.h +++ b/app/node/factory.h @@ -13,7 +13,6 @@ public: kViewerOutput, kClipBlock, kGapBlock, - kAlphaOverBlend, kAudioInput, kTransformDistort, kTransitionBlock, diff --git a/app/node/output/timeline/tracklist.cpp b/app/node/output/timeline/tracklist.cpp index 79c7968f2..f944332a8 100644 --- a/app/node/output/timeline/tracklist.cpp +++ b/app/node/output/timeline/tracklist.cpp @@ -20,7 +20,7 @@ #include "tracklist.h" -#include "node/blend/alphaover/alphaover.h" +#include "node/factory.h" #include "timeline.h" TrackList::TrackList(TimelineOutput* parent, const enum TrackType &type, NodeInputArray *track_input) : @@ -117,11 +117,11 @@ TrackOutput* TrackList::AddTrack() if (last_track && last_track->output()->IsConnected()) { foreach (NodeEdgePtr edge, last_track->output()->edges()) { if (edge->input()->parentNode() != track_input_->parentNode()) { - AlphaOverBlend* blend = new AlphaOverBlend(); + Node* blend = NodeFactory::CreateFromID("org.olivevideoeditor.Olive.alphaoverblend"); GetParentGraph()->AddNode(blend); - NodeParam::ConnectEdge(track->output(), blend->blend_input()); - NodeParam::ConnectEdge(last_track->output(), blend->base_input()); + NodeParam::ConnectEdge(track->output(), static_cast(blend->GetParameterWithID("blend_in"))); + NodeParam::ConnectEdge(last_track->output(), static_cast(blend->GetParameterWithID("base_in"))); NodeParam::ConnectEdge(blend->output(), edge->input()); } } diff --git a/app/shaders/alphaover.xml b/app/shaders/alphaover.xml new file mode 100644 index 000000000..e9df1a47b --- /dev/null +++ b/app/shaders/alphaover.xml @@ -0,0 +1,24 @@ + + + + Alpha Over + + + Blend + + + + A blending node that composites one texture over another using its alpha channel. + + + + + Base + + + Blend + + + + + diff --git a/app/shaders/shaders.qrc b/app/shaders/shaders.qrc index 5eb6cd753..4c389df86 100644 --- a/app/shaders/shaders.qrc +++ b/app/shaders/shaders.qrc @@ -1,6 +1,7 @@ alphaover.frag + alphaover.xml boxblur.frag boxblur.xml crossdissolve.frag