aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-08-17 18:46:01 +0200
committerKim M. Kalland <kim.kalland@nokia.com>2011-08-18 10:24:05 +0200
commitc1af214c80ccc3035e71febc389767092f3fb6bd (patch)
treef77177d1b5f6e882a0f12ae5845ca29ae375e6a9 /src/declarative/items
parent96348d4146a3faac194f18ceb251f3b0252f6a77 (diff)
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 <qt_sanity_bot@ovi.com> Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
Diffstat (limited to 'src/declarative/items')
-rw-r--r--src/declarative/items/qsgshadereffectsource.cpp25
-rw-r--r--src/declarative/items/qsgshadereffectsource_p.h6
2 files changed, 25 insertions, 6 deletions
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<QSGRootNode *>(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);
}
diff --git a/src/declarative/items/qsgshadereffectsource_p.h b/src/declarative/items/qsgshadereffectsource_p.h
index ac8fde50d9..1108e8cca8 100644
--- a/src/declarative/items/qsgshadereffectsource_p.h
+++ b/src/declarative/items/qsgshadereffectsource_p.h
@@ -114,6 +114,8 @@ public:
void scheduleUpdate();
+ void scheduleForCleanup();
+
Q_SIGNALS:
void textureChanged();
@@ -137,6 +139,8 @@ private:
QSGRectangleNode *m_debugOverlay;
#endif
+ QSGContext *m_context;
+
uint m_mipmap : 1;
uint m_live : 1;
uint m_recursive : 1;
@@ -226,7 +230,7 @@ protected:
virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
private:
- QSGTexture *m_texture;
+ QSGShaderEffectTexture *m_texture;
WrapMode m_wrapMode;
QPointer<QSGItem> m_sourceItem;
QRectF m_sourceRect;