SkAnimTimer -> AnimTimer
Change-Id: I700b7c0461475062ac66712cc29070f150cf777d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202315
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index f65d472..8f241b1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1580,7 +1580,7 @@
"tools/fonts/TestTypeface.h",
"tools/fonts/ToolUtilsFont.cpp",
"tools/random_parse_path.cpp",
- "tools/timer/SkAnimTimer.h",
+ "tools/timer/AnimTimer.h",
"tools/timer/Timer.cpp",
"tools/trace/SkChromeTracingTracer.cpp",
"tools/trace/SkChromeTracingTracer.h",
diff --git a/gm/3dgm.cpp b/gm/3dgm.cpp
index c628ef9..e530d09 100644
--- a/gm/3dgm.cpp
+++ b/gm/3dgm.cpp
@@ -14,7 +14,7 @@
#ifdef SK_ENABLE_SKOTTIE
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "Resources.h"
#include "SkStream.h"
#include "Skottie.h"
@@ -182,7 +182,7 @@
SkString onShortName() override { return SkString("3dgm"); }
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (!fAnim) {
return false;
}
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index 8a6dd73..c9b7633 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkPathMeasure.h"
#include "SkRandom.h"
@@ -52,7 +52,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fRotate = timer.scaled(1, 360);
return true;
}
@@ -138,7 +138,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fRotate = timer.scaled(60, 360);
return true;
}
@@ -191,7 +191,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fRotate = timer.scaled(60, 360);
return true;
}
diff --git a/gm/animatedGif.cpp b/gm/animatedGif.cpp
index 2d941fa..c66f58b 100644
--- a/gm/animatedGif.cpp
+++ b/gm/animatedGif.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "CommandLineFlags.h"
#include "Resources.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkCodec.h"
#include "SkColor.h"
@@ -131,7 +131,7 @@
return DrawResult::kOk;
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (!fCodec || fTotalFrames == 1) {
return false;
}
@@ -214,7 +214,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (fBaseMSec == 0) {
fBaseMSec = timer.msec();
}
diff --git a/gm/animatedimageblurs.cpp b/gm/animatedimageblurs.cpp
index 1c2d173..e08f1d0 100644
--- a/gm/animatedimageblurs.cpp
+++ b/gm/animatedimageblurs.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkBlurImageFilter.h"
-#include "SkRandom.h"
#include "SkRRect.h"
+#include "SkRandom.h"
+#include "gm.h"
static const SkScalar kBlurMax = 7.0f;
static const int kNumNodes = 30;
@@ -59,7 +59,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (0.0f != fLastTime) {
for (int i = 0; i < kNumNodes; ++i) {
fNodes[i].update(timer, fLastTime);
@@ -96,8 +96,7 @@
fSpeed = rand->nextRangeF(20.0f, 60.0f);
}
- void update(const SkAnimTimer& timer, SkScalar lastTime) {
-
+ void update(const AnimTimer& timer, SkScalar lastTime) {
SkScalar deltaTime = timer.secs() - lastTime;
fPos.fX += deltaTime * fSpeed * fDir.fX;
diff --git a/gm/blurcircles2.cpp b/gm/blurcircles2.cpp
index c2739a9..b28c932 100644
--- a/gm/blurcircles2.cpp
+++ b/gm/blurcircles2.cpp
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
-#include "SkString.h"
#include "SkRandom.h"
+#include "SkString.h"
+#include "gm.h"
/**
* In GM mode this draws an array of circles with different radii and different blur radii. Below
@@ -28,11 +28,13 @@
class BlurCircles2GM : public skiagm::GM {
public:
BlurCircles2GM() {
- fAnimRadius = SkAnimTimer::PingPong(0, kRadiusPingPoingPeriod, kRadiusPingPoingShift,
- kMinRadius, kMaxRadius);
- fAnimBlurRadius = SkAnimTimer::PingPong(0, kBlurRadiusPingPoingPeriod,
- kBlurRadiusPingPoingShift, kMinBlurRadius,
- kMaxBlurRadius);
+ fAnimRadius = AnimTimer::PingPong(
+ 0, kRadiusPingPoingPeriod, kRadiusPingPoingShift, kMinRadius, kMaxRadius);
+ fAnimBlurRadius = AnimTimer::PingPong(0,
+ kBlurRadiusPingPoingPeriod,
+ kBlurRadiusPingPoingShift,
+ kMinBlurRadius,
+ kMaxBlurRadius);
}
protected:
@@ -133,7 +135,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fAnimRadius = timer.pingPong(kRadiusPingPoingPeriod, kRadiusPingPoingShift, kMinRadius,
kMaxRadius);
fAnimBlurRadius = timer.pingPong(kBlurRadiusPingPoingPeriod, kBlurRadiusPingPoingShift,
diff --git a/gm/dashcircle.cpp b/gm/dashcircle.cpp
index 3168a0e..f92404f 100644
--- a/gm/dashcircle.cpp
+++ b/gm/dashcircle.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkAnimTimer.h"
-#include "SkPath.h"
+#include "AnimTimer.h"
#include "SkDashPathEffect.h"
+#include "SkPath.h"
+#include "gm.h"
int dash1[] = { 1, 1 };
int dash2[] = { 1, 3 };
@@ -94,7 +94,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
constexpr SkScalar kDesiredDurationSecs = 100.0f;
fRotation = timer.scaled(360.0f/kDesiredDurationSecs, 360.0f);
@@ -215,7 +215,7 @@
}
protected:
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fPhaseDegrees = timer.secs();
return true;
}
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
index 4c1f028..0e24cf9 100644
--- a/gm/dashcubics.cpp
+++ b/gm/dashcubics.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkDashPathEffect.h"
-#include "SkPath.h"
#include "SkParsePath.h"
+#include "SkPath.h"
#include "SkTArray.h"
#include "SkTrimPathEffect.h"
+#include "gm.h"
#include <utility>
@@ -153,7 +153,7 @@
}
}
- bool onAnimate(const SkAnimTimer& t) override {
+ bool onAnimate(const AnimTimer& t) override {
fOffset = t.msec() / 2000.0f;
fOffset -= floorf(fOffset);
return true;
diff --git a/gm/gm.cpp b/gm/gm.cpp
index 3bb58a7..d5c9e79 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -127,16 +127,14 @@
fBGColor = color;
}
-bool GM::animate(const SkAnimTimer& timer) {
- return this->onAnimate(timer);
-}
+bool GM::animate(const AnimTimer& timer) { return this->onAnimate(timer); }
bool GM::runAsBench() const { return false; }
void GM::modifyGrContextOptions(GrContextOptions* options) {}
void GM::onOnceBeforeDraw() {}
-bool GM::onAnimate(const SkAnimTimer&) { return false; }
+bool GM::onAnimate(const AnimTimer&) { return false; }
bool GM::onHandleKey(SkUnichar uni) { return false; }
bool GM::onGetControls(SkMetaData*) { return false; }
void GM::onSetControls(const SkMetaData&) {}
diff --git a/gm/gm.h b/gm/gm.h
index 4c84376..e7dee35 100644
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -17,7 +17,7 @@
#include "SkSize.h"
#include "SkString.h"
-class SkAnimTimer;
+class AnimTimer;
class SkMetaData;
struct GrContextOptions;
@@ -142,7 +142,7 @@
fCanvasIsDeferred = isDeferred;
}
- bool animate(const SkAnimTimer&);
+ bool animate(const AnimTimer&);
bool handleKey(SkUnichar uni) {
return this->onHandleKey(uni);
}
@@ -160,7 +160,7 @@
virtual SkISize onISize() = 0;
virtual SkString onShortName() = 0;
- virtual bool onAnimate(const SkAnimTimer&);
+ virtual bool onAnimate(const AnimTimer&);
virtual bool onHandleKey(SkUnichar uni);
virtual bool onGetControls(SkMetaData*);
virtual void onSetControls(const SkMetaData&);
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index d56a428..2ced090 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkLightingImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPoint3.h"
@@ -156,7 +156,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
constexpr SkScalar kDesiredDurationSecs = 15.0f;
fAzimuth = kStartAzimuth + timer.scaled(360.0f/kDesiredDurationSecs, 360.0f);
diff --git a/gm/mixercolorfilter.cpp b/gm/mixercolorfilter.cpp
index a98e7b8..2c20b6a 100644
--- a/gm/mixercolorfilter.cpp
+++ b/gm/mixercolorfilter.cpp
@@ -7,12 +7,12 @@
#include "gm.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkGradientShader.h"
#include "SkLumaColorFilter.h"
#include "SkTableColorFilter.h"
-#include "SkAnimTimer.h"
namespace {
@@ -186,7 +186,7 @@
canvas->drawRect(r, paint);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fPos = (sin(timer.secs()) + 1) * 0.5f;
return true;
}
diff --git a/gm/simplerect.cpp b/gm/simplerect.cpp
index 24c5016..8076bc9 100644
--- a/gm/simplerect.cpp
+++ b/gm/simplerect.cpp
@@ -45,9 +45,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
- return true;
- }
+ bool onAnimate(const AnimTimer& timer) override { return true; }
private:
diff --git a/gm/stringart.cpp b/gm/stringart.cpp
index 48f7df0..ccd84f8 100644
--- a/gm/stringart.cpp
+++ b/gm/stringart.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkPath.h"
#include "ToolUtils.h"
@@ -61,7 +61,7 @@
canvas->drawPath(path, paint);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
constexpr SkScalar kDesiredDurationSecs = 3.0f;
// Make the animation ping-pong back and forth but start in the fully drawn state
@@ -141,7 +141,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
SkScalar time = (float)(fmod(timer.secs(), fDur) / fDur);
for (auto anim : fAnims) {
anim->seek(time);
diff --git a/modules/skottie/gm/SkottieGM.cpp b/modules/skottie/gm/SkottieGM.cpp
index fb68c76..e63c39d 100644
--- a/modules/skottie/gm/SkottieGM.cpp
+++ b/modules/skottie/gm/SkottieGM.cpp
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-#include "gm.h"
+#include "AnimTimer.h"
#include "Resources.h"
#include "SkAnimCodecPlayer.h"
-#include "SkAnimTimer.h"
#include "SkColor.h"
#include "SkMakeUnique.h"
#include "Skottie.h"
#include "SkottieProperty.h"
#include "SkottieUtils.h"
+#include "gm.h"
#include <cmath>
#include <vector>
@@ -72,7 +72,7 @@
return DrawResult::kOk;
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (!fAnimation) {
return false;
}
@@ -125,7 +125,7 @@
return DrawResult::kOk;
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (!fAnimation) {
return false;
}
@@ -198,7 +198,7 @@
return DrawResult::kOk;
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (!fAnimation) {
return false;
}
diff --git a/modules/sksg/samples/SampleSVGPong.cpp b/modules/sksg/samples/SampleSVGPong.cpp
index 7869607..7b99417 100644
--- a/modules/sksg/samples/SampleSVGPong.cpp
+++ b/modules/sksg/samples/SampleSVGPong.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkColor.h"
-#include "SkRandom.h"
#include "SkRRect.h"
+#include "SkRandom.h"
#include "SkSGColor.h"
#include "SkSGDraw.h"
@@ -192,7 +192,7 @@
fScene->render(canvas);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
// onAnimate may fire before the first draw.
if (fScene) {
SkScalar dt = (timer.msec() - fLastTick) * fTimeScale;
diff --git a/platform_tools/android/apps/arcore/src/main/cpp/hello_ar_application.cc b/platform_tools/android/apps/arcore/src/main/cpp/hello_ar_application.cc
index aafc0d0..34fb87a 100644
--- a/platform_tools/android/apps/arcore/src/main/cpp/hello_ar_application.cc
+++ b/platform_tools/android/apps/arcore/src/main/cpp/hello_ar_application.cc
@@ -17,29 +17,29 @@
#include "hello_ar_application.h"
#include <gtx/string_cast.hpp>
-#include "anchor_wrapper.h"
-#include "plane_renderer.h"
-#include "pending_anchor.h"
-#include "util.h"
-#include "SkCanvas.h"
-#include "GrContext.h"
-#include "gl/GrGLTypes.h"
-#include "SkSurface.h"
-#include "SkTypeface.h"
-#include "SkFontStyle.h"
+#include <math.h> /* acos */
+#include "AnimTimer.h"
#include "GrBackendSurface.h"
-#include "SkMatrix44.h"
-#include "SkMatrix.h"
-#include "SkTextBlob.h"
-#include "glm.h"
-#include "SkPoint3.h"
-#include "Sk3D.h"
-#include <math.h> /* acos */
-#include "SkShaper.h"
-#include "Skottie.h"
-#include "SkAnimTimer.h"
+#include "GrContext.h"
#include "Resources.h"
+#include "Sk3D.h"
+#include "SkCanvas.h"
+#include "SkFontStyle.h"
+#include "SkMatrix.h"
+#include "SkMatrix44.h"
+#include "SkPoint3.h"
+#include "SkShaper.h"
#include "SkStream.h"
+#include "SkSurface.h"
+#include "SkTextBlob.h"
+#include "SkTypeface.h"
+#include "Skottie.h"
+#include "anchor_wrapper.h"
+#include "gl/GrGLTypes.h"
+#include "glm.h"
+#include "pending_anchor.h"
+#include "plane_renderer.h"
+#include "util.h"
namespace hello_ar {
namespace {
diff --git a/samplecode/PerlinPatch.cpp b/samplecode/PerlinPatch.cpp
index c962e19..8bac913 100644
--- a/samplecode/PerlinPatch.cpp
+++ b/samplecode/PerlinPatch.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkPatchUtils.h"
@@ -125,12 +125,11 @@
return this->INHERITED::onQuery(evt);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fSeed += 0.005f;
return true;
}
-
void onDrawContent(SkCanvas* canvas) override {
if (!canvas->getTotalMatrix().invert(&fInvMatrix)) {
return;
diff --git a/samplecode/Sample.h b/samplecode/Sample.h
index e906e31..ecf3189 100644
--- a/samplecode/Sample.h
+++ b/samplecode/Sample.h
@@ -16,7 +16,7 @@
#include "SkRefCnt.h"
#include "SkString.h"
-class SkAnimTimer;
+class AnimTimer;
class SkCanvas;
class Sample;
@@ -81,7 +81,7 @@
static void DoClickUp(Click*, int x, int y, unsigned modi);
void setBGColor(SkColor color) { fBGColor = color; }
- bool animate(const SkAnimTimer& timer) { return this->onAnimate(timer); }
+ bool animate(const AnimTimer& timer) { return this->onAnimate(timer); }
class Event {
public:
@@ -209,7 +209,7 @@
virtual void onDrawBackground(SkCanvas*);
virtual void onDrawContent(SkCanvas*) = 0;
- virtual bool onAnimate(const SkAnimTimer&) { return false; }
+ virtual bool onAnimate(const AnimTimer&) { return false; }
virtual void onOnceBeforeDraw() {}
private:
diff --git a/samplecode/SampleAndroidShadows.cpp b/samplecode/SampleAndroidShadows.cpp
index b367ae9..8449b34 100644
--- a/samplecode/SampleAndroidShadows.cpp
+++ b/samplecode/SampleAndroidShadows.cpp
@@ -5,8 +5,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCamera.h"
@@ -341,7 +341,7 @@
lightPos, kLightWidth, .5f);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fAnimTranslate = timer.pingPong(30, 0, 125, -125);
fAnimAngle = timer.pingPong(15, 0, 0, 20);
if (fDoAlphaAnimation) {
diff --git a/samplecode/SampleAnimBlur.cpp b/samplecode/SampleAnimBlur.cpp
index 2d433ee..21d886d 100644
--- a/samplecode/SampleAnimBlur.cpp
+++ b/samplecode/SampleAnimBlur.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
-#include "SkColorPriv.h"
#include "SkCanvas.h"
+#include "SkColorPriv.h"
#include "SkMaskFilter.h"
#include "SkRandom.h"
@@ -55,7 +55,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fBlurSigma = get_anim_sin(timer.secs(), 100, 4, 5);
fCircleRadius = 3 + get_anim_sin(timer.secs(), 150, 25, 3);
return true;
diff --git a/samplecode/SampleAnimatedImage.cpp b/samplecode/SampleAnimatedImage.cpp
index 8f73935..9f66f3a 100644
--- a/samplecode/SampleAnimatedImage.cpp
+++ b/samplecode/SampleAnimatedImage.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "SkAndroidCodec.h"
#include "SkAnimatedImage.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkPaint.h"
@@ -56,7 +56,7 @@
canvas->drawDrawable(fDrawable.get(), fImage->getBounds().width(), 0);
}
- bool onAnimate(const SkAnimTimer& animTimer) override {
+ bool onAnimate(const AnimTimer& animTimer) override {
if (!fImage) {
return false;
}
diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp
index cfc071a..e927ffc 100644
--- a/samplecode/SampleAnimatedText.cpp
+++ b/samplecode/SampleAnimatedText.cpp
@@ -129,7 +129,7 @@
canvas->drawString(modeString, 768.f, 540.f, font, paint);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
// We add noise to the scale and rotation animations to
// keep the font atlas from falling into a steady state
fRotation += (1.0f + gRand.nextRangeF(-0.1f, 0.1f));
diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp
index 58e4057..54bada0 100644
--- a/samplecode/SampleArc.cpp
+++ b/samplecode/SampleArc.cpp
@@ -5,8 +5,9 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
+#include "Sk1DPathEffect.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
@@ -22,7 +23,6 @@
#include "SkString.h"
#include "SkTextUtils.h"
#include "SkUTF.h"
-#include "Sk1DPathEffect.h"
#include "SkParsePath.h"
static void testparse() {
@@ -187,7 +187,7 @@
canvas->drawDrawable(fRootDrawable.get());
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360));
fAnimatingDrawable->setSweep(angle);
return true;
diff --git a/samplecode/SampleAtlas.cpp b/samplecode/SampleAtlas.cpp
index 5464204..a2ef015 100644
--- a/samplecode/SampleAtlas.cpp
+++ b/samplecode/SampleAtlas.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkDrawable.h"
#include "SkPath.h"
-#include "SkRandom.h"
#include "SkRSXform.h"
+#include "SkRandom.h"
#include "SkSurface.h"
#include "SkTextUtils.h"
@@ -234,12 +234,10 @@
canvas->drawDrawable(fDrawable.get());
}
- bool onAnimate(const SkAnimTimer&) override {
- return true;
- }
+ bool onAnimate(const AnimTimer&) override { return true; }
#if 0
// TODO: switch over to use this for our animation
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360));
fAnimatingDrawable->setSweep(angle);
return true;
diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp
index 9dcf98c..fb8771d 100644
--- a/samplecode/SampleBitmapRect.cpp
+++ b/samplecode/SampleBitmapRect.cpp
@@ -5,21 +5,21 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkColorFilter.h"
+#include "SkColorPriv.h"
#include "SkFont.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
-#include "SkUTF.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
#include "SkTime.h"
#include "SkTypeface.h"
+#include "SkUTF.h"
#include "SkOSFile.h"
#include "SkStream.h"
@@ -136,7 +136,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (timer.isStopped()) {
this->resetBounce();
} else if (timer.isRunning()) {
@@ -232,7 +232,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (timer.isStopped()) {
this->resetBounce();
} else if (timer.isRunning()) {
diff --git a/samplecode/SampleCamera.cpp b/samplecode/SampleCamera.cpp
index 6584867..ec30606 100644
--- a/samplecode/SampleCamera.cpp
+++ b/samplecode/SampleCamera.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "DecodeFile.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
-#include "SkCanvas.h"
#include "SkCamera.h"
+#include "SkCanvas.h"
#include "SkEmbossMaskFilter.h"
#include "SkGradientShader.h"
#include "SkPath.h"
@@ -83,7 +83,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (timer.isStopped()) {
fRY = 0;
} else {
diff --git a/samplecode/SampleClock.cpp b/samplecode/SampleClock.cpp
index dc240b3..2bd65e2 100644
--- a/samplecode/SampleClock.cpp
+++ b/samplecode/SampleClock.cpp
@@ -216,9 +216,7 @@
canvas->restore();
}
- bool onAnimate(const SkAnimTimer&) override {
- return true;
- }
+ bool onAnimate(const AnimTimer&) override { return true; }
private:
diff --git a/samplecode/SampleCowboy.cpp b/samplecode/SampleCowboy.cpp
index 06bbf88..e598f87 100644
--- a/samplecode/SampleCowboy.cpp
+++ b/samplecode/SampleCowboy.cpp
@@ -105,7 +105,7 @@
return this->INHERITED::onQuery(evt);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (!fDom) {
return false;
}
diff --git a/samplecode/SampleCusp.cpp b/samplecode/SampleCusp.cpp
index 32ba90d..d978e33 100644
--- a/samplecode/SampleCusp.cpp
+++ b/samplecode/SampleCusp.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
+#include <string>
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkGeometry.h"
#include "SkPath.h"
-#include <string>
// This draws an animation where every cubic has a cusp, to test drawing a circle
// at the cusp point. Create a unit square. A cubic with its control points
@@ -171,7 +171,7 @@
SkDebugf("");
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
curTime = timer.msec();
if (!start) {
start = curTime;
diff --git a/samplecode/SampleDegenerateTwoPtRadials.cpp b/samplecode/SampleDegenerateTwoPtRadials.cpp
index 7392c66..eb04d22 100644
--- a/samplecode/SampleDegenerateTwoPtRadials.cpp
+++ b/samplecode/SampleDegenerateTwoPtRadials.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkGradientShader.h"
@@ -73,7 +73,7 @@
SkFont(), SkPaint());
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fTime = SkDoubleToScalar(timer.secs() / 15);
return true;
}
diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp
index 69ade73..6d1d465 100644
--- a/samplecode/SampleFilterQuality.cpp
+++ b/samplecode/SampleFilterQuality.cpp
@@ -5,17 +5,17 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Resources.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
-#include "SkInterpolator.h"
+#include "SkData.h"
#include "SkFont.h"
#include "SkGradientShader.h"
-#include "SkData.h"
+#include "SkInterpolator.h"
#include "SkPath.h"
-#include "SkSurface.h"
#include "SkRandom.h"
+#include "SkSurface.h"
#include "SkTime.h"
static sk_sp<SkSurface> make_surface(SkCanvas* canvas, const SkImageInfo& info) {
@@ -283,7 +283,7 @@
canvas->drawString(SkStringPrintf("%.8g", trans[1] ), textX, 250, font, paint);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fCurrTime = timer.msec();
return true;
}
diff --git a/samplecode/SampleFlutterAnimate.cpp b/samplecode/SampleFlutterAnimate.cpp
index bffee4a..0953fe8 100644
--- a/samplecode/SampleFlutterAnimate.cpp
+++ b/samplecode/SampleFlutterAnimate.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
-#include "SkFont.h"
-#include "SkColorPriv.h"
#include "SkColorFilter.h"
+#include "SkColorPriv.h"
+#include "SkFont.h"
#include "SkImage.h"
#include "SkRandom.h"
#include "SkTime.h"
@@ -64,7 +64,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fCurrTime = timer.secs() - fResetTime;
if (fCurrTime > kDuration) {
this->initChars();
diff --git a/samplecode/SampleGlyphTransform.cpp b/samplecode/SampleGlyphTransform.cpp
index ecd160c..497a6be 100644
--- a/samplecode/SampleGlyphTransform.cpp
+++ b/samplecode/SampleGlyphTransform.cpp
@@ -7,11 +7,11 @@
#include "Sample.h"
#include "ToolUtils.h"
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkPath.h"
-#include "SkRandom.h"
#include "SkRRect.h"
+#include "SkRandom.h"
#include "SkTypeface.h"
#include <cmath>
@@ -60,7 +60,7 @@
font, paint);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
constexpr SkScalar maxt = 100000;
double t = timer.pingPong(20, 0, 0, maxt); // d3 t is in milliseconds
diff --git a/samplecode/SampleHT.cpp b/samplecode/SampleHT.cpp
index b12aa27..05b9aec 100644
--- a/samplecode/SampleHT.cpp
+++ b/samplecode/SampleHT.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkDrawable.h"
#include "SkInterpolator.h"
@@ -154,7 +154,7 @@
canvas->drawDrawable(fRoot.get());
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fTime = timer.msec();
for (int i = 0; i < N; ++i) {
fArray[i].fDrawable->setTime(fTime);
diff --git a/samplecode/SampleHairline.cpp b/samplecode/SampleHairline.cpp
index 1ebbc1e..f6ec0ca 100644
--- a/samplecode/SampleHairline.cpp
+++ b/samplecode/SampleHairline.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
@@ -216,7 +216,7 @@
canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), nullptr);
}
- bool onAnimate(const SkAnimTimer&) override {
+ bool onAnimate(const AnimTimer&) override {
if (fDoAA) {
fProcIndex = cycle_hairproc_index(fProcIndex);
// todo: signal that we want to rebuild our TITLE
diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp
index 33cbe4d..6b77e97 100644
--- a/samplecode/SampleLayers.cpp
+++ b/samplecode/SampleLayers.cpp
@@ -184,8 +184,8 @@
#include "SkMatrixConvolutionImageFilter.h"
#include "SkMorphologyImageFilter.h"
+#include "AnimTimer.h"
#include "Resources.h"
-#include "SkAnimTimer.h"
class BackdropView : public Sample {
SkPoint fCenter;
@@ -231,7 +231,7 @@
canvas->restore();
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fAngle = SkDoubleToScalar(fmod(timer.secs() * 360 / 5, 360));
return true;
}
diff --git a/samplecode/SampleLighting.cpp b/samplecode/SampleLighting.cpp
index ef0694b..28bdea3 100644
--- a/samplecode/SampleLighting.cpp
+++ b/samplecode/SampleLighting.cpp
@@ -81,7 +81,7 @@
return this->INHERITED::onFindClickHandler(x, y, modi);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fLightAngle += 0.015f;
fColorFactor += 0.01f;
if (fColorFactor > 1.0f) {
diff --git a/samplecode/SampleLitAtlas.cpp b/samplecode/SampleLitAtlas.cpp
index 13a2656..6a39a53 100644
--- a/samplecode/SampleLitAtlas.cpp
+++ b/samplecode/SampleLitAtlas.cpp
@@ -5,16 +5,16 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkBitmapProcShader.h"
#include "SkCanvas.h"
#include "SkDrawable.h"
#include "SkLightingShader.h"
#include "SkLights.h"
#include "SkNormalSource.h"
-#include "SkRandom.h"
#include "SkRSXform.h"
+#include "SkRandom.h"
#include "ToolUtils.h"
@@ -482,9 +482,7 @@
canvas->drawDrawable(fDrawable.get());
}
- bool onAnimate(const SkAnimTimer& timer) override {
- return true;
- }
+ bool onAnimate(const AnimTimer& timer) override { return true; }
private:
sk_sp<DrawLitAtlasDrawable> fDrawable;
diff --git a/samplecode/SampleMegaStroke.cpp b/samplecode/SampleMegaStroke.cpp
index a8f349a..3248ab9 100644
--- a/samplecode/SampleMegaStroke.cpp
+++ b/samplecode/SampleMegaStroke.cpp
@@ -78,9 +78,7 @@
fClip.set(0, 0, 950, 600);
}
- bool onAnimate(const SkAnimTimer& ) override {
- return true;
- }
+ bool onAnimate(const AnimTimer&) override { return true; }
private:
SkPath fMegaPath;
diff --git a/samplecode/SampleNima.cpp b/samplecode/SampleNima.cpp
index 6912518..3ecd764 100644
--- a/samplecode/SampleNima.cpp
+++ b/samplecode/SampleNima.cpp
@@ -7,8 +7,8 @@
#include "Sample.h"
+#include "AnimTimer.h"
#include "Resources.h"
-#include "SkAnimTimer.h"
#include "nima/NimaActor.h"
#include <nima/Animation/ActorAnimationInstance.hpp>
@@ -54,7 +54,7 @@
canvas->restore();
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
if (fActor) {
float time = std::fmod(timer.secs(), fActor->duration());
fActor->seek(time);
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index af14ac3..5197616 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -5,21 +5,21 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "DecodeFile.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
+#include "SkColorFilter.h"
+#include "SkColorPriv.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
#include "SkShader.h"
-#include "SkUTF.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
#include "SkTime.h"
#include "SkTypeface.h"
+#include "SkUTF.h"
#include "SkVertices.h"
#include "SkOSFile.h"
@@ -292,7 +292,7 @@
drawpatches(canvas, paint, nu, nv, &patch);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fAngle = timer.scaled(60, 360);
return true;
}
@@ -396,9 +396,7 @@
return this->INHERITED::onQuery(evt);
}
- bool onAnimate(const SkAnimTimer& timer) override {
- return true;
- }
+ bool onAnimate(const AnimTimer& timer) override { return true; }
void onDrawContent(SkCanvas* canvas) override {
if (fDirty) {
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 74de725..0cd31ab 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -5,22 +5,22 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkColorFilter.h"
+#include "SkColorPriv.h"
+#include "SkFont.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkFont.h"
+#include "SkParsePath.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
-#include "SkUTF.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
-#include "SkParsePath.h"
#include "SkTime.h"
#include "SkTypeface.h"
+#include "SkUTF.h"
#include "SkGeometry.h"
@@ -183,7 +183,7 @@
}
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
SkScalar currSecs = timer.scaled(100);
SkScalar delta = currSecs - fPrevSecs;
fPrevSecs = currSecs;
diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp
index e59b64d..e4a7422 100644
--- a/samplecode/SamplePathEffects.cpp
+++ b/samplecode/SamplePathEffects.cpp
@@ -5,19 +5,19 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
+#include "Sk1DPathEffect.h"
#include "SkCanvas.h"
+#include "SkColorPriv.h"
+#include "SkCornerPathEffect.h"
#include "SkGradientShader.h"
#include "SkPath.h"
+#include "SkPathMeasure.h"
+#include "SkRandom.h"
#include "SkRegion.h"
#include "SkShader.h"
#include "SkUTF.h"
-#include "Sk1DPathEffect.h"
-#include "SkCornerPathEffect.h"
-#include "SkPathMeasure.h"
-#include "SkRandom.h"
-#include "SkColorPriv.h"
#define CORNER_RADIUS 12
@@ -138,7 +138,7 @@
canvas->drawPath(fPath, paint);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
fPhase = timer.scaled(40);
return true;
}
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index e9b2be3..57a8268 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
@@ -167,7 +167,7 @@
fLastTick = 0;
}
- bool onAnimate(const SkAnimTimer& timer) final {
+ bool onAnimate(const AnimTimer& timer) final {
fBackgroundAnimationTask.wait();
this->swapAnimationBuffers();
diff --git a/samplecode/SampleShadowUtils.cpp b/samplecode/SampleShadowUtils.cpp
index 5389c38..c7ab6de 100644
--- a/samplecode/SampleShadowUtils.cpp
+++ b/samplecode/SampleShadowUtils.cpp
@@ -5,8 +5,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCamera.h"
diff --git a/samplecode/SampleShip.cpp b/samplecode/SampleShip.cpp
index 2e95181..7e3cbd4 100644
--- a/samplecode/SampleShip.cpp
+++ b/samplecode/SampleShip.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
-#include "Sample.h"
+#include "AnimTimer.h"
#include "Resources.h"
-#include "SkAnimTimer.h"
+#include "Sample.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkRSXform.h"
@@ -156,7 +156,7 @@
#if 0
// TODO: switch over to use this for our animation
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360));
fAnimatingDrawable->setSweep(angle);
return true;
diff --git a/samplecode/SampleThinAA.cpp b/samplecode/SampleThinAA.cpp
index bbb2427..c38f453 100644
--- a/samplecode/SampleThinAA.cpp
+++ b/samplecode/SampleThinAA.cpp
@@ -7,7 +7,7 @@
#include "Sample.h"
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkFont.h"
@@ -316,7 +316,7 @@
this->drawShapes(canvas, "SSx64", 4, fSS16);
}
- bool onAnimate(const SkAnimTimer& timer) override {
+ bool onAnimate(const AnimTimer& timer) override {
SkScalar t = timer.secs();
SkScalar dt = fLastFrameTime < 0.f ? 0.f : t - fLastFrameTime;
fLastFrameTime = t;
diff --git a/samplecode/SampleXfer.cpp b/samplecode/SampleXfer.cpp
index bc6b911..849b585 100644
--- a/samplecode/SampleXfer.cpp
+++ b/samplecode/SampleXfer.cpp
@@ -5,18 +5,17 @@
* found in the LICENSE file.
*/
+#include "AnimTimer.h"
#include "Sample.h"
-#include "SkAnimTimer.h"
-#include "SkDrawable.h"
#include "SkCanvas.h"
#include "SkDrawable.h"
+#include "SkGradientShader.h"
#include "SkPath.h"
-#include "SkRandom.h"
#include "SkRSXform.h"
+#include "SkRandom.h"
#include "SkString.h"
#include "SkSurface.h"
#include "SkTextUtils.h"
-#include "SkGradientShader.h"
const SkBlendMode gModes[] = {
SkBlendMode::kSrcOver,
diff --git a/tools/timer/SkAnimTimer.h b/tools/timer/AnimTimer.h
similarity index 80%
rename from tools/timer/SkAnimTimer.h
rename to tools/timer/AnimTimer.h
index bcec008..8517951 100644
--- a/tools/timer/SkAnimTimer.h
+++ b/tools/timer/AnimTimer.h
@@ -8,8 +8,8 @@
#include "SkScalar.h"
#include "SkTime.h"
-#ifndef SkAnimTimer_DEFINED
-#define SkAnimTimer_DEFINED
+#ifndef AnimTimer_DEFINED
+#define AnimTimer_DEFINED
/**
* Class to track a "timer". It supports 3 states: stopped, paused, and running.
@@ -20,24 +20,17 @@
* are consistent if called repeatedly, as they only reflect the time since the last
* calle to updateTimer().
*/
-class SkAnimTimer {
+class AnimTimer {
public:
- enum State {
- kStopped_State,
- kPaused_State,
- kRunning_State
- };
+ enum State { kStopped_State, kPaused_State, kRunning_State };
/**
* Class begins in the "stopped" state.
*/
- SkAnimTimer() : fPreviousNanos(0), fElapsedNanos(0), fSpeed(1), fState(kStopped_State) {}
+ AnimTimer() : fPreviousNanos(0), fElapsedNanos(0), fSpeed(1), fState(kStopped_State) {}
- SkAnimTimer(double elapsed)
- : fPreviousNanos(0)
- , fElapsedNanos(elapsed)
- , fSpeed(1)
- , fState(kRunning_State) {}
+ AnimTimer(double elapsed)
+ : fPreviousNanos(0), fElapsedNanos(elapsed), fSpeed(1), fState(kRunning_State) {}
bool isStopped() const { return kStopped_State == fState; }
bool isRunning() const { return kRunning_State == fState; }
@@ -47,22 +40,18 @@
* Stops the timer, and resets it, such that the next call to run or togglePauseResume
* will begin at time 0.
*/
- void stop() {
- this->setState(kStopped_State);
- }
+ void stop() { this->setState(kStopped_State); }
/**
* If the timer is paused or stopped, it will resume (or start if it was stopped).
*/
- void run() {
- this->setState(kRunning_State);
- }
+ void run() { this->setState(kRunning_State); }
/**
* Control the rate at which time advances.
*/
float getSpeed() const { return fSpeed; }
- void setSpeed(float speed) { fSpeed = speed; }
+ void setSpeed(float speed) { fSpeed = speed; }
/**
* If the timer is stopped, start running, else it toggles between paused and running.
@@ -128,12 +117,15 @@
return PingPong(this->secs(), period, phase, ends, mid);
}
- /** Helper for computing a ping-pong value without a SkAnimTimer object. */
- static SkScalar PingPong(double t, SkScalar period, SkScalar phase, SkScalar ends,
+ /** Helper for computing a ping-pong value without a AnimTimer object. */
+ static SkScalar PingPong(double t,
+ SkScalar period,
+ SkScalar phase,
+ SkScalar ends,
SkScalar mid) {
double value = ::fmod(t + phase, period);
- double half = period / 2.0;
- double diff = ::fabs(value - half);
+ double half = period / 2.0;
+ double diff = ::fabs(value - half);
return SkDoubleToScalar(ends + (1.0 - diff / half) * (mid - ends));
}
@@ -147,24 +139,23 @@
switch (newState) {
case kStopped_State:
fPreviousNanos = fElapsedNanos = 0;
- fState = kStopped_State;
+ fState = kStopped_State;
break;
case kPaused_State:
if (kRunning_State == fState) {
fState = kPaused_State;
- } // else stay stopped or paused
+ } // else stay stopped or paused
break;
case kRunning_State:
switch (fState) {
case kStopped_State:
fPreviousNanos = SkTime::GetNSecs();
- fElapsedNanos = 0;
+ fElapsedNanos = 0;
break;
case kPaused_State: // they want "resume"
fPreviousNanos = SkTime::GetNSecs();
break;
- case kRunning_State:
- break;
+ case kRunning_State: break;
}
fState = kRunning_State;
break;
diff --git a/tools/viewer/GMSlide.cpp b/tools/viewer/GMSlide.cpp
index cfd4853..07c0392 100644
--- a/tools/viewer/GMSlide.cpp
+++ b/tools/viewer/GMSlide.cpp
@@ -27,9 +27,7 @@
fGM->drawContent(canvas);
}
-bool GMSlide::animate(const SkAnimTimer& timer) {
- return fGM->animate(timer);
-}
+bool GMSlide::animate(const AnimTimer& timer) { return fGM->animate(timer); }
bool GMSlide::onChar(SkUnichar c) {
return fGM->handleKey(c);
diff --git a/tools/viewer/GMSlide.h b/tools/viewer/GMSlide.h
index c03cc8a..fc34fe4 100644
--- a/tools/viewer/GMSlide.h
+++ b/tools/viewer/GMSlide.h
@@ -19,7 +19,7 @@
SkISize getDimensions() const override { return fGM->getISize(); }
void draw(SkCanvas* canvas) override;
- bool animate(const SkAnimTimer&) override;
+ bool animate(const AnimTimer&) override;
bool onChar(SkUnichar c) override;
diff --git a/tools/viewer/NIMASlide.cpp b/tools/viewer/NIMASlide.cpp
index bf516a8..c04c82b 100644
--- a/tools/viewer/NIMASlide.cpp
+++ b/tools/viewer/NIMASlide.cpp
@@ -7,8 +7,8 @@
#include "NIMASlide.h"
+#include "AnimTimer.h"
#include "Resources.h"
-#include "SkAnimTimer.h"
#include "SkOSPath.h"
#include "imgui.h"
#include "nima/NimaActor.h"
@@ -88,7 +88,7 @@
fActor.reset(nullptr);
}
-bool NIMASlide::animate(const SkAnimTimer& timer) {
+bool NIMASlide::animate(const AnimTimer& timer) {
// Apply the animation.
if (fActor) {
float time = std::fmod(timer.secs(), fActor->duration());
diff --git a/tools/viewer/NIMASlide.h b/tools/viewer/NIMASlide.h
index ea2c227..05892b9 100644
--- a/tools/viewer/NIMASlide.h
+++ b/tools/viewer/NIMASlide.h
@@ -24,7 +24,7 @@
void draw(SkCanvas* canvas) override;
void load(SkScalar winWidth, SkScalar winHeight) override;
void unload() override;
- bool animate(const SkAnimTimer& timer) override;
+ bool animate(const AnimTimer& timer) override;
bool onChar(SkUnichar c) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
diff --git a/tools/viewer/ParticlesSlide.cpp b/tools/viewer/ParticlesSlide.cpp
index b92b166..cd41656 100644
--- a/tools/viewer/ParticlesSlide.cpp
+++ b/tools/viewer/ParticlesSlide.cpp
@@ -7,9 +7,9 @@
#include "ParticlesSlide.h"
+#include "AnimTimer.h"
#include "ImGuiLayer.h"
#include "Resources.h"
-#include "SkAnimTimer.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
#include "SkParticleAffector.h"
@@ -322,7 +322,7 @@
}
}
-bool ParticlesSlide::animate(const SkAnimTimer& timer) {
+bool ParticlesSlide::animate(const AnimTimer& timer) {
fTimer = &timer;
for (const auto& effect : fRunning) {
effect.fEffect->update(timer.secs());
diff --git a/tools/viewer/ParticlesSlide.h b/tools/viewer/ParticlesSlide.h
index b98abe1..8211513 100644
--- a/tools/viewer/ParticlesSlide.h
+++ b/tools/viewer/ParticlesSlide.h
@@ -14,7 +14,7 @@
#include "SkRandom.h"
#include "SkTArray.h"
-class SkAnimTimer;
+class AnimTimer;
class SkParticleEffect;
class SkParticleEffectParams;
@@ -27,7 +27,7 @@
void load(SkScalar winWidth, SkScalar winHeight) override;
void draw(SkCanvas* canvas) override;
- bool animate(const SkAnimTimer& timer) override;
+ bool animate(const AnimTimer& timer) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
uint32_t modifiers) override;
@@ -36,7 +36,7 @@
void loadEffects(const char* dirname);
SkRandom fRandom;
- const SkAnimTimer* fTimer;
+ const AnimTimer* fTimer;
SkPoint fPlayPosition;
struct LoadedEffect {
diff --git a/tools/viewer/SampleSlide.h b/tools/viewer/SampleSlide.h
index 7cf1d3c..69d48ac 100644
--- a/tools/viewer/SampleSlide.h
+++ b/tools/viewer/SampleSlide.h
@@ -24,9 +24,7 @@
fSample->setSize(winWidth, winHeight);
}
void unload() override;
- bool animate(const SkAnimTimer& timer) override {
- return fSample->animate(timer);
- }
+ bool animate(const AnimTimer& timer) override { return fSample->animate(timer); }
bool onChar(SkUnichar c) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
diff --git a/tools/viewer/SkottieSlide.cpp b/tools/viewer/SkottieSlide.cpp
index 981dc53..6198e47 100644
--- a/tools/viewer/SkottieSlide.cpp
+++ b/tools/viewer/SkottieSlide.cpp
@@ -9,7 +9,7 @@
#if defined(SK_ENABLE_SKOTTIE)
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkOSPath.h"
@@ -136,7 +136,7 @@
}
}
-bool SkottieSlide::animate(const SkAnimTimer& timer) {
+bool SkottieSlide::animate(const AnimTimer& timer) {
if (fTimeBase == 0) {
// Reset the animation time.
fTimeBase = timer.msec();
diff --git a/tools/viewer/SkottieSlide.h b/tools/viewer/SkottieSlide.h
index 9bf6bf5..1a6a075 100644
--- a/tools/viewer/SkottieSlide.h
+++ b/tools/viewer/SkottieSlide.h
@@ -26,7 +26,7 @@
SkISize getDimensions() const override;
void draw(SkCanvas*) override;
- bool animate(const SkAnimTimer&) override;
+ bool animate(const AnimTimer&) override;
bool onChar(SkUnichar) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
diff --git a/tools/viewer/Slide.h b/tools/viewer/Slide.h
index a2ee307..10080ce 100644
--- a/tools/viewer/Slide.h
+++ b/tools/viewer/Slide.h
@@ -14,7 +14,7 @@
#include "sk_app/Window.h"
class SkCanvas;
-class SkAnimTimer;
+class AnimTimer;
class SkMetaData;
class Slide : public SkRefCnt {
@@ -24,7 +24,7 @@
virtual SkISize getDimensions() const = 0;
virtual void draw(SkCanvas* canvas) = 0;
- virtual bool animate(const SkAnimTimer&) { return false; }
+ virtual bool animate(const AnimTimer&) { return false; }
virtual void load(SkScalar winWidth, SkScalar winHeight) {}
virtual void resize(SkScalar winWidth, SkScalar winHeight) {}
virtual void unload() {}
diff --git a/tools/viewer/SlideDir.cpp b/tools/viewer/SlideDir.cpp
index ccc9334..5737697 100644
--- a/tools/viewer/SlideDir.cpp
+++ b/tools/viewer/SlideDir.cpp
@@ -7,7 +7,7 @@
#include "SlideDir.h"
-#include "SkAnimTimer.h"
+#include "AnimTimer.h"
#include "SkCanvas.h"
#include "SkCubicMap.h"
#include "SkMakeUnique.h"
@@ -84,7 +84,7 @@
private:
void tick(SkMSec t) {
- fSlide->animate(SkAnimTimer(t * 1e6));
+ fSlide->animate(AnimTimer(t * 1e6));
this->invalidate();
}
@@ -353,7 +353,7 @@
fScene->render(canvas);
}
-bool SlideDir::animate(const SkAnimTimer& timer) {
+bool SlideDir::animate(const AnimTimer& timer) {
if (fTimeBase == 0) {
// Reset the animation time.
fTimeBase = timer.msec();
diff --git a/tools/viewer/SlideDir.h b/tools/viewer/SlideDir.h
index 376aee5..eeb4904 100644
--- a/tools/viewer/SlideDir.h
+++ b/tools/viewer/SlideDir.h
@@ -33,7 +33,7 @@
SkISize getDimensions() const override;
void draw(SkCanvas*) override;
- bool animate(const SkAnimTimer&) override;
+ bool animate(const AnimTimer&) override;
bool onChar(SkUnichar) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index 1ea53f2..013b86c 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -8,18 +8,18 @@
#ifndef Viewer_DEFINED
#define Viewer_DEFINED
-#include "sk_app/Application.h"
-#include "sk_app/CommandSet.h"
-#include "sk_app/Window.h"
-#include "gm.h"
+#include "AnimTimer.h"
#include "ImGuiLayer.h"
-#include "SkAnimTimer.h"
#include "SkExecutor.h"
#include "SkFont.h"
#include "SkScan.h"
#include "Slide.h"
#include "StatsLayer.h"
#include "TouchGesture.h"
+#include "gm.h"
+#include "sk_app/Application.h"
+#include "sk_app/CommandSet.h"
+#include "sk_app/Window.h"
class SkCanvas;
@@ -121,7 +121,7 @@
StatsLayer::Timer fFlushTimer;
StatsLayer::Timer fAnimateTimer;
- SkAnimTimer fAnimTimer;
+ AnimTimer fAnimTimer;
SkTArray<sk_sp<Slide>> fSlides;
int fCurrentSlide;