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

Unified Diff: samplecode/SampleAnimBlur.cpp

Issue 894083003: add SkAnimTimer, SPACE = pause/resume, ESP = stop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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
Index: samplecode/SampleAnimBlur.cpp
diff --git a/samplecode/SampleAnimBlur.cpp b/samplecode/SampleAnimBlur.cpp
index 527d4300e7acd616048673229cfa4f8448899fd0..3c0be8376848909129bd29c1d2e6c8b6ffeec847 100644
--- a/samplecode/SampleAnimBlur.cpp
+++ b/samplecode/SampleAnimBlur.cpp
@@ -1,21 +1,22 @@
-
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "SampleCode.h"
+#include "SkAnimTimer.h"
#include "SkBlurMaskFilter.h"
#include "SkColorPriv.h"
#include "SkCanvas.h"
#include "SkRandom.h"
-SkScalar get_anim_sin(SkMSec time, SkScalar amplitude, SkScalar periodInSec, SkScalar phaseInSec) {
+SkScalar get_anim_sin(double secs, SkScalar amplitude, SkScalar periodInSec, SkScalar phaseInSec) {
if (!periodInSec) {
return 0;
}
- double t = (double)time / 1000.0 + phaseInSec;
+ double t = secs + phaseInSec;
t *= SkScalarToFloat(2 * SK_ScalarPI) / periodInSec;
amplitude = SK_ScalarHalf * amplitude;
return amplitude * SkDoubleToScalar(sin(t)) + amplitude;
@@ -58,9 +59,9 @@ protected:
}
}
- bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE {
- fBlurSigma = get_anim_sin(curr, 100, 4, 5);
- fCircleRadius = 3 + get_anim_sin(curr, 150, 25, 3);
+ bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
+ fBlurSigma = get_anim_sin(timer.secs(), 100, 4, 5);
+ fCircleRadius = 3 + get_anim_sin(timer.secs(), 150, 25, 3);
return true;
}
« gm/SkAnimTimer.h ('K') | « samplecode/GMSampleView.h ('k') | samplecode/SampleApp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698