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

Side by Side Diff: samplecode/SampleCamera.cpp

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: switch all existing animations to use animatePulse 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleArc.cpp ('k') | samplecode/SampleCode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 fFrontFace = frontFace; 79 fFrontFace = frontFace;
80 fShaderIndex = (fShaderIndex + 1) % fShaders.count(); 80 fShaderIndex = (fShaderIndex + 1) % fShaders.count();
81 } 81 }
82 82
83 paint.setAntiAlias(true); 83 paint.setAntiAlias(true);
84 paint.setShader(fShaders[fShaderIndex]); 84 paint.setShader(fShaders[fShaderIndex]);
85 paint.setFilterLevel(SkPaint::kLow_FilterLevel); 85 paint.setFilterLevel(SkPaint::kLow_FilterLevel);
86 SkRect r = { -150, -150, 150, 150 }; 86 SkRect r = { -150, -150, 150, 150 };
87 canvas->drawRoundRect(r, 30, 30, paint); 87 canvas->drawRoundRect(r, 30, 30, paint);
88 } 88 }
89 }
89 90
90 fRY += SampleCode::GetAnimSecondsDelta() * 90; 91 bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE {
91 if (fRY >= SkIntToScalar(360)) { 92 fRY += (curr - prev) * 0.09f;
93 if (fRY >= 360) {
92 fRY = 0; 94 fRY = 0;
93 } 95 }
94 this->inval(NULL); 96 return true;
95 } 97 }
96 98
97 private: 99 private:
98 SkScalar fRX, fRY, fRZ; 100 SkScalar fRX, fRY, fRZ;
99 typedef SampleView INHERITED; 101 typedef SampleView INHERITED;
100 }; 102 };
101 103
102 ////////////////////////////////////////////////////////////////////////////// 104 //////////////////////////////////////////////////////////////////////////////
103 105
104 static SkView* MyFactory() { return new CameraView; } 106 static SkView* MyFactory() { return new CameraView; }
105 static SkViewRegister reg(MyFactory); 107 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleArc.cpp ('k') | samplecode/SampleCode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698