openglcolorprocessor: delete texture when context is about to be destroyed
This commit is contained in:
@@ -17,6 +17,8 @@ void OpenGLColorProcessor::Enable(QOpenGLContext *context, bool alpha_is_associa
|
||||
ocio_lut_,
|
||||
GetProcessor(),
|
||||
alpha_is_associated);
|
||||
|
||||
connect(context_, &QOpenGLContext::aboutToBeDestroyed, this, &OpenGLColorProcessor::ClearTexture, Qt::DirectConnection);
|
||||
}
|
||||
|
||||
bool OpenGLColorProcessor::IsEnabled() const
|
||||
@@ -34,6 +36,19 @@ void OpenGLColorProcessor::ProcessOpenGL()
|
||||
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_);
|
||||
}
|
||||
|
||||
void OpenGLColorProcessor::ClearTexture()
|
||||
{
|
||||
if (IsEnabled()) {
|
||||
// Clean up OCIO LUT texture and shader
|
||||
context_->functions()->glDeleteTextures(1, &ocio_lut_);
|
||||
|
||||
disconnect(context_, &QOpenGLContext::aboutToBeDestroyed, this, &OpenGLColorProcessor::ClearTexture);
|
||||
|
||||
ocio_lut_ = 0;
|
||||
pipeline_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) :
|
||||
ColorProcessor(config, source_space, dest_space),
|
||||
ocio_lut_(0)
|
||||
@@ -48,11 +63,7 @@ OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const
|
||||
|
||||
OpenGLColorProcessor::~OpenGLColorProcessor()
|
||||
{
|
||||
if (IsEnabled()) {
|
||||
// Clean up OCIO LUT texture and shader
|
||||
context_->functions()->glDeleteTextures(1, &ocio_lut_);
|
||||
pipeline_ = nullptr;
|
||||
}
|
||||
ClearTexture();
|
||||
}
|
||||
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::CreateOpenGL(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space)
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
class OpenGLColorProcessor;
|
||||
using OpenGLColorProcessorPtr = std::shared_ptr<OpenGLColorProcessor>;
|
||||
|
||||
class OpenGLColorProcessor : public ColorProcessor
|
||||
class OpenGLColorProcessor : public QObject, public ColorProcessor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
|
||||
|
||||
@@ -42,6 +43,9 @@ private:
|
||||
|
||||
OpenGLShaderPtr pipeline_;
|
||||
|
||||
private slots:
|
||||
void ClearTexture();
|
||||
|
||||
};
|
||||
|
||||
#endif // OPENGLCOLORPROCESSOR_H
|
||||
|
||||
Reference in New Issue
Block a user