/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "lottie/lottie_player.h" #include "lottie/lottie_animation.h" #include "base/timer.h" #include namespace Lottie { class FrameRenderer; struct DisplayFrameRequest { }; struct Update { base::variant< Information, DisplayFrameRequest> data; }; class SinglePlayer final : public Player { public: SinglePlayer( const QByteArray &content, const FrameRequest &request, Quality quality = Quality::Default, std::shared_ptr renderer = nullptr); SinglePlayer( FnMut)> get, // Main thread. FnMut put, // Unknown thread. const QByteArray &content, const FrameRequest &request, Quality quality = Quality::Default, std::shared_ptr renderer = nullptr); ~SinglePlayer(); void start( not_null animation, std::unique_ptr state) override; void failed(not_null animation, Error error) override; void updateFrameRequest( not_null animation, const FrameRequest &request) override; void markFrameShown() override; void checkStep() override; rpl::producer updates() const; [[nodiscard]] bool ready() const; [[nodiscard]] QImage frame() const; [[nodiscard]] QImage frame(const FrameRequest &request) const; private: void checkNextFrameAvailability(); void checkNextFrameRender(); Animation _animation; base::Timer _timer; const std::shared_ptr _renderer; SharedState *_state = nullptr; crl::time _nextFrameTime = kTimeUnknown; rpl::event_stream _updates; rpl::lifetime _lifetime; }; } // namespace Lottie