OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SampleCode.h" | 9 #include "SampleCode.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 return true; | 439 return true; |
440 case 't': | 440 case 't': |
441 fFB.setTriangle(!fFB.getTriangle()); | 441 fFB.setTriangle(!fFB.getTriangle()); |
442 this->inval(NULL); | 442 this->inval(NULL); |
443 return true; | 443 return true; |
444 } | 444 } |
445 } | 445 } |
446 return this->INHERITED::onQuery(evt); | 446 return this->INHERITED::onQuery(evt); |
447 } | 447 } |
448 | 448 |
449 virtual void onDrawContent(SkCanvas* canvas) { | 449 void onDrawContent(SkCanvas* canvas) override { |
450 fFB.drawBG(canvas); | 450 fFB.drawBG(canvas); |
451 if (fFB.getTriangle()) { | 451 if (fFB.getTriangle()) { |
452 fFB.drawTriangle(canvas, fPts); | 452 fFB.drawTriangle(canvas, fPts); |
453 } | 453 } |
454 else if (fIsRect) { | 454 else if (fIsRect) { |
455 fFB.drawRect(canvas, fPts); | 455 fFB.drawRect(canvas, fPts); |
456 } else { | 456 } else { |
457 fFB.drawLine(canvas, fPts); | 457 fFB.drawLine(canvas, fPts); |
458 } | 458 } |
459 fFB.drawFG(canvas); | 459 fFB.drawFG(canvas); |
460 | 460 |
461 { | 461 { |
462 SkString str; | 462 SkString str; |
463 str.printf("%s %s %s %s", | 463 str.printf("%s %s %s %s", |
464 fFB.getAA() ? "AA" : "BW", | 464 fFB.getAA() ? "AA" : "BW", |
465 FatBits::kHair_Style == fFB.getStyle() ? "Hair" : "Stroke
", | 465 FatBits::kHair_Style == fFB.getStyle() ? "Hair" : "Stroke
", |
466 fFB.getUseGPU() ? "GPU" : "CPU", | 466 fFB.getUseGPU() ? "GPU" : "CPU", |
467 fFB.getUseClip() ? "clip" : "noclip"); | 467 fFB.getUseClip() ? "clip" : "noclip"); |
468 SkPaint paint; | 468 SkPaint paint; |
469 paint.setAntiAlias(true); | 469 paint.setAntiAlias(true); |
470 paint.setTextSize(16); | 470 paint.setTextSize(16); |
471 paint.setColor(SK_ColorBLUE); | 471 paint.setColor(SK_ColorBLUE); |
472 canvas->drawText(str.c_str(), str.size(), 10, 16, paint); | 472 canvas->drawText(str.c_str(), str.size(), 10, 16, paint); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 476 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { |
477 unsigned modi) override { | |
478 SkPoint pt = { x, y }; | 477 SkPoint pt = { x, y }; |
479 int index = -1; | 478 int index = -1; |
480 int count = fFB.getTriangle() ? 3 : 2; | 479 int count = fFB.getTriangle() ? 3 : 2; |
481 SkScalar tol = 12; | 480 SkScalar tol = 12; |
482 | 481 |
483 for (int i = 0; i < count; ++i) { | 482 for (int i = 0; i < count; ++i) { |
484 if (fPts[i].equalsWithinTolerance(pt, tol)) { | 483 if (fPts[i].equalsWithinTolerance(pt, tol)) { |
485 index = i; | 484 index = i; |
486 break; | 485 break; |
487 } | 486 } |
(...skipping 18 matching lines...) Expand all Loading... |
506 | 505 |
507 private: | 506 private: |
508 | 507 |
509 typedef SampleView INHERITED; | 508 typedef SampleView INHERITED; |
510 }; | 509 }; |
511 | 510 |
512 ////////////////////////////////////////////////////////////////////////////// | 511 ////////////////////////////////////////////////////////////////////////////// |
513 | 512 |
514 static SkView* MyFactory() { return new DrawLineView; } | 513 static SkView* MyFactory() { return new DrawLineView; } |
515 static SkViewRegister reg(MyFactory); | 514 static SkViewRegister reg(MyFactory); |
OLD | NEW |