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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user