work on internal color management

This commit is contained in:
itsmattkc
2019-09-28 01:38:15 +10:00
parent 4c90405feb
commit d2dc0d2823
24 changed files with 983 additions and 175 deletions
+75 -7
View File
@@ -20,6 +20,7 @@
#include "viewerglwidget.h"
#include <QMenu>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
@@ -32,8 +33,17 @@ ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
texture_(0),
ocio_lut_(0)
{
// FIXME: Hardcoded values for testing
color_service_ = ColorService::Create(OCIO::ROLE_SCENE_LINEAR, "srgb");
connect(ColorManager::instance(), SIGNAL(ConfigChanged()), this, SLOT(ColorConfigChangedSlot()));
RefreshColorSettings();
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));
}
ViewerGLWidget::~ViewerGLWidget()
{
ContextCleanup();
}
void ViewerGLWidget::SetTexture(GLuint tex)
@@ -47,11 +57,7 @@ void ViewerGLWidget::SetTexture(GLuint tex)
void ViewerGLWidget::initializeGL()
{
// Re-retrieve pipeline pertaining to this context
pipeline_ = olive::ShaderGenerator::OCIOPipeline(context(),
ocio_lut_,
color_service_->GetProcessor(),
true);
SetupPipeline();
connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(ContextCleanup()), Qt::DirectConnection);
}
@@ -78,6 +84,31 @@ void ViewerGLWidget::paintGL()
}
}
void ViewerGLWidget::SetupPipeline()
{
// Re-retrieve pipeline pertaining to this context
pipeline_ = olive::ShaderGenerator::OCIOPipeline(context(),
ocio_lut_,
color_service_->GetProcessor(),
true);
}
void ViewerGLWidget::RefreshColorSettings()
{
// FIXME: Should probably check first whether the new config has the existing settings
ocio_display_ = ColorManager::GetDefaultDisplay();
ocio_view_ = ColorManager::GetDefaultView(ocio_display_);
ocio_look_.clear();
SetupColorProcessor();
}
void ViewerGLWidget::SetupColorProcessor()
{
color_service_ = ColorProcessor::Create(OCIO::ROLE_SCENE_LINEAR, ocio_display_, ocio_view_, ocio_look_);
}
void ViewerGLWidget::ContextCleanup()
{
makeCurrent();
@@ -91,3 +122,40 @@ void ViewerGLWidget::ContextCleanup()
doneCurrent();
}
void ViewerGLWidget::ShowContextMenu(const QPoint &pos)
{
QMenu menu;
QStringList displays = ColorManager::ListAvailableDisplays();
QMenu* ocio_display_menu = menu.addMenu(tr("OCIO Display"));
foreach (QString d, displays) {
QAction* action = ocio_display_menu->addAction(d);
action->setChecked(ocio_display_ == d);
}
QStringList views = ColorManager::ListAvailableViews(ocio_display_);
QMenu* ocio_view_menu = menu.addMenu(tr("OCIO View"));
foreach (QString v, views) {
QAction* action = ocio_view_menu->addAction(v);
action->setChecked(ocio_view_ == v);
}
QStringList looks = ColorManager::ListAvailableLooks();
QMenu* ocio_look_menu = menu.addMenu(tr("OCIO Look"));
foreach (QString l, looks) {
QAction* action = ocio_look_menu->addAction(l);
action->setChecked(ocio_look_ == l);
}
menu.exec(mapToGlobal(pos));
}
void ViewerGLWidget::ColorConfigChangedSlot()
{
RefreshColorSettings();
if (pipeline_ != nullptr) {
SetupPipeline();
}
}