c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
/*
|
|
* Copyright 2019 Google LLC
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkParticleEffect_DEFINED
|
|
#define SkParticleEffect_DEFINED
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
#include "include/private/SkTArray.h"
|
|
#include "include/utils/SkRandom.h"
|
|
#include "modules/particles/include/SkCurve.h"
|
|
#include "src/core/SkAutoMalloc.h"
|
|
|
|
class SkCanvas;
|
|
class SkFieldVisitor;
|
|
class SkParticleAffector;
|
|
class SkParticleDrawable;
|
|
struct SkParticleState;
|
|
|
|
class SkParticleEffectParams : public SkRefCnt {
|
|
public:
|
|
int fMaxCount = 128;
|
|
float fEffectDuration = 1.0f;
|
|
float fRate = 8.0f;
|
|
SkCurve fLifetime = 1.0f;
|
|
|
|
// Drawable (image, sprite sheet, etc.)
|
|
sk_sp<SkParticleDrawable> fDrawable;
|
|
|
|
// Rules that configure particles at spawn time
|
|
SkTArray<sk_sp<SkParticleAffector>> fSpawnAffectors;
|
|
|
|
// Rules that update existing particles over their lifetime
|
|
SkTArray<sk_sp<SkParticleAffector>> fUpdateAffectors;
|
|
|
|
void visitFields(SkFieldVisitor* v);
|
|
};
|
|
|
|
class SkParticleEffect : public SkRefCnt {
|
|
public:
|
|
SkParticleEffect(sk_sp<SkParticleEffectParams> params, const SkRandom& random);
|
|
|
|
void start(double now, bool looping = false);
|
|
void update(double now);
|
|
void draw(SkCanvas* canvas);
|
|
|
|
bool isAlive() const { return fSpawnTime >= 0; }
|
|
int getCount() const { return fCount; }
|
|
|
|
private:
|
|
void setCapacity(int capacity);
|
|
|
|
sk_sp<SkParticleEffectParams> fParams;
|
|
|
|
SkRandom fRandom;
|
|
|
|
bool fLooping;
|
|
double fSpawnTime;
|
|
|
|
int fCount;
|
|
double fLastTime;
|
|
float fSpawnRemainder;
|
|
|
|
SkAutoTMalloc<SkParticleState> fParticles;
|
|
SkAutoTMalloc<SkRandom> fStableRandoms;
|
|
|
|
// Cached
|
|
int fCapacity;
|
|
};
|
|
|
|
#endif // SkParticleEffect_DEFINED
|