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 { |