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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 } | 645 } |
646 | 646 |
647 class PathFuzzView : public SampleView { | 647 class PathFuzzView : public SampleView { |
648 public: | 648 public: |
649 PathFuzzView() | 649 PathFuzzView() |
650 : fOneDraw(false) | 650 : fOneDraw(false) |
651 { | 651 { |
652 } | 652 } |
653 protected: | 653 protected: |
654 // overrides from SkEventSink | 654 // overrides from SkEventSink |
655 virtual bool onQuery(SkEvent* evt) { | 655 bool onQuery(SkEvent* evt) override { |
656 if (SampleCode::TitleQ(*evt)) { | 656 if (SampleCode::TitleQ(*evt)) { |
657 SampleCode::TitleR(evt, "PathFuzzer"); | 657 SampleCode::TitleR(evt, "PathFuzzer"); |
658 return true; | 658 return true; |
659 } | 659 } |
660 return this->INHERITED::onQuery(evt); | 660 return this->INHERITED::onQuery(evt); |
661 } | 661 } |
662 | 662 |
663 void onOnceBeforeDraw() override { | 663 void onOnceBeforeDraw() override { |
664 fIndex = 0; | 664 fIndex = 0; |
665 SkImageInfo info(SkImageInfo::MakeN32Premul(SkScalarRoundToInt(width()), | 665 SkImageInfo info(SkImageInfo::MakeN32Premul(SkScalarRoundToInt(width()), |
666 SkScalarRoundToInt(height()))); | 666 SkScalarRoundToInt(height()))); |
667 offscreen.allocPixels(info); | 667 offscreen.allocPixels(info); |
668 path_fuzz_stroker(&offscreen, fIndex); | 668 path_fuzz_stroker(&offscreen, fIndex); |
669 } | 669 } |
670 | 670 |
671 virtual void onDrawContent(SkCanvas* canvas) { | 671 void onDrawContent(SkCanvas* canvas) override { |
672 if (fOneDraw) { | 672 if (fOneDraw) { |
673 fuzzPath.randomize(); | 673 fuzzPath.randomize(); |
674 const SkPath& path = fuzzPath.getPath(); | 674 const SkPath& path = fuzzPath.getPath(); |
675 const SkPaint& paint = fuzzPath.getPaint(); | 675 const SkPaint& paint = fuzzPath.getPaint(); |
676 const SkPath& clip = fuzzPath.getClip(); | 676 const SkPath& clip = fuzzPath.getClip(); |
677 const SkMatrix& matrix = fuzzPath.getMatrix(); | 677 const SkMatrix& matrix = fuzzPath.getMatrix(); |
678 if (!contains_only_moveTo(clip)) { | 678 if (!contains_only_moveTo(clip)) { |
679 canvas->clipPath(clip); | 679 canvas->clipPath(clip); |
680 } | 680 } |
681 canvas->setMatrix(matrix); | 681 canvas->setMatrix(matrix); |
(...skipping 10 matching lines...) Expand all Loading... |
692 SkBitmap offscreen; | 692 SkBitmap offscreen; |
693 FuzzPath fuzzPath; | 693 FuzzPath fuzzPath; |
694 bool fOneDraw; | 694 bool fOneDraw; |
695 typedef SkView INHERITED; | 695 typedef SkView INHERITED; |
696 }; | 696 }; |
697 | 697 |
698 static SkView* MyFactory() { return new PathFuzzView; } | 698 static SkView* MyFactory() { return new PathFuzzView; } |
699 static SkViewRegister reg(MyFactory); | 699 static SkViewRegister reg(MyFactory); |
700 | 700 |
701 | 701 |
OLD | NEW |