blob: 6c278d484f18692256b183d3ee461a0f78a47395 [file] [log] [blame]
Florin Malita54f65c42018-01-16 17:04:30 -05001/*
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 "Slide.h"
12
13namespace skottie { class Animation; }
14
15class SkottieSlide : public Slide {
16public:
17 SkottieSlide(const SkString& name, const SkString& path);
18 ~SkottieSlide() override = default;
19
20 void load(SkScalar winWidth, SkScalar winHeight) override;
21 void unload() override;
22
23 SkISize getDimensions() const override;
24
25 void draw(SkCanvas*) override;
26 bool animate(const SkAnimTimer&) override;
27
28 bool onChar(SkUnichar) override;
29
30private:
31 SkString fPath;
32 std::unique_ptr<skottie::Animation> fAnimation;
33 SkMSec fTimeBase = 0;
34 bool fShowAnimationInval = false;
35
36 typedef Slide INHERITED;
37};
38
39class SkottieSlide2 : public Slide {
40public:
41 SkottieSlide2(const SkString& path);
42 ~SkottieSlide2() override = default;
43
44 void load(SkScalar winWidth, SkScalar winHeight) override;
45 void unload() override;
46
47 SkISize getDimensions() const override;
48
49 void draw(SkCanvas*) override;
50 bool animate(const SkAnimTimer&) override;
51 bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
52private:
53 struct Rec {
54 std::unique_ptr<skottie::Animation> fAnimation;
55 SkMSec fTimeBase = 0;
56 SkString fName;
57 bool fShowAnimationInval = false;
58
59 Rec(std::unique_ptr<skottie::Animation> anim);
60 Rec(Rec&& o);
61 };
62
63 int findCell(float x, float y) const;
64
65 SkString fPath;
66 SkTArray<Rec> fAnims;
67
68 int fTrackingCell = -1;
69
70 typedef Slide INHERITED;
71};
72
73#endif // SkottieSlide_DEFINED