OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 fCurrTime = 0; | 149 fCurrTime = 0; |
150 | 150 |
151 fTrans.setRepeatCount(999); | 151 fTrans.setRepeatCount(999); |
152 values[0] = values[1] = 0; | 152 values[0] = values[1] = 0; |
153 fTrans.setKeyFrame(0, fCurrTime, values); | 153 fTrans.setKeyFrame(0, fCurrTime, values); |
154 values[0] = values[1] = 1; | 154 values[0] = values[1] = 1; |
155 fTrans.setKeyFrame(1, fCurrTime + 2000, values); | 155 fTrans.setKeyFrame(1, fCurrTime + 2000, values); |
156 } | 156 } |
157 | 157 |
158 protected: | 158 protected: |
159 bool onQuery(SkEvent* evt) SK_OVERRIDE { | 159 bool onQuery(SkEvent* evt) override { |
160 if (SampleCode::TitleQ(*evt)) { | 160 if (SampleCode::TitleQ(*evt)) { |
161 SampleCode::TitleR(evt, "FilterQuality"); | 161 SampleCode::TitleR(evt, "FilterQuality"); |
162 return true; | 162 return true; |
163 } | 163 } |
164 SkUnichar uni; | 164 SkUnichar uni; |
165 if (SampleCode::CharQ(*evt, &uni)) { | 165 if (SampleCode::CharQ(*evt, &uni)) { |
166 switch (uni) { | 166 switch (uni) { |
167 case '1': fAngle.inc(-ANGLE_DELTA); this->inval(NULL); return tr
ue; | 167 case '1': fAngle.inc(-ANGLE_DELTA); this->inval(NULL); return tr
ue; |
168 case '2': fAngle.inc( ANGLE_DELTA); this->inval(NULL); return tr
ue; | 168 case '2': fAngle.inc( ANGLE_DELTA); this->inval(NULL); return tr
ue; |
169 case '3': fScale.inc(-SCALE_DELTA); this->inval(NULL); return tr
ue; | 169 case '3': fScale.inc(-SCALE_DELTA); this->inval(NULL); return tr
ue; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 p.setStyle(SkPaint::kStroke_Style); | 232 p.setStyle(SkPaint::kStroke_Style); |
233 p.setColor(SK_ColorBLUE); | 233 p.setColor(SK_ColorBLUE); |
234 | 234 |
235 SkRect r = SkRect::MakeWH(fCell.width() * 2, fCell.height() * 2); | 235 SkRect r = SkRect::MakeWH(fCell.width() * 2, fCell.height() * 2); |
236 r.inset(SK_ScalarHalf, SK_ScalarHalf); | 236 r.inset(SK_ScalarHalf, SK_ScalarHalf); |
237 canvas->drawRect(r, p); | 237 canvas->drawRect(r, p); |
238 canvas->drawLine(r.left(), r.centerY(), r.right(), r.centerY(), p); | 238 canvas->drawLine(r.left(), r.centerY(), r.right(), r.centerY(), p); |
239 canvas->drawLine(r.centerX(), r.top(), r.centerX(), r.bottom(), p); | 239 canvas->drawLine(r.centerX(), r.top(), r.centerX(), r.bottom(), p); |
240 } | 240 } |
241 | 241 |
242 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 242 void onDrawContent(SkCanvas* canvas) override { |
243 fCell.set(this->height() / 2, this->height() / 2); | 243 fCell.set(this->height() / 2, this->height() / 2); |
244 | 244 |
245 SkScalar trans[2]; | 245 SkScalar trans[2]; |
246 fTrans.timeToValues(fCurrTime, trans); | 246 fTrans.timeToValues(fCurrTime, trans); |
247 | 247 |
248 for (int y = 0; y < 2; ++y) { | 248 for (int y = 0; y < 2; ++y) { |
249 for (int x = 0; x < 2; ++x) { | 249 for (int x = 0; x < 2; ++x) { |
250 int index = y * 2 + x; | 250 int index = y * 2 + x; |
251 SkAutoCanvasRestore acr(canvas, true); | 251 SkAutoCanvasRestore acr(canvas, true); |
252 canvas->translate(fCell.width() * x, fCell.height() * y); | 252 canvas->translate(fCell.width() * x, fCell.height() * y); |
(...skipping 16 matching lines...) Expand all Loading... |
269 canvas->drawText(str.c_str(), str.size(), textX, 100, paint); | 269 canvas->drawText(str.c_str(), str.size(), textX, 100, paint); |
270 str.reset(); str.appendScalar(fAngle); | 270 str.reset(); str.appendScalar(fAngle); |
271 canvas->drawText(str.c_str(), str.size(), textX, 150, paint); | 271 canvas->drawText(str.c_str(), str.size(), textX, 150, paint); |
272 | 272 |
273 str.reset(); str.appendScalar(trans[0]); | 273 str.reset(); str.appendScalar(trans[0]); |
274 canvas->drawText(str.c_str(), str.size(), textX, 200, paint); | 274 canvas->drawText(str.c_str(), str.size(), textX, 200, paint); |
275 str.reset(); str.appendScalar(trans[1]); | 275 str.reset(); str.appendScalar(trans[1]); |
276 canvas->drawText(str.c_str(), str.size(), textX, 250, paint); | 276 canvas->drawText(str.c_str(), str.size(), textX, 250, paint); |
277 } | 277 } |
278 | 278 |
279 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE { | 279 bool onAnimate(const SkAnimTimer& timer) override { |
280 fCurrTime = timer.msec(); | 280 fCurrTime = timer.msec(); |
281 return true; | 281 return true; |
282 } | 282 } |
283 | 283 |
284 virtual bool handleKey(SkKey key) { | 284 virtual bool handleKey(SkKey key) { |
285 this->inval(NULL); | 285 this->inval(NULL); |
286 return true; | 286 return true; |
287 } | 287 } |
288 | 288 |
289 private: | 289 private: |
290 typedef SampleView INHERITED; | 290 typedef SampleView INHERITED; |
291 }; | 291 }; |
292 | 292 |
293 ////////////////////////////////////////////////////////////////////////////// | 293 ////////////////////////////////////////////////////////////////////////////// |
294 | 294 |
295 static SkView* MyFactory() { return new FilterQualityView; } | 295 static SkView* MyFactory() { return new FilterQualityView; } |
296 static SkViewRegister reg(MyFactory); | 296 static SkViewRegister reg(MyFactory); |
OLD | NEW |