| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 140     SkASSERT(size > 0); | 140     SkASSERT(size > 0); | 
| 141     // If we get here, we have buffered all that can be buffered. | 141     // If we get here, we have buffered all that can be buffered. | 
| 142     SkASSERT(fBufferSize == fBufferedSoFar && fOffset >= fBufferSize); | 142     SkASSERT(fBufferSize == fBufferedSoFar && fOffset >= fBufferSize); | 
| 143 | 143 | 
| 144     const size_t bytesReadDirectly = fStream->read(dst, size); | 144     const size_t bytesReadDirectly = fStream->read(dst, size); | 
| 145     fOffset += bytesReadDirectly; | 145     fOffset += bytesReadDirectly; | 
| 146 | 146 | 
| 147     // If we have read past the end of the buffer, rewinding is no longer | 147     // If we have read past the end of the buffer, rewinding is no longer | 
| 148     // supported, so we can go ahead and free the memory. | 148     // supported, so we can go ahead and free the memory. | 
| 149     if (bytesReadDirectly > 0) { | 149     if (bytesReadDirectly > 0) { | 
| 150         sk_free(fBuffer.detach()); | 150         sk_free(fBuffer.release()); | 
| 151     } | 151     } | 
| 152 | 152 | 
| 153     return bytesReadDirectly; | 153     return bytesReadDirectly; | 
| 154 } | 154 } | 
| 155 | 155 | 
| 156 size_t FrontBufferedStream::peek(void* dst, size_t size) const { | 156 size_t FrontBufferedStream::peek(void* dst, size_t size) const { | 
| 157     // Keep track of the offset so we can return to it. | 157     // Keep track of the offset so we can return to it. | 
| 158     const size_t start = fOffset; | 158     const size_t start = fOffset; | 
| 159 | 159 | 
| 160     if (start >= fBufferSize) { | 160     if (start >= fBufferSize) { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 203     } | 203     } | 
| 204 | 204 | 
| 205     if (size > 0 && !fStream->isAtEnd()) { | 205     if (size > 0 && !fStream->isAtEnd()) { | 
| 206         SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre
     am(dst, size); | 206         SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre
     am(dst, size); | 
| 207         SkDEBUGCODE(size -= bytesReadDirectly;) | 207         SkDEBUGCODE(size -= bytesReadDirectly;) | 
| 208         SkASSERT(size + (fOffset - start) == totalSize); | 208         SkASSERT(size + (fOffset - start) == totalSize); | 
| 209     } | 209     } | 
| 210 | 210 | 
| 211     return fOffset - start; | 211     return fOffset - start; | 
| 212 } | 212 } | 
| OLD | NEW | 
|---|