| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkFrontBufferedStream.h" | 8 #include "SkFrontBufferedStream.h" |
| 9 #include "SkStream.h" | 9 #include "SkStream.h" |
| 10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // and the destination buffer. | 168 // and the destination buffer. |
| 169 size -= bytesCopied; | 169 size -= bytesCopied; |
| 170 SkASSERT(size + (fOffset - start) == totalSize); | 170 SkASSERT(size + (fOffset - start) == totalSize); |
| 171 if (dst != NULL) { | 171 if (dst != NULL) { |
| 172 dst += bytesCopied; | 172 dst += bytesCopied; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Buffer any more data that should be buffered, and copy it to the | 176 // Buffer any more data that should be buffered, and copy it to the |
| 177 // destination. | 177 // destination. |
| 178 if (size > 0 && fBufferedSoFar < fBufferSize) { | 178 if (size > 0 && fBufferedSoFar < fBufferSize && !fStream->isAtEnd()) { |
| 179 const size_t buffered = this->bufferAndWriteTo(dst, size); | 179 const size_t buffered = this->bufferAndWriteTo(dst, size); |
| 180 | 180 |
| 181 // Update the remaining number of bytes needed to read | 181 // Update the remaining number of bytes needed to read |
| 182 // and the destination buffer. | 182 // and the destination buffer. |
| 183 size -= buffered; | 183 size -= buffered; |
| 184 SkASSERT(size + (fOffset - start) == totalSize); | 184 SkASSERT(size + (fOffset - start) == totalSize); |
| 185 if (dst != NULL) { | 185 if (dst != NULL) { |
| 186 dst += buffered; | 186 dst += buffered; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (size > 0 && !fStream->isAtEnd()) { | 190 if (size > 0 && !fStream->isAtEnd()) { |
| 191 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre
am(dst, size); | 191 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre
am(dst, size); |
| 192 SkDEBUGCODE(size -= bytesReadDirectly;) | 192 SkDEBUGCODE(size -= bytesReadDirectly;) |
| 193 SkASSERT(size + (fOffset - start) == totalSize); | 193 SkASSERT(size + (fOffset - start) == totalSize); |
| 194 } | 194 } |
| 195 | 195 |
| 196 return fOffset - start; | 196 return fOffset - start; |
| 197 } | 197 } |
| OLD | NEW |