aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleFilterQuality.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-02-05 22:02:37 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-05 22:02:37 -0800
commit339cdbfb754ff0837ad4772b4837543e1092d62f (patch)
tree6fa804624ada329f2984b8fe35c92cd92fdd7284 /samplecode/SampleFilterQuality.cpp
parent27f398f04dff306418a142c27175eaa35d21a915 (diff)
migrate more samples over to SkAnimTImer
BUG=skia: TBR= Review URL: https://codereview.chromium.org/901933004
Diffstat (limited to 'samplecode/SampleFilterQuality.cpp')
-rw-r--r--samplecode/SampleFilterQuality.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp
index 12aae83245..fe9486497c 100644
--- a/samplecode/SampleFilterQuality.cpp
+++ b/samplecode/SampleFilterQuality.cpp
@@ -9,6 +9,7 @@
#include "Resources.h"
#include "SampleCode.h"
+#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkInterpolator.h"
#include "SkSurface.h"
@@ -131,6 +132,7 @@ class FilterQualityView : public SampleView {
AnimValue fScale, fAngle;
SkSize fCell;
SkInterpolator fTrans;
+ SkMSec fCurrTime;
bool fShowFatBits;
public:
@@ -144,11 +146,13 @@ public:
fTrans.setMirror(true);
fTrans.setReset(true);
+ fCurrTime = 0;
+
fTrans.setRepeatCount(999);
values[0] = values[1] = 0;
- fTrans.setKeyFrame(0, SkTime::GetMSecs(), values);
+ fTrans.setKeyFrame(0, fCurrTime, values);
values[0] = values[1] = 1;
- fTrans.setKeyFrame(1, SkTime::GetMSecs() + 2000, values);
+ fTrans.setKeyFrame(1, fCurrTime + 2000, values);
}
protected:
@@ -239,7 +243,7 @@ protected:
fCell.set(this->height() / 2, this->height() / 2);
SkScalar trans[2];
- fTrans.timeToValues(SkTime::GetMSecs(), trans);
+ fTrans.timeToValues(fCurrTime, trans);
for (int y = 0; y < 2; ++y) {
for (int x = 0; x < 2; ++x) {
@@ -270,8 +274,11 @@ protected:
canvas->drawText(str.c_str(), str.size(), textX, 200, paint);
str.reset(); str.appendScalar(trans[1]);
canvas->drawText(str.c_str(), str.size(), textX, 250, paint);
+ }
- this->inval(NULL);
+ bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
+ fCurrTime = timer.msec();
+ return true;
}
virtual bool handleKey(SkKey key) {