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 "SubsetSingleBench.h" | 8 #include "SubsetSingleBench.h" |
9 #include "SubsetBenchPriv.h" | 9 #include "SubsetBenchPriv.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 SkPMColor colors[256]; | 63 SkPMColor colors[256]; |
64 if (fUseCodec) { | 64 if (fUseCodec) { |
65 for (int count = 0; count < n; count++) { | 65 for (int count = 0; count < n; count++) { |
66 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica te())); | 66 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica te())); |
67 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); | 67 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
68 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s())); | 68 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s())); |
69 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder( | 69 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder( |
70 info, NULL, colors, &colorCount); | 70 info, NULL, colors, &colorCount); |
71 | 71 |
72 SkBitmap bitmap; | 72 SkBitmap bitmap; |
73 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight)); | 73 if (kIndex_8_SkColorType == fColorType) { |
scroggo
2015/06/30 16:40:19
I agree that this is better (I think in patch set
msarett
2015/06/30 18:40:28
Acknowledged.
| |
74 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight), NUL L, | |
75 SkNEW_ARGS(SkColorTable, (colors, colorCount))); | |
scroggo
2015/06/30 16:40:19
According to the documentation for tryAllocPixels
msarett
2015/06/30 18:40:27
You're right. Sorry should have put a little more
| |
76 } else { | |
77 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight)); | |
78 } | |
74 | 79 |
75 scanlineDecoder->skipScanlines(fOffsetTop); | 80 scanlineDecoder->skipScanlines(fOffsetTop); |
76 uint32_t bpp = info.bytesPerPixel(); | 81 uint32_t bpp = info.bytesPerPixel(); |
77 for (uint32_t y = 0; y < fSubsetHeight; y++) { | 82 for (uint32_t y = 0; y < fSubsetHeight; y++) { |
78 scanlineDecoder->getScanlines(row.get(), 1, 0); | 83 scanlineDecoder->getScanlines(row.get(), 1, 0); |
79 memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp, | 84 memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp, |
80 fSubsetWidth * bpp); | 85 fSubsetWidth * bpp); |
81 } | 86 } |
82 } | 87 } |
83 } else { | 88 } else { |
84 for (int count = 0; count < n; count++) { | 89 for (int count = 0; count < n; count++) { |
85 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea m)); | 90 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea m)); |
86 int width, height; | 91 int width, height; |
87 decoder->buildTileIndex(fStream->duplicate(), &width, &height); | 92 decoder->buildTileIndex(fStream->duplicate(), &width, &height); |
88 SkBitmap bitmap; | 93 SkBitmap bitmap; |
89 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid th, | 94 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid th, |
90 fSubsetHeight); | 95 fSubsetHeight); |
91 decoder->decodeSubset(&bitmap, rect, fColorType); | 96 decoder->decodeSubset(&bitmap, rect, fColorType); |
92 } | 97 } |
93 } | 98 } |
94 } | 99 } |
OLD | NEW |