mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 data = media->bytes();
|
||||||
const auto filepath = document->filepath();
|
const auto filepath = document->filepath();
|
||||||
return std::make_unique<Lottie::SinglePlayer>(
|
const auto request = Lottie::FrameRequest{
|
||||||
kCachesCount,
|
_emojiSize * kSizeMultiplier * style::DevicePixelRatio(),
|
||||||
get,
|
};
|
||||||
put,
|
auto &weakProvider = _sharedProviders[document];
|
||||||
Lottie::ReadContent(data, filepath),
|
auto shared = [&] {
|
||||||
Lottie::FrameRequest{
|
if (const auto result = weakProvider.lock()) {
|
||||||
_emojiSize * kSizeMultiplier * style::DevicePixelRatio() },
|
return result;
|
||||||
|
}
|
||||||
|
const auto result = Lottie::SinglePlayer::SharedProvider(
|
||||||
|
kCachesCount,
|
||||||
|
get,
|
||||||
|
put,
|
||||||
|
Lottie::ReadContent(data, filepath),
|
||||||
|
request,
|
||||||
Lottie::Quality::High);
|
Lottie::Quality::High);
|
||||||
|
weakProvider = result;
|
||||||
|
return result;
|
||||||
|
}();
|
||||||
|
return std::make_unique<Lottie::SinglePlayer>(std::move(shared), request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiInteractions::visibleAreaUpdated(
|
void EmojiInteractions::visibleAreaUpdated(
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct EmojiInteractionPlayRequest;
|
||||||
|
|
||||||
namespace Lottie {
|
namespace Lottie {
|
||||||
class SinglePlayer;
|
class SinglePlayer;
|
||||||
|
class FrameProvider;
|
||||||
} // namespace Lottie
|
} // namespace Lottie
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
|
@ -81,6 +82,9 @@ private:
|
||||||
std::vector<Delayed> _delayed;
|
std::vector<Delayed> _delayed;
|
||||||
rpl::event_stream<QRect> _updateRequests;
|
rpl::event_stream<QRect> _updateRequests;
|
||||||
rpl::event_stream<QString> _playStarted;
|
rpl::event_stream<QString> _playStarted;
|
||||||
|
base::flat_map<
|
||||||
|
not_null<DocumentData*>,
|
||||||
|
std::weak_ptr<Lottie::FrameProvider>> _sharedProviders;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 11003d490b8a89b5b62e4185ea34b79565b5da16
|
Subproject commit 6e3c468a9c58ecaf576c9b44599b816e5b03e98a
|
Loading…
Add table
Reference in a new issue