OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 path->lineTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480); | 209 path->lineTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480); |
210 } | 210 } |
211 } | 211 } |
212 virtual int complexity() SK_OVERRIDE { return 2; } | 212 virtual int complexity() SK_OVERRIDE { return 2; } |
213 private: | 213 private: |
214 typedef PathBench INHERITED; | 214 typedef PathBench INHERITED; |
215 }; | 215 }; |
216 | 216 |
217 class RandomPathBench : public SkBenchmark { | 217 class RandomPathBench : public SkBenchmark { |
218 public: | 218 public: |
219 RandomPathBench() { | 219 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
220 fIsRendering = false; | 220 return backend == kNonRendering_Backend; |
221 } | 221 } |
222 | 222 |
223 protected: | 223 protected: |
224 void createData(int minVerbs, | 224 void createData(int minVerbs, |
225 int maxVerbs, | 225 int maxVerbs, |
226 bool allowMoves = true, | 226 bool allowMoves = true, |
227 SkRect* bounds = NULL) { | 227 SkRect* bounds = NULL) { |
228 SkRect tempBounds; | 228 SkRect tempBounds; |
229 if (NULL == bounds) { | 229 if (NULL == bounds) { |
230 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1); | 230 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1); |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 754 |
755 class ConservativelyContainsBench : public SkBenchmark { | 755 class ConservativelyContainsBench : public SkBenchmark { |
756 public: | 756 public: |
757 enum Type { | 757 enum Type { |
758 kRect_Type, | 758 kRect_Type, |
759 kRoundRect_Type, | 759 kRoundRect_Type, |
760 kOval_Type, | 760 kOval_Type, |
761 }; | 761 }; |
762 | 762 |
763 ConservativelyContainsBench(Type type) { | 763 ConservativelyContainsBench(Type type) { |
764 fIsRendering = false; | |
765 fParity = false; | 764 fParity = false; |
766 fName = "conservatively_contains_"; | 765 fName = "conservatively_contains_"; |
767 switch (type) { | 766 switch (type) { |
768 case kRect_Type: | 767 case kRect_Type: |
769 fName.append("rect"); | 768 fName.append("rect"); |
770 fPath.addRect(kBaseRect); | 769 fPath.addRect(kBaseRect); |
771 break; | 770 break; |
772 case kRoundRect_Type: | 771 case kRoundRect_Type: |
773 fName.append("round_rect"); | 772 fName.append("round_rect"); |
774 fPath.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1]); | 773 fPath.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1]); |
775 break; | 774 break; |
776 case kOval_Type: | 775 case kOval_Type: |
777 fName.append("oval"); | 776 fName.append("oval"); |
778 fPath.addOval(kBaseRect); | 777 fPath.addOval(kBaseRect); |
779 break; | 778 break; |
780 } | 779 } |
781 } | 780 } |
782 | 781 |
| 782 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 783 return backend == kNonRendering_Backend; |
| 784 } |
| 785 |
783 private: | 786 private: |
784 virtual const char* onGetName() SK_OVERRIDE { | 787 virtual const char* onGetName() SK_OVERRIDE { |
785 return fName.c_str(); | 788 return fName.c_str(); |
786 } | 789 } |
787 | 790 |
788 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 791 virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
789 for (int i = 0; i < this->getLoops(); ++i) { | 792 for (int i = 0; i < this->getLoops(); ++i) { |
790 const SkRect& rect = fQueryRects[i % kQueryRectCnt]; | 793 const SkRect& rect = fQueryRects[i % kQueryRectCnt]; |
791 fParity = fParity != fPath.conservativelyContainsRect(rect); | 794 fParity = fParity != fPath.conservativelyContainsRect(rect); |
792 } | 795 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 } | 899 } |
897 } | 900 } |
898 | 901 |
899 class ConicBench : public SkBenchmark { | 902 class ConicBench : public SkBenchmark { |
900 public: | 903 public: |
901 ConicBench() { | 904 ConicBench() { |
902 SkRandom rand; | 905 SkRandom rand; |
903 for (int i = 0; i < CONICS; ++i) { | 906 for (int i = 0; i < CONICS; ++i) { |
904 rand_conic(&fConics[i], rand); | 907 rand_conic(&fConics[i], rand); |
905 } | 908 } |
906 fIsRendering = false; | 909 } |
| 910 |
| 911 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 912 return backend == kNonRendering_Backend; |
907 } | 913 } |
908 | 914 |
909 protected: | 915 protected: |
910 enum { | 916 enum { |
911 CONICS = 100 | 917 CONICS = 100 |
912 }; | 918 }; |
913 SkConic fConics[CONICS]; | 919 SkConic fConics[CONICS]; |
914 | 920 |
915 private: | 921 private: |
916 typedef SkBenchmark INHERITED; | 922 typedef SkBenchmark INHERITED; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 DEF_BENCH( return new ArbRoundRectBench(true); ) | 1040 DEF_BENCH( return new ArbRoundRectBench(true); ) |
1035 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Rect_Type); ) | 1041 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Rect_Type); ) |
1036 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
RoundRect_Type); ) | 1042 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
RoundRect_Type); ) |
1037 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Oval_Type); ) | 1043 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Oval_Type); ) |
1038 | 1044 |
1039 DEF_BENCH( return new ConicBench_Chop5() ) | 1045 DEF_BENCH( return new ConicBench_Chop5() ) |
1040 DEF_BENCH( return new ConicBench_ChopHalf() ) | 1046 DEF_BENCH( return new ConicBench_ChopHalf() ) |
1041 DEF_BENCH( return new ConicBench_ComputeError() ) | 1047 DEF_BENCH( return new ConicBench_ComputeError() ) |
1042 DEF_BENCH( return new ConicBench_asQuadTol() ) | 1048 DEF_BENCH( return new ConicBench_asQuadTol() ) |
1043 DEF_BENCH( return new ConicBench_quadPow2() ) | 1049 DEF_BENCH( return new ConicBench_quadPow2() ) |
OLD | NEW |