#ifdef QSG_DEBUG_FBO_OVERLAY
, m_debugOverlay(0)
#endif
- , m_context(0)
+ , m_context(QSGItemPrivate::get(shaderSource)->sceneGraphContext())
, m_mipmap(false)
, m_live(true)
, m_recursive(false)
#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
{
return m_fbo ? m_fbo->texture() : 0;
return;
}
- if (!m_context)
- m_context = QSGItemPrivate::get(m_shaderSource)->sceneGraphContext();
- Q_ASSERT(QSGItemPrivate::get(m_shaderSource)->sceneGraphContext() == m_context);
-
if (!m_renderer) {
m_renderer = m_context->createRenderer();
connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()), Qt::DirectConnection);
QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent)
: QSGItem(parent)
, m_provider(0)
+ , m_texture(0)
, m_wrapMode(ClampToEdge)
, m_sourceItem(0)
, m_textureSize(0, 0)
, m_grab(true)
{
setFlag(ItemHasContents);
- m_texture = new QSGShaderEffectTexture(this);
- connect(m_texture, SIGNAL(textureChanged()), this, SLOT(update()));
}
QSGShaderEffectSource::~QSGShaderEffectSource()
{
- m_texture->scheduleForCleanup();
+ if (m_texture)
+ m_texture->deleteLater();
if (m_provider)
m_provider->deleteLater();
QSGItemPrivate::get(m_sourceItem)->derefFromEffectItem(m_hideSource);
}
+void QSGShaderEffectSource::ensureTexture()
+{
+ if (m_texture)
+ return;
+
+ Q_ASSERT_X(QSGItemPrivate::get(this)->canvas
+ && QSGItemPrivate::get(this)->sceneGraphContext()
+ && QThread::currentThread() == QSGItemPrivate::get(this)->sceneGraphContext()->thread(),
+ "QSGShaderEffectSource::ensureTexture",
+ "Cannot be used outside the rendering thread");
+
+ m_texture = new QSGShaderEffectTexture(this);
+ connect(m_texture, SIGNAL(textureChanged()), this, SLOT(update()));
+}
+
QSGTextureProvider *QSGShaderEffectSource::textureProvider() const
{
if (!m_provider) {
&& QSGItemPrivate::get(this)->sceneGraphContext()
&& QThread::currentThread() == QSGItemPrivate::get(this)->sceneGraphContext()->thread(),
"QSGShaderEffectSource::textureProvider",
- "Cannot be used outside the GUI thread");
+ "Cannot be used outside the rendering thread");
const_cast<QSGShaderEffectSource *>(this)->m_provider = new QSGShaderEffectSourceTextureProvider();
+
+ const_cast<QSGShaderEffectSource *>(this)->ensureTexture();
connect(m_texture, SIGNAL(textureChanged()), m_provider, SIGNAL(textureChanged()), Qt::DirectConnection);
m_provider->sourceTexture = m_texture;
}
return 0;
}
+ ensureTexture();
+
QSGShaderEffectTexture *tex = qobject_cast<QSGShaderEffectTexture *>(m_texture);
tex->setLive(m_live);
tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode());