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 "CodecBenchPriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkCommandLineFlags.h" | |
12 #include "SkOSFile.h" | 13 #include "SkOSFile.h" |
13 | 14 |
15 // Actually zeroing the memory would throw off timing, so we just lie. | |
16 DEFINE_bool(zero_init, false, "Pretend our destination is zero-intialized, simul ating Android?"); | |
scroggo
2016/01/08 22:20:29
Hahaha - we could also add this as another option
| |
17 | |
14 CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType , | 18 CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType , |
15 SkAlphaType alphaType) | 19 SkAlphaType alphaType) |
16 : fColorType(colorType) | 20 : fColorType(colorType) |
17 , fAlphaType(alphaType) | 21 , fAlphaType(alphaType) |
18 , fData(SkRef(encoded)) | 22 , fData(SkRef(encoded)) |
19 { | 23 { |
20 // Parse filename and the color type to give the benchmark a useful name | 24 // Parse filename and the color type to give the benchmark a useful name |
21 fName.printf("Codec_%s_%s%s", baseName.c_str(), color_type_to_str(colorType) , | 25 fName.printf("Codec_%s_%s%s", baseName.c_str(), color_type_to_str(colorType) , |
22 alpha_type_to_str(alphaType)); | 26 alpha_type_to_str(alphaType)); |
23 #ifdef SK_DEBUG | 27 #ifdef SK_DEBUG |
(...skipping 16 matching lines...) Expand all Loading... | |
40 | 44 |
41 fInfo = codec->getInfo().makeColorType(fColorType).makeAlphaType(fAlphaType) ; | 45 fInfo = codec->getInfo().makeColorType(fColorType).makeAlphaType(fAlphaType) ; |
42 | 46 |
43 fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes())); | 47 fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes())); |
44 } | 48 } |
45 | 49 |
46 void CodecBench::onDraw(int n, SkCanvas* canvas) { | 50 void CodecBench::onDraw(int n, SkCanvas* canvas) { |
47 SkAutoTDelete<SkCodec> codec; | 51 SkAutoTDelete<SkCodec> codec; |
48 SkPMColor colorTable[256]; | 52 SkPMColor colorTable[256]; |
49 int colorCount; | 53 int colorCount; |
54 SkCodec::Options options; | |
55 if (FLAGS_zero_init) { | |
56 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized; | |
57 } | |
50 for (int i = 0; i < n; i++) { | 58 for (int i = 0; i < n; i++) { |
51 colorCount = 256; | 59 colorCount = 256; |
52 codec.reset(SkCodec::NewFromData(fData)); | 60 codec.reset(SkCodec::NewFromData(fData)); |
53 #ifdef SK_DEBUG | 61 #ifdef SK_DEBUG |
54 const SkCodec::Result result = | 62 const SkCodec::Result result = |
55 #endif | 63 #endif |
56 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), | 64 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), |
57 nullptr, colorTable, &colorCount); | 65 &options, colorTable, &colorCount); |
58 SkASSERT(result == SkCodec::kSuccess | 66 SkASSERT(result == SkCodec::kSuccess |
59 || result == SkCodec::kIncompleteInput); | 67 || result == SkCodec::kIncompleteInput); |
60 } | 68 } |
61 } | 69 } |
OLD | NEW |