tools: separate TimeUtils from AnimTimer
gm, slides, and samples no longer need to know about the implementation
details of AnimTimer.
This
virtual bool onAnimate(const AnimTimer&);
becomes this:
virtual bool onAnimate(double /*nanoseconds*/);
which is much easier to reason about.
AnimTimer itself is now part of viewer.
Change-Id: Ib70bf7a0798b1991f25204ae84f70463cdbeb358
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226838
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/tools/viewer/ParticlesSlide.cpp b/tools/viewer/ParticlesSlide.cpp
index 4bf2575..64a748a 100644
--- a/tools/viewer/ParticlesSlide.cpp
+++ b/tools/viewer/ParticlesSlide.cpp
@@ -15,7 +15,6 @@
#include "src/core/SkOSFile.h"
#include "src/utils/SkOSPath.h"
#include "tools/Resources.h"
-#include "tools/timer/AnimTimer.h"
#include "tools/viewer/ImGuiLayer.h"
#include "imgui.h"
@@ -282,9 +281,9 @@
SkGuiVisitor gui;
for (int i = 0; i < fLoaded.count(); ++i) {
ImGui::PushID(i);
- if (fTimer && ImGui::Button("Play")) {
+ if (fAnimated && ImGui::Button("Play")) {
sk_sp<SkParticleEffect> effect(new SkParticleEffect(fLoaded[i].fParams, fRandom));
- effect->start(fTimer->secs(), looped);
+ effect->start(fAnimationTime, looped);
fRunning.push_back({ fPlayPosition, fLoaded[i].fName, effect });
}
ImGui::SameLine();
@@ -339,10 +338,11 @@
}
}
-bool ParticlesSlide::animate(const AnimTimer& timer) {
- fTimer = &timer;
+bool ParticlesSlide::animate(double nanos) {
+ fAnimated = true;
+ fAnimationTime = 1e-9 * nanos;
for (const auto& effect : fRunning) {
- effect.fEffect->update(timer.secs());
+ effect.fEffect->update(fAnimationTime);
}
return true;
}