| OLD | NEW |
| 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 "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
| 10 #include "SkView.h" | 10 #include "SkView.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 if (true) { | 312 if (true) { |
| 313 SkMatrix m; | 313 SkMatrix m; |
| 314 m.setRotate(fAngle); | 314 m.setRotate(fAngle); |
| 315 SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m
); | 315 SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m
); |
| 316 paint.setShader(s)->unref(); | 316 paint.setShader(s)->unref(); |
| 317 } | 317 } |
| 318 patch.setBounds(fSize1.fX, fSize1.fY); | 318 patch.setBounds(fSize1.fX, fSize1.fY); |
| 319 drawpatches(canvas, paint, nu, nv, &patch); | 319 drawpatches(canvas, paint, nu, nv, &patch); |
| 320 } | 320 } |
| 321 | 321 |
| 322 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE { | 322 bool onAnimate(const SkAnimTimer& timer) override { |
| 323 fAngle = timer.scaled(60, 360); | 323 fAngle = timer.scaled(60, 360); |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 class PtClick : public Click { | 327 class PtClick : public Click { |
| 328 public: | 328 public: |
| 329 int fIndex; | 329 int fIndex; |
| 330 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} | 330 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { | 333 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { |
| 334 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); | 334 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); |
| 335 } | 335 } |
| 336 | 336 |
| 337 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 337 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, |
| 338 unsigned modi) SK_OVERRIDE { | 338 unsigned modi) override { |
| 339 x -= DX; | 339 x -= DX; |
| 340 y -= DY; | 340 y -= DY; |
| 341 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) { | 341 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) { |
| 342 if (hittest(fPts[i], x, y)) { | 342 if (hittest(fPts[i], x, y)) { |
| 343 return new PtClick(this, (int)i); | 343 return new PtClick(this, (int)i); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 return this->INHERITED::onFindClickHandler(x, y, modi); | 346 return this->INHERITED::onFindClickHandler(x, y, modi); |
| 347 } | 347 } |
| 348 | 348 |
| 349 virtual bool onClick(Click* click) { | 349 virtual bool onClick(Click* click) { |
| 350 fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX - DX, click->fCurr.f
Y - DY); | 350 fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX - DX, click->fCurr.f
Y - DY); |
| 351 this->inval(NULL); | 351 this->inval(NULL); |
| 352 return true; | 352 return true; |
| 353 } | 353 } |
| 354 | 354 |
| 355 private: | 355 private: |
| 356 typedef SampleView INHERITED; | 356 typedef SampleView INHERITED; |
| 357 }; | 357 }; |
| 358 | 358 |
| 359 ////////////////////////////////////////////////////////////////////////////// | 359 ////////////////////////////////////////////////////////////////////////////// |
| 360 | 360 |
| 361 static SkView* MyFactory() { return new PatchView; } | 361 static SkView* MyFactory() { return new PatchView; } |
| 362 static SkViewRegister reg(MyFactory); | 362 static SkViewRegister reg(MyFactory); |
| OLD | NEW |