Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Unified Diff: samplecode/SampleFilterQuality.cpp

Issue 901933004: migrate more samples over to SkAnimTImer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/SampleApp.gyp ('k') | samplecode/SampleMipMap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleFilterQuality.cpp
diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp
index 12aae83245c40d7bcc801316979fabbd53e77fb2..fe9486497c2f2dc24d20a926aca9a7c13668da2d 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) {
« no previous file with comments | « gyp/SampleApp.gyp ('k') | samplecode/SampleMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698