| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); | 68 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
| 69 | 69 |
| 70 SkDEBUGCODE(SkCodec::Result result =) | 70 SkDEBUGCODE(SkCodec::Result result =) |
| 71 codec->startScanlineDecode(info, nullptr, colors, &colorCount); | 71 codec->startScanlineDecode(info, nullptr, colors, &colorCount); |
| 72 SkASSERT(result == SkCodec::kSuccess); | 72 SkASSERT(result == SkCodec::kSuccess); |
| 73 | 73 |
| 74 SkBitmap bitmap; | 74 SkBitmap bitmap; |
| 75 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); | 75 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
| 76 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); | 76 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
| 77 | 77 |
| 78 SkDEBUGCODE(result = ) codec->skipScanlines(fOffsetTop); | 78 SkDEBUGCODE(int lines = ) codec->skipScanlines(fOffsetTop); |
| 79 SkASSERT(result == SkCodec::kSuccess); | 79 SkASSERT((uint32_t) lines == fOffsetTop); |
| 80 | 80 |
| 81 const uint32_t bpp = info.bytesPerPixel(); | 81 const uint32_t bpp = info.bytesPerPixel(); |
| 82 | 82 |
| 83 switch (codec->getScanlineOrder()) { | 83 switch (codec->getScanlineOrder()) { |
| 84 case SkCodec::kTopDown_SkScanlineOrder: { | 84 case SkCodec::kTopDown_SkScanlineOrder: { |
| 85 SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes
()]); | 85 SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes
()]); |
| 86 for (uint32_t y = 0; y < fSubsetHeight; y++) { | 86 for (uint32_t y = 0; y < fSubsetHeight; y++) { |
| 87 SkDEBUGCODE(result = ) codec->getScanlines(row.get(), 1,
0); | 87 SkDEBUGCODE(lines = ) codec->getScanlines(row.get(), 1,
0); |
| 88 SkASSERT(result == SkCodec::kSuccess); | 88 SkASSERT(lines == 1); |
| 89 | 89 |
| 90 memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * b
pp, | 90 memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * b
pp, |
| 91 fSubsetWidth * bpp); | 91 fSubsetWidth * bpp); |
| 92 } | 92 } |
| 93 break; | 93 break; |
| 94 } | 94 } |
| 95 case SkCodec::kNone_SkScanlineOrder: { | 95 case SkCodec::kNone_SkScanlineOrder: { |
| 96 // decode all scanlines that intersect the subset, and copy
the subset | 96 // decode all scanlines that intersect the subset, and copy
the subset |
| 97 // into the output. | 97 // into the output. |
| 98 SkImageInfo stripeInfo = info.makeWH(info.width(), fSubsetHe
ight); | 98 SkImageInfo stripeInfo = info.makeWH(info.width(), fSubsetHe
ight); |
| 99 SkBitmap stripeBm; | 99 SkBitmap stripeBm; |
| 100 alloc_pixels(&stripeBm, stripeInfo, colors, colorCount); | 100 alloc_pixels(&stripeBm, stripeInfo, colors, colorCount); |
| 101 | 101 |
| 102 SkDEBUGCODE(result = ) codec->getScanlines(stripeBm.getPixel
s(), fSubsetHeight, | 102 SkDEBUGCODE(lines = ) codec->getScanlines(stripeBm.getPixels
(), fSubsetHeight, |
| 103 stripeBm.rowBytes
()); | 103 stripeBm.rowBytes
()); |
| 104 SkASSERT(result == SkCodec::kSuccess); | 104 SkASSERT((uint32_t) lines == fSubsetHeight); |
| 105 | 105 |
| 106 for (uint32_t y = 0; y < fSubsetHeight; y++) { | 106 for (uint32_t y = 0; y < fSubsetHeight; y++) { |
| 107 memcpy(bitmap.getAddr(0, y), stripeBm.getAddr(fOffsetLef
t, y), | 107 memcpy(bitmap.getAddr(0, y), stripeBm.getAddr(fOffsetLef
t, y), |
| 108 fSubsetWidth * bpp); | 108 fSubsetWidth * bpp); |
| 109 } | 109 } |
| 110 break; | 110 break; |
| 111 } | 111 } |
| 112 default: | 112 default: |
| 113 // We currently are only testing kTopDown and kNone, which a
re the only | 113 // We currently are only testing kTopDown and kNone, which a
re the only |
| 114 // two used by the subsets we care about. skbug.com/4428 | 114 // two used by the subsets we care about. skbug.com/4428 |
| 115 SkASSERT(false); | 115 SkASSERT(false); |
| 116 | 116 |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 } else { | 119 } else { |
| 120 for (int count = 0; count < n; count++) { | 120 for (int count = 0; count < n; count++) { |
| 121 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea
m)); | 121 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea
m)); |
| 122 int width, height; | 122 int width, height; |
| 123 SkAssertResult(decoder->buildTileIndex(fStream->duplicate(), &width,
&height)); | 123 SkAssertResult(decoder->buildTileIndex(fStream->duplicate(), &width,
&height)); |
| 124 SkBitmap bitmap; | 124 SkBitmap bitmap; |
| 125 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid
th, | 125 SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWid
th, |
| 126 fSubsetHeight); | 126 fSubsetHeight); |
| 127 SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorType)); | 127 SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorType)); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 } | 130 } |
| OLD | NEW |