summaryrefslogtreecommitdiffstats
path: root/src/runtime/q3dsuippresentation.cpp
diff options
context:
space:
mode:
authorMäättä Antti <antti.maatta@qt.io>2019-02-05 15:31:46 +0200
committerAntti Määttä <antti.maatta@qt.io>2019-03-12 12:11:08 +0000
commitdb433e6b7b543a54865c770fd4ca15160e44b2c7 (patch)
tree68fb6c56f7d6b2fee91975733ee94c06698eeae0 /src/runtime/q3dsuippresentation.cpp
parent63ec9f17ed1cf4da27015244f97bb161e51949ce (diff)
Implement delayed image loading and slide resource list
Task-number: QT3DS-2664 Change-Id: I5310329fbf6e4e07cade28ae68161081ddf77f3c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/runtime/q3dsuippresentation.cpp')
-rw-r--r--src/runtime/q3dsuippresentation.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/runtime/q3dsuippresentation.cpp b/src/runtime/q3dsuippresentation.cpp
index 0e654c5..56f97a1 100644
--- a/src/runtime/q3dsuippresentation.cpp
+++ b/src/runtime/q3dsuippresentation.cpp
@@ -691,6 +691,20 @@ void Q3DSGraphObject::notifyPropertyChanges(int changeFlags, const QSet<QString>
}
}
+void Q3DSGraphObject::listCustomPropertyResources(
+ QSet<QString> &resources, const QMap<QString, Q3DSMaterial::PropertyElement> &meta) const
+{
+ auto properties = dynamicProperties();
+ for (auto it = properties.cbegin(), itEnd = properties.cend(); it != itEnd; ++it) {
+ const QString &propName(it.key());
+ const Q3DSMaterial::PropertyElement &propMeta(meta[propName]);
+ if (propMeta.type == Q3DS::Texture) {
+ const QVariant &propValue(it.value());
+ resources.insert(propValue.toString());
+ }
+ }
+}
+
// Setters return a change object that can be passed straight to
// notifyPropertyChange (via the changelists' intializer list even). When the
// value does not change, the returned change object has isValid()==false, these
@@ -1646,6 +1660,16 @@ Q3DSPropertyChange Q3DSSlide::setPlayThroughValue(const QVariant &v)
return createPropSetter(m_playThroughValue, v, "playthroughto");
}
+void Q3DSSlide::generateResourceSet(Q3DSUipPresentation *presentation)
+{
+ m_resources.clear();
+ QSet<QString> resources;
+ for (const auto *object : qAsConst(m_objects))
+ object->listResources(resources);
+ for (auto res : qAsConst(resources))
+ m_resources << presentation->imageUrl(res);
+}
+
Q3DSImage::Q3DSImage()
: Q3DSGraphObject(Image)
{
@@ -1721,6 +1745,12 @@ void Q3DSImage::resolveReferences(Q3DSUipPresentation &presentation)
}
}
+void Q3DSImage::listResources(QSet<QString> &resources) const
+{
+ if (!m_sourcePath.isEmpty() && !resources.contains(m_sourcePath))
+ resources.insert(m_sourcePath);
+}
+
namespace {
#if 0
bool scanImageForAlpha(const uchar *data, int width, int height, unsigned pixelSizeInBytes, unsigned alphaSizeInBits, bool isAlphaFirst = false)
@@ -3936,6 +3966,24 @@ Q3DSGraphObject *Q3DSUipPresentation::getObjectByName(const QString &name) const
return nullptr;
}
+QUrl Q3DSUipPresentation::imageUrl(const QString &sourcePath)
+{
+ QUrl ret;
+ if (d->preferKtx) {
+ QString ktxSource = sourcePath;
+ ktxSource = ktxSource.left(ktxSource.lastIndexOf(QLatin1Char('.')));
+ ktxSource.append(QLatin1String(".ktx"));
+ QFileInfo info(ktxSource);
+ if (info.exists())
+ ret = QUrl::fromLocalFile(ktxSource);
+ else
+ ret = QUrl::fromLocalFile(sourcePath);
+ } else {
+ ret = QUrl::fromLocalFile(sourcePath);
+ }
+ return ret;
+}
+
namespace {
struct ClonedObject {
Q3DSGraphObject *original;