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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return fName.c_str(); | 35 return fName.c_str(); |
36 } | 36 } |
37 | 37 |
38 bool CodecBench::isSuitableFor(Backend backend) { | 38 bool CodecBench::isSuitableFor(Backend backend) { |
39 return kNonRendering_Backend == backend; | 39 return kNonRendering_Backend == backend; |
40 } | 40 } |
41 | 41 |
42 void CodecBench::onDelayedSetup() { | 42 void CodecBench::onDelayedSetup() { |
43 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData)); | 43 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData)); |
44 | 44 |
45 fInfo = codec->getInfo().makeColorType(fColorType) | 45 fInfo = codec->getInfo().makeColorType(fColorType).makeAlphaType(fAlphaType)
; |
46 .makeAlphaType(fAlphaType) | |
47 .makeColorSpace(nullptr); | |
48 | 46 |
49 fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes())); | 47 fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes())); |
50 } | 48 } |
51 | 49 |
52 void CodecBench::onDraw(int n, SkCanvas* canvas) { | 50 void CodecBench::onDraw(int n, SkCanvas* canvas) { |
53 SkAutoTDelete<SkCodec> codec; | 51 SkAutoTDelete<SkCodec> codec; |
54 SkPMColor colorTable[256]; | 52 SkPMColor colorTable[256]; |
55 int colorCount; | 53 int colorCount; |
56 SkCodec::Options options; | 54 SkCodec::Options options; |
57 if (FLAGS_zero_init) { | 55 if (FLAGS_zero_init) { |
58 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized; | 56 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized; |
59 } | 57 } |
60 for (int i = 0; i < n; i++) { | 58 for (int i = 0; i < n; i++) { |
61 colorCount = 256; | 59 colorCount = 256; |
62 codec.reset(SkCodec::NewFromData(fData)); | 60 codec.reset(SkCodec::NewFromData(fData)); |
63 #ifdef SK_DEBUG | 61 #ifdef SK_DEBUG |
64 const SkCodec::Result result = | 62 const SkCodec::Result result = |
65 #endif | 63 #endif |
66 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), | 64 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), |
67 &options, colorTable, &colorCount); | 65 &options, colorTable, &colorCount); |
68 SkASSERT(result == SkCodec::kSuccess | 66 SkASSERT(result == SkCodec::kSuccess |
69 || result == SkCodec::kIncompleteInput); | 67 || result == SkCodec::kIncompleteInput); |
70 } | 68 } |
71 } | 69 } |
OLD | NEW |