backend color management on viewer
This commit is contained in:
+3
-1
@@ -33,6 +33,7 @@
|
|||||||
#include "panel/project/project.h"
|
#include "panel/project/project.h"
|
||||||
#include "project/item/footage/footage.h"
|
#include "project/item/footage/footage.h"
|
||||||
#include "project/item/sequence/sequence.h"
|
#include "project/item/sequence/sequence.h"
|
||||||
|
#include "render/colorservice.h"
|
||||||
#include "task/import/import.h"
|
#include "task/import/import.h"
|
||||||
#include "task/taskmanager.h"
|
#include "task/taskmanager.h"
|
||||||
#include "ui/style/style.h"
|
#include "ui/style/style.h"
|
||||||
@@ -359,7 +360,8 @@ void Core::StartGUI(bool full_screen)
|
|||||||
// When a new project is opened, update the mainwindow
|
// When a new project is opened, update the mainwindow
|
||||||
connect(this, SIGNAL(ProjectOpened(Project*)), main_window_, SLOT(ProjectOpen(Project*)));
|
connect(this, SIGNAL(ProjectOpened(Project*)), main_window_, SLOT(ProjectOpen(Project*)));
|
||||||
|
|
||||||
|
// Initialize color service
|
||||||
|
ColorService::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Project *Core::GetActiveProject()
|
Project *Core::GetActiveProject()
|
||||||
|
|||||||
@@ -4,13 +4,25 @@
|
|||||||
|
|
||||||
ColorService::ColorService(const char* source_space, const char* dest_space)
|
ColorService::ColorService(const char* source_space, const char* dest_space)
|
||||||
{
|
{
|
||||||
// FIXME: Hardcoded values for testing purposes
|
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||||
OCIO::ConstConfigRcPtr config = OCIO::Config::CreateFromFile("/run/media/matt/Home/OpenColorIO/ocio.configs.0.7v4/nuke-default/config.ocio");
|
|
||||||
|
|
||||||
processor = config->getProcessor(source_space,
|
processor = config->getProcessor(source_space,
|
||||||
dest_space);
|
dest_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorService::Init()
|
||||||
|
{
|
||||||
|
// FIXME: Hardcoded values for testing purposes
|
||||||
|
OCIO::ConstConfigRcPtr config = OCIO::Config::CreateFromFile("/run/media/matt/Home/OpenColorIO/ocio.configs.0.7v4/nuke-default/config.ocio");
|
||||||
|
|
||||||
|
OCIO::SetCurrentConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorServicePtr ColorService::Create(const char *source_space, const char *dest_space)
|
||||||
|
{
|
||||||
|
return std::make_shared<ColorService>(source_space, dest_space);
|
||||||
|
}
|
||||||
|
|
||||||
void ColorService::ConvertFrame(FramePtr f)
|
void ColorService::ConvertFrame(FramePtr f)
|
||||||
{
|
{
|
||||||
OCIO::PackedImageDesc img(reinterpret_cast<float*>(f->data()), f->width(), f->height(), kRGBAChannels);
|
OCIO::PackedImageDesc img(reinterpret_cast<float*>(f->data()), f->width(), f->height(), kRGBAChannels);
|
||||||
|
|||||||
@@ -8,11 +8,18 @@ namespace OCIO = OCIO_NAMESPACE::v1;
|
|||||||
#include "decoder/frame.h"
|
#include "decoder/frame.h"
|
||||||
#include "render/gl/shadergenerators.h"
|
#include "render/gl/shadergenerators.h"
|
||||||
|
|
||||||
|
class ColorService;
|
||||||
|
using ColorServicePtr = std::shared_ptr<ColorService>;
|
||||||
|
|
||||||
class ColorService
|
class ColorService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorService(const char *source_space, const char *dest_space);
|
ColorService(const char *source_space, const char *dest_space);
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
|
||||||
|
static ColorServicePtr Create(const char *source_space, const char *dest_space);
|
||||||
|
|
||||||
void ConvertFrame(FramePtr f);
|
void ConvertFrame(FramePtr f);
|
||||||
|
|
||||||
OCIO::ConstProcessorRcPtr GetProcessor();
|
OCIO::ConstProcessorRcPtr GetProcessor();
|
||||||
@@ -21,6 +28,4 @@ private:
|
|||||||
OCIO::ConstProcessorRcPtr processor;
|
OCIO::ConstProcessorRcPtr processor;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ColorServicePtr = std::shared_ptr<ColorService>;
|
|
||||||
|
|
||||||
#endif // COLORSERVICE_H
|
#endif // COLORSERVICE_H
|
||||||
|
|||||||
@@ -29,8 +29,11 @@
|
|||||||
|
|
||||||
ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
|
ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
|
||||||
QOpenGLWidget(parent),
|
QOpenGLWidget(parent),
|
||||||
texture_(0)
|
texture_(0),
|
||||||
|
ocio_lut_(0)
|
||||||
{
|
{
|
||||||
|
// FIXME: Hardcoded values for testing
|
||||||
|
color_service_ = ColorService::Create(OCIO::ROLE_SCENE_LINEAR, "srgb");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerGLWidget::SetTexture(GLuint tex)
|
void ViewerGLWidget::SetTexture(GLuint tex)
|
||||||
@@ -45,7 +48,12 @@ void ViewerGLWidget::SetTexture(GLuint tex)
|
|||||||
void ViewerGLWidget::initializeGL()
|
void ViewerGLWidget::initializeGL()
|
||||||
{
|
{
|
||||||
// Re-retrieve pipeline pertaining to this context
|
// Re-retrieve pipeline pertaining to this context
|
||||||
pipeline_ = olive::ShaderGenerator::DefaultPipeline();
|
pipeline_ = olive::ShaderGenerator::OCIOPipeline(context(),
|
||||||
|
ocio_lut_,
|
||||||
|
color_service_->GetProcessor(),
|
||||||
|
true);
|
||||||
|
|
||||||
|
connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(ContextCleanup()), Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerGLWidget::paintGL()
|
void ViewerGLWidget::paintGL()
|
||||||
@@ -63,9 +71,23 @@ void ViewerGLWidget::paintGL()
|
|||||||
f->glBindTexture(GL_TEXTURE_2D, texture_);
|
f->glBindTexture(GL_TEXTURE_2D, texture_);
|
||||||
|
|
||||||
// Blit using the pipeline retrieved in initializeGL()
|
// Blit using the pipeline retrieved in initializeGL()
|
||||||
olive::gl::Blit(pipeline_, true);
|
olive::gl::OCIOBlit(pipeline_, ocio_lut_, true);
|
||||||
|
|
||||||
// Release retrieved texture
|
// Release retrieved texture
|
||||||
f->glBindTexture(GL_TEXTURE_2D, 0);
|
f->glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewerGLWidget::ContextCleanup()
|
||||||
|
{
|
||||||
|
makeCurrent();
|
||||||
|
|
||||||
|
if (ocio_lut_ != 0) {
|
||||||
|
context()->functions()->glDeleteTextures(1, &ocio_lut_);
|
||||||
|
ocio_lut_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pipeline_ = nullptr;
|
||||||
|
|
||||||
|
doneCurrent();
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
|
|
||||||
|
#include "render/colorservice.h"
|
||||||
#include "render/gl/shaderptr.h"
|
#include "render/gl/shaderptr.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
class ViewerGLWidget : public QOpenGLWidget
|
class ViewerGLWidget : public QOpenGLWidget
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief ViewerGLWidget Constructor
|
* @brief ViewerGLWidget Constructor
|
||||||
@@ -88,6 +90,19 @@ private:
|
|||||||
* Retrieved every initializeGL() in order to stay up to date when new contexts are generated.
|
* Retrieved every initializeGL() in order to stay up to date when new contexts are generated.
|
||||||
*/
|
*/
|
||||||
ShaderPtr pipeline_;
|
ShaderPtr pipeline_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief OCIO LUT texture used for conversions
|
||||||
|
*/
|
||||||
|
GLuint ocio_lut_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Color management service
|
||||||
|
*/
|
||||||
|
ColorServicePtr color_service_;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ContextCleanup();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIEWERGLWIDGET_H
|
#endif // VIEWERGLWIDGET_H
|
||||||
|
|||||||
Reference in New Issue
Block a user