| 1 |
/* |
| 2 |
* Copyright 2017 Google Inc. |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef SkottieSlide_DEFINED |
| 9 |
#define SkottieSlide_DEFINED |
| 10 |
|
| 11 |
#include "tools/viewer/Slide.h" |
| 12 |
|
| 13 |
#if defined(SK_ENABLE_SKOTTIE) |
| 14 |
#include "modules/skottie/include/Skottie.h" |
| 15 |
#include "modules/sksg/include/SkSGInvalidationController.h" |
| 16 |
|
| 17 |
#include <vector> |
| 18 |
|
| 19 |
namespace skottie_utils { |
| 20 |
class TextEditor; |
| 21 |
} |
| 22 |
|
| 23 |
namespace sksg { class Scene; } |
| 24 |
|
| 25 |
class SkottieSlide : public Slide { |
| 26 |
public: |
| 27 |
SkottieSlide(const SkString& name, const SkString& path); |
| 28 |
~SkottieSlide() override = default; |
| 29 |
|
| 30 |
void load(SkScalar winWidth, SkScalar winHeight) override; |
| 31 |
void unload() override; |
| 32 |
void resize(SkScalar, SkScalar) override; |
| 33 |
|
| 34 |
void draw(SkCanvas*) override; |
| 35 |
bool animate(double) override; |
| 36 |
|
| 37 |
bool onChar(SkUnichar) override; |
| 38 |
bool onMouse(SkScalar x, SkScalar y, skui::InputState, skui::ModifierKey modifiers) override; |
| 39 |
|
| 40 |
// Initializes the Skottie animation independent of window size. |
| 41 |
void init(); |
| 42 |
|
| 43 |
private: |
| 44 |
SkRect UIArea() const; |
| 45 |
void renderUI(); |
| 46 |
|
| 47 |
class TransformTracker; |
| 48 |
class SlotManagerInterface; |
| 49 |
|
| 50 |
const SkString fPath; |
| 51 |
|
| 52 |
sk_sp<skottie::Animation> fAnimation; |
| 53 |
skottie::Animation::Builder::Stats fAnimationStats; |
| 54 |
sksg::InvalidationController fInvalController; |
| 55 |
sk_sp<TransformTracker> fTransformTracker; |
| 56 |
std::unique_ptr<SlotManagerInterface>fSlotManagerInterface; |
| 57 |
sk_sp<skottie_utils::TextEditor> fTextEditor; |
| 58 |
std::vector<float> fFrameTimes; |
| 59 |
SkSize fWinSize = SkSize::MakeEmpty(); |
| 60 |
double fTimeBase = 0, |
| 61 |
fFrameRate = 0; |
| 62 |
const char* fFrameRateLabel = nullptr; |
| 63 |
float fCurrentFrame = 0; |
| 64 |
bool fShowAnimationInval = false, |
| 65 |
fShowAnimationStats = false, |
| 66 |
fShowUI = false, |
| 67 |
fShowTrackerUI = false, |
| 68 |
fShowSlotManager = false, |
| 69 |
fDraggingProgress = false, |
| 70 |
fPreferGlyphPaths = false; |
| 71 |
}; |
| 72 |
|
| 73 |
#endif // SK_ENABLE_SKOTTIE |
| 74 |
|
| 75 |
#endif // SkottieSlide_DEFINED |