2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Prepare lottie animations caching.

This commit is contained in:
John Preston
2019-06-26 12:01:04 +02:00
parent f20d9395d1
commit 35bc2cc2a5
17 changed files with 148 additions and 40 deletions

View File

@@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "ui/toast/toast.h"
#include "ui/emoji_config.h"
#include "lottie/lottie_animation.h"
#include "styles/style_chat_helpers.h"
namespace Stickers {
@@ -1086,4 +1087,24 @@ RecentStickerPack &GetRecentPack() {
return cRefRecentStickers();
}
std::unique_ptr<Lottie::Animation> LottieFromDocument(
not_null<DocumentData*> document,
LottieSize sizeTag,
QSize box) {
const auto data = document->data();
const auto filepath = document->filepath();
if (const auto key = document->bigFileBaseCacheKey()) {
return Lottie::FromCached(
&document->session().data().cacheBigFile(),
Storage::Cache::Key{ key->high, key->low + int(sizeTag) },
data,
filepath,
box);
} else if (!data.isEmpty()) {
return Lottie::FromData(data);
} else {
return Lottie::FromFile(filepath);
}
}
} // namespace Stickers