backend color management on viewer
This commit is contained in:
@@ -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