cache: fixed signalling issue where changing default input didn't update the cache
This commit is contained in:
@@ -47,7 +47,7 @@ VideoStreamProperties::VideoStreamProperties(ImageStreamPtr stream) :
|
||||
OCIO::ConstConfigRcPtr config = stream->footage()->project()->color_manager()->GetConfig();
|
||||
int number_of_colorspaces = config->getNumColorSpaces();
|
||||
|
||||
video_color_space_->addItem(tr("Default (%1)").arg(stream->footage()->project()->default_input_colorspace()));
|
||||
video_color_space_->addItem(tr("Default (%1)").arg(stream->footage()->project()->color_manager()->GetDefaultInputColorSpace()));
|
||||
|
||||
for (int i=0;i<number_of_colorspaces;i++) {
|
||||
QString colorspace = config->getColorSpaceNameByIndex(i);
|
||||
|
||||
@@ -85,17 +85,15 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project* p, QWidget *parent) :
|
||||
return;
|
||||
}
|
||||
|
||||
ocio_filename_->setText(working_project_->ocio_config());
|
||||
ListPossibleInputSpaces(working_project_->ocio_config());
|
||||
ocio_filename_->setText(working_project_->color_manager()->GetConfigFilename());
|
||||
ListPossibleInputSpaces(working_project_->color_manager()->GetConfigFilename());
|
||||
}
|
||||
|
||||
void ProjectPropertiesDialog::accept()
|
||||
{
|
||||
try {
|
||||
// This should ripple changes throughout the program that the color config has changed, therefore must be done last
|
||||
working_project_->set_ocio_config(ocio_filename_->text());
|
||||
|
||||
working_project_->set_default_input_colorspace(default_input_colorspace_->currentText());
|
||||
working_project_->color_manager()->SetConfigAndDefaultInput(ocio_filename_->text(), default_input_colorspace_->currentText());
|
||||
|
||||
QDialog::accept();
|
||||
} catch (OCIO::Exception& e) {
|
||||
@@ -132,7 +130,7 @@ void ProjectPropertiesDialog::ListPossibleInputSpaces(const QString& fn)
|
||||
foreach (QString cs, input_cs) {
|
||||
default_input_colorspace_->addItem(cs);
|
||||
|
||||
if (cs == working_project_->default_input_colorspace()) {
|
||||
if (cs == working_project_->color_manager()->GetDefaultInputColorSpace()) {
|
||||
default_input_colorspace_->setCurrentIndex(default_input_colorspace_->count()-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ void ImageStream::FootageSetEvent(Footage *f)
|
||||
this,
|
||||
&ImageStream::ColorConfigChanged,
|
||||
Qt::DirectConnection);
|
||||
|
||||
connect(f->project()->color_manager(),
|
||||
&ColorManager::DefaultInputColorSpaceChanged,
|
||||
this,
|
||||
&ImageStream::DefaultColorSpaceChanged,
|
||||
Qt::DirectConnection);
|
||||
}
|
||||
|
||||
void ImageStream::LoadCustomParameters(QXmlStreamReader *reader)
|
||||
@@ -101,7 +107,7 @@ void ImageStream::set_premultiplied_alpha(bool e)
|
||||
const QString &ImageStream::colorspace(bool default_if_empty) const
|
||||
{
|
||||
if (colorspace_.isEmpty() && default_if_empty) {
|
||||
return footage()->project()->default_input_colorspace();
|
||||
return footage()->project()->color_manager()->GetDefaultInputColorSpace();
|
||||
} else {
|
||||
return colorspace_;
|
||||
}
|
||||
|
||||
+4
-26
@@ -52,9 +52,9 @@ void Project::Load(QXmlStreamReader *reader, const QAtomicInt* cancelled)
|
||||
// Read color management info
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
if (reader->name() == QStringLiteral("config")) {
|
||||
set_ocio_config(reader->readElementText());
|
||||
color_manager_.SetConfig(reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("default")) {
|
||||
set_default_input_colorspace(reader->readElementText());
|
||||
color_manager_.SetDefaultInputColorSpace(reader->readElementText());
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -86,9 +86,9 @@ void Project::Save(QXmlStreamWriter *writer) const
|
||||
|
||||
writer->writeStartElement("colormanagement");
|
||||
|
||||
writer->writeTextElement("config", ocio_config_);
|
||||
writer->writeTextElement("config", color_manager_.GetConfigFilename());
|
||||
|
||||
writer->writeTextElement("default", default_input_colorspace());
|
||||
writer->writeTextElement("default", color_manager_.GetDefaultInputColorSpace());
|
||||
|
||||
writer->writeEndElement(); // colormanagement
|
||||
|
||||
@@ -135,28 +135,6 @@ void Project::set_filename(const QString &s)
|
||||
emit NameChanged();
|
||||
}
|
||||
|
||||
const QString &Project::ocio_config() const
|
||||
{
|
||||
return ocio_config_;
|
||||
}
|
||||
|
||||
void Project::set_ocio_config(const QString &ocio_config)
|
||||
{
|
||||
color_manager_.SetConfig(ocio_config);
|
||||
|
||||
ocio_config_ = ocio_config;
|
||||
}
|
||||
|
||||
const QString &Project::default_input_colorspace() const
|
||||
{
|
||||
return color_manager_.GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
void Project::set_default_input_colorspace(const QString &colorspace)
|
||||
{
|
||||
color_manager_.SetDefaultInputColorSpace(colorspace);
|
||||
}
|
||||
|
||||
ColorManager *Project::color_manager()
|
||||
{
|
||||
return &color_manager_;
|
||||
|
||||
@@ -58,12 +58,6 @@ public:
|
||||
QString pretty_filename() const;
|
||||
void set_filename(const QString& s);
|
||||
|
||||
const QString& ocio_config() const;
|
||||
void set_ocio_config(const QString& ocio_config);
|
||||
|
||||
const QString& default_input_colorspace() const;
|
||||
void set_default_input_colorspace(const QString& colorspace);
|
||||
|
||||
ColorManager* color_manager();
|
||||
|
||||
QList<ItemPtr> get_items_of_type(Item::Type type) const;
|
||||
@@ -86,8 +80,6 @@ private:
|
||||
|
||||
QString filename_;
|
||||
|
||||
QString ocio_config_;
|
||||
|
||||
ColorManager color_manager_;
|
||||
|
||||
bool is_modified_;
|
||||
|
||||
@@ -77,7 +77,7 @@ void OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, NodeValueTable*
|
||||
ImageStreamPtr video_stream = std::static_pointer_cast<ImageStream>(stream);
|
||||
|
||||
// Set up OCIO context
|
||||
QString colorspace_match = QStringLiteral("%1:%2").arg(video_stream->footage()->project()->ocio_config(), video_stream->colorspace());
|
||||
QString colorspace_match = QStringLiteral("%1:%2").arg(video_stream->footage()->project()->color_manager()->GetConfigFilename(), video_stream->colorspace());
|
||||
|
||||
OpenGLTextureCache::ReferencePtr footage_tex_ref = nullptr;
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ void VideoRenderWorker::HashNodeRecursively(QCryptographicHash *hash, const Node
|
||||
ImageStreamPtr image_stream = std::static_pointer_cast<ImageStream>(stream);
|
||||
|
||||
// Current color config and space
|
||||
hash->addData(image_stream->footage()->project()->ocio_config().toUtf8());
|
||||
hash->addData(image_stream->footage()->project()->color_manager()->GetConfigFilename().toUtf8());
|
||||
hash->addData(image_stream->colorspace().toUtf8());
|
||||
|
||||
// Alpha associated setting
|
||||
|
||||
@@ -42,24 +42,62 @@ OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
return config_;
|
||||
}
|
||||
|
||||
const QString &ColorManager::GetConfigFilename() const
|
||||
{
|
||||
return config_filename_;
|
||||
}
|
||||
|
||||
void ColorManager::SetConfig(const QString &filename)
|
||||
{
|
||||
if (filename != config_filename_) {
|
||||
SetConfigInternal(filename);
|
||||
|
||||
emit ConfigChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void ColorManager::SetConfigInternal(const QString &filename)
|
||||
{
|
||||
config_filename_ = filename;
|
||||
|
||||
OCIO::ConstConfigRcPtr cfg;
|
||||
|
||||
if (filename.isEmpty()) {
|
||||
if (config_filename_.isEmpty()) {
|
||||
cfg = OCIO::Config::CreateFromEnv();
|
||||
} else {
|
||||
cfg = OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
}
|
||||
|
||||
SetConfig(cfg);
|
||||
config_ = cfg;
|
||||
}
|
||||
|
||||
void ColorManager::SetConfig(OCIO::ConstConfigRcPtr config)
|
||||
void ColorManager::SetDefaultInputColorSpaceInternal(const QString &s)
|
||||
{
|
||||
config_ = config;
|
||||
default_input_color_space_ = s;
|
||||
}
|
||||
|
||||
emit ConfigChanged();
|
||||
void ColorManager::SetConfigAndDefaultInput(const QString &filename, const QString &s)
|
||||
{
|
||||
bool config_changed = false;
|
||||
bool default_input_changed = false;
|
||||
|
||||
if (filename != config_filename_) {
|
||||
SetConfigInternal(filename);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
if (default_input_color_space_ != s) {
|
||||
SetDefaultInputColorSpaceInternal(s);
|
||||
default_input_changed = true;
|
||||
}
|
||||
|
||||
if (config_changed) {
|
||||
emit ConfigChanged();
|
||||
}
|
||||
|
||||
if (default_input_changed) {
|
||||
emit DefaultInputColorSpaceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void ColorManager::DisassociateAlpha(FramePtr f)
|
||||
@@ -138,7 +176,11 @@ const QString &ColorManager::GetDefaultInputColorSpace() const
|
||||
|
||||
void ColorManager::SetDefaultInputColorSpace(const QString &s)
|
||||
{
|
||||
default_input_color_space_ = s;
|
||||
if (default_input_color_space_ != s) {
|
||||
SetDefaultInputColorSpaceInternal(s);
|
||||
|
||||
emit DefaultInputColorSpaceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
const QString &ColorManager::GetReferenceColorSpace() const
|
||||
@@ -149,6 +191,8 @@ const QString &ColorManager::GetReferenceColorSpace() const
|
||||
void ColorManager::SetReferenceColorSpace(const QString &s)
|
||||
{
|
||||
reference_space_ = s;
|
||||
|
||||
emit ConfigChanged();
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
|
||||
@@ -36,9 +36,11 @@ public:
|
||||
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
|
||||
const QString& GetConfigFilename() const;
|
||||
|
||||
void SetConfig(const QString& filename);
|
||||
|
||||
void SetConfig(OCIO::ConstConfigRcPtr config);
|
||||
void SetConfigAndDefaultInput(const QString& filename, const QString& s);
|
||||
|
||||
static void DisassociateAlpha(FramePtr f);
|
||||
|
||||
@@ -80,7 +82,13 @@ public:
|
||||
signals:
|
||||
void ConfigChanged();
|
||||
|
||||
void DefaultInputColorSpaceChanged();
|
||||
|
||||
private:
|
||||
void SetConfigInternal(const QString& filename);
|
||||
|
||||
void SetDefaultInputColorSpaceInternal(const QString& s);
|
||||
|
||||
OCIO::ConstConfigRcPtr config_;
|
||||
|
||||
enum AlphaAction {
|
||||
@@ -94,6 +102,8 @@ private:
|
||||
template<typename T>
|
||||
static void AssociateAlphaInternal(AlphaAction action, T* data, int pix_count);
|
||||
|
||||
QString config_filename_;
|
||||
|
||||
QString default_input_color_space_;
|
||||
|
||||
QString reference_space_;
|
||||
|
||||
Reference in New Issue
Block a user