OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "CodecBench.h" | 8 #include "CodecBench.h" |
| 9 #include "CodecBenchPriv.h" |
9 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
10 #include "SkCodec.h" | 11 #include "SkCodec.h" |
11 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
12 | 13 |
13 CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType
) | 14 CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType
) |
14 : fColorType(colorType) | 15 : fColorType(colorType) |
15 , fData(SkRef(encoded)) | 16 , fData(SkRef(encoded)) |
16 { | 17 { |
17 // Parse filename and the color type to give the benchmark a useful name | 18 // Parse filename and the color type to give the benchmark a useful name |
18 const char* colorName; | 19 fName.printf("Codec_%s_%s", baseName.c_str(), color_type_to_str(colorType)); |
19 switch(colorType) { | |
20 case kN32_SkColorType: | |
21 colorName = "N32"; | |
22 break; | |
23 case kRGB_565_SkColorType: | |
24 colorName = "565"; | |
25 break; | |
26 case kAlpha_8_SkColorType: | |
27 colorName = "Alpha8"; | |
28 break; | |
29 default: | |
30 colorName = "Unknown"; | |
31 } | |
32 fName.printf("Codec_%s_%s", baseName.c_str(), colorName); | |
33 #ifdef SK_DEBUG | 20 #ifdef SK_DEBUG |
34 // Ensure that we can create an SkCodec from this data. | 21 // Ensure that we can create an SkCodec from this data. |
35 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData)); | 22 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData)); |
36 SkASSERT(codec); | 23 SkASSERT(codec); |
37 #endif | 24 #endif |
38 } | 25 } |
39 | 26 |
40 const char* CodecBench::onGetName() { | 27 const char* CodecBench::onGetName() { |
41 return fName.c_str(); | 28 return fName.c_str(); |
42 } | 29 } |
(...skipping 27 matching lines...) Expand all Loading... |
70 codec.reset(SkCodec::NewFromData(fData)); | 57 codec.reset(SkCodec::NewFromData(fData)); |
71 #ifdef SK_DEBUG | 58 #ifdef SK_DEBUG |
72 const SkCodec::Result result = | 59 const SkCodec::Result result = |
73 #endif | 60 #endif |
74 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), | 61 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), |
75 nullptr, colorTable, &colorCount); | 62 nullptr, colorTable, &colorCount); |
76 SkASSERT(result == SkCodec::kSuccess | 63 SkASSERT(result == SkCodec::kSuccess |
77 || result == SkCodec::kIncompleteInput); | 64 || result == SkCodec::kIncompleteInput); |
78 } | 65 } |
79 } | 66 } |
OLD | NEW |