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 "SubsetSingleBench.h" | 9 #include "SubsetSingleBench.h" |
10 #include "SubsetBenchPriv.h" | 10 #include "SubsetBenchPriv.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 const char* SubsetSingleBench::onGetName() { | 52 const char* SubsetSingleBench::onGetName() { |
53 return fName.c_str(); | 53 return fName.c_str(); |
54 } | 54 } |
55 | 55 |
56 bool SubsetSingleBench::isSuitableFor(Backend backend) { | 56 bool SubsetSingleBench::isSuitableFor(Backend backend) { |
57 return kNonRendering_Backend == backend; | 57 return kNonRendering_Backend == backend; |
58 } | 58 } |
59 | 59 |
60 void SubsetSingleBench::onDraw(const int n, SkCanvas* canvas) { | 60 void SubsetSingleBench::onDraw(int n, SkCanvas* canvas) { |
61 // When the color type is kIndex8, we will need to store the color table. I
f it is | 61 // When the color type is kIndex8, we will need to store the color table. I
f it is |
62 // used, it will be initialized by the codec. | 62 // used, it will be initialized by the codec. |
63 int colorCount; | 63 int colorCount; |
64 SkPMColor colors[256]; | 64 SkPMColor colors[256]; |
65 if (fUseCodec) { | 65 if (fUseCodec) { |
66 for (int count = 0; count < n; count++) { | 66 for (int count = 0; count < n; count++) { |
67 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica
te())); | 67 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica
te())); |
68 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); | 68 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
69 SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]); | 69 SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]); |
70 codec->startScanlineDecode(info, nullptr, colors, &colorCount); | 70 codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
(...skipping 15 matching lines...) Expand all Loading... |
86 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea
m)); | 86 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea
m)); |
87 int width, height; | 87 int width, height; |
88 decoder->buildTileIndex(fStream->duplicate(), &width, &height); | 88 decoder->buildTileIndex(fStream->duplicate(), &width, &height); |
89 SkBitmap bitmap; | 89 SkBitmap bitmap; |
90 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid
th, | 90 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid
th, |
91 fSubsetHeight); | 91 fSubsetHeight); |
92 decoder->decodeSubset(&bitmap, rect, fColorType); | 92 decoder->decodeSubset(&bitmap, rect, fColorType); |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
OLD | NEW |