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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
11 #include "SkImageGenerator.h" | |
12 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
13 | 12 |
14 CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType
) | 13 CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType
) |
15 : fColorType(colorType) | 14 : fColorType(colorType) |
16 , fData(SkRef(encoded)) | 15 , fData(SkRef(encoded)) |
17 { | 16 { |
18 // Parse filename and the color type to give the benchmark a useful name | 17 // Parse filename and the color type to give the benchmark a useful name |
19 const char* colorName; | 18 const char* colorName; |
20 switch(colorType) { | 19 switch(colorType) { |
21 case kN32_SkColorType: | 20 case kN32_SkColorType: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 62 } |
64 | 63 |
65 void CodecBench::onDraw(const int n, SkCanvas* canvas) { | 64 void CodecBench::onDraw(const int n, SkCanvas* canvas) { |
66 SkAutoTDelete<SkCodec> codec; | 65 SkAutoTDelete<SkCodec> codec; |
67 SkPMColor colorTable[256]; | 66 SkPMColor colorTable[256]; |
68 int colorCount; | 67 int colorCount; |
69 for (int i = 0; i < n; i++) { | 68 for (int i = 0; i < n; i++) { |
70 colorCount = 256; | 69 colorCount = 256; |
71 codec.reset(SkCodec::NewFromData(fData)); | 70 codec.reset(SkCodec::NewFromData(fData)); |
72 #ifdef SK_DEBUG | 71 #ifdef SK_DEBUG |
73 const SkImageGenerator::Result result = | 72 const SkCodec::Result result = |
74 #endif | 73 #endif |
75 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), | 74 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), |
76 NULL, colorTable, &colorCount); | 75 NULL, colorTable, &colorCount); |
77 SkASSERT(result == SkImageGenerator::kSuccess | 76 SkASSERT(result == SkCodec::kSuccess |
78 || result == SkImageGenerator::kIncompleteInput); | 77 || result == SkCodec::kIncompleteInput); |
79 } | 78 } |
80 } | 79 } |
OLD | NEW |