Merge branch 'master' into gizmos

This commit is contained in:
itsmattkc
2020-05-06 16:35:40 +10:00
86 changed files with 1276 additions and 1589 deletions
+4 -3
View File
@@ -174,9 +174,10 @@ FramePtr OIIODecoder::RetrieveVideo(const rational &timecode, const int& divider
FramePtr frame = Frame::Create();
frame->set_video_params(VideoRenderingParams(buffer_->spec().width / divider,
buffer_->spec().height / divider,
pix_fmt_));
frame->set_video_params(VideoRenderingParams(buffer_->spec().width,
buffer_->spec().height,
pix_fmt_,
divider));
frame->allocate();
if (divider == 1) {
+10
View File
@@ -83,6 +83,16 @@ void Config::SetDefaults()
config_map_["DropWithoutSequenceBehavior"] = TimelineWidget::kDWSAsk;
config_map_["Loop"] = false;
config_map_["NodeCatColor0"] = QVariant::fromValue(Color(0.25, 0.25, 0.65));
config_map_["NodeCatColor1"] = QVariant::fromValue(Color(0.6, 0.6, 0.85));
config_map_["NodeCatColor2"] = QVariant::fromValue(Color(0.75, 0.75, 0.45));
config_map_["NodeCatColor3"] = QVariant::fromValue(Color(0.25, 0.5, 0.25));
config_map_["NodeCatColor4"] = QVariant::fromValue(Color(0.25, 0.65, 0.25));
config_map_["NodeCatColor5"] = QVariant::fromValue(Color(0.35, 0.35, 0.35));
config_map_["NodeCatColor6"] = QVariant::fromValue(Color(0.45, 0.45, 0.45));
config_map_["NodeCatColor7"] = QVariant::fromValue(Color(0.7, 0.3, 0.7));
config_map_["NodeCatColor8"] = QVariant::fromValue(Color(0.85, 0.65, 0.4));
config_map_["AudioOutput"] = QString();
config_map_["AudioInput"] = QString();
@@ -20,10 +20,14 @@
#include "preferencesappearancetab.h"
#include <QColorDialog>
#include <QFileDialog>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include "node/node.h"
#include "widget/colorbutton/colorbutton.h"
OLIVE_NAMESPACE_ENTER
@@ -44,7 +48,7 @@ PreferencesAppearanceTab::PreferencesAppearanceTab()
style_list_ = StyleManager::ListInternal();
foreach (StyleDescriptor s, style_list_) {
foreach (const StyleDescriptor& s, style_list_) {
style_->addItem(s.name(), s.path());
if (s.path() == StyleManager::GetStyle()) {
@@ -52,10 +56,34 @@ PreferencesAppearanceTab::PreferencesAppearanceTab()
}
}
appearance_layout->addWidget(style_, row, 1, 1, 2);
appearance_layout->addWidget(style_, row, 1);
row++;
{
QGroupBox* color_group = new QGroupBox();
color_group->setTitle(tr("Node Color Scheme"));
QGridLayout* color_layout = new QGridLayout(color_group);
for (int i=0; i<Node::kCategoryCount; i++) {
QString cat_name = Node::GetCategoryName(static_cast<Node::CategoryID>(i));
color_layout->addWidget(new QLabel(cat_name), i, 0);
Color c = Config::Current()[QStringLiteral("NodeCatColor%1").arg(i)].value<Color>();
colors_.append(c.toQColor());
QPushButton* color_btn = new QPushButton();
connect(color_btn, &QPushButton::clicked, this, &PreferencesAppearanceTab::ColorButtonClicked);
color_layout->addWidget(color_btn, i, 1);
color_btns_.append(color_btn);
UpdateButtonColor(i);
}
appearance_layout->addWidget(color_group, row, 0, 1, 2);
}
layout->addStretch();
}
@@ -67,6 +95,29 @@ void PreferencesAppearanceTab::Accept()
StyleManager::SetStyle(style_path);
Config::Current()["Style"] = style_path;
}
for (int i=0;i<colors_.size();i++) {
Config::Current()[QStringLiteral("NodeCatColor%1").arg(i)] = QVariant::fromValue(Color(colors_.at(i)));
}
}
void PreferencesAppearanceTab::UpdateButtonColor(int index)
{
color_btns_.at(index)->setStyleSheet(QStringLiteral("background: %1;")
.arg(colors_.at(index).name()));
}
void PreferencesAppearanceTab::ColorButtonClicked()
{
int index = color_btns_.indexOf(static_cast<QPushButton*>(sender()));
QColor new_color = QColorDialog::getColor(colors_.at(index), this);
if (new_color.isValid()) {
colors_.replace(index, new_color);
UpdateButtonColor(index);
}
}
OLIVE_NAMESPACE_EXIT
@@ -23,6 +23,7 @@
#include <QComboBox>
#include <QLineEdit>
#include <QPushButton>
#include "preferencestab.h"
#include "ui/style/style.h"
@@ -43,6 +44,8 @@ private:
*/
void BrowseForCSS();
void UpdateButtonColor(int index);
/**
* @brief UI widget for selecting the current UI style
*/
@@ -54,6 +57,14 @@ private:
QList<StyleDescriptor> style_list_;
QString custom_style_path_;
QList<QColor> colors_;
QList<QPushButton*> color_btns_;
private slots:
void ColorButtonClicked();
};
OLIVE_NAMESPACE_EXIT
@@ -177,7 +177,7 @@ void ProjectPropertiesDialog::OCIOFilenameUpdated()
if (ocio_filename_->text().isEmpty()) {
c = ColorManager::GetDefaultConfig();
} else {
c = OCIO::Config::CreateFromFile(ocio_filename_->text().toUtf8());
c = ColorManager::CreateConfigFromFile(ocio_filename_->text());
}
ocio_filename_->setStyleSheet(QString());
+1 -4
View File
@@ -16,6 +16,7 @@
add_subdirectory(audio)
add_subdirectory(block)
add_subdirectory(filter)
add_subdirectory(generator)
add_subdirectory(input)
add_subdirectory(math)
@@ -27,8 +28,6 @@ set(OLIVE_SOURCES
node/dependency.cpp
node/edge.h
node/edge.cpp
node/external.h
node/external.cpp
node/factory.h
node/factory.cpp
node/graph.h
@@ -39,8 +38,6 @@ set(OLIVE_SOURCES
node/inputarray.cpp
node/keyframe.h
node/keyframe.cpp
node/metareader.h
node/metareader.cpp
node/node.h
node/node.cpp
node/output.h
+3 -3
View File
@@ -49,9 +49,9 @@ QString PanNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.pan");
}
QString PanNode::Category() const
QList<Node::CategoryID> PanNode::Category() const
{
return tr("Audio");
return {kCategoryChannels};
}
QString PanNode::Description() const
@@ -64,7 +64,7 @@ Node::Capabilities PanNode::GetCapabilities(const NodeValueDatabase &) const
return kSampleProcessor;
}
NodeInput *PanNode::ProcessesSamplesFrom(const NodeValueDatabase &value) const
NodeInput *PanNode::ProcessesSamplesFrom(const NodeValueDatabase &) const
{
return samples_input_;
}
+1 -1
View File
@@ -34,7 +34,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
+2 -2
View File
@@ -48,9 +48,9 @@ QString VolumeNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.volume");
}
QString VolumeNode::Category() const
QList<Node::CategoryID> VolumeNode::Category() const
{
return tr("Audio");
return {kCategoryFilter};
}
QString VolumeNode::Description() const
+1 -1
View File
@@ -34,7 +34,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
+7 -2
View File
@@ -63,9 +63,9 @@ Block::Block() :
set_length_and_media_out(1);
}
QString Block::Category() const
QList<Node::CategoryID> Block::Category() const
{
return tr("Block");
return {kCategoryTimeline};
}
const rational &Block::in() const
@@ -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
+3 -1
View File
@@ -49,7 +49,7 @@ public:
virtual Type type() const = 0;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
const rational& in() const;
const rational& out() const;
@@ -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:
+9
View File
@@ -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
+2
View File
@@ -54,6 +54,8 @@ public:
virtual void Retranslate() override;
virtual void Hash(QCryptographicHash &hash, const rational &time) const override;
signals:
void PreviewUpdated();
-2
View File
@@ -16,8 +16,6 @@
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/block/transition/externaltransition.h
node/block/transition/externaltransition.cpp
node/block/transition/transition.h
node/block/transition/transition.cpp
PARENT_SCOPE
@@ -1,93 +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 "externaltransition.h"
OLIVE_NAMESPACE_ENTER
ExternalTransition::ExternalTransition(const QString &xml_meta_filename) :
meta_(xml_meta_filename)
{
foreach (NodeInput* input, meta_.inputs()) {
AddInput(input);
}
}
Node *ExternalTransition::copy() const
{
return new ExternalTransition(meta_.filename());
}
QString ExternalTransition::Name() const
{
return meta_.Name();
}
QString ExternalTransition::ShortName() const
{
return meta_.ShortName();
}
QString ExternalTransition::id() const
{
return meta_.id();
}
QString ExternalTransition::Category() const
{
return meta_.Category();
}
QString ExternalTransition::Description() const
{
return meta_.Description();
}
void ExternalTransition::Retranslate()
{
meta_.Retranslate();
}
Node::Capabilities ExternalTransition::GetCapabilities(const NodeValueDatabase &) const
{
return kShader;
}
QString ExternalTransition::ShaderVertexCode(const NodeValueDatabase &) const
{
return meta_.vert_code();
}
QString ExternalTransition::ShaderFragmentCode(const NodeValueDatabase&) const
{
return meta_.frag_code();
}
int ExternalTransition::ShaderIterations() const
{
return meta_.iterations();
}
NodeInput *ExternalTransition::ShaderIterativeInput() const
{
return meta_.iteration_input();
}
OLIVE_NAMESPACE_EXIT
+8 -2
View File
@@ -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
-95
View File
@@ -1,95 +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 "external.h"
#include <QFile>
OLIVE_NAMESPACE_ENTER
ExternalNode::ExternalNode(const QString &xml_meta_filename) :
meta_(xml_meta_filename)
{
foreach (NodeInput* input, meta_.inputs()) {
AddInput(input);
}
}
Node *ExternalNode::copy() const
{
return new ExternalNode(meta_.filename());
}
QString ExternalNode::Name() const
{
return meta_.Name();
}
QString ExternalNode::ShortName() const
{
return meta_.ShortName();
}
QString ExternalNode::id() const
{
return meta_.id();
}
QString ExternalNode::Category() const
{
return meta_.Category();
}
QString ExternalNode::Description() const
{
return meta_.Description();
}
void ExternalNode::Retranslate()
{
meta_.Retranslate();
}
Node::Capabilities ExternalNode::GetCapabilities(const NodeValueDatabase &) const
{
return kShader;
}
QString ExternalNode::ShaderVertexCode(const NodeValueDatabase&) const
{
return meta_.vert_code();
}
QString ExternalNode::ShaderFragmentCode(const NodeValueDatabase&) const
{
return meta_.frag_code();
}
int ExternalNode::ShaderIterations() const
{
return meta_.iterations();
}
NodeInput *ExternalNode::ShaderIterativeInput() const
{
return meta_.iteration_input();
}
OLIVE_NAMESPACE_EXIT
+29 -31
View File
@@ -24,17 +24,19 @@
#include "audio/volume/volume.h"
#include "block/clip/clip.h"
#include "block/gap/gap.h"
#include "block/transition/externaltransition.h"
#include "generator/matrix/matrix.h"
#include "generator/polygon/polygon.h"
#include "generator/solid/solid.h"
#include "filter/blur/blur.h"
#include "filter/stroke/stroke.h"
#include "input/media/video/video.h"
#include "input/media/audio/audio.h"
#include "input/time/timeinput.h"
#include "math/math/math.h"
#include "math/merge/merge.h"
#include "math/trigonometry/trigonometry.h"
#include "output/track/track.h"
#include "output/viewer/viewer.h"
#include "external.h"
OLIVE_NAMESPACE_ENTER
QList<Node*> NodeFactory::library_;
@@ -48,13 +50,10 @@ void NodeFactory::Initialize()
library_.append(CreateInternal(static_cast<InternalID>(i)));
}
library_.append(new ExternalNode(":/shaders/blur.xml"));
library_.append(new ExternalNode(":/shaders/solid.xml"));
library_.append(new ExternalNode(":/shaders/stroke.xml"));
library_.append(new ExternalNode(":/shaders/alphaover.xml"));
library_.append(new ExternalNode(":/shaders/dropshadow.xml"));
/*
library_.append(new ExternalTransition(":/shaders/crossdissolve.xml"));
library_.append(new ExternalTransition(":/shaders/diptoblack.xml"));
*/
}
void NodeFactory::Destroy()
@@ -74,34 +73,25 @@ Menu *NodeFactory::CreateMenu(QWidget* parent)
// Make sure nodes are up-to-date with the current translation
n->Retranslate();
QStringList path = n->Category().split('/');
Menu* destination = nullptr;
Menu* destination = menu;
QString category_name = Node::GetCategoryName(n->Category().isEmpty()
? Node::kCategoryUnknown
: n->Category().first());
// Find destination menu based on category hierarchy
foreach (const QString& dir_name, path) {
// Ignore an empty directory
if (dir_name.isEmpty()) {
continue;
// See if a menu with this category name already exists
QList<QAction*> menu_actions = menu->actions();
foreach (QAction* action, menu_actions) {
if (action->menu() && action->menu()->title() == category_name) {
destination = static_cast<Menu*>(action->menu());
break;
}
}
// See if a menu with this dir_name already exists
bool found_cat = false;
QList<QAction*> menu_actions = destination->actions();
foreach (QAction* action, menu_actions) {
if (action->menu() && action->menu()->title() == dir_name) {
destination = static_cast<Menu*>(action->menu());
found_cat = true;
break;
}
}
// Create menu here if it doesn't exist
if (!found_cat) {
Menu* new_category = new Menu(dir_name, destination);
destination->InsertAlphabetically(new_category);
destination = new_category;
}
// Create menu here if it doesn't exist
if (!destination) {
destination = new Menu(category_name, menu);
menu->InsertAlphabetically(destination);
}
// Add entry to menu
@@ -164,6 +154,14 @@ Node *NodeFactory::CreateInternal(const NodeFactory::InternalID &id)
return new TrigonometryNode();
case kTime:
return new TimeInput();
case kBlurFilter:
return new BlurFilterNode();
case kSolidGenerator:
return new SolidGenerator();
case kMerge:
return new MergeNode();
case kStrokeFilter:
return new StrokeFilterNode();
case kInternalNodeCount:
break;
+4
View File
@@ -45,6 +45,10 @@ public:
kMath,
kTime,
kTrigonometry,
kBlurFilter,
kSolidGenerator,
kMerge,
kStrokeFilter,
// Count value
kInternalNodeCount
+23
View File
@@ -0,0 +1,23 @@
# 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(blur)
add_subdirectory(stroke)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
+22
View File
@@ -0,0 +1,22 @@
# 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/filter/blur/blur.h
node/filter/blur/blur.cpp
PARENT_SCOPE
)
+104
View File
@@ -0,0 +1,104 @@
/***
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 "blur.h"
OLIVE_NAMESPACE_ENTER
BlurFilterNode::BlurFilterNode()
{
texture_input_ = new NodeInput("tex_in", NodeParam::kTexture);
AddInput(texture_input_);
method_input_ = new NodeInput("method_in", NodeParam::kCombo, 0);
AddInput(method_input_);
radius_input_ = new NodeInput("radius_in", NodeParam::kFloat, 10.0f);
radius_input_->set_property(QStringLiteral("min"), 0.0f);
AddInput(radius_input_);
horiz_input_ = new NodeInput("horiz_in", NodeParam::kBoolean, true);
AddInput(horiz_input_);
vert_input_ = new NodeInput("vert_in", NodeParam::kBoolean, true);
AddInput(vert_input_);
repeat_edge_pixels_input_ = new NodeInput("repeat_edge_pixels_in", NodeParam::kBoolean, false);
AddInput(repeat_edge_pixels_input_);
}
Node *BlurFilterNode::copy() const
{
return new BlurFilterNode();
}
QString BlurFilterNode::Name() const
{
return tr("Blur");
}
QString BlurFilterNode::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.blur");
}
QList<Node::CategoryID> BlurFilterNode::Category() const
{
return {kCategoryFilter};
}
QString BlurFilterNode::Description() const
{
return tr("Blurs an image.");
}
void BlurFilterNode::Retranslate()
{
texture_input_->set_name(tr("Input"));
method_input_->set_name(tr("Method"));
method_input_->set_combobox_strings({ tr("Box"), tr("Gaussian") });
radius_input_->set_name(tr("Radius"));
horiz_input_->set_name(tr("Horizontal"));
vert_input_->set_name(tr("Vertical"));
repeat_edge_pixels_input_->set_name(tr("Repeat Edge Pixels"));
}
Node::Capabilities BlurFilterNode::GetCapabilities(const NodeValueDatabase &) const
{
return kShader;
}
QString BlurFilterNode::ShaderFragmentCode(const NodeValueDatabase &) const
{
return ReadFileAsString(":/shaders/blur.frag");
}
int BlurFilterNode::ShaderIterations() const
{
// FIXME: Optimize if horiz_in or vert_in is disabled
return 2;
}
NodeInput *BlurFilterNode::ShaderIterativeInput() const
{
return texture_input_;
}
OLIVE_NAMESPACE_EXIT
@@ -18,40 +18,48 @@
***/
#ifndef EXTERNALTRANSITION_H
#define EXTERNALTRANSITION_H
#ifndef BLURFILTERNODE_H
#define BLURFILTERNODE_H
#include "transition.h"
#include "node/metareader.h"
#include "node/node.h"
OLIVE_NAMESPACE_ENTER
class ExternalTransition : public TransitionBlock
class BlurFilterNode : public Node
{
public:
ExternalTransition(const QString& xml_meta_filename);
BlurFilterNode();
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString ShortName() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
virtual QString ShaderVertexCode(const NodeValueDatabase&) const override;
virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override;
virtual int ShaderIterations() const override;
virtual NodeInput* ShaderIterativeInput() const override;
private:
NodeMetaReader meta_;
NodeInput* texture_input_;
NodeInput* method_input_;
NodeInput* radius_input_;
NodeInput* horiz_input_;
NodeInput* vert_input_;
NodeInput* repeat_edge_pixels_input_;
};
OLIVE_NAMESPACE_EXIT
#endif // EXTERNALTRANSITION_H
#endif // BLURFILTERNODE_H
+22
View File
@@ -0,0 +1,22 @@
# 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/filter/stroke/stroke.h
node/filter/stroke/stroke.cpp
PARENT_SCOPE
)
+95
View File
@@ -0,0 +1,95 @@
/***
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 "stroke.h"
#include "render/color.h"
OLIVE_NAMESPACE_ENTER
StrokeFilterNode::StrokeFilterNode()
{
tex_input_ = new NodeInput("tex_in", NodeParam::kTexture);
AddInput(tex_input_);
color_input_ = new NodeInput("color_in",
NodeParam::kColor,
QVariant::fromValue(Color(1.0f, 1.0f, 1.0f, 1.0f)));
AddInput(color_input_);
radius_input_ = new NodeInput("radius_in", NodeParam::kFloat, 10.0f);
radius_input_->set_property("min", 0.0f);
AddInput(radius_input_);
opacity_input_ = new NodeInput("opacity_in", NodeParam::kFloat, 1.0f);
opacity_input_->set_property("view", "percent");
opacity_input_->set_property("min", 0.0f);
opacity_input_->set_property("max", 1.0f);
AddInput(opacity_input_);
inner_input_ = new NodeInput("inner_in", NodeParam::kBoolean, false);
AddInput(inner_input_);
}
Node *StrokeFilterNode::copy() const
{
return new StrokeFilterNode();
}
QString StrokeFilterNode::Name() const
{
return tr("Stroke");
}
QString StrokeFilterNode::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.stroke");
}
QList<Node::CategoryID> StrokeFilterNode::Category() const
{
return {kCategoryFilter};
}
QString StrokeFilterNode::Description() const
{
return tr("Creates a stroke outline around an image.");
}
void StrokeFilterNode::Retranslate()
{
tex_input_->set_name(tr("Input"));
color_input_->set_name(tr("Color"));
radius_input_->set_name(tr("Radius"));
opacity_input_->set_name(tr("Opacity"));
inner_input_->set_name(tr("Inner"));
}
Node::Capabilities StrokeFilterNode::GetCapabilities(const NodeValueDatabase &) const
{
return kShader;
}
QString StrokeFilterNode::ShaderFragmentCode(const NodeValueDatabase &) const
{
return ReadFileAsString(":/shaders/stroke.frag");
}
OLIVE_NAMESPACE_EXIT
@@ -18,44 +18,43 @@
***/
#ifndef EXTERNALNODE_H
#define EXTERNALNODE_H
#ifndef STROKEFILTERNODE_H
#define STROKEFILTERNODE_H
#include <QXmlStreamReader>
#include "node.h"
#include "metareader.h"
#include "node/node.h"
OLIVE_NAMESPACE_ENTER
/**
* @brief A node generated from an external XML metadata file
*/
class ExternalNode : public Node
class StrokeFilterNode : public Node
{
public:
ExternalNode(const QString& xml_meta_filename);
StrokeFilterNode();
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString ShortName() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
virtual QString ShaderVertexCode(const NodeValueDatabase&) const override;
virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override;
virtual int ShaderIterations() const override;
virtual NodeInput* ShaderIterativeInput() const override;
private:
NodeMetaReader meta_;
NodeInput* tex_input_;
NodeInput* color_input_;
NodeInput* radius_input_;
NodeInput* opacity_input_;
NodeInput* inner_input_;
};
OLIVE_NAMESPACE_EXIT
#endif // EXTERNALNODE_H
#endif // STROKEFILTERNODE_H
+1
View File
@@ -16,6 +16,7 @@
add_subdirectory(matrix)
add_subdirectory(polygon)
add_subdirectory(solid)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
+2 -2
View File
@@ -69,9 +69,9 @@ QString MatrixGenerator::id() const
return QStringLiteral("org.olivevideoeditor.Olive.transform");
}
QString MatrixGenerator::Category() const
QList<Node::CategoryID> MatrixGenerator::Category() const
{
return tr("Generator");
return {kCategoryGenerator, kCategoryMath};
}
QString MatrixGenerator::Description() const
+1 -1
View File
@@ -36,7 +36,7 @@ public:
virtual QString Name() const override;
virtual QString ShortName() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
+22
View File
@@ -0,0 +1,22 @@
# 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/generator/solid/solid.h
node/generator/solid/solid.cpp
PARENT_SCOPE
)
+76
View File
@@ -0,0 +1,76 @@
/***
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 "solid.h"
#include "render/color.h"
OLIVE_NAMESPACE_ENTER
SolidGenerator::SolidGenerator()
{
// Default to a color that isn't black
color_input_ = new NodeInput("color_in",
NodeInput::kColor,
QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f)));
AddInput(color_input_);
}
Node *SolidGenerator::copy() const
{
return new SolidGenerator();
}
QString SolidGenerator::Name() const
{
return tr("Solid");
}
QString SolidGenerator::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.solidgenerator");
}
QList<Node::CategoryID> SolidGenerator::Category() const
{
return {kCategoryGenerator};
}
QString SolidGenerator::Description() const
{
return tr("Generate a solid color.");
}
void SolidGenerator::Retranslate()
{
color_input_->set_name(tr("Color"));
}
Node::Capabilities SolidGenerator::GetCapabilities(const NodeValueDatabase &) const
{
return kShader;
}
QString SolidGenerator::ShaderFragmentCode(const NodeValueDatabase &) const
{
return ReadFileAsString(":/shaders/solid.frag");
}
OLIVE_NAMESPACE_EXIT
+52
View File
@@ -0,0 +1,52 @@
/***
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 SOLIDGENERATOR_H
#define SOLIDGENERATOR_H
#include "node/node.h"
OLIVE_NAMESPACE_ENTER
class SolidGenerator : public Node
{
public:
SolidGenerator();
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString id() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override;
private:
NodeInput* color_input_;
};
OLIVE_NAMESPACE_EXIT
#endif // SOLIDGENERATOR_H
+2 -2
View File
@@ -35,9 +35,9 @@ MediaInput::MediaInput() :
AddInput(footage_input_);
}
QString MediaInput::Category() const
QList<Node::CategoryID> MediaInput::Category() const
{
return tr("Input");
return {kCategoryInput};
}
StreamPtr MediaInput::footage()
+1 -1
View File
@@ -35,7 +35,7 @@ class MediaInput : public Node
public:
MediaInput();
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
StreamPtr footage();
void SetFootage(StreamPtr f);
+2 -2
View File
@@ -41,9 +41,9 @@ QString TimeInput::id() const
return QStringLiteral("org.olivevideoeditor.Olive.time");
}
QString TimeInput::Category() const
QList<Node::CategoryID> TimeInput::Category() const
{
return tr("Input");
return {kCategoryInput};
}
QString TimeInput::Description() const
+1 -1
View File
@@ -35,7 +35,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(math)
add_subdirectory(merge)
add_subdirectory(trigonometry)
set(OLIVE_SOURCES
+2 -2
View File
@@ -61,9 +61,9 @@ QString MathNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.math");
}
QString MathNode::Category() const
QList<Node::CategoryID> MathNode::Category() const
{
return tr("Math");
return {kCategoryMath};
}
QString MathNode::Description() const
+1 -1
View File
@@ -34,7 +34,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
+22
View File
@@ -0,0 +1,22 @@
# 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/math/merge/merge.h
node/math/merge/merge.cpp
PARENT_SCOPE
)
+96
View File
@@ -0,0 +1,96 @@
/***
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 "merge.h"
OLIVE_NAMESPACE_ENTER
MergeNode::MergeNode()
{
base_in_ = new NodeInput("base_in", NodeParam::kTexture);
AddInput(base_in_);
blend_in_ = new NodeInput("blend_in", NodeParam::kTexture);
AddInput(blend_in_);
}
Node *MergeNode::copy() const
{
return new MergeNode();
}
QString MergeNode::Name() const
{
return tr("Merge");
}
QString MergeNode::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.merge");
}
QList<Node::CategoryID> MergeNode::Category() const
{
return {kCategoryMath};
}
QString MergeNode::Description() const
{
return tr("Merge two textures together.");
}
void MergeNode::Retranslate()
{
base_in_->set_name(tr("Base"));
blend_in_->set_name(tr("Blend"));
}
Node::Capabilities MergeNode::GetCapabilities(const NodeValueDatabase &) const
{
return kShader;
}
QString MergeNode::ShaderFragmentCode(const NodeValueDatabase &) const
{
return ReadFileAsString(":/shaders/alphaover.frag");
}
NodeInput *MergeNode::base_in() const
{
return base_in_;
}
NodeInput *MergeNode::blend_in() const
{
return blend_in_;
}
void MergeNode::Hash(QCryptographicHash &hash, const rational &time) const
{
if (base_in_->IsConnected()) {
base_in_->get_connected_node()->Hash(hash, time);
}
if (blend_in_->IsConnected()) {
blend_in_->get_connected_node()->Hash(hash, time);
}
}
OLIVE_NAMESPACE_EXIT
+59
View File
@@ -0,0 +1,59 @@
/***
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 MERGENODE_H
#define MERGENODE_H
#include "node/node.h"
OLIVE_NAMESPACE_ENTER
class MergeNode : public Node
{
public:
MergeNode();
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString id() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
virtual QString ShaderFragmentCode(const NodeValueDatabase&) const override;
NodeInput* base_in() const;
NodeInput* blend_in() const;
virtual void Hash(QCryptographicHash &hash, const rational &time) const override;
private:
NodeInput* base_in_;
NodeInput* blend_in_;
};
OLIVE_NAMESPACE_EXIT
#endif // MERGENODE_H
+2 -2
View File
@@ -48,9 +48,9 @@ QString TrigonometryNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.trigonometry");
}
QString TrigonometryNode::Category() const
QList<Node::CategoryID> TrigonometryNode::Category() const
{
return tr("Math");
return {kCategoryMath};
}
QString TrigonometryNode::Description() const
+1 -1
View File
@@ -34,7 +34,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
virtual void Retranslate() override;
-386
View File
@@ -1,386 +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 "metareader.h"
#include <QFile>
#include "common/xmlutils.h"
#include "config/config.h"
#include "node.h"
OLIVE_NAMESPACE_ENTER
NodeMetaReader::NodeMetaReader(const QString &xml_meta_filename) :
xml_filename_(xml_meta_filename),
iterations_(1),
iteration_input_(nullptr)
{
QFile metadata_file(xml_filename_);
if (metadata_file.open(QFile::ReadOnly)) {
QXmlStreamReader reader(&metadata_file);
while (XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("effect")) {
XMLReadEffect(&reader);
} else {
reader.skipCurrentElement();
}
}
metadata_file.close();
} else {
qWarning() << "Failed to load node metadata file" << xml_filename_;
}
}
QString NodeMetaReader::Name() const
{
return GetStringForCurrentLanguage(&names_);
}
QString NodeMetaReader::ShortName() const
{
if (short_names_.isEmpty()) {
return Name();
} else {
return GetStringForCurrentLanguage(&short_names_);
}
}
const QString &NodeMetaReader::id() const
{
return id_;
}
QString NodeMetaReader::Category() const
{
return GetStringForCurrentLanguage(&categories_);
}
QString NodeMetaReader::Description() const
{
return GetStringForCurrentLanguage(&descriptions_);
}
const QString &NodeMetaReader::filename() const
{
return xml_filename_;
}
const QString &NodeMetaReader::frag_code() const
{
return frag_code_;
}
const QString &NodeMetaReader::vert_code() const
{
return vert_code_;
}
const int &NodeMetaReader::iterations() const
{
return iterations_;
}
NodeInput *NodeMetaReader::iteration_input() const
{
return iteration_input_;
}
const QList<NodeInput *> &NodeMetaReader::inputs() const
{
return inputs_;
}
void NodeMetaReader::Retranslate()
{
{
// Re-translate every parameter name
QMap<QString, LanguageMap>::const_iterator iterator;
// Iterate through parameter language tables that we have
for (iterator=param_names_.begin();iterator!=param_names_.end();iterator++) {
NodeInput* this_input = GetInputWithID(iterator.key());
this_input->set_name(GetStringForCurrentLanguage(&iterator.value()));
}
}
{
// Re-translate any combobox items
QMap<QString, QList<LanguageMap> >::const_iterator param_it;
for (param_it=combo_names_.begin(); param_it!=combo_names_.end(); param_it++) {
NodeInput* input = GetInputWithID(param_it.key());
QStringList combo_items;
foreach (const LanguageMap& lang_map, param_it.value()) {
combo_items.append(GetStringForCurrentLanguage(&lang_map));
}
input->set_combobox_strings(combo_items);
}
}
}
void NodeMetaReader::XMLReadLanguageString(QXmlStreamReader* reader, LanguageMap* map)
{
QString lang;
// Traverse through name attributes for its language
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("lang")) {
lang = attr.value().toString();
// We don't recognize any other "name" attributes at this time
break;
}
}
// Insert name with language into map
map->insert(lang, reader->readElementText().trimmed());
}
void NodeMetaReader::XMLReadEffect(QXmlStreamReader* reader)
{
// Traverse through effect attributes for an ID
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
id_ = attr.value().toString();
// We don't recognize any other "effect" attributes at this time
break;
}
}
if (id_.isEmpty()) {
qWarning() << "Effect metadata" << xml_filename_ << "has no ID";
return;
}
// Continue reading for other metadata
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("name")) {
// Pick up name
XMLReadLanguageString(reader, &names_);
} else if (reader->name() == QStringLiteral("shortnames")) {
// Pick up short name
XMLReadLanguageString(reader, &short_names_);
} else if (reader->name() == QStringLiteral("category")) {
// Pick up category
XMLReadLanguageString(reader, &categories_);
} else if (reader->name() == QStringLiteral("description")) {
// Pick up description
XMLReadLanguageString(reader, &descriptions_);
} else if (reader->name() == QStringLiteral("iterations")) {
// Pick up iterations
XMLReadIterations(reader);
} else if (reader->name() == QStringLiteral("fragment")) {
// Pick up fragment shader code
XMLReadShader(reader, frag_code_);
} else if (reader->name() == QStringLiteral("vertex")) {
// Pick up vertex shader code
XMLReadShader(reader, vert_code_);
} else if (reader->name() == QStringLiteral("param")) {
// Pick up a parameter
XMLReadParam(reader);
} else {
reader->skipCurrentElement();
}
}
}
void NodeMetaReader::XMLReadIterations(QXmlStreamReader* reader)
{
int iteration_pickup = reader->readElementText().toInt();
if (iterations_ > 0) {
iterations_ = iteration_pickup;
} else {
// If the iteration value is invalid, don't set it, print an error instead
qWarning() << "Invalid iteration number in" << xml_filename_ << "- setting to default (1)";
}
}
void NodeMetaReader::XMLReadParam(QXmlStreamReader *reader)
{
QString param_id;
NodeParam::DataType param_type = NodeParam::kAny;
bool is_iterative = false;
// Traverse through parameter attributes for an ID
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
param_id = attr.value().toString();
} else if (attr.name() == QStringLiteral("type")) {
param_type = NodeParam::StringToDataType(attr.value().toString());
} else if (attr.name() == QStringLiteral("iterative_input")) {
is_iterative = true;
}
}
if (param_id.isEmpty()) {
qWarning() << "Effect metadata" << xml_filename_ << "contains a parameter with no ID - parameter was not added";
return;
}
QVector<QVariant> default_val;
QHash<QString, QVariant> properties;
LanguageMap param_names;
QList<LanguageMap> combo_names;
QList<LanguageMap> combo_descriptions;
// Traverse through param contents for more data
while (XMLReadNextStartElement(reader)) {
// NOTE: readElementText() returns a string, but for number types (which min and max apply to), QVariant will
// convert them automatically
if (reader->name() == QStringLiteral("name")) {
// Insert language into map
XMLReadLanguageString(reader, &param_names);
} else if (reader->name() == QStringLiteral("default")) {
// Reads the default value
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("value")) {
default_val.append(NodeInput::StringToValue(param_type, reader->readElementText()));
} else {
reader->skipCurrentElement();
}
}
} else if (reader->name() == QStringLiteral("option")) {
// Read names and descriptions
LanguageMap names;
LanguageMap descriptions;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("name")) {
XMLReadLanguageString(reader, &names);
} else if (reader->name() == QStringLiteral("description")) {
XMLReadLanguageString(reader, &descriptions);
} else {
reader->skipCurrentElement();
}
}
combo_names.append(names);
combo_descriptions.append(descriptions);
} else {
properties.insert(reader->name().toString(), reader->readElementText());
}
}
param_names_.insert(param_id, param_names);
// Insert combo options if they exist
if (!combo_names.isEmpty()) {
combo_names_.insert(param_id, combo_names);
combo_descriptions_.insert(param_id, combo_descriptions);
}
NodeInput* input = new NodeInput(param_id, param_type, default_val);
QHash<QString, QVariant>::const_iterator iterator;
for (iterator=properties.begin();iterator!=properties.end();iterator++) {
input->set_property(iterator.key(), iterator.value());
}
if (is_iterative) {
iteration_input_ = input;
}
inputs_.append(input);
}
void NodeMetaReader::XMLReadShader(QXmlStreamReader *reader, QString &destination)
{
QString code_url;
// Traverse through parameter attributes for an ID
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("url")) {
code_url = attr.value().toString();
// We don't recognize any other "shader" attributes at this time
break;
}
}
// Add code in file from URL
if (!code_url.isEmpty()) {
destination.append(Node::ReadFileAsString(code_url));
}
// Add any code that's inline in the XML
QString element_text = reader->readElementText().trimmed();
if (!element_text.isEmpty()) {
destination.append(element_text);
}
}
QString NodeMetaReader::GetStringForCurrentLanguage(const LanguageMap *language_map)
{
if (language_map->isEmpty()) {
// There are no entries for this map, this must be an empty string
return QString();
}
// Get current language config
QString language = Config::Current()[QStringLiteral("Language")].toString();
// See if our map has an exact language match
QString str_for_lang = language_map->value(language);
if (!str_for_lang.isEmpty()) {
return str_for_lang;
}
// If not, try to find a match with the same language but not the same derivation
QString base_lang = language.split('_').first();
QList<QString> available_languages = language_map->keys();
foreach (const QString& l, available_languages) {
if (l.startsWith(base_lang)) {
// This is the same language, so we can return this
return language_map->value(l);
}
}
// We couldn't find an exact or close match, just return the first in the list
// (assume a string in the wrong language is better than no string at all)
return language_map->first();
}
NodeInput *NodeMetaReader::GetInputWithID(const QString &id) const
{
foreach (NodeInput* input, inputs_) {
if (input->id() == id) {
return input;
}
}
return nullptr;
}
OLIVE_NAMESPACE_EXIT
-91
View File
@@ -1,91 +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 NODEMETAREADER_H
#define NODEMETAREADER_H
#include <QMap>
#include <QString>
#include <QXmlStreamReader>
#include "input.h"
OLIVE_NAMESPACE_ENTER
class NodeMetaReader
{
public:
NodeMetaReader(const QString& xml_meta_filename);
QString Name() const;
QString ShortName() const;
const QString& id() const;
QString Category() const;
QString Description() const;
const QString& filename() const;
const QString& frag_code() const;
const QString& vert_code() const;
const int& iterations() const;
NodeInput* iteration_input() const;
const QList<NodeInput*>& inputs() const;
void Retranslate();
private:
using LanguageMap = QMap<QString, QString>;
void XMLReadLanguageString(QXmlStreamReader* reader, LanguageMap *map);
void XMLReadEffect(QXmlStreamReader *reader);
void XMLReadIterations(QXmlStreamReader* reader);
void XMLReadParam(QXmlStreamReader* reader);
void XMLReadShader(QXmlStreamReader* reader, QString& destination);
static QString GetStringForCurrentLanguage(const LanguageMap *language_map);
NodeInput* GetInputWithID(const QString& id) const;
QString xml_filename_;
LanguageMap names_;
LanguageMap short_names_;
LanguageMap descriptions_;
LanguageMap categories_;
QMap<QString, LanguageMap > param_names_;
QMap<QString, QList<LanguageMap> > combo_names_;
QMap<QString, QList<LanguageMap> > combo_descriptions_;
QString id_;
QString frag_code_;
QString vert_code_;
int iterations_;
NodeInput* iteration_input_;
QList<NodeInput*> inputs_;
};
OLIVE_NAMESPACE_EXIT
#endif // NODEMETAREADER_H
+29 -6
View File
@@ -127,12 +127,6 @@ QString Node::ShortName() const
return Name();
}
QString Node::Category() const
{
// Return an empty category for any nodes that don't use one
return QString();
}
QString Node::Description() const
{
// Return an empty string by default
@@ -582,6 +576,35 @@ void Node::DisconnectAll()
}
}
QString Node::GetCategoryName(const CategoryID &c)
{
switch (c) {
case kCategoryInput:
return tr("Input");
case kCategoryOutput:
return tr("Output");
case kCategoryGeneral:
return tr("General");
case kCategoryMath:
return tr("Math");
case kCategoryColor:
return tr("Color");
case kCategoryFilter:
return tr("Filter");
case kCategoryTimeline:
return tr("Timeline");
case kCategoryGenerator:
return tr("Generator");
case kCategoryChannels:
return tr("Channel");
case kCategoryUnknown:
case kCategoryCount:
break;
}
return tr("Uncategorized");
}
QList<TimeRange> Node::TransformTimeTo(const TimeRange &time, Node *target, NodeParam::Type direction)
{
QList<TimeRange> paths_found;
+22 -1
View File
@@ -62,6 +62,22 @@ public:
kSampleProcessor = 0x2
};
enum CategoryID {
kCategoryUnknown = -1,
kCategoryInput,
kCategoryOutput,
kCategoryGenerator,
kCategoryMath,
kCategoryFilter,
kCategoryColor,
kCategoryGeneral,
kCategoryTimeline,
kCategoryChannels,
kCategoryCount
};
Node();
virtual ~Node() override;
@@ -116,7 +132,7 @@ public:
* interpreted as an empty string category. This value should be run through a translator as its largely user
* oriented.
*/
virtual QString Category() const;
virtual QList<CategoryID> Category() const = 0;
/**
* @brief Return a description of this node's purpose (optional for subclassing, but recommended)
@@ -242,6 +258,11 @@ public:
*/
void DisconnectAll();
/**
* @brief Get the human-readable name for any category
*/
static QString GetCategoryName(const CategoryID &c);
/**
* @brief Transforms time from this node through the connections it takes to get to the specified node
*/
+4 -4
View File
@@ -80,9 +80,9 @@ QString TrackOutput::id() const
return QStringLiteral("org.olivevideoeditor.Olive.track");
}
QString TrackOutput::Category() const
QList<Node::CategoryID> TrackOutput::Category() const
{
return tr("Output");
return {kCategoryTimeline};
}
QString TrackOutput::Description() 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);
}
}
+1 -1
View File
@@ -44,7 +44,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
QString GetTrackName();
+4 -3
View File
@@ -22,6 +22,7 @@
#include "node/factory.h"
#include "node/math/math/math.h"
#include "node/math/merge/merge.h"
#include "node/output/viewer/viewer.h"
OLIVE_NAMESPACE_ENTER
@@ -104,11 +105,11 @@ TrackOutput* TrackList::AddTrack()
switch (type_) {
case Timeline::kTrackTypeVideo:
{
Node* blend = NodeFactory::CreateFromID(QStringLiteral("org.olivevideoeditor.Olive.alphaoverblend"));
MergeNode* blend = new MergeNode();
GetParentGraph()->AddNode(blend);
NodeParam::ConnectEdge(track->output(), static_cast<NodeInput*>(blend->GetInputWithID("blend_in")));
NodeParam::ConnectEdge(last_track->output(), static_cast<NodeInput*>(blend->GetInputWithID("base_in")));
NodeParam::ConnectEdge(track->output(), blend->blend_in());
NodeParam::ConnectEdge(last_track->output(), blend->base_in());
NodeParam::ConnectEdge(blend->output(), edge->input());
break;
}
+2 -2
View File
@@ -72,9 +72,9 @@ QString ViewerOutput::id() const
return QStringLiteral("org.olivevideoeditor.Olive.vieweroutput");
}
QString ViewerOutput::Category() const
QList<Node::CategoryID> ViewerOutput::Category() const
{
return tr("Output");
return {kCategoryOutput};
}
QString ViewerOutput::Description() const
+1 -1
View File
@@ -49,7 +49,7 @@ public:
virtual QString Name() const override;
virtual QString id() const override;
virtual QString Category() const override;
virtual QList<CategoryID> Category() const override;
virtual QString Description() const override;
NodeInput* texture_input() const;
+13
View File
@@ -78,6 +78,14 @@ Color::Color(const char *data, const PixelFormat::Format &format)
}
}
Color::Color(const QColor &c)
{
set_red(c.redF());
set_green(c.greenF());
set_blue(c.blueF());
set_alpha(c.alphaF());
}
void Color::toHsv(float *hue, float *sat, float *val) const
{
float fCMax = qMax(qMax(red(), green()), blue());
@@ -207,6 +215,11 @@ QColor Color::toQColor() const
return c;
}
float Color::GetRoughLuminance() const
{
return (2*red()+blue()+3*green())/6.0f;
}
const Color &Color::operator+=(const Color &rhs)
{
for (int i=0;i<kRGBAChannels;i++) {
+6
View File
@@ -52,6 +52,8 @@ public:
Color(const char *data, const PixelFormat::Format &format);
Color(const QColor& c);
/**
* @brief Creates a Color struct from hue/saturation/value
*
@@ -86,6 +88,10 @@ public:
QColor toQColor() const;
// Suuuuper rough luminance value mostly used for UI (determining whether to overlay with black
// or white text)
float GetRoughLuminance() const;
// Assignment math operators
const Color& operator+=(const Color& rhs);
const Color& operator-=(const Color& rhs);
+23 -2
View File
@@ -49,6 +49,13 @@ OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
return config_;
}
OCIO::ConstConfigRcPtr ColorManager::CreateConfigFromFile(const QString &filename)
{
OCIO_SET_C_LOCALE_FOR_SCOPE;
return OCIO::Config::CreateFromFile(filename.toUtf8());
}
const QString &ColorManager::GetConfigFilename() const
{
return config_filename_;
@@ -61,7 +68,10 @@ OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
void ColorManager::SetUpDefaultConfig()
{
OCIO_SET_C_LOCALE_FOR_SCOPE;
if (!qgetenv("OCIO").isEmpty()) {
// Attempt to set config from "OCIO" environment variable
try {
default_config_ = OCIO::Config::CreateFromEnv();
@@ -71,7 +81,7 @@ void ColorManager::SetUpDefaultConfig()
}
}
// Kind of hacky, but it'll work
// Extract OCIO config - kind of hacky, but it'll work
QString dir = QDir(FileFunctions::GetTempFilePath()).filePath(QStringLiteral("ocioconf"));
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
@@ -80,7 +90,7 @@ void ColorManager::SetUpDefaultConfig()
qDebug() << "Extracting default OCIO config to" << dir;
default_config_ = OCIO::Config::CreateFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")).toUtf8());
default_config_ = CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
}
void ColorManager::SetConfig(const QString &filename)
@@ -372,4 +382,15 @@ void ColorManager::AssociateAlphaInternal(ColorManager::AlphaAction action, T *d
}
}
ColorManager::SetLocale::SetLocale(const char* new_locale)
{
old_locale_ = setlocale(LC_NUMERIC, nullptr);
setlocale(LC_NUMERIC, new_locale);
}
ColorManager::SetLocale::~SetLocale()
{
setlocale(LC_NUMERIC, old_locale_.toUtf8());
}
OLIVE_NAMESPACE_EXIT
+16
View File
@@ -26,6 +26,8 @@
#include "codec/frame.h"
#include "colorprocessor.h"
#define OCIO_SET_C_LOCALE_FOR_SCOPE ColorManager::SetLocale d("C")
OLIVE_NAMESPACE_ENTER
class ColorManager : public QObject
@@ -36,6 +38,8 @@ public:
OCIO::ConstConfigRcPtr GetConfig() const;
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString& filename);
const QString& GetConfigFilename() const;
static OCIO::ConstConfigRcPtr GetDefaultConfig();
@@ -90,6 +94,18 @@ public:
static void SetOCIOMethodForMode(RenderMode::Mode mode, OCIOMethod method);
class SetLocale
{
public:
SetLocale(const char* new_locale);
~SetLocale();
private:
QString old_locale_;
};
signals:
void ConfigChanged();
+2
View File
@@ -44,10 +44,12 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const
display_transform->setLooksOverrideEnabled(true);
}
OCIO_SET_C_LOCALE_FOR_SCOPE;
processor_ = config->GetConfig()->getProcessor(display_transform);
} else {
OCIO_SET_C_LOCALE_FOR_SCOPE;
processor_ = config->GetConfig()->getProcessor(input.toUtf8(),
output.toUtf8());
+9 -1
View File
@@ -14,8 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
file(GLOB_RECURSE OCIOCONF_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ocio *.spi3d *.spi1d)
set(QRC_BODY "")
foreach(OCIOCONF_FILE ${OCIOCONF_RESOURCES})
string(APPEND QRC_BODY "<file>${OCIOCONF_FILE}</file>\n")
configure_file(${OCIOCONF_FILE} ${OCIOCONF_FILE} COPYONLY)
endforeach()
configure_file(ocioconf.qrc.in ocioconf.qrc @ONLY)
set(OLIVE_RESOURCES
${OLIVE_RESOURCES}
render/ocioconf/ocioconf.qrc
${CMAKE_CURRENT_BINARY_DIR}/ocioconf.qrc
PARENT_SCOPE
)
-17
View File
@@ -1,17 +0,0 @@
#!/bin/sh
ourbasename=$(basename "$0")
rm ocioconf.qrc
echo "<RCC>" >> ocioconf.qrc
echo " <qresource prefix=\"/ocioconf\">" >> ocioconf.qrc
for f in $(find * -type f)
do
if [ "$f" != "CMakeLists.txt" ] && [ "$f" != "ocioconf.qrc" ] && [ "$f" != "$ourbasename" ]
then
echo " <file>$f</file>" >> ocioconf.qrc
fi
done
echo " </qresource>" >> ocioconf.qrc
echo "</RCC>" >> ocioconf.qrc
-19
View File
@@ -1,19 +0,0 @@
<RCC>
<qresource prefix="/ocioconf">
<file>config.ocio</file>
<file>looks/Filmic_False_Colour.spi3d</file>
<file>looks/Filmic_to_0-35_1-30.spi1d</file>
<file>looks/Filmic_to_0-48_1-09.spi1d</file>
<file>looks/Filmic_to_0-60_1-04.spi1d</file>
<file>looks/Filmic_to_0-70_1-03.spi1d</file>
<file>looks/Filmic_to_0-85_1-011.spi1d</file>
<file>looks/Filmic_to_0.99_1-0075.spi1d</file>
<file>looks/Filmic_to_1.20_1-00.spi1d</file>
<file>luts/F-Log_to_Linear.spi1d</file>
<file>luts/V-Log_to_linear.spi1d</file>
<file>luts/V3_LogC_400_to_linear.spi1d</file>
<file>luts/V3_LogC_800_to_linear.spi1d</file>
<file>luts/desat65cube.spi3d</file>
<file>luts/sRGB_OETF_to_Linear.spi1d</file>
</qresource>
</RCC>
+5
View File
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/ocioconf">
@QRC_BODY@
</qresource>
</RCC>
+9 -1
View File
@@ -14,8 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
file(GLOB_RECURSE SHADER_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.frag *.vert)
set(QRC_BODY "")
foreach(SHADER_FILE ${SHADER_RESOURCES})
string(APPEND QRC_BODY "<file>${SHADER_FILE}</file>\n")
configure_file(${SHADER_FILE} ${SHADER_FILE} COPYONLY)
endforeach()
configure_file(shaders.qrc.in shaders.qrc @ONLY)
set(OLIVE_RESOURCES
${OLIVE_RESOURCES}
shaders/shaders.qrc
${CMAKE_CURRENT_BINARY_DIR}/shaders.qrc
PARENT_SCOPE
)
-24
View File
@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.alphaoverblend">
<!-- Effect Name -->
<name lang="en_US">Alpha Over</name>
<!-- Effect Category -->
<category lang="en_US">Blend</category>
<!-- Effect Description -->
<description lang="en_US">
A blending node that composites one texture over another using its alpha channel.
</description>
<!-- Blending Parameters -->
<param id="base_in" type="texture">
<name lang="en_US">Base</name>
</param>
<param id="blend_in" type="texture">
<name lang="en_US">Blend</name>
</param>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/alphaover.frag" />
</effect>
-70
View File
@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.blur">
<!-- Effect Name -->
<name lang="en_US">Blur</name>
<!-- Effect Category -->
<category lang="en_US">Blur</category>
<!-- Effect Description -->
<description lang="en_US">
Blurs an image.
</description>
<!-- Parameter: Texture Input -->
<param id="tex_in" type="texture" iterative_input="1">
<name lang="en_US">Input</name>
</param>
<!-- Parameter: Method Input -->
<param id="method_in" type="combo">
<name lang="en_US">Method</name>
<option>
<name lang="en_US">Box</name>
<description lang="en_US">A fast blur calculated by averaging a square of pixels around each pixel. Fast, but can have a "striated" look to it.</description>
</option>
<option>
<name lang="en_US">Gaussian</name>
<description lang="en_US">A smooth blur using the gaussian function. Slower than box blur but much prettier.</description>
</option>
</param>
<!-- Parameter: Radius Input -->
<param id="radius_in" type="float">
<name lang="en_US">Radius</name>
<min>0</min>
<default>
<value>10</value>
</default>
</param>
<!-- Parameter: Horizontal Enable -->
<param id="horiz_in" type="bool">
<name lang="en_US">Horizontal</name>
<default>
<value>1</value>
</default>
</param>
<!-- Parameter: Vertical Enable -->
<param id="vert_in" type="bool">
<name lang="en_US">Vertical</name>
<default>
<value>1</value>
</default>
</param>
<!-- Parameter: Repeat Edge Pixels -->
<param id="repeat_edge_pixels_in" type="bool">
<name lang="en_US">Repeat Edge Pixels</name>
<default>
<value>0</value>
</default>
</param>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/blur.frag"/>
<!-- Blur uses two iterations for horizontal and vertical since calculating 2*radius is faster than radius^2 -->
<iterations>2</iterations>
</effect>
-16
View File
@@ -1,16 +0,0 @@
<?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>
-16
View File
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.diptoblack">
<!-- Effect Name -->
<name lang="en_US">Dip to Black</name>
<!-- Effect Category -->
<category lang="en_US">Transition</category>
<!-- Effect Description -->
<description lang="en_US">
A smooth dip to transparency and back into another clip.
</description>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/diptoblack.frag"/>
</effect>
-62
View File
@@ -1,62 +0,0 @@
#version 150
#define M_PI 3.1415926535897932384626433832795
uniform sampler2D tex_in;
uniform vec3 color_in;
uniform float softness_in;
uniform float opacity_in;
uniform float distance_in;
uniform float direction_in;
uniform vec2 ove_resolution;
in vec2 ove_texcoord;
out vec4 fragColor;
void main(void) {
// Use pythagoras with the distance (hypotenuse) to find the shadow offset
float direction_radians = direction_in * (M_PI / 180.0);
float opposite = sin(direction_radians) * distance_in;
float adjacent = cos(direction_radians) * distance_in;
vec2 angle = vec2(adjacent, opposite);
// Convert distance from pixels to 0.0 - 1.0 texture coordinates
angle /= ove_resolution;
float shadow_alpha;
// For a soft shadow, we use a box blur-like formula
if (softness_in > 0.0) {
float radius = ceil(softness_in);
float divider = 1.0 / pow(softness_in, 2.0);
shadow_alpha = 0.0;
for (float x = -radius + 0.5; x <= radius; x += 2.0) {
for (float y = -radius + 0.5; y <= radius; y += 2.0) {
vec2 pixel_coord = ove_texcoord - angle;
pixel_coord.x += x / ove_resolution.x;
pixel_coord.y += y / ove_resolution.y;
vec4 pixel_color = texture(tex_in, pixel_coord);
shadow_alpha += pixel_color.a * divider;
}
}
} else {
// Perfectly hard shadow
vec4 src_color = texture(tex_in, ove_texcoord - angle);
shadow_alpha = src_color.a;
}
vec4 shadow_px = vec4(color_in, shadow_alpha * opacity_in * 0.01);
// Get current pixel and perform an alpha over for it over the shadow we've made
vec4 dst_color = texture(tex_in, ove_texcoord);
shadow_px *= (1.0 - dst_color.a);
shadow_px += dst_color;
fragColor = shadow_px;
}
-64
View File
@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.dropshadow">
<!-- Effect Name -->
<name lang="en_US">Drop Shadow</name>
<!-- Effect Category -->
<category lang="en_US">Stylize</category>
<category lang="en_GB">Stylise</category>
<!-- Effect Description -->
<description lang="en_US">
Generate a drop shadow of a clip.
</description>
<!-- Parameter: Texture Input -->
<param id="tex_in" type="texture">
<name lang="en_US">Input</name>
</param>
<!-- Parameter: Color Input -->
<param id="color_in" type="color">
<name lang="en_US">Color</name>
<name lang="en_GB">Colour</name>
</param>
<!-- Parameter: Softness Input -->
<param id="softness_in" type="float">
<name lang="en_US">Softness</name>
<min>0</min>
<default>
<value>10</value>
</default>
</param>
<!-- Parameter: Opacity Input -->
<param id="opacity_in" type="float">
<name lang="en_US">Opacity</name>
<min>0</min>
<default>
<value>80</value>
</default>
<max>100</max>
</param>
<!-- Parameter: Distance Input -->
<param id="distance_in" type="float">
<name lang="en_US">Distance</name>
<min>0</min>
<default>
<value>10</value>
</default>
</param>
<!-- Parameter: Direction Input -->
<param id="direction_in" type="float">
<name lang="en_US">Direction</name>
<default>
<value>45</value>
</default>
</param>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/dropshadow.frag"/>
</effect>
+1 -1
View File
@@ -52,7 +52,7 @@ void main(void) {
float waveform_x = (ove_texcoord.x - waveform_uv.x) / waveform_scale;
float waveform_y = (ove_texcoord.y - waveform_uv.y) / waveform_scale;
for (int i = 0; i < waveform_dims.y; i++) {
ratio = float(i) / float(waveform_dims.y);
ratio = float(i) / float(waveform_dims.y - 1);
cur_col = texture(
ove_maintex,
vec2(waveform_x, ratio)
+5
View File
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/shaders">
@QRC_BODY@
</qresource>
</RCC>
-31
View File
@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.solidgenerator">
<!-- Effect Name -->
<name lang="en_US">Solid</name>
<!-- Effect Category -->
<category lang="en_US">Generator</category>
<!-- Effect Description -->
<description lang="en_US">
Generate a solid color.
</description>
<description lang="en_GB">
Generate a solid colour.
</description>
<!-- Parameter: Color Value -->
<param id="color_in" type="color">
<name lang="en_US">Color</name>
<name lang="en_GB">Colour</name>
<default>
<value>1.0</value>
<value>0.0</value>
<value>0.0</value>
<value>1.0</value>
</default>
</param>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/solid.frag" />
</effect>
+3 -4
View File
@@ -2,7 +2,7 @@
// Node parameter inputs
uniform sampler2D tex_in;
uniform vec3 color_in;
uniform vec4 color_in;
uniform float radius_in;
uniform float opacity_in;
uniform bool inner_in;
@@ -61,15 +61,14 @@ void main(void) {
}
}
stroke_weight *= opacity_in * 0.01;
stroke_weight *= opacity_in;
if (inner_in) {
stroke_weight *= pixel_here.a;
}
// Make RGBA color
vec4 stroke_col = vec4(vec3(1.0) * stroke_weight, stroke_weight);
//vec4 stroke_col = vec4(color_in * stroke_weight, stroke_weight);
vec4 stroke_col = color_in * stroke_weight;
if (inner_in) {
// Alpha over the stroke over the texture
-55
View File
@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect id="org.olivevideoeditor.Olive.stroke">
<!-- Effect Name -->
<name lang="en_US">Stroke</name>
<!-- Effect Category -->
<category lang="en_US">Stylize</category>
<category lang="en_GB">Stylise</category>
<!-- Effect Description -->
<description lang="en_US">
Creates a stroke outline around an image.
</description>
<!-- Parameter: Texture Input -->
<param id="tex_in" type="texture">
<name lang="en_US">Input</name>
</param>
<!-- Parameter: Color Value -->
<param id="color_in" type="color">
<name lang="en_US">Color</name>
<name lang="en_GB">Colour</name>
</param>
<!-- Parameter: Radius Value -->
<param id="radius_in" type="float">
<name lang="en_US">Radius</name>
<min>0</min>
<default>
<value>10</value>
</default>
</param>
<!-- Parameter: Opacity Value -->
<param id="opacity_in" type="float">
<name lang="en_US">Opacity</name>
<min>0</min>
<default>
<value>100</value>
</default>
<max>100</max>
</param>
<!-- Parameter: Inner Value -->
<param id="inner_in" type="bool">
<name lang="en_US">Inner</name>
<default>
<value>false</value>
</default>
</param>
<!-- Qt Resource path to fragment shader -->
<fragment url=":/shaders/stroke.frag" />
</effect>
+1 -3
View File
@@ -77,9 +77,7 @@ void ColorSwatchWidget::SelectedColorChangedEvent(const Color &, bool)
Qt::GlobalColor ColorSwatchWidget::GetUISelectorColor() const
{
float rough_color_luma = (GetSelectedColor().red()+GetSelectedColor().red()+GetSelectedColor().blue()+GetSelectedColor().green()+GetSelectedColor().green()+GetSelectedColor().green())/6;
if (rough_color_luma > 0.66) {
if (GetSelectedColor().GetRoughLuminance() > 0.66) {
return Qt::black;
} else {
return Qt::white;
+12 -2
View File
@@ -28,6 +28,7 @@
#include "common/flipmodifiers.h"
#include "common/qtutils.h"
#include "config/config.h"
#include "core.h"
#include "nodeview.h"
#include "nodeviewscene.h"
@@ -260,8 +261,11 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
// Draw the titlebar
if (!hide_titlebar_ && node_) {
Color node_color = Config::Current()[QStringLiteral("NodeCatColor%1")
.arg(node_->Category().first())].value<Color>();
painter->setPen(Qt::black);
painter->setBrush(css_proxy_.TitleBarColor());
painter->setBrush(node_color.toQColor());
painter->drawRect(title_bar_rect_);
@@ -293,6 +297,12 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
}
if (node_color.GetRoughLuminance() > 0.66) {
painter->setPen(Qt::black);
} else {
painter->setPen(Qt::white);
}
// Draw the text in a rect (the rect is sized around text already in the constructor)
painter->drawText(title_bar_rect_,
Qt::AlignCenter,
@@ -307,7 +317,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
if (option->state & QStyle::State_Selected) {
border_pen.setColor(app_pal.color(QPalette::Highlight));
} else {
border_pen.setColor(css_proxy_.BorderColor());
border_pen.setColor(Qt::black);
}
painter->setPen(border_pen);
-7
View File
@@ -130,13 +130,6 @@ private:
*/
QList<NodeInput*> node_inputs_;
/**
* @brief A QWidget that can receive CSS properties that NodeViewItem can use
*
* \see NodeViewItemWidget
*/
NodeViewItemWidget css_proxy_;
/**
* @brief Rectangle of the Node's title bar (equal to rect() when collapsed)
*/
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(histogram)
add_subdirectory(scopebase)
add_subdirectory(waveform)
set(OLIVE_SOURCES
+1 -182
View File
@@ -29,189 +29,8 @@
OLIVE_NAMESPACE_ENTER
HistogramScope::HistogramScope(QWidget* parent) :
ManagedDisplayWidget(parent),
buffer_(nullptr)
ScopeBase(parent)
{
EnableDefaultContextMenu();
connect(&worker_, &HistogramScopeWorker::Finished, this, &HistogramScope::FinishedProcessing, Qt::QueuedConnection);
worker_.start(QThread::IdlePriority);
}
HistogramScope::~HistogramScope()
{
worker_.Cancel();
worker_.quit();
worker_.wait();
}
void HistogramScope::SetBuffer(Frame* frame)
{
buffer_ = frame;
if (isVisible()) {
StartUpdate();
}
}
void HistogramScope::FinishedProcessing(QVector<double> red, QVector<double> green, QVector<double> blue)
{
red_val_ = red;
green_val_ = green;
blue_val_ = blue;
update();
}
void HistogramScope::paintGL()
{
QVector<QLine> red_lines(red_val_.size());
QVector<QLine> green_lines(green_val_.size());
QVector<QLine> blue_lines(blue_val_.size());
for (int i=0;i<red_lines.size();i++) {
red_lines.replace(i, QLine(i, height() * (1.0 - red_val_.at(i)), i, height()));
green_lines.replace(i, QLine(i, height() * (1.0 - green_val_.at(i)), i, height()));
blue_lines.replace(i, QLine(i, height() * (1.0 - blue_val_.at(i)), i, height()));
}
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_Plus);
p.setPen(Qt::red);
p.drawLines(red_lines);
p.setPen(Qt::green);
p.drawLines(green_lines);
p.setPen(Qt::blue);
p.drawLines(blue_lines);
}
void HistogramScope::resizeEvent(QResizeEvent *e)
{
QOpenGLWidget::resizeEvent(e);
StartUpdate();
}
void HistogramScope::ColorProcessorChangedEvent()
{
StartUpdate();
}
void HistogramScope::StartUpdate()
{
if (buffer_) {
worker_.QueueNext(*buffer_, color_service(), width());
} else {
// Update with nothing
red_val_.clear();
green_val_.clear();
blue_val_.clear();
update();
}
}
void HistogramScope::showEvent(QShowEvent* e)
{
ManagedDisplayWidget::showEvent(e);
StartUpdate();
}
HistogramScopeWorker::HistogramScopeWorker() :
cancelled_(false)
{
}
void HistogramScopeWorker::run()
{
while (!cancelled_) {
next_lock_.lock();
while (!next_.is_allocated()) {
next_wait_.wait(&next_lock_);
if (cancelled_){
next_lock_.unlock();
return;
}
}
// Copy values
Frame f = next_;
int w = next_width_;
ColorProcessorPtr processor = next_processor_;
next_.destroy();
next_lock_.unlock();
// Color manage frame
QVector<int> data(w * kRGBChannels, 0);
int max_w = w-1;
for (int x=0;x<f.width();x++) {
for (int y=0;y<f.height();y++) {
Color c = f.get_pixel(x, y);
if (processor) {
c = processor->ConvertColor(c);
}
data[qFloor(clamp(c.red(), 0.0f, 1.0f) * max_w)]++;
data[qFloor(clamp(c.green(), 0.0f, 1.0f) * max_w) + w]++;
data[qFloor(clamp(c.blue(), 0.0f, 1.0f) * max_w) + w * 2]++;
}
}
int max_val = 0;
foreach (const int& i, data) {
if (i > max_val) {
max_val = i;
}
}
if (!max_val) {
// Prevent divide by zero
return;
}
QVector<double> red_lines(w);
QVector<double> green_lines(w);
QVector<double> blue_lines(w);
for (int i=0;i<w;i++) {
red_lines.replace(i, static_cast<double>(data.at(i)) / static_cast<double>(max_val));
green_lines.replace(i, static_cast<double>(data.at(i + w)) / static_cast<double>(max_val));
blue_lines.replace(i, static_cast<double>(data.at(i + w * 2)) / static_cast<double>(max_val));
}
emit Finished(red_lines, green_lines, blue_lines);
}
}
void HistogramScopeWorker::QueueNext(const Frame &f, ColorProcessorPtr processor, int width)
{
next_lock_.lock();
next_ = f;
next_width_ = width;
next_processor_ = processor;
next_wait_.wakeOne();
next_lock_.unlock();
}
void HistogramScopeWorker::Cancel()
{
cancelled_ = true;
next_lock_.lock();
next_wait_.wakeOne();
next_lock_.unlock();
}
OLIVE_NAMESPACE_EXIT
+4 -64
View File
@@ -21,80 +21,20 @@
#ifndef HISTOGRAMSCOPE_H
#define HISTOGRAMSCOPE_H
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
#include "codec/frame.h"
#include "render/colorprocessor.h"
#include "widget/manageddisplay/manageddisplay.h"
#include "widget/scope/scopebase/scopebase.h"
OLIVE_NAMESPACE_ENTER
class HistogramScopeWorker : public QThread
{
Q_OBJECT
public:
HistogramScopeWorker();
// Thread-safe
void QueueNext(const Frame& f, ColorProcessorPtr processor, int width);
// Thread-safe
void Cancel();
protected:
virtual void run() override;
signals:
void Finished(QVector<double> red, QVector<double> green, QVector<double> blue);
private:
QAtomicInt cancelled_;
QMutex next_lock_;
QWaitCondition next_wait_;
Frame next_;
int next_width_;
ColorProcessorPtr next_processor_;
};
class HistogramScope : public ManagedDisplayWidget
class HistogramScope : public ScopeBase
{
Q_OBJECT
public:
HistogramScope(QWidget* parent = nullptr);
virtual ~HistogramScope() override;
public slots:
void SetBuffer(Frame* frame);
protected:
virtual void paintGL() override;
//virtual OpenGLShaderPtr CreateShader() override;
virtual void resizeEvent(QResizeEvent* e) override;
virtual void ColorProcessorChangedEvent() override;
virtual void showEvent(QShowEvent* e) override;
private:
void StartUpdate();
Frame* buffer_;
QVector<double> red_val_;
QVector<double> green_val_;
QVector<double> blue_val_;
HistogramScopeWorker worker_;
private slots:
void FinishedProcessing(QVector<double> red, QVector<double> green, QVector<double> blue);
//virtual void DrawScope() override;
};
+22
View File
@@ -0,0 +1,22 @@
# 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}
widget/scope/scopebase/scopebase.h
widget/scope/scopebase/scopebase.cpp
PARENT_SCOPE
)
+163
View File
@@ -0,0 +1,163 @@
/***
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 "scopebase.h"
#include "render/backend/opengl/openglrenderfunctions.h"
OLIVE_NAMESPACE_ENTER
ScopeBase::ScopeBase(QWidget* parent) :
ManagedDisplayWidget(parent),
buffer_(nullptr)
{
EnableDefaultContextMenu();
}
ScopeBase::~ScopeBase()
{
CleanUp();
if (context()) {
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ScopeBase::CleanUp);
}
}
void ScopeBase::SetBuffer(Frame *frame)
{
buffer_ = frame;
UploadTextureFromBuffer();
}
void ScopeBase::showEvent(QShowEvent* e)
{
ManagedDisplayWidget::showEvent(e);
UploadTextureFromBuffer();
}
OpenGLShaderPtr ScopeBase::CreateShader()
{
return OpenGLShader::CreateDefault();
}
void ScopeBase::DrawScope()
{
managed_tex().Bind();
OpenGLRenderFunctions::Blit(pipeline());
managed_tex().Release();
}
OpenGLShaderPtr ScopeBase::pipeline()
{
return pipeline_;
}
OpenGLTexture &ScopeBase::managed_tex()
{
return managed_tex_;
}
void ScopeBase::UploadTextureFromBuffer()
{
if (!isVisible()) {
return;
}
if (buffer_) {
makeCurrent();
if (!texture_.IsCreated()
|| texture_.width() != buffer_->width()
|| texture_.height() != buffer_->height()
|| texture_.format() != buffer_->format()) {
texture_.Destroy();
managed_tex_.Destroy();
texture_.Create(context(), buffer_);
managed_tex_.Create(context(), buffer_->video_params());
} else {
texture_.Upload(buffer_);
}
doneCurrent();
}
update();
}
void ScopeBase::CleanUp()
{
makeCurrent();
pipeline_ = nullptr;
texture_.Destroy();
managed_tex_.Destroy();
framebuffer_.Destroy();
doneCurrent();
}
void ScopeBase::initializeGL()
{
ManagedDisplayWidget::initializeGL();
pipeline_ = CreateShader();
framebuffer_.Create(context());
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ScopeBase::CleanUp, Qt::DirectConnection);
UploadTextureFromBuffer();
}
void ScopeBase::paintGL()
{
QOpenGLFunctions* f = context()->functions();
f->glClearColor(0, 0, 0, 0);
f->glClear(GL_COLOR_BUFFER_BIT);
if (buffer_ && pipeline() && texture_.IsCreated()) {
// Convert reference frame to display space
framebuffer_.Attach(&managed_tex_);
framebuffer_.Bind();
texture_.Bind();
f->glViewport(0, 0, texture_.width(), texture_.height());
color_service()->ProcessOpenGL();
texture_.Release();
framebuffer_.Release();
framebuffer_.Detach();
f->glViewport(0, 0, width(), height());
DrawScope();
}
}
OLIVE_NAMESPACE_EXIT
+78
View File
@@ -0,0 +1,78 @@
/***
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 SCOPEBASE_H
#define SCOPEBASE_H
#include "codec/frame.h"
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglframebuffer.h"
#include "render/backend/opengl/openglshader.h"
#include "render/backend/opengl/opengltexture.h"
#include "widget/manageddisplay/manageddisplay.h"
OLIVE_NAMESPACE_ENTER
class ScopeBase : public ManagedDisplayWidget
{
public:
ScopeBase(QWidget* parent = nullptr);
virtual ~ScopeBase() override;
public slots:
void SetBuffer(Frame* frame);
protected:
virtual void initializeGL() override;
virtual void paintGL() override;
virtual void showEvent(QShowEvent* e) override;
virtual OpenGLShaderPtr CreateShader();
virtual void DrawScope();
OpenGLShaderPtr pipeline();
OpenGLTexture& managed_tex();
private:
void UploadTextureFromBuffer();
OpenGLShaderPtr pipeline_;
OpenGLTexture texture_;
OpenGLTexture managed_tex_;
OpenGLFramebuffer framebuffer_;
Frame* buffer_;
private slots:
void CleanUp();
};
OLIVE_NAMESPACE_EXIT
#endif // SCOPEBASE_H
+38 -132
View File
@@ -32,59 +32,24 @@
OLIVE_NAMESPACE_ENTER
WaveformScope::WaveformScope(QWidget* parent) :
ManagedDisplayWidget(parent),
buffer_(nullptr)
ScopeBase(parent)
{
EnableDefaultContextMenu();
}
WaveformScope::~WaveformScope()
OpenGLShaderPtr WaveformScope::CreateShader()
{
CleanUp();
OpenGLShaderPtr pipeline = OpenGLShader::Create();
if (context()) {
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WaveformScope::CleanUp);
}
pipeline->create();
pipeline->addShaderFromSourceCode(QOpenGLShader::Vertex, OpenGLShader::CodeDefaultVertex());
pipeline->addShaderFromSourceCode(QOpenGLShader::Fragment, Node::ReadFileAsString(":/shaders/rgbwaveform.frag"));
pipeline->link();
return pipeline;
}
void WaveformScope::SetBuffer(Frame *frame)
void WaveformScope::DrawScope()
{
buffer_ = frame;
UploadTextureFromBuffer();
}
void WaveformScope::showEvent(QShowEvent* e)
{
ManagedDisplayWidget::showEvent(e);
UploadTextureFromBuffer();
}
void WaveformScope::initializeGL()
{
ManagedDisplayWidget::initializeGL();
pipeline_ = OpenGLShader::Create();
pipeline_->create();
pipeline_->addShaderFromSourceCode(QOpenGLShader::Vertex, OpenGLShader::CodeDefaultVertex());
pipeline_->addShaderFromSourceCode(QOpenGLShader::Fragment, Node::ReadFileAsString(":/shaders/rgbwaveform.frag"));
pipeline_->link();
framebuffer_.Create(context());
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WaveformScope::CleanUp, Qt::DirectConnection);
UploadTextureFromBuffer();
}
void WaveformScope::paintGL()
{
QOpenGLFunctions* f = context()->functions();
f->glClearColor(0, 0, 0, 0);
f->glClear(GL_COLOR_BUFFER_BIT);
float waveform_scale = 0.80f;
float waveform_dim_x = width() * waveform_scale;
float waveform_dim_y = height() * waveform_scale;
@@ -93,66 +58,47 @@ void WaveformScope::paintGL()
float waveform_end_dim_x = width() - waveform_start_dim_x;
float waveform_end_dim_y = height() - waveform_start_dim_y;
if (buffer_ && pipeline_ && texture_.IsCreated()) {
// Convert reference frame to display space
framebuffer_.Attach(&managed_tex_);
framebuffer_.Bind();
// Draw waveform through shader
pipeline()->bind();
pipeline()->setUniformValue("ove_resolution", managed_tex().width(), managed_tex().height());
pipeline()->setUniformValue("ove_viewport", width(), height());
GLfloat luma[3] = {0.0, 0.0, 0.0};
color_manager()->GetDefaultLumaCoefs(luma);
pipeline()->setUniformValue("luma_coeffs", luma[0], luma[1], luma[2]);
texture_.Bind();
// Scale of the waveform relative to the viewport surface.
pipeline()->setUniformValue("waveform_scale", waveform_scale);
pipeline()->setUniformValue(
"waveform_dims", waveform_dim_x, waveform_dim_y);
f->glViewport(0, 0, texture_.width(), texture_.height());
pipeline()->setUniformValue(
"waveform_region",
waveform_start_dim_x, waveform_start_dim_y,
waveform_end_dim_x, waveform_end_dim_y);
color_service()->ProcessOpenGL();
float waveform_start_uv_x = waveform_start_dim_x / width();
float waveform_start_uv_y = waveform_start_dim_y / height();
float waveform_end_uv_x = waveform_end_dim_x / width();
float waveform_end_uv_y = waveform_end_dim_y / height();
pipeline()->setUniformValue(
"waveform_uv",
waveform_start_uv_x, waveform_start_uv_y,
waveform_end_uv_x, waveform_end_uv_y);
texture_.Release();
pipeline()->release();
framebuffer_.Release();
framebuffer_.Detach();
managed_tex().Bind();
// Draw waveform through shader
pipeline_->bind();
pipeline_->setUniformValue("ove_resolution", texture_.width(), texture_.height());
pipeline_->setUniformValue("ove_viewport", width(), height());
GLfloat luma[3] = {0.0, 0.0, 0.0};
color_manager()->GetDefaultLumaCoefs(luma);
pipeline_->setUniformValue("luma_coeffs", luma[0], luma[1], luma[2]);
OpenGLRenderFunctions::Blit(pipeline());
// Scale of the waveform relative to the viewport surface.
pipeline_->setUniformValue("waveform_scale", waveform_scale);
pipeline_->setUniformValue(
"waveform_dims", waveform_dim_x, waveform_dim_y);
pipeline_->setUniformValue(
"waveform_region",
waveform_start_dim_x, waveform_start_dim_y,
waveform_end_dim_x, waveform_end_dim_y);
float waveform_start_uv_x = waveform_start_dim_x / width();
float waveform_start_uv_y = waveform_start_dim_y / height();
float waveform_end_uv_x = waveform_end_dim_x / width();
float waveform_end_uv_y = waveform_end_dim_y / height();
pipeline_->setUniformValue(
"waveform_uv",
waveform_start_uv_x, waveform_start_uv_y,
waveform_end_uv_x, waveform_end_uv_y);
pipeline_->release();
f->glViewport(0, 0, width(), height());
managed_tex_.Bind();
OpenGLRenderFunctions::Blit(pipeline_);
managed_tex_.Release();
}
managed_tex().Release();
// Draw line overlays
QPainter p(this);
QFontMetrics font_metrics = QFontMetrics(QFont());
QString label;
float ire_increment = 0.1f;
float ire_steps = int(1.0 / ire_increment);
int ire_steps = qRound(1.0 / ire_increment);
QVector<QLine> ire_lines(ire_steps + 1);
int font_x_offset = 0;
int font_y_offset = font_metrics.capHeight() / 2.0f;
@@ -179,44 +125,4 @@ void WaveformScope::paintGL()
p.drawLines(ire_lines);
}
void WaveformScope::UploadTextureFromBuffer()
{
if (!isVisible()) {
return;
}
if (buffer_) {
makeCurrent();
if (!texture_.IsCreated()
|| texture_.width() != buffer_->width()
|| texture_.height() != buffer_->height()
|| texture_.format() != buffer_->format()) {
texture_.Destroy();
managed_tex_.Destroy();
texture_.Create(context(), buffer_);
managed_tex_.Create(context(), buffer_->video_params());
} else {
texture_.Upload(buffer_);
}
doneCurrent();
}
update();
}
void WaveformScope::CleanUp()
{
makeCurrent();
pipeline_ = nullptr;
texture_.Destroy();
managed_tex_.Destroy();
framebuffer_.Destroy();
doneCurrent();
}
OLIVE_NAMESPACE_EXIT
+4 -32
View File
@@ -21,48 +21,20 @@
#ifndef WAVEFORMSCOPE_H
#define WAVEFORMSCOPE_H
#include "codec/frame.h"
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglframebuffer.h"
#include "render/backend/opengl/openglshader.h"
#include "render/backend/opengl/opengltexture.h"
#include "widget/manageddisplay/manageddisplay.h"
#include "widget/scope/scopebase/scopebase.h"
OLIVE_NAMESPACE_ENTER
class WaveformScope : public ManagedDisplayWidget
class WaveformScope : public ScopeBase
{
Q_OBJECT
public:
WaveformScope(QWidget* parent = nullptr);
virtual ~WaveformScope() override;
public slots:
void SetBuffer(Frame* frame);
protected:
virtual void initializeGL() override;
virtual OpenGLShaderPtr CreateShader() override;
virtual void paintGL() override;
virtual void showEvent(QShowEvent* e) override;
private:
void UploadTextureFromBuffer();
OpenGLShaderPtr pipeline_;
OpenGLTexture texture_;
OpenGLTexture managed_tex_;
OpenGLFramebuffer framebuffer_;
Frame* buffer_;
private slots:
void CleanUp();
virtual void DrawScope() override;
};