| 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 "SubsetTranslateBench.h" | 9 #include "SubsetTranslateBench.h" |
| 10 #include "SubsetBenchPriv.h" | 10 #include "SubsetBenchPriv.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); | 84 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
| 85 | 85 |
| 86 const uint32_t bpp = info.bytesPerPixel(); | 86 const uint32_t bpp = info.bytesPerPixel(); |
| 87 | 87 |
| 88 for (int x = 0; x < info.width(); x += fSubsetWidth) { | 88 for (int x = 0; x < info.width(); x += fSubsetWidth) { |
| 89 for (int y = 0; y < info.height(); y += fSubsetHeight) { | 89 for (int y = 0; y < info.height(); y += fSubsetHeight) { |
| 90 SkDEBUGCODE(SkCodec::Result result =) | 90 SkDEBUGCODE(SkCodec::Result result =) |
| 91 codec->startScanlineDecode(info, nullptr, get_colors(&bitmap
), &colorCount); | 91 codec->startScanlineDecode(info, nullptr, get_colors(&bitmap
), &colorCount); |
| 92 SkASSERT(SkCodec::kSuccess == result); | 92 SkASSERT(SkCodec::kSuccess == result); |
| 93 | 93 |
| 94 SkDEBUGCODE(result =) codec->skipScanlines(y); | 94 SkDEBUGCODE(int lines =) codec->skipScanlines(y); |
| 95 SkASSERT(SkCodec::kSuccess == result); | 95 SkASSERT(y == lines); |
| 96 | 96 |
| 97 const uint32_t currSubsetWidth = | 97 const uint32_t currSubsetWidth = |
| 98 x + (int) fSubsetWidth > info.width() ? | 98 x + (int) fSubsetWidth > info.width() ? |
| 99 info.width() - x : fSubsetWidth; | 99 info.width() - x : fSubsetWidth; |
| 100 const uint32_t currSubsetHeight = | 100 const uint32_t currSubsetHeight = |
| 101 y + (int) fSubsetHeight > info.height() ? | 101 y + (int) fSubsetHeight > info.height() ? |
| 102 info.height() - y : fSubsetHeight; | 102 info.height() - y : fSubsetHeight; |
| 103 | 103 |
| 104 switch (codec->getScanlineOrder()) { | 104 switch (codec->getScanlineOrder()) { |
| 105 case SkCodec::kTopDown_SkScanlineOrder: | 105 case SkCodec::kTopDown_SkScanlineOrder: |
| 106 for (uint32_t y = 0; y < currSubsetHeight; y++) { | 106 for (uint32_t y = 0; y < currSubsetHeight; y++) { |
| 107 SkDEBUGCODE(result =) codec->getScanlines(row.ge
t(), 1, 0); | 107 SkDEBUGCODE(lines =) codec->getScanlines(row.get
(), 1, 0); |
| 108 SkASSERT(SkCodec::kSuccess == result); | 108 SkASSERT(1 == lines); |
| 109 | 109 |
| 110 memcpy(bitmap.getAddr(0, y), row.get() + x * bpp
, | 110 memcpy(bitmap.getAddr(0, y), row.get() + x * bpp
, |
| 111 currSubsetWidth * bpp); | 111 currSubsetWidth * bpp); |
| 112 } | 112 } |
| 113 break; | 113 break; |
| 114 case SkCodec::kNone_SkScanlineOrder: { | 114 case SkCodec::kNone_SkScanlineOrder: { |
| 115 // decode all scanlines that intersect the subset, a
nd copy the subset | 115 // decode all scanlines that intersect the subset, a
nd copy the subset |
| 116 // into the output. | 116 // into the output. |
| 117 SkImageInfo stripeInfo = info.makeWH(info.width(), c
urrSubsetHeight); | 117 SkImageInfo stripeInfo = info.makeWH(info.width(), c
urrSubsetHeight); |
| 118 SkBitmap stripeBm; | 118 SkBitmap stripeBm; |
| 119 alloc_pixels(&stripeBm, stripeInfo, colors, colorCou
nt); | 119 alloc_pixels(&stripeBm, stripeInfo, colors, colorCou
nt); |
| 120 | 120 |
| 121 SkDEBUGCODE(result =) codec->getScanlines(stripeBm.g
etPixels(), | 121 SkDEBUGCODE(lines =) codec->getScanlines(stripeBm.ge
tPixels(), |
| 122 currSubsetHeight, stripeBm.rowBytes()); | 122 currSubsetHeight, stripeBm.rowBytes()); |
| 123 SkASSERT(SkCodec::kSuccess == result); | 123 SkASSERT(currSubsetHeight == (uint32_t) lines); |
| 124 | 124 |
| 125 for (uint32_t subsetY = 0; subsetY < currSubsetHeigh
t; subsetY++) { | 125 for (uint32_t subsetY = 0; subsetY < currSubsetHeigh
t; subsetY++) { |
| 126 memcpy(bitmap.getAddr(0, subsetY), stripeBm.getA
ddr(x, subsetY), | 126 memcpy(bitmap.getAddr(0, subsetY), stripeBm.getA
ddr(x, subsetY), |
| 127 currSubsetWidth * bpp); | 127 currSubsetWidth * bpp); |
| 128 } | 128 } |
| 129 break; | 129 break; |
| 130 } | 130 } |
| 131 default: | 131 default: |
| 132 // We currently are only testing kTopDown and kNone,
which are the only | 132 // We currently are only testing kTopDown and kNone,
which are the only |
| 133 // two used by the subsets we care about. skbug.com/
4428 | 133 // two used by the subsets we care about. skbug.com/
4428 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 163 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? | 163 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? |
| 164 height - y : fSubsetHeight; | 164 height - y : fSubsetHeight; |
| 165 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, | 165 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, |
| 166 currSubsetHeight); | 166 currSubsetHeight); |
| 167 SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorTy
pe)); | 167 SkAssertResult(decoder->decodeSubset(&bitmap, rect, fColorTy
pe)); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 } | 172 } |
| OLD | NEW |