Cache interactions in four cache keys.

This commit is contained in:
John Preston
2021-09-17 19:23:52 +03:00
parent 26b9146c32
commit 42cc24e167
5 changed files with 52 additions and 17 deletions
@@ -60,12 +60,11 @@ auto LottieFromDocument(
Method &&method,
not_null<Data::DocumentMedia*> media,
uint8 keyShift,
QSize box,
int cacheAreaLimit) {
QSize box) {
const auto document = media->owner();
const auto data = media->bytes();
const auto filepath = document->filepath();
if (box.width() * box.height() > cacheAreaLimit) {
if (box.width() * box.height() > kDontCacheLottieAfterArea) {
// Don't use frame caching for large stickers.
return method(
Lottie::ReadContent(data, filepath),
@@ -114,12 +113,9 @@ std::unique_ptr<Lottie::SinglePlayer> LottiePlayerFromDocument(
replacements,
std::move(renderer));
};
const auto limit = (sizeTag == StickerLottieSize::EmojiInteraction)
? (3 * kDontCacheLottieAfterArea)
: kDontCacheLottieAfterArea;
const auto tag = replacements ? replacements->tag : uint8(0);
const auto keyShift = ((tag << 4) & 0xF0) | (uint8(sizeTag) & 0x0F);
return LottieFromDocument(method, media, uint8(keyShift), box, limit);
return LottieFromDocument(method, media, uint8(keyShift), box);
}
not_null<Lottie::Animation*> LottieAnimationFromDocument(
@@ -130,8 +126,7 @@ not_null<Lottie::Animation*> LottieAnimationFromDocument(
const auto method = [&](auto &&...args) {
return player->append(std::forward<decltype(args)>(args)...);
};
const auto limit = kDontCacheLottieAfterArea;
return LottieFromDocument(method, media, uint8(sizeTag), box, limit);
return LottieFromDocument(method, media, uint8(sizeTag), box);
}
bool HasLottieThumbnail(