| 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 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
| 74 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
| 74 | 75 |
| 75 scanlineDecoder->skipScanlines(fOffsetTop); | 76 scanlineDecoder->skipScanlines(fOffsetTop); |
| 76 uint32_t bpp = info.bytesPerPixel(); | 77 uint32_t bpp = info.bytesPerPixel(); |
| 77 for (uint32_t y = 0; y < fSubsetHeight; y++) { | 78 for (uint32_t y = 0; y < fSubsetHeight; y++) { |
| 78 scanlineDecoder->getScanlines(row.get(), 1, 0); | 79 scanlineDecoder->getScanlines(row.get(), 1, 0); |
| 79 memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp, | 80 memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp, |
| 80 fSubsetWidth * bpp); | 81 fSubsetWidth * bpp); |
| 81 } | 82 } |
| 82 } | 83 } |
| 83 } else { | 84 } else { |
| 84 for (int count = 0; count < n; count++) { | 85 for (int count = 0; count < n; count++) { |
| 85 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea
m)); | 86 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea
m)); |
| 86 int width, height; | 87 int width, height; |
| 87 decoder->buildTileIndex(fStream->duplicate(), &width, &height); | 88 decoder->buildTileIndex(fStream->duplicate(), &width, &height); |
| 88 SkBitmap bitmap; | 89 SkBitmap bitmap; |
| 89 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid
th, | 90 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid
th, |
| 90 fSubsetHeight); | 91 fSubsetHeight); |
| 91 decoder->decodeSubset(&bitmap, rect, fColorType); | 92 decoder->decodeSubset(&bitmap, rect, fColorType); |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 } | 95 } |
| OLD | NEW |