2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Support optimized lottie emoji.

This commit is contained in:
John Preston
2022-06-28 17:13:20 +04:00
parent 9d280da80b
commit 6db3a0ec98
10 changed files with 831 additions and 213 deletions

View File

@@ -27,6 +27,10 @@ constexpr auto kDontCacheLottieAfterArea = 512 * 512;
} // namespace
uint8 LottieCacheKeyShift(uint8 replacementsTag, StickerLottieSize sizeTag) {
return ((replacementsTag << 4) & 0xF0) | (uint8(sizeTag) & 0x0F);
}
template <typename Method>
auto LottieCachedFromContent(
Method &&method,
@@ -115,8 +119,9 @@ std::unique_ptr<Lottie::SinglePlayer> LottiePlayerFromDocument(
replacements,
std::move(renderer));
};
const auto tag = replacements ? replacements->tag : uint8(0);
const auto keyShift = ((tag << 4) & 0xF0) | (uint8(sizeTag) & 0x0F);
const auto keyShift = LottieCacheKeyShift(
replacements ? replacements->tag : uint8(0),
sizeTag);
return LottieFromDocument(method, media, uint8(keyShift), box);
}

View File

@@ -49,7 +49,7 @@ using StickersSetFlags = base::flags<StickersSetFlag>;
namespace ChatHelpers {
enum class StickerLottieSize : uchar {
enum class StickerLottieSize : uint8 {
MessageHistory,
StickerSet,
StickersPanel,
@@ -66,6 +66,9 @@ enum class StickerLottieSize : uchar {
EmojiInteractionReserved7,
PremiumReactionPreview,
};
[[nodiscard]] uint8 LottieCacheKeyShift(
uint8 replacementsTag,
StickerLottieSize sizeTag);
[[nodiscard]] std::unique_ptr<Lottie::SinglePlayer> LottiePlayerFromDocument(
not_null<Data::DocumentMedia*> media,