• 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 namespace sksg    { class Scene;     }
18 
19 class SkottieSlide : public Slide {
20 public:
21     SkottieSlide(const SkString& name, const SkString& path);
22     ~SkottieSlide() override = default;
23 
24     void load(SkScalar winWidth, SkScalar winHeight) override;
25     void unload() override;
26 
27     SkISize getDimensions() const override;
28 
29     void draw(SkCanvas*) override;
30     bool animate(double) override;
31 
32     bool onChar(SkUnichar) override;
33     bool onMouse(SkScalar x, SkScalar y, InputState, ModifierKey modifiers) override;
34 
35 private:
36     SkString                           fPath;
37     sk_sp<skottie::Animation>          fAnimation;
38     skottie::Animation::Builder::Stats fAnimationStats;
39     sksg::InvalidationController       fInvalController;
40     SkSize                             fWinSize = SkSize::MakeEmpty();
41     SkMSec                             fTimeBase  = 0;
42     bool                               fShowAnimationInval = false,
43                                        fShowAnimationStats = false;
44 
45     typedef Slide INHERITED;
46 };
47 
48 #endif // SK_ENABLE_SKOTTIE
49 
50 #endif // SkottieSlide_DEFINED
51