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

Unified Diff: samplecode/SamplePatch.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 | « samplecode/SampleOvalTest.cpp ('k') | samplecode/SamplePath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePatch.cpp
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 83849a091e3ec535000d70e5e645e07eb9a498de..415368260eb7c6a4687b6c9830a77c9d604913cf 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -1,11 +1,12 @@
-
/*
* Copyright 2011 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 "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
@@ -221,13 +222,14 @@ const SkScalar DX = 20;
const SkScalar DY = 0;
class PatchView : public SampleView {
+ SkScalar fAngle;
SkShader* fShader0;
SkShader* fShader1;
SkIPoint fSize0, fSize1;
SkPoint fPts[12];
public:
- PatchView() {
+ PatchView() : fAngle(0) {
fShader0 = make_shader0(&fSize0);
fSize1 = fSize0;
if (fSize0.fX == 0 || fSize0.fY == 0) {
@@ -308,16 +310,18 @@ protected:
paint.setShader(s)->unref();
}
if (true) {
- static int gAngle;
SkMatrix m;
- m.setRotate(SkIntToScalar(gAngle++));
+ m.setRotate(fAngle);
SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m);
paint.setShader(s)->unref();
}
patch.setBounds(fSize1.fX, fSize1.fY);
drawpatches(canvas, paint, nu, nv, &patch);
+ }
- this->inval(NULL);
+ bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
+ fAngle = timer.scaled(60, 360);
+ return true;
}
class PtClick : public Click {
« no previous file with comments | « samplecode/SampleOvalTest.cpp ('k') | samplecode/SamplePath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698