• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 sksg    { class Scene;     }
20 
21 class SkottieSlide : public Slide {
22 public:
23     SkottieSlide(const SkString& name, const SkString& path);
24     ~SkottieSlide() override = default;
25 
26     void load(SkScalar winWidth, SkScalar winHeight) override;
27     void unload() override;
28     void resize(SkScalar, SkScalar) override;
29 
30     SkISize getDimensions() const 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 private:
39     SkRect UIArea() const;
40     void renderUI();
41 
42     const SkString                     fPath;
43 
44     sk_sp<skottie::Animation>          fAnimation;
45     skottie::Animation::Builder::Stats fAnimationStats;
46     sksg::InvalidationController       fInvalController;
47     std::vector<float>                 fFrameTimes;
48     SkSize                             fWinSize            = SkSize::MakeEmpty();
49     double                             fTimeBase           = 0,
50                                        fFrameRate          = 0;
51     const char*                        fFrameRateLabel     = nullptr;
52     float                              fCurrentFrame       = 0;
53     bool                               fShowAnimationInval = false,
54                                        fShowAnimationStats = false,
55                                        fShowUI             = false,
56                                        fDraggingProgress   = false,
57                                        fPreferGlyphPaths   = false;
58 
59     using INHERITED = Slide;
60 };
61 
62 #endif // SK_ENABLE_SKOTTIE
63 
64 #endif // SkottieSlide_DEFINED
65