2022-01-06 22:15:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//
|
|
|
|
// EmulationStation Desktop Edition
|
|
|
|
// LottieComponent.h
|
|
|
|
//
|
|
|
|
// Component to play Lottie animations using the rlottie library.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ES_CORE_COMPONENTS_LOTTIE_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_LOTTIE_COMPONENT_H
|
|
|
|
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
#include "renderers/Renderer.h"
|
|
|
|
#include "resources/TextureResource.h"
|
|
|
|
|
|
|
|
#include "rlottie.h"
|
|
|
|
|
|
|
|
#include <chrono>
|
2022-01-07 18:09:07 +00:00
|
|
|
#include <future>
|
2022-01-06 22:15:29 +00:00
|
|
|
|
|
|
|
class LottieComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LottieComponent(Window* window);
|
|
|
|
|
2022-01-08 10:25:29 +00:00
|
|
|
void setAnimation(const std::string& path);
|
|
|
|
void setKeepAspectRatio(bool value) { mKeepAspectRatio = value; }
|
|
|
|
|
|
|
|
void onSizeChanged() override;
|
|
|
|
|
2022-01-06 22:15:29 +00:00
|
|
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|
|
|
const std::string& view,
|
|
|
|
const std::string& element,
|
|
|
|
unsigned int properties) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void update(int deltaTime) override;
|
|
|
|
void render(const glm::mat4& parentTrans) override;
|
|
|
|
|
|
|
|
std::shared_ptr<TextureResource> mTexture;
|
|
|
|
std::vector<uint8_t> mPictureRGBA;
|
|
|
|
|
2022-01-07 18:09:07 +00:00
|
|
|
std::unique_ptr<rlottie::Animation> mAnimation;
|
2022-01-06 22:15:29 +00:00
|
|
|
std::unique_ptr<rlottie::Surface> mSurface;
|
2022-01-07 18:09:07 +00:00
|
|
|
std::future<rlottie::Surface> mFuture;
|
2022-01-08 10:25:29 +00:00
|
|
|
std::string mPath;
|
2022-01-06 22:15:29 +00:00
|
|
|
size_t mTotalFrames;
|
2022-01-07 18:09:07 +00:00
|
|
|
size_t mFrameNum;
|
2022-01-06 22:15:29 +00:00
|
|
|
double mFrameRate;
|
|
|
|
int mTargetPacing;
|
2022-01-07 18:09:07 +00:00
|
|
|
int mTimeAccumulator;
|
|
|
|
bool mHoldFrame;
|
2022-01-06 22:15:29 +00:00
|
|
|
|
2022-01-08 10:25:29 +00:00
|
|
|
bool mKeepAspectRatio;
|
|
|
|
|
2022-01-06 22:15:29 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> mAnimationStartTime;
|
|
|
|
std::chrono::time_point<std::chrono::system_clock> mAnimationEndTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_LOTTIE_COMPONENT_H
|