blob: c267c1ea07ed0f7365b18b091dd22a02c7a29a92 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "tools/viewer/Slide.h"
Florin Malita3d856bd2018-05-26 09:49:28 -040012
13#if defined(SK_ENABLE_SKOTTIE)
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "modules/skottie/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;
Mike Kleincd5104e2019-03-20 11:55:08 -050029 bool animate(const AnimTimer&) override;
Florin Malita54f65c42018-01-16 17:04:30 -050030
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