本文整理汇总了C++中QQuickItem::isTextureProvider方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickItem::isTextureProvider方法的具体用法?C++ QQuickItem::isTextureProvider怎么用?C++ QQuickItem::isTextureProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickItem
的用法示例。
在下文中一共展示了QQuickItem::isTextureProvider方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMaterial
void QQuickShaderEffectCommon::updateMaterial(QQuickShaderEffectNode *node,
QQuickShaderEffectMaterial *material,
bool updateUniforms, bool updateUniformValues,
bool updateTextureProviders)
{
if (updateUniforms) {
for (int i = 0; i < material->textureProviders.size(); ++i) {
QSGTextureProvider *t = material->textureProviders.at(i);
if (t) {
QObject::disconnect(t, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()));
QObject::disconnect(t, SIGNAL(destroyed(QObject*)), node, SLOT(textureProviderDestroyed(QObject*)));
}
}
// First make room in the textureProviders array. Set to proper value further down.
int textureProviderCount = 0;
for (int shaderType = 0; shaderType < Key::ShaderTypeCount; ++shaderType) {
for (int i = 0; i < uniformData[shaderType].size(); ++i) {
if (uniformData[shaderType].at(i).specialType == UniformData::Sampler)
++textureProviderCount;
}
material->uniforms[shaderType] = uniformData[shaderType];
}
material->textureProviders.fill(0, textureProviderCount);
updateUniformValues = false;
updateTextureProviders = true;
}
if (updateUniformValues) {
for (int shaderType = 0; shaderType < Key::ShaderTypeCount; ++shaderType) {
Q_ASSERT(uniformData[shaderType].size() == material->uniforms[shaderType].size());
for (int i = 0; i < uniformData[shaderType].size(); ++i)
material->uniforms[shaderType][i].value = uniformData[shaderType].at(i).value;
}
}
if (updateTextureProviders) {
int index = 0;
for (int shaderType = 0; shaderType < Key::ShaderTypeCount; ++shaderType) {
for (int i = 0; i < uniformData[shaderType].size(); ++i) {
const UniformData &d = uniformData[shaderType].at(i);
if (d.specialType != UniformData::Sampler)
continue;
QSGTextureProvider *oldProvider = material->textureProviders.at(index);
QSGTextureProvider *newProvider = 0;
QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value));
if (source && source->isTextureProvider())
newProvider = source->textureProvider();
if (newProvider != oldProvider) {
if (oldProvider) {
QObject::disconnect(oldProvider, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()));
QObject::disconnect(oldProvider, SIGNAL(destroyed(QObject*)), node, SLOT(textureProviderDestroyed(QObject*)));
}
if (newProvider) {
Q_ASSERT_X(newProvider->thread() == QThread::currentThread(),
"QQuickShaderEffect::updatePaintNode",
"Texture provider must belong to the rendering thread");
QObject::connect(newProvider, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()));
QObject::connect(newProvider, SIGNAL(destroyed(QObject*)), node, SLOT(textureProviderDestroyed(QObject*)));
} else {
const char *typeName = source ? source->metaObject()->className() : d.value.typeName();
qWarning("ShaderEffect: Property '%s' is not assigned a valid texture provider (%s).",
d.name.constData(), typeName);
}
material->textureProviders[index] = newProvider;
}
++index;
}
}
Q_ASSERT(index == material->textureProviders.size());
}
}