1 // This file is part of Desktop App Toolkit, 2 // a set of libraries for developing nice desktop applications. 3 // 4 // For license and copyright information please follow this link: 5 // https://github.com/desktop-app/legal/blob/master/LEGAL 6 // 7 #pragma once 8 9 #include "lottie/details/lottie_frame_provider.h" 10 #include "lottie/lottie_common.h" 11 12 namespace rlottie { 13 class Animation; 14 } // namespace rlottie 15 16 namespace Lottie { 17 18 class FrameProviderDirect final : public FrameProvider { 19 public: 20 explicit FrameProviderDirect(Quality quality); 21 ~FrameProviderDirect(); 22 23 bool load( 24 const QByteArray &content, 25 const ColorReplacements *replacements); 26 [[nodiscard]] bool loaded() const; 27 void unload(); 28 29 bool setInformation(Information information); 30 31 QImage construct( 32 const std::unique_ptr<FrameProviderToken> &token, 33 const FrameRequest &request) override; 34 const Information &information() override; 35 bool valid() override; 36 37 int sizeRounding() override; 38 39 bool render( 40 const std::unique_ptr<FrameProviderToken> &token, 41 QImage &to, 42 const FrameRequest &request, 43 int index) override; 44 void renderToPrepared(QImage &to, int index) const; 45 46 private: cthis()47 const FrameProviderDirect *cthis() const { 48 return this; 49 } 50 51 std::unique_ptr<rlottie::Animation> _animation; 52 Information _information; 53 Quality _quality = Quality::Default; 54 55 }; 56 57 } // namespace Lottie 58