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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 class RandomPathBench : public Benchmark { | 217 class RandomPathBench : public Benchmark { |
218 public: | 218 public: |
219 bool isSuitableFor(Backend backend) override { | 219 bool isSuitableFor(Backend backend) override { |
220 return backend == kNonRendering_Backend; | 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 = nullptr) { |
228 SkRect tempBounds; | 228 SkRect tempBounds; |
229 if (NULL == bounds) { | 229 if (nullptr == bounds) { |
230 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1); | 230 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1); |
231 bounds = &tempBounds; | 231 bounds = &tempBounds; |
232 } | 232 } |
233 fVerbCnts.reset(kNumVerbCnts); | 233 fVerbCnts.reset(kNumVerbCnts); |
234 for (int i = 0; i < kNumVerbCnts; ++i) { | 234 for (int i = 0; i < kNumVerbCnts; ++i) { |
235 fVerbCnts[i] = fRandom.nextRangeU(minVerbs, maxVerbs + 1); | 235 fVerbCnts[i] = fRandom.nextRangeU(minVerbs, maxVerbs + 1); |
236 } | 236 } |
237 fVerbs.reset(kNumVerbs); | 237 fVerbs.reset(kNumVerbs); |
238 for (int i = 0; i < kNumVerbs; ++i) { | 238 for (int i = 0; i < kNumVerbs; ++i) { |
239 do { | 239 do { |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 r.fLeft = rand.nextUScalar1() * 300; | 704 r.fLeft = rand.nextUScalar1() * 300; |
705 r.fTop = rand.nextUScalar1() * 300; | 705 r.fTop = rand.nextUScalar1() * 300; |
706 r.fRight = r.fLeft + 2 * size; | 706 r.fRight = r.fLeft + 2 * size; |
707 r.fBottom = r.fTop + 2 * size; | 707 r.fBottom = r.fTop + 2 * size; |
708 | 708 |
709 SkPath temp; | 709 SkPath temp; |
710 | 710 |
711 if (fZeroRad) { | 711 if (fZeroRad) { |
712 make_arb_round_rect(&temp, r, 0, 0); | 712 make_arb_round_rect(&temp, r, 0, 0); |
713 | 713 |
714 SkASSERT(temp.isRect(NULL)); | 714 SkASSERT(temp.isRect(nullptr)); |
715 } else { | 715 } else { |
716 make_arb_round_rect(&temp, r, r.width() / 10, r.height() / 15); | 716 make_arb_round_rect(&temp, r, r.width() / 10, r.height() / 15); |
717 } | 717 } |
718 | 718 |
719 canvas->drawPath(temp, paint); | 719 canvas->drawPath(temp, paint); |
720 } | 720 } |
721 } | 721 } |
722 | 722 |
723 private: | 723 private: |
724 bool fZeroRad; // should 0 radius rounds rects be tested? | 724 bool fZeroRad; // should 0 radius rounds rects be tested? |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 void onDraw(const int loops, SkCanvas*) override { | 844 void onDraw(const int loops, SkCanvas*) override { |
845 if (fUseV2) { | 845 if (fUseV2) { |
846 for (int i = 0; i < loops; ++i) { | 846 for (int i = 0; i < loops; ++i) { |
847 for (int j = 0; j < 1000; ++j) { | 847 for (int j = 0; j < 1000; ++j) { |
848 fDst[0].fPts[0] = fRQ.evalAt(0.4f); | 848 fDst[0].fPts[0] = fRQ.evalAt(0.4f); |
849 } | 849 } |
850 } | 850 } |
851 } else { | 851 } else { |
852 for (int i = 0; i < loops; ++i) { | 852 for (int i = 0; i < loops; ++i) { |
853 for (int j = 0; j < 1000; ++j) { | 853 for (int j = 0; j < 1000; ++j) { |
854 fRQ.evalAt(0.4f, &fDst[0].fPts[0], NULL); | 854 fRQ.evalAt(0.4f, &fDst[0].fPts[0], nullptr); |
855 } | 855 } |
856 } | 856 } |
857 } | 857 } |
858 } | 858 } |
859 }; | 859 }; |
860 DEF_BENCH( return new ConicBench_EvalPos(false); ) | 860 DEF_BENCH( return new ConicBench_EvalPos(false); ) |
861 DEF_BENCH( return new ConicBench_EvalPos(true); ) | 861 DEF_BENCH( return new ConicBench_EvalPos(true); ) |
862 | 862 |
863 class ConicBench_EvalTan : public ConicBench_Chop { | 863 class ConicBench_EvalTan : public ConicBench_Chop { |
864 const bool fUseV2; | 864 const bool fUseV2; |
865 public: | 865 public: |
866 ConicBench_EvalTan(bool useV2) : fUseV2(useV2) { | 866 ConicBench_EvalTan(bool useV2) : fUseV2(useV2) { |
867 fName.printf("conic-eval-tan%d", useV2); | 867 fName.printf("conic-eval-tan%d", useV2); |
868 } | 868 } |
869 void onDraw(const int loops, SkCanvas*) override { | 869 void onDraw(const int loops, SkCanvas*) override { |
870 if (fUseV2) { | 870 if (fUseV2) { |
871 for (int i = 0; i < loops; ++i) { | 871 for (int i = 0; i < loops; ++i) { |
872 for (int j = 0; j < 1000; ++j) { | 872 for (int j = 0; j < 1000; ++j) { |
873 fDst[0].fPts[0] = fRQ.evalTangentAt(0.4f); | 873 fDst[0].fPts[0] = fRQ.evalTangentAt(0.4f); |
874 } | 874 } |
875 } | 875 } |
876 } else { | 876 } else { |
877 for (int i = 0; i < loops; ++i) { | 877 for (int i = 0; i < loops; ++i) { |
878 for (int j = 0; j < 1000; ++j) { | 878 for (int j = 0; j < 1000; ++j) { |
879 fRQ.evalAt(0.4f, NULL, &fDst[0].fPts[0]); | 879 fRQ.evalAt(0.4f, nullptr, &fDst[0].fPts[0]); |
880 } | 880 } |
881 } | 881 } |
882 } | 882 } |
883 } | 883 } |
884 }; | 884 }; |
885 DEF_BENCH( return new ConicBench_EvalTan(false); ) | 885 DEF_BENCH( return new ConicBench_EvalTan(false); ) |
886 DEF_BENCH( return new ConicBench_EvalTan(true); ) | 886 DEF_BENCH( return new ConicBench_EvalTan(true); ) |
887 | 887 |
888 /////////////////////////////////////////////////////////////////////////////// | 888 /////////////////////////////////////////////////////////////////////////////// |
889 | 889 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Oval_Type); ) | 1042 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Oval_Type); ) |
1043 | 1043 |
1044 | 1044 |
1045 // These seem to be optimized away, which is troublesome for timing. | 1045 // These seem to be optimized away, which is troublesome for timing. |
1046 /* | 1046 /* |
1047 DEF_BENCH( return new ConicBench_Chop5() ) | 1047 DEF_BENCH( return new ConicBench_Chop5() ) |
1048 DEF_BENCH( return new ConicBench_ComputeError() ) | 1048 DEF_BENCH( return new ConicBench_ComputeError() ) |
1049 DEF_BENCH( return new ConicBench_asQuadTol() ) | 1049 DEF_BENCH( return new ConicBench_asQuadTol() ) |
1050 DEF_BENCH( return new ConicBench_quadPow2() ) | 1050 DEF_BENCH( return new ConicBench_quadPow2() ) |
1051 */ | 1051 */ |
OLD | NEW |