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/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index c547802..273573a 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -15,7 +15,6 @@
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkTaskGroup.h"
#include "tools/ToolUtils.h"
-#include "tools/timer/AnimTimer.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Static text from paths.
@@ -164,15 +163,15 @@
fLastTick = 0;
}
- bool onAnimate(const AnimTimer& timer) final {
+ bool onAnimate(double nanos) final {
fBackgroundAnimationTask.wait();
this->swapAnimationBuffers();
- const double tsec = timer.secs();
- const double dt = fLastTick ? (timer.secs() - fLastTick) : 0;
+ const double tsec = 1e-9 * nanos;
+ const double dt = fLastTick ? (1e-9 * nanos - fLastTick) : 0;
fBackgroundAnimationTask.add(std::bind(&MovingPathText::runAnimationTask, this, tsec,
dt, this->width(), this->height()));
- fLastTick = timer.secs();
+ fLastTick = 1e-9 * nanos;
return true;
}