OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "Resources.h" | 9 #include "Resources.h" |
10 #include "SkAutoPixmapStorage.h" | 10 #include "SkAutoPixmapStorage.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void onDraw(int loops, SkCanvas*) override { | 157 void onDraw(int loops, SkCanvas*) override { |
158 SkRandom random; | 158 SkRandom random; |
159 char dst[SkPDFUtils::kMaximumFloatDecimalLength]; | 159 char dst[SkPDFUtils::kMaximumFloatDecimalLength]; |
160 while (loops-- > 0) { | 160 while (loops-- > 0) { |
161 auto f = random.nextRangeF(-500.0f, 1500.0f); | 161 auto f = random.nextRangeF(-500.0f, 1500.0f); |
162 (void)SkPDFUtils::FloatToDecimal(f, dst); | 162 (void)SkPDFUtils::FloatToDecimal(f, dst); |
163 } | 163 } |
164 } | 164 } |
165 }; | 165 }; |
166 | 166 |
| 167 struct PDFColorComponentBench : public Benchmark { |
| 168 bool isSuitableFor(Backend b) override { |
| 169 return b == kNonRendering_Backend; |
| 170 } |
| 171 const char* onGetName() override { return "PDFColorComponent"; } |
| 172 void onDraw(int loops, SkCanvas*) override { |
| 173 char dst[5]; |
| 174 while (loops-- > 0) { |
| 175 for (int i = 0; i < 256; ++i) { |
| 176 (void)SkPDFUtils::ColorToDecimal(SkToU8(i), dst); |
| 177 } |
| 178 } |
| 179 } |
| 180 }; |
| 181 |
167 struct PDFShaderBench : public Benchmark { | 182 struct PDFShaderBench : public Benchmark { |
168 sk_sp<SkShader> fShader; | 183 sk_sp<SkShader> fShader; |
169 const char* onGetName() final { return "PDFShader"; } | 184 const char* onGetName() final { return "PDFShader"; } |
170 bool isSuitableFor(Backend b) final { return b == kNonRendering_Backend; } | 185 bool isSuitableFor(Backend b) final { return b == kNonRendering_Backend; } |
171 void onDelayedSetup() final { | 186 void onDelayedSetup() final { |
172 const SkPoint pts[2] = {{0.0f, 0.0f}, {100.0f, 100.0f}}; | 187 const SkPoint pts[2] = {{0.0f, 0.0f}, {100.0f, 100.0f}}; |
173 const SkColor colors[] = { | 188 const SkColor colors[] = { |
174 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, | 189 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, |
175 SK_ColorWHITE, SK_ColorBLACK, | 190 SK_ColorWHITE, SK_ColorBLACK, |
176 }; | 191 }; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 240 } |
226 } | 241 } |
227 } | 242 } |
228 }; | 243 }; |
229 | 244 |
230 } // namespace | 245 } // namespace |
231 DEF_BENCH(return new PDFImageBench;) | 246 DEF_BENCH(return new PDFImageBench;) |
232 DEF_BENCH(return new PDFJpegImageBench;) | 247 DEF_BENCH(return new PDFJpegImageBench;) |
233 DEF_BENCH(return new PDFCompressionBench;) | 248 DEF_BENCH(return new PDFCompressionBench;) |
234 DEF_BENCH(return new PDFScalarBench;) | 249 DEF_BENCH(return new PDFScalarBench;) |
| 250 DEF_BENCH(return new PDFColorComponentBench;) |
235 DEF_BENCH(return new PDFShaderBench;) | 251 DEF_BENCH(return new PDFShaderBench;) |
236 DEF_BENCH(return new WStreamWriteTextBenchmark;) | 252 DEF_BENCH(return new WStreamWriteTextBenchmark;) |
237 DEF_BENCH(return new WritePDFTextBenchmark;) | 253 DEF_BENCH(return new WritePDFTextBenchmark;) |
OLD | NEW |