aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-10 16:38:44 +0200
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-10 16:57:59 +0200
commit67d5026372cf8a7c9319703fc58073910820b740 (patch)
treedb76f774c513295e1b1ef7cb094254707bebc093 /src
parent79f6db432ef9a05586176ad4e2fd3ed83be6f53c (diff)
Replaced grab() with scheduleUpdate().
Replaced the synchronous function grab() with an asynchronous function scheduleUpdate() in QShaderEffectSource because synchronous grabbing doesn't work with threaded rendering.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/items/qsgshadereffectsource.cpp38
-rw-r--r--src/declarative/items/qsgshadereffectsource_p.h8
2 files changed, 30 insertions, 16 deletions
diff --git a/src/declarative/items/qsgshadereffectsource.cpp b/src/declarative/items/qsgshadereffectsource.cpp
index 11d7f6f97e..26be39d45e 100644
--- a/src/declarative/items/qsgshadereffectsource.cpp
+++ b/src/declarative/items/qsgshadereffectsource.cpp
@@ -82,6 +82,7 @@ QSGShaderEffectTexture::QSGShaderEffectTexture(QSGItem *shaderSource)
, m_dirtyTexture(true)
, m_multisamplingSupportChecked(false)
, m_multisampling(false)
+ , m_grab(false)
{
}
@@ -124,8 +125,9 @@ void QSGShaderEffectTexture::bind()
bool QSGShaderEffectTexture::updateTexture()
{
- if (m_dirtyTexture) {
+ if ((m_live || m_grab) && m_dirtyTexture) {
grab();
+ m_grab = false;
return true;
}
return false;
@@ -181,6 +183,15 @@ void QSGShaderEffectTexture::setLive(bool live)
markDirtyTexture();
}
+void QSGShaderEffectTexture::scheduleUpdate()
+{
+ if (m_grab)
+ return;
+ m_grab = true;
+ if (m_dirtyTexture)
+ emit textureChanged();
+}
+
void QSGShaderEffectTexture::setRecursive(bool recursive)
{
m_recursive = recursive;
@@ -188,10 +199,9 @@ void QSGShaderEffectTexture::setRecursive(bool recursive)
void QSGShaderEffectTexture::markDirtyTexture()
{
- if (m_live) {
- m_dirtyTexture = true;
+ m_dirtyTexture = true;
+ if (m_live || m_grab)
emit textureChanged();
- }
}
void QSGShaderEffectTexture::grab()
@@ -360,6 +370,7 @@ QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent)
, m_hideSource(false)
, m_mipmap(false)
, m_recursive(false)
+ , m_grab(true)
{
setFlag(ItemHasContents);
m_texture = new QSGShaderEffectTexture(this);
@@ -516,17 +527,12 @@ void QSGShaderEffectSource::setRecursive(bool enabled)
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)
@@ -582,6 +588,7 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
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())
@@ -591,11 +598,14 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
? 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;
diff --git a/src/declarative/items/qsgshadereffectsource_p.h b/src/declarative/items/qsgshadereffectsource_p.h
index 891cc1ebba..5842ec7295 100644
--- a/src/declarative/items/qsgshadereffectsource_p.h
+++ b/src/declarative/items/qsgshadereffectsource_p.h
@@ -112,7 +112,7 @@ public:
bool recursive() const { return bool(m_recursive); }
void setRecursive(bool recursive);
- void grab();
+ void scheduleUpdate();
Q_SIGNALS:
void textureChanged();
@@ -121,6 +121,8 @@ public Q_SLOTS:
void markDirtyTexture();
private:
+ void grab();
+
QSGNode *m_item;
QRectF m_rect;
QSize m_size;
@@ -141,6 +143,7 @@ private:
uint m_dirtyTexture : 1;
uint m_multisamplingSupportChecked : 1;
uint m_multisampling : 1;
+ uint m_grab : 1;
};
class QSGShaderEffectSource : public QSGItem, public QSGTextureProvider
@@ -204,7 +207,7 @@ public:
QSGTexture *texture() const;
const char *textureChangedSignal() const { return SIGNAL(textureChanged()); }
- Q_INVOKABLE void grab();
+ Q_INVOKABLE void scheduleUpdate();
Q_SIGNALS:
void wrapModeChanged();
@@ -233,6 +236,7 @@ private:
uint m_hideSource : 1;
uint m_mipmap : 1;
uint m_recursive : 1;
+ uint m_grab : 1;
};
QT_END_NAMESPACE