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

Side by Side Diff: samplecode/SampleHT.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 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkAnimTimer.h"
9 #include "SkView.h" 10 #include "SkView.h"
10 #include "SkCanvas.h" 11 #include "SkCanvas.h"
11 #include "SkCanvasDrawable.h" 12 #include "SkCanvasDrawable.h"
12 #include "SkInterpolator.h" 13 #include "SkInterpolator.h"
13 #include "SkPictureRecorder.h" 14 #include "SkPictureRecorder.h"
14 #include "SkRandom.h" 15 #include "SkRandom.h"
15 16
16 const SkRect gUnitSquare = { -1, -1, 1, 1 }; 17 const SkRect gUnitSquare = { -1, -1, 1, 1 };
17 18
18 static void color_to_floats(SkColor c, SkScalar f[4]) { 19 static void color_to_floats(SkColor c, SkScalar f[4]) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 SampleCode::TitleR(evt, "HT"); 149 SampleCode::TitleR(evt, "HT");
149 return true; 150 return true;
150 } 151 }
151 return this->INHERITED::onQuery(evt); 152 return this->INHERITED::onQuery(evt);
152 } 153 }
153 154
154 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 155 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
155 canvas->EXPERIMENTAL_drawDrawable(fRoot); 156 canvas->EXPERIMENTAL_drawDrawable(fRoot);
156 } 157 }
157 158
158 bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE { 159 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
159 fTime = curr; 160 fTime = timer.msec();
160 for (int i = 0; i < N; ++i) { 161 for (int i = 0; i < N; ++i) {
161 fArray[i].fDrawable->setTime(fTime); 162 fArray[i].fDrawable->setTime(fTime);
162 } 163 }
163 return true; 164 return true;
164 } 165 }
165 166
166 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_ OVERRIDE { 167 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_ OVERRIDE {
167 // search backwards to find the top-most 168 // search backwards to find the top-most
168 for (int i = N - 1; i >= 0; --i) { 169 for (int i = N - 1; i >= 0; --i) {
169 if (fArray[i].fDrawable->hitTest(x, y)) { 170 if (fArray[i].fDrawable->hitTest(x, y)) {
170 fArray[i].fDrawable->spawnAnimation(fTime); 171 fArray[i].fDrawable->spawnAnimation(fTime);
171 break; 172 break;
172 } 173 }
173 } 174 }
174 this->inval(NULL); 175 this->inval(NULL);
175 return NULL; 176 return NULL;
176 } 177 }
177 178
178 private: 179 private:
179 typedef SampleView INHERITED; 180 typedef SampleView INHERITED;
180 }; 181 };
181 182
182 ////////////////////////////////////////////////////////////////////////////// 183 //////////////////////////////////////////////////////////////////////////////
183 184
184 static SkView* MyFactory() { return new HTView; } 185 static SkView* MyFactory() { return new HTView; }
185 static SkViewRegister reg(MyFactory); 186 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698