Chromium Code Reviews| 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 "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkMath.h" | 10 #include "SkMath.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 if (!fCodec->skipScanlines(sampleY - 1)) { | 219 if (!fCodec->skipScanlines(sampleY - 1)) { |
| 220 fCodec->fillIncompleteImage(info, pixels, rowBytes, | 220 fCodec->fillIncompleteImage(info, pixels, rowBytes, |
| 221 options.fZeroInitialized, dstHeight, y + 1); | 221 options.fZeroInitialized, dstHeight, y + 1); |
| 222 return SkCodec::kIncompleteInput; | 222 return SkCodec::kIncompleteInput; |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 pixelPtr = SkTAddOffset<void>(pixelPtr, rowBytes); | 225 pixelPtr = SkTAddOffset<void>(pixelPtr, rowBytes); |
| 226 } | 226 } |
| 227 return SkCodec::kSuccess; | 227 return SkCodec::kSuccess; |
| 228 } | 228 } |
| 229 case SkCodec::kBottomUp_SkScanlineOrder: { | |
| 230 // Note that this mode does not support subsetting. | |
| 231 SkASSERT(0 == subsetY && nativeSize.height() == subsetHeight); | |
| 232 int y; | |
| 233 for (y = 0; y < nativeSize.height(); y++) { | |
| 234 int srcY = fCodec->nextScanline(); | |
| 235 if (is_coord_necessary(srcY, sampleY, dstHeight)) { | |
| 236 void* pixelPtr = SkTAddOffset<void>(pixels, | |
| 237 rowBytes * get_dst_coord(srcY, sampleY)); | |
| 238 if (1 != fCodec->getScanlines(pixelPtr, 1, rowBytes)) { | |
| 239 break; | |
| 240 } | |
| 241 } else { | |
| 242 if (!fCodec->skipScanlines(1)) { | |
| 243 break; | |
| 244 } | |
| 245 } | |
| 246 } | |
| 247 | |
| 248 if (nativeSize.height() == y) { | |
| 249 return SkCodec::kSuccess; | |
|
scroggo
2015/11/17 16:13:58
nit: four space indent
(Joke's on you for copying
msarett
2015/11/17 16:24:27
:). Not the first time I've fallen for this.
| |
| 250 } | |
| 251 | |
| 252 // We handle filling uninitialized memory here instead of using fCod ec. | |
| 253 // fCodec does not know that we are sampling. | |
| 254 const uint32_t fillValue = fCodec->getFillValue(info.colorType(), in fo.alphaType()); | |
| 255 for (; y < nativeSize.height(); y++) { | |
| 256 int srcY = fCodec->outputScanline(y); | |
| 257 if (is_coord_necessary(srcY, sampleY, dstHeight)) { | |
|
scroggo
2015/11/17 16:13:58
nit: You could give yourself a little extra width
msarett
2015/11/17 16:24:27
sgtm
| |
| 258 void* pixelPtr = SkTAddOffset<void>(pixels, | |
| 259 rowBytes * get_dst_coord(srcY, sampleY)); | |
| 260 SkSampler::Fill(info.makeWH(info.width(), 1), pixelPtr, rowB ytes, fillValue, | |
|
scroggo
2015/11/17 16:13:58
nit: I think you should create this info once outs
msarett
2015/11/17 16:24:27
Done.
| |
| 261 options.fZeroInitialized); | |
| 262 } | |
| 263 } | |
| 264 return SkCodec::kIncompleteInput; | |
| 265 } | |
| 229 case SkCodec::kNone_SkScanlineOrder: { | 266 case SkCodec::kNone_SkScanlineOrder: { |
| 230 const int linesNeeded = subsetHeight - samplingOffsetY; | 267 const int linesNeeded = subsetHeight - samplingOffsetY; |
| 231 SkAutoMalloc storage(linesNeeded * rowBytes); | 268 SkAutoMalloc storage(linesNeeded * rowBytes); |
| 232 uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); | 269 uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); |
| 233 | 270 |
| 234 if (!fCodec->skipScanlines(startY)) { | 271 if (!fCodec->skipScanlines(startY)) { |
| 235 fCodec->fillIncompleteImage(info, pixels, rowBytes, options.fZer oInitialized, | 272 fCodec->fillIncompleteImage(info, pixels, rowBytes, options.fZer oInitialized, |
| 236 dstHeight, 0); | 273 dstHeight, 0); |
| 237 return SkCodec::kIncompleteInput; | 274 return SkCodec::kIncompleteInput; |
| 238 } | 275 } |
| 239 int scanlines = fCodec->getScanlines(storagePtr, linesNeeded, rowByt es); | 276 int scanlines = fCodec->getScanlines(storagePtr, linesNeeded, rowByt es); |
| 240 | 277 |
| 241 for (int y = 0; y < dstHeight; y++) { | 278 for (int y = 0; y < dstHeight; y++) { |
| 242 memcpy(pixels, storagePtr, info.minRowBytes()); | 279 memcpy(pixels, storagePtr, info.minRowBytes()); |
| 243 storagePtr += sampleY * rowBytes; | 280 storagePtr += sampleY * rowBytes; |
| 244 pixels = SkTAddOffset<void>(pixels, rowBytes); | 281 pixels = SkTAddOffset<void>(pixels, rowBytes); |
| 245 } | 282 } |
| 246 | 283 |
| 247 if (scanlines < dstHeight) { | 284 if (scanlines < dstHeight) { |
| 248 // fCodec has already handled filling uninitialized memory. | 285 // fCodec has already handled filling uninitialized memory. |
| 249 return SkCodec::kIncompleteInput; | 286 return SkCodec::kIncompleteInput; |
| 250 } | 287 } |
| 251 return SkCodec::kSuccess; | 288 return SkCodec::kSuccess; |
| 252 } | 289 } |
| 253 default: | 290 default: |
| 254 SkASSERT(false); | 291 SkASSERT(false); |
| 255 return SkCodec::kUnimplemented; | 292 return SkCodec::kUnimplemented; |
| 256 } | 293 } |
| 257 } | 294 } |
| OLD | NEW |