From c1af214c80ccc3035e71febc389767092f3fb6bd Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 17 Aug 2011 18:46:01 +0200 Subject: The QSGShaderEffectTexture needs to be deleted in the rendering thread Change-Id: Id01d65b84e0dc7ab89bc4e90c3b52285ef79ac39 Reviewed-on: http://codereview.qt.nokia.com/3135 Reviewed-by: Qt Sanity Bot Reviewed-by: Kim M. Kalland --- src/declarative/items/qsgshadereffectsource.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/declarative/items/qsgshadereffectsource.cpp') diff --git a/src/declarative/items/qsgshadereffectsource.cpp b/src/declarative/items/qsgshadereffectsource.cpp index 5114d8c042..d2854e6079 100644 --- a/src/declarative/items/qsgshadereffectsource.cpp +++ b/src/declarative/items/qsgshadereffectsource.cpp @@ -76,6 +76,7 @@ QSGShaderEffectTexture::QSGShaderEffectTexture(QSGItem *shaderSource) #ifdef QSG_DEBUG_FBO_OVERLAY , m_debugOverlay(0) #endif + , m_context(0) , m_mipmap(false) , m_live(true) , m_recursive(false) @@ -96,6 +97,17 @@ QSGShaderEffectTexture::~QSGShaderEffectTexture() #endif } +void QSGShaderEffectTexture::scheduleForCleanup() +{ + if (m_context) + m_context->scheduleTextureForCleanup(this); + else { + // Never really been used, hence we can delete it right away.. + Q_ASSERT(!m_fbo); + delete this; + } +} + int QSGShaderEffectTexture::textureId() const { @@ -226,10 +238,12 @@ void QSGShaderEffectTexture::grab() return; } - QSGContext *context = QSGItemPrivate::get(m_shaderSource)->sceneGraphContext(); + if (!m_context) + m_context = QSGItemPrivate::get(m_shaderSource)->sceneGraphContext(); + Q_ASSERT(QSGItemPrivate::get(m_shaderSource)->sceneGraphContext() == m_context); if (!m_renderer) { - m_renderer = context->createRenderer(); + m_renderer = m_context->createRenderer(); connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()), Qt::DirectConnection); } m_renderer->setRootNode(static_cast(root)); @@ -293,7 +307,7 @@ void QSGShaderEffectTexture::grab() #ifdef QSG_DEBUG_FBO_OVERLAY if (qmlFboOverlay()) { if (!m_debugOverlay) - m_debugOverlay = context->createRectangleNode(); + m_debugOverlay = m_context->createRectangleNode(); m_debugOverlay->setRect(QRectF(0, 0, m_size.width(), m_size.height())); m_debugOverlay->setColor(QColor(0xff, 0x00, 0x80, 0x40)); m_debugOverlay->setPenColor(QColor()); @@ -306,7 +320,7 @@ void QSGShaderEffectTexture::grab() m_dirtyTexture = false; - const QGLContext *ctx = QGLContext::currentContext(); + const QGLContext *ctx = m_context->glContext(); m_renderer->setDeviceRect(m_size); m_renderer->setViewportRect(m_size); QRectF mirrored(m_rect.left(), m_rect.bottom(), m_rect.width(), -m_rect.height()); @@ -462,7 +476,8 @@ QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent) QSGShaderEffectSource::~QSGShaderEffectSource() { - delete m_texture; + m_texture->scheduleForCleanup(); + if (m_sourceItem) QSGItemPrivate::get(m_sourceItem)->derefFromEffectItem(m_hideSource); } -- cgit v1.2.3