nodes: color management when setting color parameters is now preserved

This commit is contained in:
itsmattkc
2020-04-18 17:43:37 +10:00
parent f73c41d3fa
commit d3b71e6576
19 changed files with 311 additions and 106 deletions
+2
View File
@@ -28,6 +28,8 @@ set(OLIVE_SOURCES
render/colorprocessor.cpp
render/diskmanager.h
render/diskmanager.cpp
render/managedcolor.h
render/managedcolor.cpp
render/pixelformat.h
render/pixelformat.cpp
render/rendermodes.h
@@ -71,13 +71,13 @@ void OpenGLColorProcessor::ClearTexture()
}
}
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) :
OpenGLColorProcessor::OpenGLColorProcessor(ColorManager* config, const QString &source_space, const QString &dest_space) :
ColorProcessor(config, source_space, dest_space),
ocio_lut_(0)
{
}
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, QString display, QString view, const QString &look, Direction dir) :
OpenGLColorProcessor::OpenGLColorProcessor(ColorManager* config, const QString &source_space, QString display, QString view, const QString &look, Direction dir) :
ColorProcessor(config, source_space, display, view, look, dir),
ocio_lut_(0)
{
@@ -88,12 +88,12 @@ OpenGLColorProcessor::~OpenGLColorProcessor()
ClearTexture();
}
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space)
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &dest_space)
{
return std::make_shared<OpenGLColorProcessor>(config, source_space, dest_space);
}
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction dir)
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction dir)
{
return std::make_shared<OpenGLColorProcessor>(config, source_space, display, view, look, dir);
}
@@ -33,9 +33,9 @@ class OpenGLColorProcessor : public QObject, public ColorProcessor
{
Q_OBJECT
public:
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
OpenGLColorProcessor(ColorManager *config, const QString &source_space, const QString &dest_space);
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config,
OpenGLColorProcessor(ColorManager *config,
const QString& source_space,
QString display,
QString view,
@@ -44,9 +44,9 @@ public:
~OpenGLColorProcessor();
static OpenGLColorProcessorPtr Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space);
static OpenGLColorProcessorPtr Create(ColorManager* config, const QString& source_space, const QString& dest_space);
static OpenGLColorProcessorPtr Create(OCIO::ConstConfigRcPtr config,
static OpenGLColorProcessorPtr Create(ColorManager* config,
const QString& source_space,
const QString& display,
const QString& view,
+1 -1
View File
@@ -97,7 +97,7 @@ void OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, NodeValueTable*
OpenGLColorProcessorPtr color_processor = std::static_pointer_cast<OpenGLColorProcessor>(color_cache_.Get(colorspace_match));
if (!color_processor) {
color_processor = OpenGLColorProcessor::Create(video_stream->footage()->project()->color_manager()->GetConfig(),
color_processor = OpenGLColorProcessor::Create(video_stream->footage()->project()->color_manager(),
video_stream->colorspace(),
video_stream->footage()->project()->color_manager()->GetReferenceColorSpace());
color_cache_.Add(colorspace_match, color_processor);
+2 -2
View File
@@ -50,6 +50,8 @@ public:
data_[3] = a;
}
Color(const char *data, const PixelFormat::Format &format);
/**
* @brief Creates a Color struct from hue/saturation/value
*
@@ -57,8 +59,6 @@ public:
*/
static Color fromHsv(const float& h, const float& s, const float &v);
Color(const char *data, const PixelFormat::Format &format);
const float& red() const {return data_[0];}
const float& green() const {return data_[1];}
const float& blue() const {return data_[2];}
+18 -13
View File
@@ -21,28 +21,33 @@
#include "colorprocessor.h"
#include "common/define.h"
#include "colormanager.h"
OLIVE_NAMESPACE_ENTER
ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
ColorProcessor::ColorProcessor(ColorManager *config, const QString& source_space, const QString& dest_space)
{
processor = config->getProcessor(source_space.toUtf8(),
dest_space.toUtf8());
processor_ = config->GetConfig()->getProcessor(source_space.toUtf8(),
dest_space.toUtf8());
}
ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config,
const QString& source_space,
ColorProcessor::ColorProcessor(ColorManager *config,
QString source_space,
QString display,
QString view,
const QString& look,
Direction direction)
{
if (source_space.isEmpty()) {
source_space = config->GetDefaultInputColorSpace();
}
if (display.isEmpty()) {
display = config->getDefaultDisplay();
display = config->GetDefaultDisplay();
}
if (view.isEmpty()) {
view = config->getDefaultView(display.toUtf8());
view = config->GetDefaultView(display);
}
// Get current display stats
@@ -58,35 +63,35 @@ ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config,
OCIO::TransformDirection dir = (direction == kInverse) ? OCIO::TRANSFORM_DIR_INVERSE : OCIO::TRANSFORM_DIR_FORWARD;
processor = config->getProcessor(transform, dir);
processor_ = config->GetConfig()->getProcessor(transform, dir);
}
void ColorProcessor::ConvertFrame(FramePtr f)
{
OCIO::PackedImageDesc img(reinterpret_cast<float*>(f->data()), f->width(), f->height(), PixelFormat::ChannelCount(f->format()));
processor->apply(img);
processor_->apply(img);
}
Color ColorProcessor::ConvertColor(Color in)
{
processor->applyRGBA(in.data());
processor_->applyRGBA(in.data());
return in;
}
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString& source_space, const QString& dest_space)
{
return std::make_shared<ColorProcessor>(config, source_space, dest_space);
}
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction direction)
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction direction)
{
return std::make_shared<ColorProcessor>(config, source_space, display, view, look, direction);
}
OCIO::ConstProcessorRcPtr ColorProcessor::GetProcessor()
{
return processor;
return processor_;
}
OLIVE_NAMESPACE_EXIT
+8 -5
View File
@@ -29,6 +29,8 @@ namespace OCIO = OCIO_NAMESPACE::v1;
OLIVE_NAMESPACE_ENTER
class ColorManager;
class ColorProcessor;
using ColorProcessorPtr = std::shared_ptr<ColorProcessor>;
@@ -40,9 +42,10 @@ public:
kInverse
};
ColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
ColorProcessor(ColorManager* config, const QString &source_space, const QString &dest_space);
ColorProcessor(OCIO::ConstConfigRcPtr config, const QString& source_space,
ColorProcessor(ColorManager* config,
QString source_space,
QString display,
QString view,
const QString& look,
@@ -50,9 +53,9 @@ public:
DISABLE_COPY_MOVE(ColorProcessor)
static ColorProcessorPtr Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space);
static ColorProcessorPtr Create(ColorManager* config, const QString& source_space, const QString& dest_space);
static ColorProcessorPtr Create(OCIO::ConstConfigRcPtr config,
static ColorProcessorPtr Create(ColorManager* config,
const QString& source_space,
const QString& display,
const QString& view,
@@ -66,7 +69,7 @@ public:
Color ConvertColor(Color in);
private:
OCIO::ConstProcessorRcPtr processor;
OCIO::ConstProcessorRcPtr processor_;
};
+84
View File
@@ -0,0 +1,84 @@
/***
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 "managedcolor.h"
OLIVE_NAMESPACE_ENTER
ManagedColor::ManagedColor()
{
}
ManagedColor::ManagedColor(const float &r, const float &g, const float &b, const float &a) :
Color(r, g, b, a)
{
}
ManagedColor::ManagedColor(const char *data, const PixelFormat::Format &format) :
Color(data, format)
{
}
ManagedColor::ManagedColor(const Color &c) :
Color(c)
{
}
const QString &ManagedColor::color_input() const
{
return color_input_;
}
void ManagedColor::set_color_input(const QString &color_input)
{
color_input_ = color_input;
}
const QString &ManagedColor::color_display() const
{
return color_display_;
}
void ManagedColor::set_color_display(const QString &color_display)
{
color_display_ = color_display;
}
const QString &ManagedColor::color_view() const
{
return color_view_;
}
void ManagedColor::set_color_view(const QString &color_view)
{
color_view_ = color_view;
}
const QString &ManagedColor::color_look() const
{
return color_look_;
}
void ManagedColor::set_color_look(const QString &color_look)
{
color_look_ = color_look;
}
OLIVE_NAMESPACE_EXIT
+61
View File
@@ -0,0 +1,61 @@
/***
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 MANAGEDCOLOR_H
#define MANAGEDCOLOR_H
#include "color.h"
OLIVE_NAMESPACE_ENTER
class ManagedColor : public Color
{
public:
ManagedColor();
ManagedColor(const float& r, const float& g, const float& b, const float& a = 1.0f);
ManagedColor(const char *data, const PixelFormat::Format &format);
ManagedColor(const Color& c);
const QString& color_input() const;
void set_color_input(const QString &color_input);
const QString& color_display() const;
void set_color_display(const QString &color_display);
const QString& color_view() const;
void set_color_view(const QString &color_view);
const QString& color_look() const;
void set_color_look(const QString &color_look);
private:
QString color_input_;
QString color_display_;
QString color_view_;
QString color_look_;
};
OLIVE_NAMESPACE_EXIT
#endif // MANAGEDCOLOR_H