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 "BitmapRegionDecoderBench.h" | 8 #include "BitmapRegionDecoderBench.h" |
9 #include "CodecBenchPriv.h" | 9 #include "CodecBenchPriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkCodecTools.h" | 11 #include "SkCodecTools.h" |
12 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
13 | 13 |
14 BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData*
encoded, | 14 BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData*
encoded, |
15 SkBitmapRegionDecoderInterface::Strategy strategy, SkColorType colorType
, | 15 SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType, |
16 uint32_t sampleSize, const SkIRect& subset) | 16 uint32_t sampleSize, const SkIRect& subset) |
17 : fBRD(nullptr) | 17 : fBRD(nullptr) |
18 , fData(SkRef(encoded)) | 18 , fData(SkRef(encoded)) |
19 , fStrategy(strategy) | 19 , fStrategy(strategy) |
20 , fColorType(colorType) | 20 , fColorType(colorType) |
21 , fSampleSize(sampleSize) | 21 , fSampleSize(sampleSize) |
22 , fSubset(subset) | 22 , fSubset(subset) |
23 { | 23 { |
24 // Choose a useful name for the region decoding strategy | 24 // Choose a useful name for the region decoding strategy |
25 const char* strategyName; | 25 const char* strategyName; |
26 switch (strategy) { | 26 switch (strategy) { |
27 case SkBitmapRegionDecoderInterface::kOriginal_Strategy: | 27 case SkBitmapRegionDecoder::kOriginal_Strategy: |
28 strategyName = "Original"; | 28 strategyName = "Original"; |
29 break; | 29 break; |
30 case SkBitmapRegionDecoderInterface::kCanvas_Strategy: | 30 case SkBitmapRegionDecoder::kCanvas_Strategy: |
31 strategyName = "Canvas"; | 31 strategyName = "Canvas"; |
32 break; | 32 break; |
33 case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy: | 33 case SkBitmapRegionDecoder::kAndroidCodec_Strategy: |
34 strategyName = "AndroidCodec"; | 34 strategyName = "AndroidCodec"; |
35 break; | 35 break; |
36 default: | 36 default: |
37 SkASSERT(false); | 37 SkASSERT(false); |
38 strategyName = ""; | 38 strategyName = ""; |
39 break; | 39 break; |
40 } | 40 } |
41 | 41 |
42 // Choose a useful name for the color type | 42 // Choose a useful name for the color type |
43 const char* colorName = color_type_to_str(colorType); | 43 const char* colorName = color_type_to_str(colorType); |
44 | 44 |
45 fName.printf("BRD_%s_%s_%s", baseName, strategyName, colorName); | 45 fName.printf("BRD_%s_%s_%s", baseName, strategyName, colorName); |
46 if (1 != sampleSize) { | 46 if (1 != sampleSize) { |
47 fName.appendf("_%.3f", get_scale_from_sample_size(sampleSize)); | 47 fName.appendf("_%.3f", get_scale_from_sample_size(sampleSize)); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 const char* BitmapRegionDecoderBench::onGetName() { | 51 const char* BitmapRegionDecoderBench::onGetName() { |
52 return fName.c_str(); | 52 return fName.c_str(); |
53 } | 53 } |
54 | 54 |
55 bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) { | 55 bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) { |
56 return kNonRendering_Backend == backend; | 56 return kNonRendering_Backend == backend; |
57 } | 57 } |
58 | 58 |
59 void BitmapRegionDecoderBench::onDelayedSetup() { | 59 void BitmapRegionDecoderBench::onDelayedSetup() { |
60 fBRD.reset(SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(fData,
fStrategy)); | 60 fBRD.reset(SkBitmapRegionDecoder::Create(fData, fStrategy)); |
61 } | 61 } |
62 | 62 |
63 void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) { | 63 void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) { |
64 for (int i = 0; i < n; i++) { | 64 for (int i = 0; i < n; i++) { |
65 SkBitmap bm; | 65 SkBitmap bm; |
66 SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, fC
olorType, false)); | 66 SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, fC
olorType, false)); |
67 } | 67 } |
68 } | 68 } |
OLD | NEW |