| 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 "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
| 9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 size_t bytesRead = stream->peek(buffer, bytesToRead); | 55 size_t bytesRead = stream->peek(buffer, bytesToRead); |
| 56 | 56 |
| 57 // It is also possible to have a complete image less than bytesToRead bytes | 57 // It is also possible to have a complete image less than bytesToRead bytes |
| 58 // (e.g. a 1 x 1 wbmp), meaning peek() would return less than bytesToRead. | 58 // (e.g. a 1 x 1 wbmp), meaning peek() would return less than bytesToRead. |
| 59 // Assume that if bytesRead < bytesToRead, but > 0, the stream is shorter | 59 // Assume that if bytesRead < bytesToRead, but > 0, the stream is shorter |
| 60 // than bytesToRead, so pass that directly to the decoder. | 60 // than bytesToRead, so pass that directly to the decoder. |
| 61 // It also is possible the stream uses too small a buffer for peeking, but | 61 // It also is possible the stream uses too small a buffer for peeking, but |
| 62 // we trust the caller to use a large enough buffer. | 62 // we trust the caller to use a large enough buffer. |
| 63 | 63 |
| 64 if (0 == bytesRead) { | 64 if (0 == bytesRead) { |
| 65 SkCodecPrintf("Could not peek!\n"); | |
| 66 // It is possible the stream does not support peeking, but does support | 65 // It is possible the stream does not support peeking, but does support |
| 67 // rewinding. | 66 // rewinding. |
| 68 // Attempt to read() and pass the actual amount read to the decoder. | 67 // Attempt to read() and pass the actual amount read to the decoder. |
| 69 bytesRead = stream->read(buffer, bytesToRead); | 68 bytesRead = stream->read(buffer, bytesToRead); |
| 70 if (!stream->rewind()) { | 69 if (!stream->rewind()) { |
| 71 SkCodecPrintf("Could not rewind!\n"); | 70 SkCodecPrintf("Could not rewind!\n"); |
| 72 return nullptr; | 71 return nullptr; |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); | 373 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); |
| 375 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); | 374 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); |
| 376 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { | 375 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { |
| 377 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); | 376 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); |
| 378 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); | 377 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); |
| 379 } | 378 } |
| 380 break; | 379 break; |
| 381 } | 380 } |
| 382 } | 381 } |
| 383 } | 382 } |
| OLD | NEW |