OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkSize.h" | 10 #include "SkSize.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 fName.append("rand"); | 57 fName.append("rand"); |
58 } else if (kRandPow2_RectType == fRectType) { | 58 } else if (kRandPow2_RectType == fRectType) { |
59 fName.append("rand2"); | 59 fName.append("rand2"); |
60 } else { | 60 } else { |
61 SkASSERT(kSmallPow2_RectType == fRectType); | 61 SkASSERT(kSmallPow2_RectType == fRectType); |
62 fName.append("sm2"); | 62 fName.append("sm2"); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 protected: | 66 protected: |
67 bool isSuitableFor(Backend backend) SK_OVERRIDE { | 67 bool isSuitableFor(Backend backend) override { |
68 return kNonRendering_Backend == backend; | 68 return kNonRendering_Backend == backend; |
69 } | 69 } |
70 | 70 |
71 const char* onGetName() SK_OVERRIDE { | 71 const char* onGetName() override { |
72 return fName.c_str(); | 72 return fName.c_str(); |
73 } | 73 } |
74 | 74 |
75 void onPreDraw() SK_OVERRIDE { | 75 void onPreDraw() override { |
76 SkASSERT(NULL == fRectanizer.get()); | 76 SkASSERT(NULL == fRectanizer.get()); |
77 | 77 |
78 if (kPow2_RectanizerType == fRectanizerType) { | 78 if (kPow2_RectanizerType == fRectanizerType) { |
79 fRectanizer.reset(SkNEW_ARGS(GrRectanizerPow2, (kWidth, kHeight))); | 79 fRectanizer.reset(SkNEW_ARGS(GrRectanizerPow2, (kWidth, kHeight))); |
80 } else { | 80 } else { |
81 SkASSERT(kSkyline_RectanizerType == fRectanizerType); | 81 SkASSERT(kSkyline_RectanizerType == fRectanizerType); |
82 fRectanizer.reset(SkNEW_ARGS(GrRectanizerSkyline, (kWidth, kHeight))
); | 82 fRectanizer.reset(SkNEW_ARGS(GrRectanizerSkyline, (kWidth, kHeight))
); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 86 void onDraw(const int loops, SkCanvas* canvas) override { |
87 SkRandom rand; | 87 SkRandom rand; |
88 SkIPoint16 loc; | 88 SkIPoint16 loc; |
89 SkISize size; | 89 SkISize size; |
90 | 90 |
91 for (int i = 0; i < loops; ++i) { | 91 for (int i = 0; i < loops; ++i) { |
92 if (kRand_RectType == fRectType) { | 92 if (kRand_RectType == fRectType) { |
93 size = SkISize::Make(rand.nextRangeU(1, kWidth / 2), | 93 size = SkISize::Make(rand.nextRangeU(1, kWidth / 2), |
94 rand.nextRangeU(1, kHeight / 2)); | 94 rand.nextRangeU(1, kHeight / 2)); |
95 } else if (kRandPow2_RectType == fRectType) { | 95 } else if (kRandPow2_RectType == fRectType) { |
96 size = SkISize::Make(GrNextPow2(rand.nextRangeU(1, kWidth / 2)), | 96 size = SkISize::Make(GrNextPow2(rand.nextRangeU(1, kWidth / 2)), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 DEF_BENCH(return new RectanizerBench(RectanizerBench::kPow2_RectanizerType, | 129 DEF_BENCH(return new RectanizerBench(RectanizerBench::kPow2_RectanizerType, |
130 RectanizerBench::kSmallPow2_RectType);) | 130 RectanizerBench::kSmallPow2_RectType);) |
131 DEF_BENCH(return new RectanizerBench(RectanizerBench::kSkyline_RectanizerType, | 131 DEF_BENCH(return new RectanizerBench(RectanizerBench::kSkyline_RectanizerType, |
132 RectanizerBench::kRand_RectType);) | 132 RectanizerBench::kRand_RectType);) |
133 DEF_BENCH(return new RectanizerBench(RectanizerBench::kSkyline_RectanizerType, | 133 DEF_BENCH(return new RectanizerBench(RectanizerBench::kSkyline_RectanizerType, |
134 RectanizerBench::kRandPow2_RectType);) | 134 RectanizerBench::kRandPow2_RectType);) |
135 DEF_BENCH(return new RectanizerBench(RectanizerBench::kSkyline_RectanizerType, | 135 DEF_BENCH(return new RectanizerBench(RectanizerBench::kSkyline_RectanizerType, |
136 RectanizerBench::kSmallPow2_RectType);) | 136 RectanizerBench::kSmallPow2_RectType);) |
137 | 137 |
138 #endif | 138 #endif |
OLD | NEW |