• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2019 Google LLC
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 ParticlesSlide_DEFINED
9 #define ParticlesSlide_DEFINED
10 
11 #include "Slide.h"
12 
13 #include "SkPath.h"
14 #include "SkRandom.h"
15 #include "SkTArray.h"
16 
17 class SkAnimTimer;
18 class SkParticleEffect;
19 class SkParticleEffectParams;
20 
21 class ParticlesSlide : public Slide {
22 public:
23     ParticlesSlide();
24 
25     // TODO: We need a way for primarily interactive slides to always be as large as the window
getDimensions()26     SkISize getDimensions() const override { return SkISize::MakeEmpty(); }
27 
28     void load(SkScalar winWidth, SkScalar winHeight) override;
29     void draw(SkCanvas* canvas) override;
30     bool animate(const SkAnimTimer& timer) override;
31 
32     bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
33                  uint32_t modifiers) override;
34 
35 private:
36     void loadEffects(const char* dirname);
37 
38     SkRandom fRandom;
39     const SkAnimTimer* fTimer;
40     SkPoint fPlayPosition;
41 
42     struct LoadedEffect {
43         SkString fName;
44         sk_sp<SkParticleEffectParams> fParams;
45     };
46     SkTArray<LoadedEffect> fLoaded;
47 
48     struct RunningEffect {
49         SkPoint fPosition;
50         SkString fName;
51         sk_sp<SkParticleEffect> fEffect;
52     };
53     SkTArray<RunningEffect> fRunning;
54 };
55 
56 #endif
57