• 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 "tools/viewer/Slide.h"
12 
13 #include "include/core/SkPath.h"
14 #include "include/private/SkTArray.h"
15 #include "include/utils/SkRandom.h"
16 
17 class SkParticleEffect;
18 class SkParticleEffectParams;
19 
20 class ParticlesSlide : public Slide {
21 public:
22     ParticlesSlide();
23 
24     // TODO: We need a way for primarily interactive slides to always be as large as the window
getDimensions()25     SkISize getDimensions() const override { return SkISize::MakeEmpty(); }
26 
27     void load(SkScalar winWidth, SkScalar winHeight) override;
28     void draw(SkCanvas* canvas) override;
29     bool animate(double) override;
30 
31     bool onMouse(SkScalar x, SkScalar y, InputState state,
32                  ModifierKey modifiers) override;
33 
34 private:
35     void loadEffects(const char* dirname);
36 
37     SkRandom fRandom;
38     bool fAnimated = false;
39     double fAnimationTime = 0;
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