| 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 "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkCodec_libpng.h" | 10 #include "SkCodec_libpng.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 , fNeedsRewind(false) | 41 , fNeedsRewind(false) |
| 42 {} | 42 {} |
| 43 | 43 |
| 44 bool SkCodec::rewindIfNeeded() { | 44 bool SkCodec::rewindIfNeeded() { |
| 45 // Store the value of fNeedsRewind so we can update it. Next read will | 45 // Store the value of fNeedsRewind so we can update it. Next read will |
| 46 // require a rewind. | 46 // require a rewind. |
| 47 const bool neededRewind = fNeedsRewind; | 47 const bool neededRewind = fNeedsRewind; |
| 48 fNeedsRewind = true; | 48 fNeedsRewind = true; |
| 49 return !neededRewind || fStream->rewind(); | 49 return !neededRewind || fStream->rewind(); |
| 50 } | 50 } |
| 51 |
| 52 SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo, |
| 53 const SkIRect* origSubset) { |
| 54 if (!rewindIfNeeded()) { |
| 55 return NULL; |
| 56 } |
| 57 SkIRect correctedSubset; |
| 58 if (NULL == origSubset) { |
| 59 // Caller wants the whole image. |
| 60 correctedSubset.setLTRB(0, 0, fInfo.width(), fInfo.height()); |
| 61 } else { |
| 62 correctedSubset = *origSubset; |
| 63 // Caller wants a subset. Make sure it intersects with the original |
| 64 // image. |
| 65 if (!correctedSubset.intersect(SkIRect::MakeSize(fInfo.dimensions()))) { |
| 66 return NULL; |
| 67 } |
| 68 } |
| 69 return this->onGetScanlineDecoder(dstInfo, correctedSubset); |
| 70 } |
| OLD | NEW |