viewer: ported to openglcolorprocessor for simpler code and fixed bug that

snuck in breaking color managed display
This commit is contained in:
itsmattkc
2020-02-22 00:13:28 +11:00
parent b0c9711974
commit 77c0c9d95a
5 changed files with 20 additions and 47 deletions
@@ -31,9 +31,9 @@ OpenGLShaderPtr OpenGLColorProcessor::pipeline() const
return pipeline_;
}
void OpenGLColorProcessor::ProcessOpenGL()
void OpenGLColorProcessor::ProcessOpenGL(bool flipped, const QMatrix4x4& matrix)
{
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_);
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, flipped, matrix);
}
void OpenGLColorProcessor::ClearTexture()
@@ -34,7 +34,7 @@ public:
OpenGLShaderPtr pipeline() const;
void ProcessOpenGL();
void ProcessOpenGL(bool flipped = false, const QMatrix4x4& matrix = QMatrix4x4());
private:
QOpenGLContext* context_;
@@ -121,9 +121,9 @@ void OpenGLRenderFunctions::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix
}
void OpenGLRenderFunctions::OCIOBlit(OpenGLShaderPtr pipeline,
GLuint lut,
bool flipped,
QMatrix4x4 matrix)
GLuint lut,
bool flipped,
QMatrix4x4 matrix)
{
QOpenGLContext* ctx = QOpenGLContext::currentContext();
QOpenGLExtraFunctions* xf = ctx->extraFunctions();
+12 -28
View File
@@ -37,7 +37,6 @@ bool ViewerGLWidget::nouveau_check_done_ = false;
ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
QOpenGLWidget(parent),
ocio_lut_(0),
color_manager_(nullptr),
has_image_(false)
{
@@ -207,16 +206,15 @@ void ViewerGLWidget::paintGL()
f->glClear(GL_COLOR_BUFFER_BIT);
// We only draw if we have a pipeline
if (!has_image_ || !pipeline_ || !texture_.IsCreated()) {
if (!has_image_ || !color_service_ || !texture_.IsCreated()) {
return;
}
// Bind retrieved texture
f->glBindTexture(GL_TEXTURE_2D, texture_.texture());
// Blit using the pipeline retrieved in initializeGL()
//OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, true, matrix_);
OpenGLRenderFunctions::Blit(pipeline_, true, matrix_);
// Blit using the color service
color_service_->ProcessOpenGL(true, matrix_);
// Release retrieved texture
f->glBindTexture(GL_TEXTURE_2D, 0);
@@ -226,7 +224,6 @@ void ViewerGLWidget::RefreshColorPipeline()
{
if (!color_manager_) {
color_service_ = nullptr;
pipeline_ = nullptr;
return;
}
@@ -267,7 +264,7 @@ void ViewerGLWidget::SetupColorProcessor()
return;
}
ClearOCIOLutTexture();
color_service_ = nullptr;
if (color_manager_) {
// (Re)create color processor
@@ -279,17 +276,14 @@ void ViewerGLWidget::SetupColorProcessor()
ocio_view_,
ocio_look_);
color_service_ = ColorProcessor::Create(color_manager_->GetConfig(),
OCIO::ROLE_SCENE_LINEAR,
ocio_display_,
ocio_view_,
ocio_look_);
color_service_ = OpenGLColorProcessor::CreateOpenGL(color_manager_->GetConfig(),
OCIO::ROLE_SCENE_LINEAR,
ocio_display_,
ocio_view_,
ocio_look_);
color_service_->Enable(context(), true);
// (Re)create pipeline from color processor
pipeline_ = OpenGLShader::CreateOCIO(context(),
ocio_lut_,
color_service_->GetProcessor(),
true);
} catch (OCIO::Exception& e) {
QMessageBox::critical(this,
tr("OpenColorIO Error"),
@@ -299,15 +293,6 @@ void ViewerGLWidget::SetupColorProcessor()
} else {
color_service_ = nullptr;
pipeline_ = nullptr;
}
}
void ViewerGLWidget::ClearOCIOLutTexture()
{
if (ocio_lut_ > 0) {
context()->functions()->glDeleteTextures(1, &ocio_lut_);
ocio_lut_ = 0;
}
}
@@ -315,9 +300,8 @@ void ViewerGLWidget::ContextCleanup()
{
makeCurrent();
ClearOCIOLutTexture();
color_service_ = nullptr;
texture_.Destroy();
pipeline_ = nullptr;
doneCurrent();
}
+2 -13
View File
@@ -23,6 +23,7 @@
#include <QOpenGLWidget>
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglshader.h"
#include "render/backend/opengl/opengltexture.h"
#include "render/colormanager.h"
@@ -164,18 +165,6 @@ private:
*/
OpenGLTexture texture_;
/**
* @brief Internal shader object to use as the pipeline shader
*
* Retrieved every initializeGL() in order to stay up to date when new contexts are generated.
*/
OpenGLShaderPtr pipeline_;
/**
* @brief OCIO LUT texture used for conversions
*/
GLuint ocio_lut_;
/**
* @brief Connected color manager
*/
@@ -184,7 +173,7 @@ private:
/**
* @brief Color management service
*/
ColorProcessorPtr color_service_;
OpenGLColorProcessorPtr color_service_;
/**
* @brief Drawing matrix (defaults to identity)