blob: 0bfe66eef4158efe43a9147d47c0a8df1000cc0b [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 Malita6eb85a12018-04-30 10:32:18 -040012#include "Skottie.h"
Florin Malita54f65c42018-01-16 17:04:30 -050013
Florin Malitabcd07232018-01-31 11:08:58 -050014namespace sksg { class Scene; }
Florin Malita54f65c42018-01-16 17:04:30 -050015
16class SkottieSlide : public Slide {
17public:
18 SkottieSlide(const SkString& name, const SkString& path);
19 ~SkottieSlide() override = default;
20
21 void load(SkScalar winWidth, SkScalar winHeight) override;
22 void unload() override;
23
24 SkISize getDimensions() const override;
25
26 void draw(SkCanvas*) override;
27 bool animate(const SkAnimTimer&) override;
28
29 bool onChar(SkUnichar) override;
Florin Malita60d3bfc2018-02-20 16:49:20 -050030 bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
Florin Malita54f65c42018-01-16 17:04:30 -050031
32private:
Florin Malita1022f742018-02-23 11:10:22 -050033 SkString fPath;
34 sk_sp<skottie::Animation> fAnimation;
Florin Malita6eb85a12018-04-30 10:32:18 -040035 skottie::Animation::Stats fAnimationStats;
Florin Malita1022f742018-02-23 11:10:22 -050036 SkSize fWinSize = SkSize::MakeEmpty();
37 SkMSec fTimeBase = 0;
Florin Malita6eb85a12018-04-30 10:32:18 -040038 bool fShowAnimationInval = false,
39 fShowAnimationStats = false;
Florin Malita54f65c42018-01-16 17:04:30 -050040
41 typedef Slide INHERITED;
42};
43
Florin Malita54f65c42018-01-16 17:04:30 -050044#endif // SkottieSlide_DEFINED