Index: src/core/SkStream.cpp |
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp |
index 426f5569e887fe83e4aee8b38c412587abfa1fe2..ad67a0ba7db43759c8c6f9e03ff2f25bc0ac43ca 100644 |
--- a/src/core/SkStream.cpp |
+++ b/src/core/SkStream.cpp |
@@ -367,6 +367,20 @@ size_t SkMemoryStream::read(void* buffer, size_t size) { |
return size; |
} |
+bool SkMemoryStream::peek(void* buffer, size_t size) const { |
+ SkASSERT(buffer != NULL); |
+ const size_t position = fOffset; |
+ if (size > fData->size() - position) { |
+ // The stream is not large enough to satisfy this request. |
+ return false; |
+ } |
+ SkMemoryStream* nonConstThis = const_cast<SkMemoryStream*>(this); |
+ SkDEBUGCODE(const size_t bytesRead =) nonConstThis->read(buffer, size); |
+ SkASSERT(bytesRead == size); |
+ nonConstThis->fOffset = position; |
+ return true; |
+} |
+ |
bool SkMemoryStream::isAtEnd() const { |
return fOffset == fData->size(); |
} |