ColorManager is now specific to the Project
OCIO config was set on a per-project basis, but we were using a singleton for the ColorManager that would break if more than one project was ever open. Now the ColorManager belongs to the Project and is always accessed through the Project.
This commit is contained in:
@@ -99,9 +99,6 @@ void Core::Start()
|
||||
// Load application config
|
||||
Config::Load();
|
||||
|
||||
// Set up color manager
|
||||
ColorManager::CreateInstance();
|
||||
|
||||
|
||||
//
|
||||
// Start GUI (FIXME CLI mode)
|
||||
@@ -121,8 +118,6 @@ void Core::Stop()
|
||||
|
||||
AudioManager::DestroyInstance();
|
||||
|
||||
ColorManager::DestroyInstance();
|
||||
|
||||
NodeFactory::Destroy();
|
||||
|
||||
delete main_window_;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <QSplitter>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "project/project.h"
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
|
||||
@@ -81,7 +83,7 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
|
||||
|
||||
QTabWidget* preferences_tabs = new QTabWidget();
|
||||
QScrollArea* video_area = new QScrollArea();
|
||||
video_tab_ = new ExportVideoTab();
|
||||
video_tab_ = new ExportVideoTab(static_cast<Sequence*>(viewer_node_->parent())->project()->color_manager());
|
||||
video_area->setWidgetResizable(true);
|
||||
video_area->setWidget(video_tab_);
|
||||
preferences_tabs->addTab(video_area, tr("Video"));
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
#include "core.h"
|
||||
#include "render/colormanager.h"
|
||||
|
||||
ExportVideoTab::ExportVideoTab(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
ExportVideoTab::ExportVideoTab(ColorManager* color_manager, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
color_manager_(color_manager)
|
||||
{
|
||||
QVBoxLayout* outer_layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -144,7 +145,7 @@ QWidget* ExportVideoTab::SetupColorSection()
|
||||
|
||||
color_layout->addWidget(new QLabel(tr("Display:")), row, 0);
|
||||
|
||||
QStringList displays = ColorManager::ListAvailableDisplays();
|
||||
QStringList displays = color_manager_->ListAvailableDisplays();
|
||||
display_combobox_ = new QComboBox();
|
||||
foreach (const QString& display, displays) {
|
||||
display_combobox_->addItem(display, display);
|
||||
@@ -160,7 +161,7 @@ QWidget* ExportVideoTab::SetupColorSection()
|
||||
|
||||
row++;
|
||||
|
||||
QStringList looks = ColorManager::ListAvailableLooks();
|
||||
QStringList looks = color_manager_->ListAvailableLooks();
|
||||
looks_combobox_ = new QComboBox();
|
||||
looks_combobox_->addItem(tr("(None)"), QString());
|
||||
foreach (const QString& look, looks) {
|
||||
@@ -205,7 +206,7 @@ void ExportVideoTab::ColorDisplayChanged()
|
||||
{
|
||||
views_combobox_->clear();
|
||||
|
||||
QStringList views = ColorManager::ListAvailableViews(display_combobox_->currentData().toString());
|
||||
QStringList views = color_manager_->ListAvailableViews(display_combobox_->currentData().toString());
|
||||
foreach (const QString& view, views) {
|
||||
views_combobox_->addItem(view, view);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "render/colormanager.h"
|
||||
#include "widget/slider/integerslider.h"
|
||||
|
||||
class ExportVideoTab : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExportVideoTab(QWidget* parent = nullptr);
|
||||
ExportVideoTab(ColorManager* color_manager, QWidget* parent = nullptr);
|
||||
|
||||
QComboBox* codec_combobox() const;
|
||||
|
||||
@@ -55,6 +56,8 @@ private:
|
||||
|
||||
QList<rational> frame_rates_;
|
||||
|
||||
ColorManager* color_manager_;
|
||||
|
||||
private slots:
|
||||
void ColorDisplayChanged();
|
||||
void ColorViewChanged();
|
||||
|
||||
@@ -84,70 +84,6 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *foota
|
||||
|
||||
row++;
|
||||
|
||||
/*if (f->video_tracks.size() > 0) {
|
||||
// frame conforming
|
||||
if (!f->video_tracks.at(0).infinite_length) {
|
||||
layout->addWidget(new QLabel(tr("Conform to Frame Rate:"), this), row, 0);
|
||||
conform_fr = new QDoubleSpinBox(this);
|
||||
conform_fr->setMinimum(0.01);
|
||||
conform_fr->setValue(f->video_tracks.at(0).video_frame_rate * f->speed);
|
||||
layout->addWidget(conform_fr, row, 1);
|
||||
}
|
||||
|
||||
row++;
|
||||
|
||||
// premultiplied alpha mode
|
||||
premultiply_alpha_setting = new QCheckBox(tr("Alpha is Premultiplied"), this);
|
||||
premultiply_alpha_setting->setChecked(f->alpha_is_associated);
|
||||
layout->addWidget(premultiply_alpha_setting, row, 0);
|
||||
|
||||
row++;
|
||||
|
||||
// deinterlacing mode
|
||||
interlacing_box = new QComboBox(this);
|
||||
interlacing_box->addItem(
|
||||
tr("Auto (%1)").arg(
|
||||
Footage::get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing)
|
||||
)
|
||||
);
|
||||
interlacing_box->addItem(Footage::get_interlacing_name(VIDEO_PROGRESSIVE));
|
||||
interlacing_box->addItem(Footage::get_interlacing_name(VIDEO_TOP_FIELD_FIRST));
|
||||
interlacing_box->addItem(Footage::get_interlacing_name(VIDEO_BOTTOM_FIELD_FIRST));
|
||||
|
||||
interlacing_box->setCurrentIndex(
|
||||
(f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing)
|
||||
? 0
|
||||
: f->video_tracks.at(0).video_interlacing + 1);
|
||||
|
||||
layout->addWidget(new QLabel(tr("Interlacing:"), this), row, 0);
|
||||
layout->addWidget(interlacing_box, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
input_color_space = new QComboBox(this);
|
||||
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
QString footage_colorspace = f->Colorspace();
|
||||
|
||||
for (int i=0;i<config->getNumColorSpaces();i++) {
|
||||
QString colorspace = config->getColorSpaceNameByIndex(i);
|
||||
|
||||
input_color_space->addItem(colorspace);
|
||||
|
||||
if (colorspace == footage_colorspace) {
|
||||
input_color_space->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
layout->addWidget(new QLabel(tr("Color Space:")), row, 0);
|
||||
layout->addWidget(input_color_space, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
connect(track_list, SIGNAL(currentRowChanged(int)), stacked_widget_, SLOT(setCurrentIndex(int)));
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
@@ -159,72 +95,6 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *foota
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::accept() {
|
||||
/*Footage* f = item->to_footage();
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// set track enable
|
||||
for (int i=0;i<track_list->count();i++) {
|
||||
QListWidgetItem* item = track_list->item(i);
|
||||
const QVariant& data = item->data(Qt::UserRole+1);
|
||||
if (!data.isNull()) {
|
||||
int index = data.toInt();
|
||||
bool found = false;
|
||||
for (int j=0;j<f->video_tracks.size();j++) {
|
||||
if (f->video_tracks.at(j).file_index == index) {
|
||||
f->video_tracks[j].enabled = (item->checkState() == Qt::Checked);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
for (int j=0;j<f->audio_tracks.size();j++) {
|
||||
if (f->audio_tracks.at(j).file_index == index) {
|
||||
f->audio_tracks[j].enabled = (item->checkState() == Qt::Checked);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool refresh_clips = false;
|
||||
|
||||
// set interlacing
|
||||
if (f->video_tracks.size() > 0) {
|
||||
if (interlacing_box->currentIndex() > 0) {
|
||||
ca->append(new SetInt(&f->video_tracks[0].video_interlacing, interlacing_box->currentIndex() - 1));
|
||||
} else {
|
||||
ca->append(new SetInt(&f->video_tracks[0].video_interlacing, f->video_tracks.at(0).video_auto_interlacing));
|
||||
}
|
||||
|
||||
// set frame rate conform
|
||||
if (!f->video_tracks.at(0).infinite_length) {
|
||||
if (!qFuzzyCompare(conform_fr->value(), f->video_tracks.at(0).video_frame_rate)) {
|
||||
ca->append(new SetDouble(&f->speed, f->speed, conform_fr->value()/f->video_tracks.at(0).video_frame_rate));
|
||||
refresh_clips = true;
|
||||
}
|
||||
}
|
||||
|
||||
// set premultiplied alpha
|
||||
f->alpha_is_associated = premultiply_alpha_setting->isChecked();
|
||||
}
|
||||
|
||||
f->SetColorspace(input_color_space->currentText());
|
||||
|
||||
// set name
|
||||
MediaRename* mr = new MediaRename(item, name_box->text());
|
||||
|
||||
ca->append(mr);
|
||||
ca->appendPost(new CloseAllClipsCommand());
|
||||
ca->appendPost(new UpdateFootageTooltip(item));
|
||||
if (refresh_clips) {
|
||||
ca->appendPost(new RefreshClips(item));
|
||||
}
|
||||
ca->appendPost(new UpdateViewer());
|
||||
|
||||
olive::undo_stack.push(ca);*/
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
if (footage_->name() != footage_name_field_->text()) {
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <OpenColorIO/OpenColorIO.h>
|
||||
namespace OCIO = OCIO_NAMESPACE::v1;
|
||||
|
||||
#include "project/item/footage/footage.h"
|
||||
#include "project/project.h"
|
||||
#include "undo/undostack.h"
|
||||
|
||||
VideoStreamProperties::VideoStreamProperties(VideoStreamPtr stream) :
|
||||
@@ -36,7 +38,7 @@ VideoStreamProperties::VideoStreamProperties(VideoStreamPtr stream) :
|
||||
video_layout->addWidget(new QLabel(tr("Color Space:")), 0, 0);
|
||||
|
||||
video_color_space_ = new QComboBox();
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
OCIO::ConstConfigRcPtr config = stream->footage()->project()->color_manager()->GetConfig();
|
||||
int number_of_colorspaces = config->getNumColorSpaces();
|
||||
|
||||
for (int i=0;i<number_of_colorspaces;i++) {
|
||||
|
||||
@@ -97,7 +97,7 @@ void ProjectPropertiesDialog::accept()
|
||||
working_project_->set_ocio_config(ocio_filename_->text());
|
||||
|
||||
// This should ripple changes throughout the program that the color config has changed, therefore must be done last
|
||||
ColorManager::instance()->SetConfig(config);
|
||||
working_project_->color_manager()->SetConfig(config);
|
||||
|
||||
QDialog::accept();
|
||||
} catch (OCIO::Exception& e) {
|
||||
|
||||
@@ -28,9 +28,12 @@ ImageStream::ImageStream() :
|
||||
premultiplied_alpha_(false)
|
||||
{
|
||||
set_type(kImage);
|
||||
}
|
||||
|
||||
void ImageStream::FootageSetEvent(Footage *f)
|
||||
{
|
||||
// For some reason this connection fails if we don't explicitly specify DirectConnection
|
||||
connect(ColorManager::instance(), SIGNAL(ConfigChanged()), this, SLOT(ColorConfigChangedSlot()), Qt::DirectConnection);
|
||||
connect(f->project()->color_manager(), SIGNAL(ConfigChanged()), this, SLOT(ColorConfigChanged()), Qt::DirectConnection);
|
||||
}
|
||||
|
||||
QString ImageStream::description()
|
||||
@@ -86,11 +89,13 @@ void ImageStream::set_colorspace(const QString &color)
|
||||
emit ColorSpaceChanged();
|
||||
}
|
||||
|
||||
void ImageStream::ColorConfigChangedSlot()
|
||||
void ImageStream::ColorConfigChanged()
|
||||
{
|
||||
ColorManager* color_manager = static_cast<ColorManager*>(sender());
|
||||
|
||||
// Check if this colorspace is in the new config
|
||||
if (!colorspace_.isEmpty()) {
|
||||
QStringList colorspaces = ColorManager::ListAvailableInputColorspaces(OCIO::GetCurrentConfig());
|
||||
QStringList colorspaces = color_manager->ListAvailableInputColorspaces();
|
||||
if (!colorspaces.contains(colorspace_)) {
|
||||
// Set to empty if not
|
||||
colorspace_.clear();
|
||||
@@ -100,3 +105,11 @@ void ImageStream::ColorConfigChangedSlot()
|
||||
// Either way, the color calculation has likely changed so we signal here
|
||||
emit ColorSpaceChanged();
|
||||
}
|
||||
|
||||
void ImageStream::DefaultColorSpaceChanged()
|
||||
{
|
||||
// If no colorspace is set, this stream uses the default color space and it's just changed
|
||||
if (colorspace_.isEmpty()) {
|
||||
emit ColorSpaceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ public:
|
||||
signals:
|
||||
void ColorSpaceChanged();
|
||||
|
||||
protected:
|
||||
virtual void FootageSetEvent(Footage*) override;
|
||||
|
||||
private:
|
||||
int width_;
|
||||
int height_;
|
||||
@@ -56,7 +59,9 @@ private:
|
||||
QString colorspace_;
|
||||
|
||||
private slots:
|
||||
void ColorConfigChangedSlot();
|
||||
void ColorConfigChanged();
|
||||
|
||||
void DefaultColorSpaceChanged();
|
||||
};
|
||||
|
||||
using ImageStreamPtr = std::shared_ptr<ImageStream>;
|
||||
|
||||
@@ -58,6 +58,7 @@ Footage *Stream::footage() const
|
||||
void Stream::set_footage(Footage *f)
|
||||
{
|
||||
footage_ = f;
|
||||
FootageSetEvent(footage_);
|
||||
}
|
||||
|
||||
const rational &Stream::timebase() const
|
||||
|
||||
@@ -97,6 +97,9 @@ public:
|
||||
|
||||
StreamID ToID() const;
|
||||
|
||||
protected:
|
||||
virtual void FootageSetEvent(Footage*){}
|
||||
|
||||
private:
|
||||
Footage* footage_;
|
||||
|
||||
|
||||
@@ -60,3 +60,8 @@ void Project::set_default_input_colorspace(const QString &colorspace)
|
||||
{
|
||||
default_input_colorspace_ = colorspace;
|
||||
}
|
||||
|
||||
ColorManager *Project::color_manager()
|
||||
{
|
||||
return &color_manager_;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
#include "render/colormanager.h"
|
||||
#include "project/item/folder/folder.h"
|
||||
|
||||
/**
|
||||
@@ -54,6 +55,8 @@ public:
|
||||
const QString& default_input_colorspace();
|
||||
void set_default_input_colorspace(const QString& colorspace);
|
||||
|
||||
ColorManager* color_manager();
|
||||
|
||||
private:
|
||||
Folder root_;
|
||||
|
||||
@@ -61,6 +64,9 @@ private:
|
||||
|
||||
QString ocio_config_;
|
||||
QString default_input_colorspace_;
|
||||
|
||||
ColorManager color_manager_;
|
||||
|
||||
};
|
||||
|
||||
using ProjectPtr = std::shared_ptr<Project>;
|
||||
|
||||
@@ -34,14 +34,14 @@ void OpenGLColorProcessor::ProcessOpenGL()
|
||||
olive::gl::OCIOBlit(pipeline_, ocio_lut_);
|
||||
}
|
||||
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(const QString &source_space, const QString &dest_space) :
|
||||
ColorProcessor(source_space, dest_space),
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) :
|
||||
ColorProcessor(config, source_space, dest_space),
|
||||
ocio_lut_(0)
|
||||
{
|
||||
}
|
||||
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(const QString &source_space, QString display, QString view, const QString &look) :
|
||||
ColorProcessor(source_space, display, view, look),
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, QString display, QString view, const QString &look) :
|
||||
ColorProcessor(config, source_space, display, view, look),
|
||||
ocio_lut_(0)
|
||||
{
|
||||
}
|
||||
@@ -55,12 +55,12 @@ OpenGLColorProcessor::~OpenGLColorProcessor()
|
||||
}
|
||||
}
|
||||
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::CreateOpenGL(const QString &source_space, const QString &dest_space)
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::CreateOpenGL(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space)
|
||||
{
|
||||
return std::make_shared<OpenGLColorProcessor>(source_space, dest_space);
|
||||
return std::make_shared<OpenGLColorProcessor>(config, source_space, dest_space);
|
||||
}
|
||||
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::CreateOpenGL(const QString &source_space, const QString &display, const QString &view, const QString &look)
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::CreateOpenGL(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
return std::make_shared<OpenGLColorProcessor>(source_space, display, view, look);
|
||||
return std::make_shared<OpenGLColorProcessor>(config, source_space, display, view, look);
|
||||
}
|
||||
|
||||
@@ -10,18 +10,20 @@ using OpenGLColorProcessorPtr = std::shared_ptr<OpenGLColorProcessor>;
|
||||
class OpenGLColorProcessor : public ColorProcessor
|
||||
{
|
||||
public:
|
||||
OpenGLColorProcessor(const QString &source_space, const QString &dest_space);
|
||||
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
|
||||
|
||||
OpenGLColorProcessor(const QString& source_space,
|
||||
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config,
|
||||
const QString& source_space,
|
||||
QString display,
|
||||
QString view,
|
||||
const QString& look);
|
||||
|
||||
~OpenGLColorProcessor();
|
||||
|
||||
static OpenGLColorProcessorPtr CreateOpenGL(const QString& source_space, const QString& dest_space);
|
||||
static OpenGLColorProcessorPtr CreateOpenGL(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space);
|
||||
|
||||
static OpenGLColorProcessorPtr CreateOpenGL(const QString& source_space,
|
||||
static OpenGLColorProcessorPtr CreateOpenGL(OCIO::ConstConfigRcPtr config,
|
||||
const QString& source_space,
|
||||
const QString& display,
|
||||
const QString& view,
|
||||
const QString& look);
|
||||
|
||||
@@ -66,7 +66,9 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable
|
||||
OpenGLColorProcessorPtr color_processor = std::static_pointer_cast<OpenGLColorProcessor>(color_cache()->Get(video_stream->colorspace()));
|
||||
|
||||
if (!color_processor) {
|
||||
color_processor = OpenGLColorProcessor::CreateOpenGL(video_stream->colorspace(),
|
||||
// FIXME: We match with the colorspace string, but this won't change if the user sets a new config with a colorspace with the same string
|
||||
color_processor = OpenGLColorProcessor::CreateOpenGL(video_stream->footage()->project()->color_manager()->GetConfig(),
|
||||
video_stream->colorspace(),
|
||||
OCIO::ROLE_SCENE_LINEAR);
|
||||
color_cache()->Add(video_stream->colorspace(), color_processor);
|
||||
}
|
||||
|
||||
+25
-39
@@ -5,7 +5,16 @@
|
||||
#include "common/define.h"
|
||||
#include "config/config.h"
|
||||
|
||||
ColorManager* ColorManager::instance_ = nullptr;
|
||||
ColorManager::ColorManager()
|
||||
{
|
||||
// Ensures config is set to something
|
||||
config_ = OCIO::GetCurrentConfig();
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
{
|
||||
return config_;
|
||||
}
|
||||
|
||||
void ColorManager::SetConfig(const QString &filename)
|
||||
{
|
||||
@@ -14,29 +23,11 @@ void ColorManager::SetConfig(const QString &filename)
|
||||
|
||||
void ColorManager::SetConfig(OCIO::ConstConfigRcPtr config)
|
||||
{
|
||||
OCIO::SetCurrentConfig(config);
|
||||
config_ = config;
|
||||
|
||||
emit ConfigChanged();
|
||||
}
|
||||
|
||||
void ColorManager::CreateInstance()
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = new ColorManager();
|
||||
}
|
||||
}
|
||||
|
||||
ColorManager *ColorManager::instance()
|
||||
{
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void ColorManager::DestroyInstance()
|
||||
{
|
||||
delete instance_;
|
||||
instance_ = nullptr;
|
||||
}
|
||||
|
||||
void ColorManager::DisassociateAlpha(FramePtr f)
|
||||
{
|
||||
AssociateAlphaPixFmtFilter(kDisassociate, f);
|
||||
@@ -56,12 +47,10 @@ QStringList ColorManager::ListAvailableDisplays()
|
||||
{
|
||||
QStringList displays;
|
||||
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
int number_of_displays = config->getNumDisplays();
|
||||
int number_of_displays = config_->getNumDisplays();
|
||||
|
||||
for (int i=0;i<number_of_displays;i++) {
|
||||
displays.append(config->getDisplay(i));
|
||||
displays.append(config_->getDisplay(i));
|
||||
}
|
||||
|
||||
return displays;
|
||||
@@ -69,19 +58,17 @@ QStringList ColorManager::ListAvailableDisplays()
|
||||
|
||||
QString ColorManager::GetDefaultDisplay()
|
||||
{
|
||||
return OCIO::GetCurrentConfig()->getDefaultDisplay();
|
||||
return config_->getDefaultDisplay();
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableViews(QString display)
|
||||
{
|
||||
QStringList views;
|
||||
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
int number_of_views = config->getNumViews(display.toUtf8());
|
||||
int number_of_views = config_->getNumViews(display.toUtf8());
|
||||
|
||||
for (int i=0;i<number_of_views;i++) {
|
||||
views.append(config->getView(display.toUtf8(), i));
|
||||
views.append(config_->getView(display.toUtf8(), i));
|
||||
}
|
||||
|
||||
return views;
|
||||
@@ -89,25 +76,28 @@ QStringList ColorManager::ListAvailableViews(QString display)
|
||||
|
||||
QString ColorManager::GetDefaultView(const QString &display)
|
||||
{
|
||||
return OCIO::GetCurrentConfig()->getDefaultView(display.toUtf8());
|
||||
return config_->getDefaultView(display.toUtf8());
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableLooks()
|
||||
{
|
||||
QStringList looks;
|
||||
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
int number_of_looks = config->getNumLooks();
|
||||
int number_of_looks = config_->getNumLooks();
|
||||
|
||||
for (int i=0;i<number_of_looks;i++) {
|
||||
looks.append(config->getLookNameByIndex(i));
|
||||
looks.append(config_->getLookNameByIndex(i));
|
||||
}
|
||||
|
||||
return looks;
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableInputColorspaces(OpenColorIO::v1::ConstConfigRcPtr config)
|
||||
QStringList ColorManager::ListAvailableInputColorspaces()
|
||||
{
|
||||
return ListAvailableInputColorspaces(config_);
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
{
|
||||
QStringList spaces;
|
||||
|
||||
@@ -120,10 +110,6 @@ QStringList ColorManager::ListAvailableInputColorspaces(OpenColorIO::v1::ConstCo
|
||||
return spaces;
|
||||
}
|
||||
|
||||
ColorManager::ColorManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ColorManager::AssociateAlphaPixFmtFilter(ColorManager::AlphaAction action, FramePtr f)
|
||||
{
|
||||
int pixel_count = f->width() * f->height() * kRGBAChannels;
|
||||
|
||||
+12
-14
@@ -10,31 +10,31 @@ class ColorManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorManager();
|
||||
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
|
||||
void SetConfig(const QString& filename);
|
||||
|
||||
void SetConfig(OCIO::ConstConfigRcPtr config);
|
||||
|
||||
static void CreateInstance();
|
||||
|
||||
static ColorManager* instance();
|
||||
|
||||
static void DestroyInstance();
|
||||
|
||||
static void DisassociateAlpha(FramePtr f);
|
||||
|
||||
static void AssociateAlpha(FramePtr f);
|
||||
|
||||
static void ReassociateAlpha(FramePtr f);
|
||||
|
||||
static QStringList ListAvailableDisplays();
|
||||
QStringList ListAvailableDisplays();
|
||||
|
||||
static QString GetDefaultDisplay();
|
||||
QString GetDefaultDisplay();
|
||||
|
||||
static QStringList ListAvailableViews(QString display);
|
||||
QStringList ListAvailableViews(QString display);
|
||||
|
||||
static QString GetDefaultView(const QString& display);
|
||||
QString GetDefaultView(const QString& display);
|
||||
|
||||
static QStringList ListAvailableLooks();
|
||||
QStringList ListAvailableLooks();
|
||||
|
||||
QStringList ListAvailableInputColorspaces();
|
||||
|
||||
static QStringList ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config);
|
||||
|
||||
@@ -42,9 +42,7 @@ signals:
|
||||
void ConfigChanged();
|
||||
|
||||
private:
|
||||
ColorManager();
|
||||
|
||||
static ColorManager* instance_;
|
||||
OCIO::ConstConfigRcPtr config_;
|
||||
|
||||
enum AlphaAction {
|
||||
kAssociate,
|
||||
|
||||
@@ -2,21 +2,18 @@
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
ColorProcessor::ColorProcessor(const QString& source_space, const QString& dest_space)
|
||||
ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
|
||||
{
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
processor = config->getProcessor(source_space.toUtf8(),
|
||||
dest_space.toUtf8());
|
||||
}
|
||||
|
||||
ColorProcessor::ColorProcessor(const QString& source_space,
|
||||
ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config,
|
||||
const QString& source_space,
|
||||
QString display,
|
||||
QString view,
|
||||
const QString& look)
|
||||
{
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
if (display.isEmpty()) {
|
||||
display = config->getDefaultDisplay();
|
||||
}
|
||||
@@ -46,14 +43,14 @@ void ColorProcessor::ConvertFrame(FramePtr f)
|
||||
processor->apply(img);
|
||||
}
|
||||
|
||||
ColorProcessorPtr ColorProcessor::Create(const QString& source_space, const QString& dest_space)
|
||||
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
|
||||
{
|
||||
return std::make_shared<ColorProcessor>(source_space, dest_space);
|
||||
return std::make_shared<ColorProcessor>(config, source_space, dest_space);
|
||||
}
|
||||
|
||||
ColorProcessorPtr ColorProcessor::Create(const QString &source_space, const QString &display, const QString &view, const QString &look)
|
||||
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
return std::make_shared<ColorProcessor>(source_space, display, view, look);
|
||||
return std::make_shared<ColorProcessor>(config, source_space, display, view, look);
|
||||
}
|
||||
|
||||
OpenColorIO::v1::ConstProcessorRcPtr ColorProcessor::GetProcessor()
|
||||
|
||||
@@ -14,18 +14,19 @@ using ColorProcessorPtr = std::shared_ptr<ColorProcessor>;
|
||||
class ColorProcessor
|
||||
{
|
||||
public:
|
||||
ColorProcessor(const QString &source_space, const QString &dest_space);
|
||||
ColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
|
||||
|
||||
ColorProcessor(const QString& source_space,
|
||||
ColorProcessor(OCIO::ConstConfigRcPtr config, const QString& source_space,
|
||||
QString display,
|
||||
QString view,
|
||||
const QString& look);
|
||||
|
||||
DISABLE_COPY_MOVE(ColorProcessor)
|
||||
|
||||
static ColorProcessorPtr Create(const QString& source_space, const QString& dest_space);
|
||||
static ColorProcessorPtr Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space);
|
||||
|
||||
static ColorProcessorPtr Create(const QString& source_space,
|
||||
static ColorProcessorPtr Create(OCIO::ConstConfigRcPtr config,
|
||||
const QString& source_space,
|
||||
const QString& display,
|
||||
const QString& view,
|
||||
const QString& look);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "audio/audiomanager.h"
|
||||
#include "common/timecodefunctions.h"
|
||||
#include "config/config.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "project/project.h"
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -142,6 +144,8 @@ void ViewerWidget::ConnectViewerNode(ViewerOutput *node)
|
||||
|
||||
// Effectively disables the viewer and clears the state
|
||||
SizeChangedSlot(0, 0);
|
||||
|
||||
gl_widget_->DisconnectColorManager();
|
||||
}
|
||||
|
||||
viewer_node_ = node;
|
||||
@@ -158,6 +162,8 @@ void ViewerWidget::ConnectViewerNode(ViewerOutput *node)
|
||||
|
||||
SizeChangedSlot(viewer_node_->video_params().width(), viewer_node_->video_params().height());
|
||||
LengthChangedSlot(viewer_node_->Length());
|
||||
|
||||
gl_widget_->ConnectColorManager(static_cast<Sequence*>(viewer_node_->parent())->project()->color_manager());
|
||||
}
|
||||
|
||||
video_renderer_->SetViewerNode(viewer_node_);
|
||||
|
||||
@@ -32,10 +32,9 @@ ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
|
||||
QOpenGLWidget(parent),
|
||||
texture_(0),
|
||||
ocio_lut_(0),
|
||||
color_manager_(nullptr),
|
||||
color_menu_enabled_(true)
|
||||
{
|
||||
connect(ColorManager::instance(), SIGNAL(ConfigChanged()), this, SLOT(RefreshColorPipeline()));
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));
|
||||
}
|
||||
@@ -50,6 +49,26 @@ void ViewerGLWidget::SetColorMenuEnabled(bool enabled)
|
||||
color_menu_enabled_ = enabled;
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ConnectColorManager(ColorManager *color_manager)
|
||||
{
|
||||
if (color_manager_ != nullptr) {
|
||||
disconnect(color_manager_, SIGNAL(ConfigChanged()), this, SLOT(RefreshColorPipeline()));
|
||||
}
|
||||
|
||||
color_manager_ = color_manager;
|
||||
|
||||
if (color_manager_ != nullptr) {
|
||||
connect(color_manager_, SIGNAL(ConfigChanged()), this, SLOT(RefreshColorPipeline()));
|
||||
}
|
||||
|
||||
RefreshColorPipeline();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::DisconnectColorManager()
|
||||
{
|
||||
ConnectColorManager(nullptr);
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetOCIODisplay(const QString &display)
|
||||
{
|
||||
ocio_display_ = display;
|
||||
@@ -98,6 +117,11 @@ void ViewerGLWidget::initializeGL()
|
||||
|
||||
void ViewerGLWidget::paintGL()
|
||||
{
|
||||
// We only draw if we have a pipeline
|
||||
if (!pipeline_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get functions attached to this context (they will already be initialized)
|
||||
QOpenGLFunctions* f = context()->functions();
|
||||
|
||||
@@ -120,17 +144,17 @@ void ViewerGLWidget::paintGL()
|
||||
|
||||
void ViewerGLWidget::RefreshColorPipeline()
|
||||
{
|
||||
QStringList displays = ColorManager::ListAvailableDisplays();
|
||||
QStringList displays = color_manager_->ListAvailableDisplays();
|
||||
if (!displays.contains(ocio_display_)) {
|
||||
ocio_display_ = ColorManager::GetDefaultDisplay();
|
||||
ocio_display_ = color_manager_->GetDefaultDisplay();
|
||||
}
|
||||
|
||||
QStringList views = ColorManager::ListAvailableViews(ocio_display_);
|
||||
QStringList views = color_manager_->ListAvailableViews(ocio_display_);
|
||||
if (!views.contains(ocio_view_)) {
|
||||
ocio_view_ = ColorManager::GetDefaultView(ocio_display_);
|
||||
ocio_view_ = color_manager_->GetDefaultView(ocio_display_);
|
||||
}
|
||||
|
||||
QStringList looks = ColorManager::ListAvailableLooks();
|
||||
QStringList looks = color_manager_->ListAvailableLooks();
|
||||
if (!looks.contains(ocio_look_)) {
|
||||
ocio_look_.clear();
|
||||
}
|
||||
@@ -147,14 +171,19 @@ void ViewerGLWidget::SetupColorProcessor()
|
||||
|
||||
ClearOCIOLutTexture();
|
||||
|
||||
// (Re)create color processor
|
||||
color_service_ = ColorProcessor::Create(OCIO::ROLE_SCENE_LINEAR, ocio_display_, ocio_view_, ocio_look_);
|
||||
if (color_manager_) {
|
||||
// (Re)create color processor
|
||||
color_service_ = ColorProcessor::Create(color_manager_->GetConfig(), OCIO::ROLE_SCENE_LINEAR, ocio_display_, ocio_view_, ocio_look_);
|
||||
|
||||
// (Re)create pipeline from color processor
|
||||
pipeline_ = OpenGLShader::CreateOCIO(context(),
|
||||
ocio_lut_,
|
||||
color_service_->GetProcessor(),
|
||||
true);
|
||||
// (Re)create pipeline from color processor
|
||||
pipeline_ = OpenGLShader::CreateOCIO(context(),
|
||||
ocio_lut_,
|
||||
color_service_->GetProcessor(),
|
||||
true);
|
||||
} else {
|
||||
color_service_ = nullptr;
|
||||
pipeline_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ClearOCIOLutTexture()
|
||||
@@ -181,7 +210,7 @@ void ViewerGLWidget::ShowContextMenu(const QPoint &pos)
|
||||
QMenu menu;
|
||||
|
||||
if (color_menu_enabled_) {
|
||||
QStringList displays = ColorManager::ListAvailableDisplays();
|
||||
QStringList displays = color_manager_->ListAvailableDisplays();
|
||||
QMenu* ocio_display_menu = menu.addMenu(tr("Display"));
|
||||
connect(ocio_display_menu, SIGNAL(triggered(QAction*)), this, SLOT(ColorDisplayChanged(QAction*)));
|
||||
foreach (const QString& d, displays) {
|
||||
@@ -191,7 +220,7 @@ void ViewerGLWidget::ShowContextMenu(const QPoint &pos)
|
||||
action->setData(d);
|
||||
}
|
||||
|
||||
QStringList views = ColorManager::ListAvailableViews(ocio_display_);
|
||||
QStringList views = color_manager_->ListAvailableViews(ocio_display_);
|
||||
QMenu* ocio_view_menu = menu.addMenu(tr("View"));
|
||||
connect(ocio_view_menu, SIGNAL(triggered(QAction*)), this, SLOT(ColorViewChanged(QAction*)));
|
||||
foreach (const QString& v, views) {
|
||||
@@ -201,7 +230,7 @@ void ViewerGLWidget::ShowContextMenu(const QPoint &pos)
|
||||
action->setData(v);
|
||||
}
|
||||
|
||||
QStringList looks = ColorManager::ListAvailableLooks();
|
||||
QStringList looks = color_manager_->ListAvailableLooks();
|
||||
QMenu* ocio_look_menu = menu.addMenu(tr("Look"));
|
||||
connect(ocio_look_menu, SIGNAL(triggered(QAction*)), this, SLOT(ColorLookChanged(QAction*)));
|
||||
QAction* no_look_action = ocio_look_menu->addAction(tr("(None)"));
|
||||
|
||||
@@ -84,6 +84,16 @@ public:
|
||||
*/
|
||||
void SetColorMenuEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Connect a ColorManager (ColorManagers usually belong to the Project)
|
||||
*/
|
||||
void ConnectColorManager(ColorManager* color_manager);
|
||||
|
||||
/**
|
||||
* @brief Disconnect a ColorManager (equivalent to ConnectColorManager(nullptr))
|
||||
*/
|
||||
void DisconnectColorManager();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Set the texture to draw and draw it
|
||||
@@ -175,6 +185,11 @@ private:
|
||||
*/
|
||||
GLuint ocio_lut_;
|
||||
|
||||
/**
|
||||
* @brief Connected color manager
|
||||
*/
|
||||
ColorManager* color_manager_;
|
||||
|
||||
/**
|
||||
* @brief Color management service
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user