blob: 9bf6bf5f2a6e7f6eb937281a712da038eeba6fb3 [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"
Florin Malita3d856bd2018-05-26 09:49:28 -040012
13#if defined(SK_ENABLE_SKOTTIE)
Florin Malita6eb85a12018-04-30 10:32:18 -040014#include "Skottie.h"
Florin Malita54f65c42018-01-16 17:04:30 -050015
Florin Malitabcd07232018-01-31 11:08:58 -050016namespace sksg { class Scene; }
Florin Malita54f65c42018-01-16 17:04:30 -050017
18class SkottieSlide : public Slide {
19public:
20 SkottieSlide(const SkString& name, const SkString& path);
21 ~SkottieSlide() override = default;
22
23 void load(SkScalar winWidth, SkScalar winHeight) override;
24 void unload() override;
25
26 SkISize getDimensions() const override;
27
28 void draw(SkCanvas*) override;
29 bool animate(const SkAnimTimer&) override;
30
31 bool onChar(SkUnichar) override;
Florin Malita60d3bfc2018-02-20 16:49:20 -050032 bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
Florin Malita54f65c42018-01-16 17:04:30 -050033
34private:
Florin Malita40c37422018-08-22 20:37:04 -040035 SkString fPath;
36 sk_sp<skottie::Animation> fAnimation;
37 skottie::Animation::Builder::Stats fAnimationStats;
38 SkSize fWinSize = SkSize::MakeEmpty();
39 SkMSec fTimeBase = 0;
40 bool fShowAnimationInval = false,
41 fShowAnimationStats = false;
Florin Malita54f65c42018-01-16 17:04:30 -050042
43 typedef Slide INHERITED;
44};
45
Florin Malita3d856bd2018-05-26 09:49:28 -040046#endif // SK_ENABLE_SKOTTIE
47
Florin Malita54f65c42018-01-16 17:04:30 -050048#endif // SkottieSlide_DEFINED