, m_dirtyTexture(true)
, m_multisamplingSupportChecked(false)
, m_multisampling(false)
+ , m_grab(false)
{
}
bool QSGShaderEffectTexture::updateTexture()
{
- if (m_dirtyTexture) {
+ if ((m_live || m_grab) && m_dirtyTexture) {
grab();
+ m_grab = false;
return true;
}
return false;
markDirtyTexture();
}
+void QSGShaderEffectTexture::scheduleUpdate()
+{
+ if (m_grab)
+ return;
+ m_grab = true;
+ if (m_dirtyTexture)
+ emit textureChanged();
+}
+
void QSGShaderEffectTexture::setRecursive(bool recursive)
{
m_recursive = recursive;
void QSGShaderEffectTexture::markDirtyTexture()
{
- if (m_live) {
- m_dirtyTexture = true;
+ m_dirtyTexture = true;
+ if (m_live || m_grab)
emit textureChanged();
- }
}
void QSGShaderEffectTexture::grab()
, m_hideSource(false)
, m_mipmap(false)
, m_recursive(false)
+ , m_grab(true)
{
setFlag(ItemHasContents);
m_texture = new QSGShaderEffectTexture(this);
emit recursiveChanged();
}
-void QSGShaderEffectSource::grab()
+void QSGShaderEffectSource::scheduleUpdate()
{
- if (!m_sourceItem)
+ if (m_grab)
return;
- QSGCanvas *canvas = m_sourceItem->canvas();
- if (!canvas)
- return;
- QSGCanvasPrivate::get(canvas)->updateDirtyNodes();
- QGLContext *glctx = const_cast<QGLContext *>(canvas->context());
- glctx->makeCurrent();
- qobject_cast<QSGShaderEffectTexture *>(m_texture)->grab();
+ m_grab = true;
+ update();
}
static void get_wrap_mode(QSGShaderEffectSource::WrapMode mode, QSGTexture::WrapMode *hWrap, QSGTexture::WrapMode *vWrap)
QSGShaderEffectTexture *tex = qobject_cast<QSGShaderEffectTexture *>(m_texture);
+ tex->setLive(m_live);
tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode());
QRectF sourceRect = m_sourceRect.isNull()
? QRectF(0, 0, m_sourceItem->width(), m_sourceItem->height())
? QSize(qCeil(qAbs(sourceRect.width())), qCeil(qAbs(sourceRect.height())))
: m_textureSize;
tex->setSize(textureSize);
- tex->setLive(m_live);
tex->setRecursive(m_recursive);
tex->setFormat(GLenum(m_format));
tex->setHasMipmaps(m_mipmap);
+ if (m_grab)
+ tex->scheduleUpdate();
+ m_grab = false;
+
QSGTexture::Filtering filtering = QSGItemPrivate::get(this)->smooth
? QSGTexture::Linear
: QSGTexture::Nearest;
bool recursive() const { return bool(m_recursive); }
void setRecursive(bool recursive);
- void grab();
+ void scheduleUpdate();
Q_SIGNALS:
void textureChanged();
void markDirtyTexture();
private:
+ void grab();
+
QSGNode *m_item;
QRectF m_rect;
QSize m_size;
uint m_dirtyTexture : 1;
uint m_multisamplingSupportChecked : 1;
uint m_multisampling : 1;
+ uint m_grab : 1;
};
class QSGShaderEffectSource : public QSGItem, public QSGTextureProvider
QSGTexture *texture() const;
const char *textureChangedSignal() const { return SIGNAL(textureChanged()); }
- Q_INVOKABLE void grab();
+ Q_INVOKABLE void scheduleUpdate();
Q_SIGNALS:
void wrapModeChanged();
uint m_hideSource : 1;
uint m_mipmap : 1;
uint m_recursive : 1;
+ uint m_grab : 1;
};
QT_END_NAMESPACE