backend color management on viewer
This commit is contained in:
+3
-1
@@ -33,6 +33,7 @@
|
||||
#include "panel/project/project.h"
|
||||
#include "project/item/footage/footage.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "render/colorservice.h"
|
||||
#include "task/import/import.h"
|
||||
#include "task/taskmanager.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
|
||||
connect(this, SIGNAL(ProjectOpened(Project*)), main_window_, SLOT(ProjectOpen(Project*)));
|
||||
|
||||
|
||||
// Initialize color service
|
||||
ColorService::Init();
|
||||
}
|
||||
|
||||
Project *Core::GetActiveProject()
|
||||
|
||||
@@ -4,13 +4,25 @@
|
||||
|
||||
ColorService::ColorService(const char* source_space, const char* dest_space)
|
||||
{
|
||||
// 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::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
|
||||
processor = config->getProcessor(source_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)
|
||||
{
|
||||
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 "render/gl/shadergenerators.h"
|
||||
|
||||
class ColorService;
|
||||
using ColorServicePtr = std::shared_ptr<ColorService>;
|
||||
|
||||
class ColorService
|
||||
{
|
||||
public:
|
||||
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);
|
||||
|
||||
OCIO::ConstProcessorRcPtr GetProcessor();
|
||||
@@ -21,6 +28,4 @@ private:
|
||||
OCIO::ConstProcessorRcPtr processor;
|
||||
};
|
||||
|
||||
using ColorServicePtr = std::shared_ptr<ColorService>;
|
||||
|
||||
#endif // COLORSERVICE_H
|
||||
|
||||
@@ -29,8 +29,11 @@
|
||||
|
||||
ViewerGLWidget::ViewerGLWidget(QWidget *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)
|
||||
@@ -45,7 +48,12 @@ void ViewerGLWidget::SetTexture(GLuint tex)
|
||||
void ViewerGLWidget::initializeGL()
|
||||
{
|
||||
// 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()
|
||||
@@ -63,9 +71,23 @@ void ViewerGLWidget::paintGL()
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture_);
|
||||
|
||||
// Blit using the pipeline retrieved in initializeGL()
|
||||
olive::gl::Blit(pipeline_, true);
|
||||
olive::gl::OCIOBlit(pipeline_, ocio_lut_, true);
|
||||
|
||||
// Release retrieved texture
|
||||
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 "render/colorservice.h"
|
||||
#include "render/gl/shaderptr.h"
|
||||
|
||||
/**
|
||||
@@ -42,6 +43,7 @@
|
||||
*/
|
||||
class ViewerGLWidget : public QOpenGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief ViewerGLWidget Constructor
|
||||
@@ -88,6 +90,19 @@ private:
|
||||
* Retrieved every initializeGL() in order to stay up to date when new contexts are generated.
|
||||
*/
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user