colormanagement: moved from passing DVL strings everywhere to a consolidated ColorTransform struct

This commit is contained in:
itsmattkc
2020-04-23 01:17:58 +10:00
parent a422f6e369
commit 6c1e90665f
21 changed files with 295 additions and 435 deletions
+7 -23
View File
@@ -61,9 +61,7 @@ ColorDialog::ColorDialog(ColorManager* color_manager, const ManagedColor& start,
chooser_ = new ColorSpaceChooser(color_manager_);
chooser_->set_input(start.color_input());
chooser_->set_display(start.color_display());
chooser_->set_view(start.color_view());
chooser_->set_look(start.color_look());
chooser_->set_output(start.color_output());
value_layout->addWidget(chooser_);
@@ -106,7 +104,7 @@ ColorDialog::ColorDialog(ColorManager* color_manager, const ManagedColor& start,
color_values_widget_->SetColor(managed_start);
connect(chooser_, &ColorSpaceChooser::ColorSpaceChanged, this, &ColorDialog::ColorSpaceChanged);
ColorSpaceChanged(chooser_->input(), chooser_->display(), chooser_->view(), chooser_->look());
ColorSpaceChanged(chooser_->input(), chooser_->output());
// Set default size ratio to 2:1
resize(sizeHint().height() * 2, sizeHint().height());
@@ -122,9 +120,7 @@ ManagedColor ColorDialog::GetSelectedColor() const
}
selected.set_color_input(GetColorSpaceInput());
selected.set_color_display(GetColorSpaceDisplay());
selected.set_color_view(GetColorSpaceView());
selected.set_color_look(GetColorSpaceLook());
selected.set_color_output(GetColorSpaceOutput());
return selected;
}
@@ -134,30 +130,18 @@ QString ColorDialog::GetColorSpaceInput() const
return chooser_->input();
}
QString ColorDialog::GetColorSpaceDisplay() const
ColorTransform ColorDialog::GetColorSpaceOutput() const
{
return chooser_->display();
return chooser_->output();
}
QString ColorDialog::GetColorSpaceView() const
{
return chooser_->view();
}
QString ColorDialog::GetColorSpaceLook() const
{
return chooser_->look();
}
void ColorDialog::ColorSpaceChanged(const QString &input, const QString &display, const QString &view, const QString &look)
void ColorDialog::ColorSpaceChanged(const QString &input, const ColorTransform &output)
{
input_to_ref_processor_ = ColorProcessor::Create(color_manager_, input, color_manager_->GetReferenceColorSpace());
ColorProcessorPtr ref_to_display = ColorProcessor::Create(color_manager_,
color_manager_->GetReferenceColorSpace(),
display,
view,
look);
output);
ColorProcessorPtr ref_to_input = ColorProcessor::Create(color_manager_, color_manager_->GetReferenceColorSpace(), input);
+5 -9
View File
@@ -23,13 +23,13 @@
#include <QDialog>
#include "colorspacechooser.h"
#include "colorvalueswidget.h"
#include "render/color.h"
#include "render/colormanager.h"
#include "render/managedcolor.h"
#include "widget/colorwheel/colorwheelwidget.h"
#include "widget/colorwheel/colorgradientwidget.h"
#include "widget/colorwheel/colorspacechooser.h"
#include "widget/colorwheel/colorvalueswidget.h"
#include "widget/colorwheel/colorwheelwidget.h"
OLIVE_NAMESPACE_ENTER
@@ -67,11 +67,7 @@ public:
QString GetColorSpaceInput() const;
QString GetColorSpaceDisplay() const;
QString GetColorSpaceView() const;
QString GetColorSpaceLook() const;
ColorTransform GetColorSpaceOutput() const;
private:
ColorManager* color_manager_;
@@ -87,7 +83,7 @@ private:
ColorSpaceChooser* chooser_;
private slots:
void ColorSpaceChanged(const QString& input, const QString& display, const QString& view, const QString& look);
void ColorSpaceChanged(const QString& input, const ColorTransform &output);
};
+2 -2
View File
@@ -218,12 +218,12 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
connect(video_tab_,
&ExportVideoTab::ColorSpaceChanged,
preview_viewer_,
static_cast<void(ViewerWidget::*)(const QString&)>(&ViewerWidget::SetOCIODisplay));
static_cast<void(ViewerWidget::*)(const ColorTransform&)>(&ViewerWidget::SetColorTransform));
// Set viewer to view the node
preview_viewer_->ConnectViewerNode(viewer_node_);
preview_viewer_->SetColorMenuEnabled(false);
preview_viewer_->SetOCIODisplay(video_tab_->CurrentOCIOColorSpace());
preview_viewer_->SetColorTransform(video_tab_->CurrentOCIOColorSpace());
// Update renderer
// FIXME: This is going to be VERY slow since it will need to hash every single frame. It would be better to have a
+1 -1
View File
@@ -26,10 +26,10 @@
#include <QWidget>
#include "common/rational.h"
#include "dialog/color/colorspacechooser.h"
#include "dialog/export/codec/h264section.h"
#include "dialog/export/codec/imagesection.h"
#include "render/colormanager.h"
#include "widget/colorwheel/colorspacechooser.h"
#include "widget/slider/integerslider.h"
OLIVE_NAMESPACE_ENTER
@@ -71,31 +71,20 @@ void OpenGLColorProcessor::ClearTexture()
}
}
OpenGLColorProcessor::OpenGLColorProcessor(ColorManager* config, const QString &source_space, const QString &dest_space) :
OpenGLColorProcessor::OpenGLColorProcessor(ColorManager* config, const QString &source_space, const ColorTransform &dest_space) :
ColorProcessor(config, source_space, dest_space),
ocio_lut_(0)
{
}
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)
{
}
OpenGLColorProcessor::~OpenGLColorProcessor()
{
ClearTexture();
}
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &dest_space)
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(ColorManager *config, const QString &source_space, const ColorTransform &dest_space)
{
return std::make_shared<OpenGLColorProcessor>(config, source_space, dest_space);
}
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);
}
OLIVE_NAMESPACE_EXIT
@@ -33,25 +33,15 @@ class OpenGLColorProcessor : public QObject, public ColorProcessor
{
Q_OBJECT
public:
OpenGLColorProcessor(ColorManager *config, const QString &source_space, const QString &dest_space);
OpenGLColorProcessor(ColorManager *config,
const QString& source_space,
QString display,
QString view,
const QString& look,
Direction dir);
const QString& input,
const ColorTransform& dest);
~OpenGLColorProcessor();
static OpenGLColorProcessorPtr Create(ColorManager* config, const QString& source_space, const QString& dest_space);
virtual ~OpenGLColorProcessor() override;
static OpenGLColorProcessorPtr Create(ColorManager* config,
const QString& source_space,
const QString& display,
const QString& view,
const QString& look,
Direction dir = kNormal);
const QString& input,
const ColorTransform& dest);
void Enable(QOpenGLContext* context, bool alpha_is_associated);
bool IsEnabled() const;
+47
View File
@@ -218,6 +218,53 @@ void ColorManager::SetReferenceColorSpace(const QString &s)
emit ConfigChanged();
}
QString ColorManager::GetCompliantColorSpace(const QString &s)
{
if (ListAvailableInputColorspaces().contains(s)) {
return s;
} else {
return GetDefaultInputColorSpace();
}
}
ColorTransform ColorManager::GetCompliantColorSpace(const ColorTransform &transform, bool force_display)
{
if (transform.is_display() || force_display) {
// Get display information
QString display = transform.display();
QString view = transform.view();
QString look = transform.look();
// Check if display still exists in config
if (!ListAvailableDisplays().contains(display)) {
display = GetDefaultDisplay();
}
// Check if view still exists in display
if (!ListAvailableViews(display).contains(view)) {
view = GetDefaultView(display);
}
// Check if looks still exists
if (!ListAvailableLooks().contains(look)) {
look.clear();
}
return ColorTransform(display, view, look);
} else {
QString output = transform.output();
if (!ListAvailableInputColorspaces().contains(output)) {
output = GetDefaultInputColorSpace();
}
return ColorTransform(output);
}
}
QStringList ColorManager::ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config)
{
QStringList spaces;
+4
View File
@@ -72,6 +72,10 @@ public:
void SetReferenceColorSpace(const QString& s);
QString GetCompliantColorSpace(const QString& s);
ColorTransform GetCompliantColorSpace(const ColorTransform& transform, bool force_display = false);
static QStringList ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config);
enum OCIOMethod {
+26 -43
View File
@@ -25,45 +25,33 @@
OLIVE_NAMESPACE_ENTER
ColorProcessor::ColorProcessor(ColorManager *config, const QString& source_space, const QString& dest_space)
ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const ColorTransform &transform)
{
processor_ = config->GetConfig()->getProcessor(source_space.toUtf8(),
dest_space.toUtf8());
}
const QString& output = (transform.output().isEmpty()) ? config->GetDefaultDisplay() : transform.output();
if (transform.is_display()) {
const QString& view = (transform.view().isEmpty()) ? config->GetDefaultView(output) : transform.view();
OCIO::DisplayTransformRcPtr display_transform = OCIO::DisplayTransform::Create();
display_transform->setInputColorSpaceName(input.toUtf8());
display_transform->setDisplay(output.toUtf8());
display_transform->setView(view.toUtf8());
if (!transform.look().isEmpty()) {
display_transform->setLooksOverride(transform.look().toUtf8());
display_transform->setLooksOverrideEnabled(true);
}
processor_ = config->GetConfig()->getProcessor(display_transform);
} else {
processor_ = config->GetConfig()->getProcessor(input.toUtf8(),
output.toUtf8());
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();
}
if (view.isEmpty()) {
view = config->GetDefaultView(display);
}
// Get current display stats
OCIO::DisplayTransformRcPtr transform = OCIO::DisplayTransform::Create();
transform->setInputColorSpaceName(source_space.toUtf8());
transform->setDisplay(display.toUtf8());
transform->setView(view.toUtf8());
if (!look.isEmpty()) {
transform->setLooksOverride(look.toUtf8());
transform->setLooksOverrideEnabled(true);
}
OCIO::TransformDirection dir = (direction == kInverse) ? OCIO::TRANSFORM_DIR_INVERSE : OCIO::TRANSFORM_DIR_FORWARD;
processor_ = config->GetConfig()->getProcessor(transform, dir);
}
void ColorProcessor::ConvertFrame(Frame *f)
@@ -85,14 +73,9 @@ Color ColorProcessor::ConvertColor(Color in)
return in;
}
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString& source_space, const QString& dest_space)
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString& input, const ColorTransform &transform)
{
return std::make_shared<ColorProcessor>(config, source_space, dest_space);
}
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);
return std::make_shared<ColorProcessor>(config, input, transform);
}
OCIO::ConstProcessorRcPtr ColorProcessor::GetProcessor()
+5 -19
View File
@@ -21,11 +21,9 @@
#ifndef COLORPROCESSOR_H
#define COLORPROCESSOR_H
#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE::v1;
#include "codec/frame.h"
#include "render/color.h"
#include "render/colortransform.h"
OLIVE_NAMESPACE_ENTER
@@ -42,25 +40,11 @@ public:
kInverse
};
ColorProcessor(ColorManager* config, const QString &source_space, const QString &dest_space);
ColorProcessor(ColorManager* config,
QString source_space,
QString display,
QString view,
const QString& look,
Direction direction);
ColorProcessor(ColorManager* config, const QString& input, const ColorTransform& dest_space);
DISABLE_COPY_MOVE(ColorProcessor)
static ColorProcessorPtr Create(ColorManager* config, const QString& source_space, const QString& dest_space);
static ColorProcessorPtr Create(ColorManager* config,
const QString& source_space,
const QString& display,
const QString& view,
const QString& look,
Direction direction = kNormal);
static ColorProcessorPtr Create(ColorManager* config, const QString& input, const ColorTransform& dest_space);
OCIO::ConstProcessorRcPtr GetProcessor();
@@ -74,6 +58,8 @@ private:
};
using ColorProcessorChain = QList<ColorProcessorPtr>;
OLIVE_NAMESPACE_EXIT
#endif // COLORPROCESSOR_H
+86
View File
@@ -0,0 +1,86 @@
/***
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 COLORTRANSFORM_H
#define COLORTRANSFORM_H
#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE::v1;
#include <QString>
#include "common/define.h"
OLIVE_NAMESPACE_ENTER
class ColorTransform
{
public:
ColorTransform()
{
is_display_ = false;
}
ColorTransform(const QString& output)
{
is_display_ = false;
output_ = output;
}
ColorTransform(const QString& display, const QString& view, const QString& look)
{
is_display_ = true;
output_ = display;
view_ = view;
look_ = look;
}
bool is_display() const {
return is_display_;
}
const QString& display() const {
return output_;
}
const QString& output() const {
return output_;
}
const QString& view() const {
return view_;
}
const QString& look() const {
return look_;
}
private:
QString output_;
bool is_display_;
QString view_;
QString look_;
};
OLIVE_NAMESPACE_EXIT
#endif // COLORTRANSFORM_H
+4 -24
View File
@@ -51,34 +51,14 @@ void ManagedColor::set_color_input(const QString &color_input)
color_input_ = color_input;
}
const QString &ManagedColor::color_display() const
const ColorTransform &ManagedColor::color_output() const
{
return color_display_;
return color_transform_;
}
void ManagedColor::set_color_display(const QString &color_display)
void ManagedColor::set_color_output(const ColorTransform &color_output)
{
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;
color_transform_ = color_output;
}
OLIVE_NAMESPACE_EXIT
+4 -13
View File
@@ -22,6 +22,7 @@
#define MANAGEDCOLOR_H
#include "color.h"
#include "colortransform.h"
OLIVE_NAMESPACE_ENTER
@@ -36,23 +37,13 @@ public:
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);
const ColorTransform& color_output() const;
void set_color_output(const ColorTransform &color_output);
private:
QString color_input_;
QString color_display_;
QString color_view_;
QString color_look_;
ColorTransform color_transform_;
};
+5 -5
View File
@@ -27,14 +27,13 @@ OLIVE_NAMESPACE_ENTER
ColorButton::ColorButton(ColorManager* color_manager, QWidget *parent) :
QPushButton(parent),
color_manager_(color_manager),
color_(1.0f, 1.0f, 1.0f),
color_processor_(nullptr)
{
setAutoFillBackground(true);
connect(this, &ColorButton::clicked, this, &ColorButton::ShowColorDialog);
UpdateColor();
SetColor(Color(1.0f, 1.0f, 1.0f));
}
const ManagedColor &ColorButton::GetColor() const
@@ -46,6 +45,9 @@ void ColorButton::SetColor(const ManagedColor &c)
{
color_ = c;
color_.set_color_input(color_manager_->GetCompliantColorSpace(color_.color_input()));
color_.set_color_output(color_manager_->GetCompliantColorSpace(color_.color_output()));
UpdateColor();
}
@@ -66,9 +68,7 @@ void ColorButton::UpdateColor()
{
color_processor_ = ColorProcessor::Create(color_manager_,
color_.color_input(),
color_.color_display(),
color_.color_view(),
color_.color_look());
color_.color_output());
QColor managed = color_processor_->ConvertColor(color_).toQColor();
+13 -52
View File
@@ -131,68 +131,29 @@ QString ColorSpaceChooser::input() const
}
}
QString ColorSpaceChooser::display() const
ColorTransform ColorSpaceChooser::output() const
{
if (display_combobox_) {
return display_combobox_->currentText();
} else {
return QString();
}
}
QString ColorSpaceChooser::view() const
{
if (view_combobox_) {
return view_combobox_->currentText();
} else {
return QString();
}
}
QString ColorSpaceChooser::look() const
{
if (look_combobox_) {
return look_combobox_->currentData().toString();
} else {
return QString();
}
return ColorTransform(display_combobox_->currentText(),
view_combobox_->currentText(),
look_combobox_->currentIndex() == 0 ? QString() : look_combobox_->currentText());
}
void ColorSpaceChooser::set_input(const QString &s)
{
if (s.isEmpty()) {
input_combobox_->setCurrentText(color_manager_->GetDefaultInputColorSpace());
} else {
input_combobox_->setCurrentText(s);
}
input_combobox_->setCurrentText(color_manager_->GetCompliantColorSpace(s));
}
void ColorSpaceChooser::set_display(const QString &s)
void ColorSpaceChooser::set_output(const ColorTransform &out)
{
if (s.isEmpty()) {
display_combobox_->setCurrentText(color_manager_->GetDefaultDisplay());
} else {
display_combobox_->setCurrentText(s);
}
ColorTransform compliant = color_manager_->GetCompliantColorSpace(out);
UpdateViews(display_combobox_->currentText());
}
display_combobox_->setCurrentText(compliant.display());
view_combobox_->setCurrentText(compliant.view());
void ColorSpaceChooser::set_view(const QString &s)
{
if (s.isEmpty()) {
view_combobox_->setCurrentText(color_manager_->GetDefaultView(display_combobox_->currentText()));
} else {
view_combobox_->setCurrentText(s);
}
}
void ColorSpaceChooser::set_look(const QString &s)
{
if (s.isEmpty()) {
if (compliant.look().isEmpty()) {
look_combobox_->setCurrentIndex(0);
} else {
look_combobox_->setCurrentText(s);
look_combobox_->setCurrentText(compliant.look());
}
}
@@ -224,11 +185,11 @@ void ColorSpaceChooser::ComboBoxChanged()
}
if (display_combobox_) {
emit DisplayColorSpaceChanged(display(), view(), look());
emit OutputColorSpaceChanged(output());
}
if (input_combobox_ && display_combobox_) {
emit ColorSpaceChanged(input(), display(), view(), look());
emit ColorSpaceChanged(input(), output());
}
}
+4 -8
View File
@@ -35,21 +35,17 @@ public:
ColorSpaceChooser(ColorManager* color_manager, bool enable_input_field = true, bool enable_display_fields = true, QWidget* parent = nullptr);
QString input() const;
QString display() const;
QString view() const;
QString look() const;
ColorTransform output() const;
void set_input(const QString& s);
void set_display(const QString& s);
void set_view(const QString& s);
void set_look(const QString& s);
void set_output(const ColorTransform& out);
signals:
void InputColorSpaceChanged(const QString& input);
void ColorSpaceChanged(const QString& input, const QString& display, const QString& view, const QString& look);
void OutputColorSpaceChanged(const ColorTransform& out);
void DisplayColorSpaceChanged(const QString& display, const QString& view, const QString& look);
void ColorSpaceChanged(const QString& input, const ColorTransform& out);
private slots:
void UpdateViews(const QString &display);
@@ -361,9 +361,9 @@ void NodeParamViewWidgetBridge::WidgetCallback()
input_->blockSignals(true);
input_->set_property(QStringLiteral("col_input"), c.color_input());
input_->set_property(QStringLiteral("col_display"), c.color_display());
input_->set_property(QStringLiteral("col_view"), c.color_view());
input_->set_property(QStringLiteral("col_look"), c.color_look());
input_->set_property(QStringLiteral("col_display"), c.color_output().display());
input_->set_property(QStringLiteral("col_view"), c.color_output().view());
input_->set_property(QStringLiteral("col_look"), c.color_output().look());
input_->blockSignals(false);
Core::instance()->undo_stack()->pushIfHasChildren(command);
@@ -471,9 +471,12 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
ManagedColor mc = input_->get_value_at_time(node_time).value<Color>();
mc.set_color_input(input_->get_property(QStringLiteral("col_input")).toString());
mc.set_color_display(input_->get_property(QStringLiteral("col_display")).toString());
mc.set_color_view(input_->get_property(QStringLiteral("col_view")).toString());
mc.set_color_look(input_->get_property(QStringLiteral("col_look")).toString());
QString d = input_->get_property(QStringLiteral("col_display")).toString();
QString v = input_->get_property(QStringLiteral("col_view")).toString();
QString l = input_->get_property(QStringLiteral("col_look")).toString();
mc.set_color_output(ColorTransform(d, v, l));
static_cast<ColorButton*>(widgets_.first())->SetColor(mc);
break;
+37 -45
View File
@@ -421,6 +421,11 @@ void ViewerWidget::UpdateMinimumScale()
}
}
void ViewerWidget::SetColorTransform(const ColorTransform &transform, ViewerGLWidget *sender)
{
sender->SetColorTransform(transform);
}
void ViewerWidget::UpdateStack()
{
if (!GetConnectedNode() || GetConnectedNode()->texture_input()->IsConnected()) {
@@ -536,6 +541,10 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
// Color options
if (context_menu_widget_->color_manager() && color_menu_enabled_) {
const ColorTransform& transform = context_menu_widget_->GetColorTransform();
qDebug() << "CMW transform" << transform.display() << transform.view() << transform.look();
{
QStringList displays = context_menu_widget_->color_manager()->ListAvailableDisplays();
@@ -546,13 +555,13 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
foreach (const QString& d, displays) {
QAction* action = ocio_display_menu->addAction(d);
action->setCheckable(true);
action->setChecked(context_menu_widget_->ocio_display() == d);
action->setChecked(transform.display() == d);
action->setData(d);
}
}
{
QStringList views = context_menu_widget_->color_manager()->ListAvailableViews(context_menu_widget_->ocio_display());
QStringList views = context_menu_widget_->color_manager()->ListAvailableViews(transform.display());
Menu* ocio_view_menu = new Menu(tr("View"), &menu);
menu.addMenu(ocio_view_menu);
@@ -561,7 +570,7 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
foreach (const QString& v, views) {
QAction* action = ocio_view_menu->addAction(v);
action->setCheckable(true);
action->setChecked(context_menu_widget_->ocio_view() == v);
action->setChecked(transform.view() == v);
action->setData(v);
}
}
@@ -575,11 +584,11 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
connect(ocio_look_menu, &QMenu::triggered, this, &ViewerWidget::ContextMenuOCIOLook);
QAction* no_look_action = ocio_look_menu->addAction(tr("(None)"));
no_look_action->setCheckable(true);
no_look_action->setChecked(context_menu_widget_->ocio_look().isEmpty());
no_look_action->setChecked(transform.look().isEmpty());
foreach (const QString& l, looks) {
QAction* action = ocio_look_menu->addAction(l);
action->setCheckable(true);
action->setChecked(context_menu_widget_->ocio_look() == l);
action->setChecked(transform.look() == l);
action->setData(l);
}
}
@@ -751,44 +760,9 @@ void ViewerWidget::ShuttleRight()
PlayInternal(current_speed, false);
}
void ViewerWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look)
void ViewerWidget::SetColorTransform(const ColorTransform &transform)
{
SetOCIOParameters(display, view, look, main_gl_widget());
}
void ViewerWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look, ViewerGLWidget* sender)
{
sender->SetOCIOParameters(display, view, look);
}
void ViewerWidget::SetOCIODisplay(const QString &display)
{
SetOCIODisplay(display, main_gl_widget());
}
void ViewerWidget::SetOCIODisplay(const QString &display, ViewerGLWidget* sender)
{
sender->SetOCIODisplay(display);
}
void ViewerWidget::SetOCIOView(const QString &view)
{
SetOCIOView(view, main_gl_widget());
}
void ViewerWidget::SetOCIOLook(const QString &look)
{
SetOCIOLook(look, main_gl_widget());
}
void ViewerWidget::SetOCIOView(const QString &view, ViewerGLWidget* sender)
{
sender->SetOCIOView(view);
}
void ViewerWidget::SetOCIOLook(const QString &look, ViewerGLWidget* sender)
{
sender->SetOCIOLook(look);
SetColorTransform(transform, main_gl_widget());
}
void ViewerWidget::SetSignalCursorColorEnabled(bool e)
@@ -909,17 +883,35 @@ void ViewerWidget::LengthChangedSlot(const rational &length)
void ViewerWidget::ContextMenuOCIODisplay(QAction* action)
{
SetOCIODisplay(action->data().toString(), context_menu_widget_);
const ColorTransform& old_transform = context_menu_widget_->GetColorTransform();
ColorTransform new_transform = context_menu_widget_->color_manager()->GetCompliantColorSpace(ColorTransform(action->data().toString(),
old_transform.view(),
old_transform.look()));
SetColorTransform(new_transform, context_menu_widget_);
}
void ViewerWidget::ContextMenuOCIOView(QAction *action)
{
SetOCIOView(action->data().toString(), context_menu_widget_);
const ColorTransform& old_transform = context_menu_widget_->GetColorTransform();
ColorTransform new_transform = context_menu_widget_->color_manager()->GetCompliantColorSpace(ColorTransform(old_transform.display(),
action->data().toString(),
old_transform.look()));
SetColorTransform(new_transform, context_menu_widget_);
}
void ViewerWidget::ContextMenuOCIOLook(QAction *action)
{
SetOCIOLook(action->data().toString(), context_menu_widget_);
const ColorTransform& old_transform = context_menu_widget_->GetColorTransform();
ColorTransform new_transform = context_menu_widget_->color_manager()->GetCompliantColorSpace(ColorTransform(old_transform.display(),
old_transform.view(),
action->data().toString()));
SetColorTransform(new_transform, context_menu_widget_);
}
void ViewerWidget::SetDividerFromMenu(QAction *action)
+2 -26
View File
@@ -98,28 +98,7 @@ public slots:
void ShuttleRight();
void SetOCIOParameters(const QString& display, const QString& view, const QString& look);
/**
* @brief Externally set the OCIO display to use
*
* This value must be a valid display in the current OCIO configuration.
*/
void SetOCIODisplay(const QString& display);
/**
* @brief Externally set the OCIO view to use
*
* This value must be a valid display in the current OCIO configuration.
*/
void SetOCIOView(const QString& view);
/**
* @brief Externally set the OCIO look to use (use empty string if none)
*
* This value must be a valid display in the current OCIO configuration.
*/
void SetOCIOLook(const QString& look);
void SetColorTransform(const ColorTransform& transform);
/**
* @brief Wrapper for ViewerGLWidget::SetSignalCursorColorEnabled()
@@ -197,10 +176,7 @@ private:
void UpdateMinimumScale();
void SetOCIOParameters(const QString& display, const QString& view, const QString& look, ViewerGLWidget* sender);
void SetOCIODisplay(const QString& display, ViewerGLWidget* sender);
void SetOCIOView(const QString& view, ViewerGLWidget* sender);
void SetOCIOLook(const QString& look, ViewerGLWidget* sender);
void SetColorTransform(const ColorTransform& transform, ViewerGLWidget* sender);
QStackedWidget* stack_;
+20 -85
View File
@@ -63,16 +63,16 @@ void ViewerGLWidget::ConnectColorManager(ColorManager *color_manager)
}
if (color_manager_ != nullptr) {
disconnect(color_manager_, &ColorManager::ConfigChanged, this, &ViewerGLWidget::RefreshColorPipeline);
disconnect(color_manager_, &ColorManager::ConfigChanged, this, &ViewerGLWidget::ColorConfigChanged);
}
color_manager_ = color_manager;
if (color_manager_ != nullptr) {
connect(color_manager_, &ColorManager::ConfigChanged, this, &ViewerGLWidget::RefreshColorPipeline);
connect(color_manager_, &ColorManager::ConfigChanged, this, &ViewerGLWidget::ColorConfigChanged);
}
RefreshColorPipeline();
ColorConfigChanged();
}
void ViewerGLWidget::DisconnectColorManager()
@@ -185,55 +185,11 @@ void ViewerGLWidget::SetEmitDrewManagedTextureEnabled(bool e)
}
}
void ViewerGLWidget::SetOCIODisplay(const QString &display)
{
ocio_display_ = display;
// Determine if the selected view is available in this display
if (color_manager_
&& !color_manager_->ListAvailableViews(ocio_display_).contains(ocio_view_)) {
// If not, set to the default view for this display
ocio_view_ = color_manager_->GetDefaultView(ocio_display_);
}
SetupColorProcessor();
update();
}
void ViewerGLWidget::SetOCIOView(const QString &view)
{
ocio_view_ = view;
SetupColorProcessor();
update();
}
void ViewerGLWidget::SetOCIOLook(const QString &look)
{
ocio_look_ = look;
SetupColorProcessor();
update();
}
ColorManager *ViewerGLWidget::color_manager() const
{
return color_manager_;
}
const QString &ViewerGLWidget::ocio_display() const
{
return ocio_display_;
}
const QString &ViewerGLWidget::ocio_view() const
{
return ocio_view_;
}
const QString &ViewerGLWidget::ocio_look() const
{
return ocio_look_;
}
void ViewerGLWidget::ConnectSibling(ViewerGLWidget *sibling)
{
connect(this, &ViewerGLWidget::LoadedBuffer, sibling, &ViewerGLWidget::SetImageFromLoadBuffer, Qt::QueuedConnection);
@@ -252,6 +208,18 @@ void ViewerGLWidget::SetSafeMargins(const ViewerSafeMarginInfo &safe_margin)
update();
}
const ColorTransform &ViewerGLWidget::GetColorTransform() const
{
return color_transform_;
}
void ViewerGLWidget::SetColorTransform(const ColorTransform &transform)
{
color_transform_ = transform;
SetupColorProcessor();
update();
}
void ViewerGLWidget::mousePressEvent(QMouseEvent *event)
{
QOpenGLWidget::mousePressEvent(event);
@@ -284,15 +252,6 @@ void ViewerGLWidget::mouseMoveEvent(QMouseEvent *event)
}
}
void ViewerGLWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look)
{
ocio_display_ = display;
ocio_view_ = view;
ocio_look_ = look;
SetupColorProcessor();
update();
}
void ViewerGLWidget::initializeGL()
{
SetupColorProcessor();
@@ -416,30 +375,14 @@ void ViewerGLWidget::paintGL()
}
}
void ViewerGLWidget::RefreshColorPipeline()
void ViewerGLWidget::ColorConfigChanged()
{
if (!color_manager_) {
color_service_ = nullptr;
return;
}
QStringList displays = color_manager_->ListAvailableDisplays();
if (!displays.contains(ocio_display_)) {
ocio_display_ = color_manager_->GetDefaultDisplay();
}
QStringList views = color_manager_->ListAvailableViews(ocio_display_);
if (!views.contains(ocio_view_)) {
ocio_view_ = color_manager_->GetDefaultView(ocio_display_);
}
QStringList looks = color_manager_->ListAvailableLooks();
if (!looks.contains(ocio_look_)) {
ocio_look_.clear();
}
SetupColorProcessor();
update();
SetColorTransform(color_manager_->GetCompliantColorSpace(color_transform_, true));
}
#ifdef Q_OS_LINUX
@@ -467,17 +410,9 @@ void ViewerGLWidget::SetupColorProcessor()
try {
if (ocio_view_.isEmpty()) {
color_service_ = OpenGLColorProcessor::Create(color_manager_,
color_manager_->GetReferenceColorSpace(),
ocio_display_);
} else {
color_service_ = OpenGLColorProcessor::Create(color_manager_,
color_manager_->GetReferenceColorSpace(),
ocio_display_,
ocio_view_,
ocio_look_);
}
color_service_ = OpenGLColorProcessor::Create(color_manager_,
color_manager_->GetReferenceColorSpace(),
color_transform_);
makeCurrent();
color_service_->Enable(context(), true);
+7 -46
View File
@@ -80,10 +80,6 @@ public:
ColorManager* color_manager() const;
const QString& ocio_display() const;
const QString& ocio_view() const;
const QString& ocio_look() const;
const QMatrix4x4& GetMatrix();
void ConnectSibling(ViewerGLWidget* sibling);
@@ -91,38 +87,13 @@ public:
const ViewerSafeMarginInfo& GetSafeMargin() const;
void SetSafeMargins(const ViewerSafeMarginInfo& safe_margin);
const ColorTransform& GetColorTransform() const;
public slots:
/**
* @brief Set the texture to draw and draw it
*
* Use this function to update the viewer.
*
* @param tex
* @brief Replaces the color transform with a new one
*/
//void SetTexture(OpenGLTexturePtr tex);
void SetOCIOParameters(const QString& display, const QString& view, const QString& look);
/**
* @brief Externally set the OCIO display to use
*
* This value must be a valid display in the current OCIO configuration.
*/
void SetOCIODisplay(const QString& display);
/**
* @brief Externally set the OCIO view to use
*
* This value must be a valid display in the current OCIO configuration.
*/
void SetOCIOView(const QString& view);
/**
* @brief Externally set the OCIO look to use (use empty string if none)
*
* This value must be a valid display in the current OCIO configuration.
*/
void SetOCIOLook(const QString& look);
void SetColorTransform(const ColorTransform& transform);
/**
* @brief Set the transformation matrix to draw with
@@ -231,19 +202,9 @@ private:
void ClearOCIOLutTexture();
/**
* @brief Internal variable to set color space to
* @brief Internal color transform storage
*/
QString ocio_display_;
/**
* @brief Internal variable to set color space to
*/
QString ocio_view_;
/**
* @brief Internal variable to set color space to
*/
QString ocio_look_;
ColorTransform color_transform_;
/**
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
@@ -308,7 +269,7 @@ private slots:
/**
* @brief Sets all color settings to the defaults pertaining to this configuration
*/
void RefreshColorPipeline();
void ColorConfigChanged();
#ifdef Q_OS_LINUX
/**