mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Use shared provider for interaction animations.
This commit is contained in:
parent
42cc24e167
commit
890a126423
3 changed files with 23 additions and 8 deletions
|
@ -145,14 +145,25 @@ std::unique_ptr<Lottie::SinglePlayer> EmojiInteractions::preparePlayer(
|
|||
};
|
||||
const auto data = media->bytes();
|
||||
const auto filepath = document->filepath();
|
||||
return std::make_unique<Lottie::SinglePlayer>(
|
||||
kCachesCount,
|
||||
get,
|
||||
put,
|
||||
Lottie::ReadContent(data, filepath),
|
||||
Lottie::FrameRequest{
|
||||
_emojiSize * kSizeMultiplier * style::DevicePixelRatio() },
|
||||
const auto request = Lottie::FrameRequest{
|
||||
_emojiSize * kSizeMultiplier * style::DevicePixelRatio(),
|
||||
};
|
||||
auto &weakProvider = _sharedProviders[document];
|
||||
auto shared = [&] {
|
||||
if (const auto result = weakProvider.lock()) {
|
||||
return result;
|
||||
}
|
||||
const auto result = Lottie::SinglePlayer::SharedProvider(
|
||||
kCachesCount,
|
||||
get,
|
||||
put,
|
||||
Lottie::ReadContent(data, filepath),
|
||||
request,
|
||||
Lottie::Quality::High);
|
||||
weakProvider = result;
|
||||
return result;
|
||||
}();
|
||||
return std::make_unique<Lottie::SinglePlayer>(std::move(shared), request);
|
||||
}
|
||||
|
||||
void EmojiInteractions::visibleAreaUpdated(
|
||||
|
|
|
@ -17,6 +17,7 @@ struct EmojiInteractionPlayRequest;
|
|||
|
||||
namespace Lottie {
|
||||
class SinglePlayer;
|
||||
class FrameProvider;
|
||||
} // namespace Lottie
|
||||
|
||||
namespace Main {
|
||||
|
@ -81,6 +82,9 @@ private:
|
|||
std::vector<Delayed> _delayed;
|
||||
rpl::event_stream<QRect> _updateRequests;
|
||||
rpl::event_stream<QString> _playStarted;
|
||||
base::flat_map<
|
||||
not_null<DocumentData*>,
|
||||
std::weak_ptr<Lottie::FrameProvider>> _sharedProviders;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 11003d490b8a89b5b62e4185ea34b79565b5da16
|
||||
Subproject commit 6e3c468a9c58ecaf576c9b44599b816e5b03e98a
|
Loading…
Add table
Reference in a new issue