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

Side by Side Diff: samplecode/SampleArc.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, 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
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h"
9 #include "SkView.h" 10 #include "SkView.h"
10 #include "SkCanvas.h" 11 #include "SkCanvas.h"
11 #include "SkGradientShader.h" 12 #include "SkGradientShader.h"
12 #include "SkPath.h" 13 #include "SkPath.h"
13 #include "SkRegion.h" 14 #include "SkRegion.h"
14 #include "SkShader.h" 15 #include "SkShader.h"
15 #include "SkUtils.h" 16 #include "SkUtils.h"
16 #include "SkComposeShader.h" 17 #include "SkComposeShader.h"
17 #include "Sk1DPathEffect.h" 18 #include "Sk1DPathEffect.h"
18 #include "SkCornerPathEffect.h" 19 #include "SkCornerPathEffect.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 192
192 canvas->EXPERIMENTAL_drawDrawable(fAnimatingDrawable); 193 canvas->EXPERIMENTAL_drawDrawable(fAnimatingDrawable);
193 194
194 DrawArcs(canvas); 195 DrawArcs(canvas);
195 } 196 }
196 197
197 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 198 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
198 canvas->EXPERIMENTAL_drawDrawable(fRootDrawable); 199 canvas->EXPERIMENTAL_drawDrawable(fRootDrawable);
199 } 200 }
200 201
201 bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE { 202 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
202 SkScalar angle = SkDoubleToScalar(fmod(curr * 0.36 / 24, 360)); 203 SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360));
203 fAnimatingDrawable->setSweep(angle); 204 fAnimatingDrawable->setSweep(angle);
204 return true; 205 return true;
205 } 206 }
206 207
207 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_ OVERRIDE { 208 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_ OVERRIDE {
208 // fSweep += SK_Scalar1; 209 // fSweep += SK_Scalar1;
209 this->inval(NULL); 210 this->inval(NULL);
210 return this->INHERITED::onFindClickHandler(x, y, modi); 211 return this->INHERITED::onFindClickHandler(x, y, modi);
211 } 212 }
212 213
213 private: 214 private:
214 SkScalar fSweep; 215 SkScalar fSweep;
215 216
216 typedef SampleView INHERITED; 217 typedef SampleView INHERITED;
217 }; 218 };
218 219
219 ////////////////////////////////////////////////////////////////////////////// 220 //////////////////////////////////////////////////////////////////////////////
220 221
221 static SkView* MyFactory() { return new ArcsView; } 222 static SkView* MyFactory() { return new ArcsView; }
222 static SkViewRegister reg(MyFactory); 223 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698