2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

QtLottie: Add support for precomp layer.

This commit is contained in:
John Preston
2019-05-02 15:08:32 +04:00
parent da845a089e
commit 2f02198ac7
8 changed files with 128 additions and 7 deletions

View File

@@ -173,6 +173,35 @@ void Animation::parse(const QByteArray &content) {
_unsupported = true;
}
}
resolveAssets();
}
void Animation::resolveAssets() {
if (_assets.empty()) {
return;
}
std::function<BMAsset*(QString)> resolver = [&](const QString &refId)
-> BMAsset* {
const auto i = _assetIndexById.find(refId);
if (i == end(_assetIndexById)) {
return nullptr;
}
const auto result = _assets[i->second].get();
result->resolveAssets(resolver);
return result->clone();
};
for (const auto &asset : _assets) {
asset->resolveAssets(resolver);
}
_treeBlueprint->resolveAssets([&](const QString &refId) {
const auto i = _assetIndexById.find(refId);
return (i != end(_assetIndexById))
? _assets[i->second]->clone()
: nullptr;
});
}
} // namespace Lottie

View File

@@ -62,6 +62,7 @@ public:
private:
void parse(const QByteArray &content);
void resolveAssets();
int _startFrame = 0;
int _endFrame = 0;