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 "SubsetTranslateBench.h" | 8 #include "SubsetTranslateBench.h" |
9 #include "SubsetBenchPriv.h" | 9 #include "SubsetBenchPriv.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
| 12 #include "SkCodecBenchPriv.h" |
12 #include "SkImageDecoder.h" | 13 #include "SkImageDecoder.h" |
13 #include "SkOSFile.h" | 14 #include "SkOSFile.h" |
14 #include "SkScanlineDecoder.h" | 15 #include "SkScanlineDecoder.h" |
15 #include "SkStream.h" | 16 #include "SkStream.h" |
16 | 17 |
17 /* | 18 /* |
18 * | 19 * |
19 * This benchmark is designed to test the performance of subset decoding. | 20 * This benchmark is designed to test the performance of subset decoding. |
20 * It uses input dimensions to decode the entire image where each block is susbe
tW x subsetH. | 21 * It uses input dimensions to decode the entire image where each block is susbe
tW x subsetH. |
21 * | 22 * |
22 */ | 23 */ |
23 | 24 |
24 SubsetTranslateBench::SubsetTranslateBench(const SkString& path, | 25 SubsetTranslateBench::SubsetTranslateBench(const SkString& path, |
25 SkColorType colorType, | 26 SkColorType colorType, |
26 uint32_t subsetWidth, | 27 uint32_t subsetWidth, |
27 uint32_t subsetHeight, | 28 uint32_t subsetHeight, |
28 bool useCodec) | 29 bool useCodec) |
29 : fColorType(colorType) | 30 : fColorType(colorType) |
30 , fSubsetWidth(subsetWidth) | 31 , fSubsetWidth(subsetWidth) |
31 , fSubsetHeight(subsetHeight) | 32 , fSubsetHeight(subsetHeight) |
32 , fUseCodec(useCodec) | 33 , fUseCodec(useCodec) |
33 { | 34 { |
34 // Parse the filename | 35 // Parse the filename |
35 SkString baseName = SkOSPath::Basename(path.c_str()); | 36 SkString baseName = SkOSPath::Basename(path.c_str()); |
36 | 37 |
37 // Choose an informative color name | 38 // Choose an informative color name |
38 const char* colorName = get_color_name(fColorType); | 39 const char* colorName = color_type_to_str(fColorType); |
39 | 40 |
40 fName.printf("%sSubsetTranslate_%dx%d_%s_%s", fUseCodec ? "Codec" : "Image",
fSubsetWidth, | 41 fName.printf("%sSubsetTranslate_%dx%d_%s_%s", fUseCodec ? "Codec" : "Image",
fSubsetWidth, |
41 fSubsetHeight, baseName.c_str(), colorName); | 42 fSubsetHeight, baseName.c_str(), colorName); |
42 | 43 |
43 // Perform the decode setup | 44 // Perform the decode setup |
44 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 45 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
45 fStream.reset(new SkMemoryStream(encoded)); | 46 fStream.reset(new SkMemoryStream(encoded)); |
46 } | 47 } |
47 | 48 |
48 const char* SubsetTranslateBench::onGetName() { | 49 const char* SubsetTranslateBench::onGetName() { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? | 118 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? |
118 height - y : fSubsetHeight; | 119 height - y : fSubsetHeight; |
119 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, | 120 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, |
120 currSubsetHeight); | 121 currSubsetHeight); |
121 decoder->decodeSubset(&bitmap, rect, fColorType); | 122 decoder->decodeSubset(&bitmap, rect, fColorType); |
122 } | 123 } |
123 } | 124 } |
124 } | 125 } |
125 } | 126 } |
126 } | 127 } |
OLD | NEW |