OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "DecodingBench.h" | |
9 #include "SkImageDecoder.h" | |
10 #include "SkOSFile.h" | |
11 | |
12 /* | |
13 * | |
14 * This benchmark is designed to test the performance of image decoding. | |
15 * It is invoked from the nanobench.cpp file. | |
16 * | |
17 */ | |
18 DecodingBench::DecodingBench(SkString path, SkColorType colorType) | |
19 : fPath(path) | |
20 , fColorType(colorType) | |
21 { | |
22 // Parse filename and the color type to give the benchmark a useful name | |
23 SkString baseName = SkOSPath::Basename(path.c_str()); | |
24 const char* colorName; | |
25 switch(colorType) { | |
26 case kN32_SkColorType: | |
scroggo
2015/02/12 14:19:02
Skia coding style dictates this should be indented
msarett
2015/02/12 18:52:56
Done.
| |
27 colorName = "N32"; | |
28 break; | |
29 case kRGB_565_SkColorType: | |
30 colorName = "565"; | |
31 break; | |
32 case kAlpha_8_SkColorType: | |
33 colorName = "Alpha8"; | |
34 break; | |
35 default: | |
36 colorName = "Unknown"; | |
37 } | |
38 fName.printf("Decode_%s_%s", baseName.c_str(), colorName); | |
39 } | |
40 | |
41 const char* DecodingBench::onGetName() { | |
42 return fName.c_str(); | |
43 } | |
44 | |
45 bool DecodingBench::isSuitableFor(Backend backend) { | |
46 return kNonRendering_Backend == backend; | |
47 } | |
48 | |
49 void DecodingBench::onDraw(const int n, SkCanvas* canvas) { | |
50 // Decode each image file n times | |
51 for (int i = 0; i < n; i++) { | |
52 SkBitmap bitmap; | |
53 SkImageDecoder::DecodeFile(fPath.c_str(), &bitmap, fColorType, | |
54 SkImageDecoder::kDecodePixels_Mode); | |
55 } | |
scroggo
2015/02/12 14:19:02
Didn't Mike suggest drawing to the canvas? Oh, I t
mtklein
2015/02/12 14:41:38
Yeah, I think in this case you'll find canvas is a
msarett
2015/02/12 18:52:56
We discussed and decided it's best to use the non-
| |
56 } | |
OLD | NEW |