summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opengl/gl2paintengineex/qglcustomshaderstage.cpp17
-rw-r--r--src/opengl/gl2paintengineex/qglcustomshaderstage_p.h1
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp7
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h1
4 files changed, 26 insertions, 0 deletions
diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
index efc3b93..bcd9f27 100644
--- a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
+++ b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp
@@ -93,6 +93,23 @@ bool QGLCustomShaderStage::setOnPainter(QPainter* p)
return true;
}
+void QGLCustomShaderStage::removeFromPainter(QPainter* p)
+{
+ Q_D(QGLCustomShaderStage);
+ if (p->paintEngine()->type() != QPaintEngine::OpenGL2)
+ return;
+
+ // Might as well go through the paint engine to get to the context
+ const QGLContext* ctx = static_cast<QGL2PaintEngineEx*>(p->paintEngine())->context();
+ d->m_manager = QGLEngineShaderManager::managerForContext(ctx);
+ Q_ASSERT(d->m_manager);
+
+ // Just set the stage to null, don't call removeCustomStage().
+ // This should leave the program in a compiled/linked state
+ // if the next custom shader stage is this one again.
+ d->m_manager->setCustomStage(0);
+}
+
const char* QGLCustomShaderStage::source()
{
Q_D(QGLCustomShaderStage);
diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h
index 6e4ca1c..659f7ba 100644
--- a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h
+++ b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h
@@ -72,6 +72,7 @@ public:
void setUniformsDirty();
bool setOnPainter(QPainter*);
+ void removeFromPainter(QPainter*);
const char* source();
protected:
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index c110c50..6363212 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -86,6 +86,8 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context)
maskType(NoMask),
useTextureCoords(false),
compositionMode(QPainter::CompositionMode_SourceOver),
+ customSrcStage(0),
+ customSrcStagePrev(0),
blitShaderProg(0),
simpleShaderProg(0),
currentShaderProg(0)
@@ -311,6 +313,11 @@ void QGLEngineShaderManager::setCompositionMode(QPainter::CompositionMode mode)
void QGLEngineShaderManager::setCustomStage(QGLCustomShaderStage* stage)
{
+ // If the custom shader has changed, then destroy the previous compilation.
+ if (customSrcStagePrev && stage && customSrcStagePrev != stage)
+ removeCustomStage(customSrcStagePrev);
+
+ customSrcStagePrev = customSrcStage;
customSrcStage = stage;
shaderProgNeedsChanging = true;
}
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index 15082c3..9d881cc 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -421,6 +421,7 @@ private:
bool useTextureCoords;
QPainter::CompositionMode compositionMode;
QGLCustomShaderStage* customSrcStage;
+ QGLCustomShaderStage* customSrcStagePrev;
QGLShaderProgram* blitShaderProg;
QGLShaderProgram* simpleShaderProg;