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 "CodecBenchPriv.h" | 8 #include "CodecBenchPriv.h" |
9 #include "DecodingBench.h" | 9 #include "DecodingBench.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 const char* DecodingBench::onGetName() { | 39 const char* DecodingBench::onGetName() { |
40 return fName.c_str(); | 40 return fName.c_str(); |
41 } | 41 } |
42 | 42 |
43 bool DecodingBench::isSuitableFor(Backend backend) { | 43 bool DecodingBench::isSuitableFor(Backend backend) { |
44 return kNonRendering_Backend == backend; | 44 return kNonRendering_Backend == backend; |
45 } | 45 } |
46 | 46 |
47 void DecodingBench::onPreDraw() { | 47 void DecodingBench::onDelayedSetup() { |
48 // Allocate the pixels now, to remove it from the loop. | 48 // Allocate the pixels now, to remove it from the loop. |
49 SkAutoTDelete<SkStreamRewindable> stream(new SkMemoryStream(fData)); | 49 SkAutoTDelete<SkStreamRewindable> stream(new SkMemoryStream(fData)); |
50 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream)); | 50 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream)); |
51 SkBitmap bm; | 51 SkBitmap bm; |
52 #ifdef SK_DEBUG | 52 #ifdef SK_DEBUG |
53 SkImageDecoder::Result result = | 53 SkImageDecoder::Result result = |
54 #endif | 54 #endif |
55 decoder->decode(stream, &bm, fColorType, SkImageDecoder::kDecodeBounds_Mode)
; | 55 decoder->decode(stream, &bm, fColorType, SkImageDecoder::kDecodeBounds_Mode)
; |
56 SkASSERT(SkImageDecoder::kFailure != result); | 56 SkASSERT(SkImageDecoder::kFailure != result); |
57 | 57 |
(...skipping 30 matching lines...) Expand all Loading... |
88 for (int i = 0; i < n; i++) { | 88 for (int i = 0; i < n; i++) { |
89 // create a new stream and a new decoder to mimic the behavior of | 89 // create a new stream and a new decoder to mimic the behavior of |
90 // CodecBench. | 90 // CodecBench. |
91 stream.reset(new SkMemoryStream(fData)); | 91 stream.reset(new SkMemoryStream(fData)); |
92 decoder.reset(SkImageDecoder::Factory(stream)); | 92 decoder.reset(SkImageDecoder::Factory(stream)); |
93 decoder->setAllocator(&allocator); | 93 decoder->setAllocator(&allocator); |
94 decoder->decode(stream, &bitmap, fColorType, | 94 decoder->decode(stream, &bitmap, fColorType, |
95 SkImageDecoder::kDecodePixels_Mode); | 95 SkImageDecoder::kDecodePixels_Mode); |
96 } | 96 } |
97 } | 97 } |
OLD | NEW |