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:
@@ -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
|
||||
|
@@ -62,6 +62,7 @@ public:
|
||||
|
||||
private:
|
||||
void parse(const QByteArray &content);
|
||||
void resolveAssets();
|
||||
|
||||
int _startFrame = 0;
|
||||
int _endFrame = 0;
|
||||
|
Reference in New Issue
Block a user