diff options
author | reed <reed@google.com> | 2015-02-05 22:02:37 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-05 22:02:37 -0800 |
commit | 339cdbfb754ff0837ad4772b4837543e1092d62f (patch) | |
tree | 6fa804624ada329f2984b8fe35c92cd92fdd7284 /samplecode/SamplePatch.cpp | |
parent | 27f398f04dff306418a142c27175eaa35d21a915 (diff) |
migrate more samples over to SkAnimTImer
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/901933004
Diffstat (limited to 'samplecode/SamplePatch.cpp')
-rw-r--r-- | samplecode/SamplePatch.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp index 83849a091e..415368260e 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 { |