2017-12-30 17:27:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
#ifndef SkottieSlide_DEFINED
|
|
|
|
#define SkottieSlide_DEFINED
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/viewer/Slide.h"
|
2018-05-26 13:49:28 +00:00
|
|
|
|
|
|
|
#if defined(SK_ENABLE_SKOTTIE)
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/skottie/include/Skottie.h"
|
2019-07-22 16:05:41 +00:00
|
|
|
#include "modules/sksg/include/SkSGInvalidationController.h"
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2019-12-10 19:23:32 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2018-01-31 16:08:58 +00:00
|
|
|
namespace sksg { class Scene; }
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
class SkottieSlide : public Slide {
|
2017-12-30 17:27:00 +00:00
|
|
|
public:
|
2018-01-16 22:04:30 +00:00
|
|
|
SkottieSlide(const SkString& name, const SkString& path);
|
|
|
|
~SkottieSlide() override = default;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
void load(SkScalar winWidth, SkScalar winHeight) override;
|
|
|
|
void unload() override;
|
2019-12-10 18:38:45 +00:00
|
|
|
void resize(SkScalar, SkScalar) override;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
SkISize getDimensions() const override;
|
|
|
|
|
|
|
|
void draw(SkCanvas*) override;
|
2019-07-11 20:32:53 +00:00
|
|
|
bool animate(double) override;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
bool onChar(SkUnichar) override;
|
2019-08-29 14:39:22 +00:00
|
|
|
bool onMouse(SkScalar x, SkScalar y, skui::InputState, skui::ModifierKey modifiers) override;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
private:
|
2019-12-10 18:38:45 +00:00
|
|
|
SkRect UIArea() const;
|
|
|
|
void renderUI();
|
|
|
|
|
|
|
|
const SkString fPath;
|
|
|
|
|
2018-08-23 00:37:04 +00:00
|
|
|
sk_sp<skottie::Animation> fAnimation;
|
|
|
|
skottie::Animation::Builder::Stats fAnimationStats;
|
2019-07-22 16:05:41 +00:00
|
|
|
sksg::InvalidationController fInvalController;
|
2019-12-10 19:23:32 +00:00
|
|
|
std::vector<float> fFrameTimes;
|
2019-12-10 18:38:45 +00:00
|
|
|
SkSize fWinSize = SkSize::MakeEmpty();
|
2019-12-11 13:55:46 +00:00
|
|
|
double fTimeBase = 0,
|
|
|
|
fFrameRate = 0;
|
|
|
|
const char* fFrameRateLabel = nullptr;
|
2019-12-10 18:38:45 +00:00
|
|
|
float fCurrentFrame = 0;
|
2018-08-23 00:37:04 +00:00
|
|
|
bool fShowAnimationInval = false,
|
2019-12-10 18:38:45 +00:00
|
|
|
fShowAnimationStats = false,
|
|
|
|
fShowUI = false,
|
2020-05-20 21:04:21 +00:00
|
|
|
fDraggingProgress = false,
|
|
|
|
fPreferGlyphPaths = false;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = Slide;
|
2017-12-30 17:27:00 +00:00
|
|
|
};
|
|
|
|
|
2018-05-26 13:49:28 +00:00
|
|
|
#endif // SK_ENABLE_SKOTTIE
|
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
#endif // SkottieSlide_DEFINED
|