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 class SkottieTextEditor; 20 21 namespace sksg { class Scene; } 22 23 class SkottieSlide : public Slide { 24 public: 25 SkottieSlide(const SkString& name, const SkString& path); 26 ~SkottieSlide() override = default; 27 28 void load(SkScalar winWidth, SkScalar winHeight) override; 29 void unload() override; 30 void resize(SkScalar, SkScalar) override; 31 32 void draw(SkCanvas*) override; 33 bool animate(double) override; 34 35 bool onChar(SkUnichar) override; 36 bool onMouse(SkScalar x, SkScalar y, skui::InputState, skui::ModifierKey modifiers) override; 37 38 // Initializes the Skottie animation independent of window size. 39 void init(); 40 41 private: 42 SkRect UIArea() const; 43 void renderUI(); 44 45 class TransformTracker; 46 class SlotManagerWrapper; 47 48 const SkString fPath; 49 50 sk_sp<skottie::Animation> fAnimation; 51 skottie::Animation::Builder::Stats fAnimationStats; 52 sksg::InvalidationController fInvalController; 53 sk_sp<TransformTracker> fTransformTracker; 54 std::unique_ptr<SlotManagerWrapper>fSlotManagerWrapper; 55 sk_sp<SkottieTextEditor> fTextEditor; 56 std::vector<float> fFrameTimes; 57 SkSize fWinSize = SkSize::MakeEmpty(); 58 double fTimeBase = 0, 59 fFrameRate = 0; 60 const char* fFrameRateLabel = nullptr; 61 float fCurrentFrame = 0; 62 bool fShowAnimationInval = false, 63 fShowAnimationStats = false, 64 fShowUI = false, 65 fShowTrackerUI = false, 66 fShowSlotManager = false, 67 fDraggingProgress = false, 68 fPreferGlyphPaths = false; 69 70 using INHERITED = Slide; 71 }; 72 73 #endif // SK_ENABLE_SKOTTIE 74 75 #endif // SkottieSlide_DEFINED 76