aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2015-04-28 07:45:28 +0200
committerGunnar Sletta <gunnar@sletta.org>2015-05-04 07:39:04 +0000
commit38621d841cfa75b1d849b0e88b38c2f18a0611ac (patch)
tree110c5e41e960ed97a606fa115106a62baeb14127
parent6c1d99c2490e1af5c42d03cf10e8fe4d2e30c025 (diff)
Avoid QQuickItem in materials's compare() on the render thread
Task-number: QTBUG-44664 Change-Id: I4438e666b75fdf2e8d4353e64454d4c665a24350 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/quick/items/qquickshadereffectnode.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp
index e593112ef5..6415c0ad22 100644
--- a/src/quick/items/qquickshadereffectnode.cpp
+++ b/src/quick/items/qquickshadereffectnode.cpp
@@ -381,11 +381,10 @@ bool QQuickShaderEffectMaterial::UniformData::operator == (const UniformData &ot
return false;
if (specialType == UniformData::Sampler) {
- QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(value));
- QQuickItem *otherSource = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(other.value));
- if (!source || !otherSource || !source->isTextureProvider() || !otherSource->isTextureProvider())
- return false;
- return source->textureProvider()->texture()->textureId() == otherSource->textureProvider()->texture()->textureId();
+ // We can't check the source objects as these live in the GUI thread,
+ // so return true here and rely on the textureProvider check for
+ // equality of these..
+ return true;
} else {
return value == other.value;
}
@@ -402,6 +401,23 @@ int QQuickShaderEffectMaterial::compare(const QSGMaterial *o) const
if (uniforms[shaderType] != other->uniforms[shaderType])
return 1;
}
+
+ // Check the texture providers..
+ if (textureProviders.size() != other->textureProviders.size())
+ return 1;
+ for (int i=0; i<textureProviders.size(); ++i) {
+ QSGTextureProvider *tp1 = textureProviders.at(i);
+ QSGTextureProvider *tp2 = other->textureProviders.at(i);
+ if (!tp1 || !tp2)
+ return tp1 == tp2 ? 0 : 1;
+ QSGTexture *t1 = tp1->texture();
+ QSGTexture *t2 = tp2->texture();
+ if (!t1 || !t2)
+ return t1 == t2 ? 0 : 1;
+ // Check texture id's as textures may be in the same atlas.
+ if (t1->textureId() != t2->textureId())
+ return 1;
+ }
return 0;
}