bool FrontBufferedStream::peek(void* dst, size_t size) const { // Keep track of the offset so we can return to it. const size_t start = fOffset; if (start + size > fBufferSize) { // This stream is not able to buffer enough. return false; } FrontBufferedStream* nonConstThis = const_cast<FrontBufferedStream*>(this); SkDEBUGCODE(const size_t bytesRead =) nonConstThis->read(dst, size); SkASSERT(bytesRead == size); nonConstThis->fOffset = start; return true; }
size_t FrontBufferedStream::peek(void* dst, size_t size) const { // Keep track of the offset so we can return to it. const size_t start = fOffset; if (start >= fBufferSize) { // This stream is not able to buffer. return 0; } size = SkTMin(size, fBufferSize - start); FrontBufferedStream* nonConstThis = const_cast<FrontBufferedStream*>(this); const size_t bytesRead = nonConstThis->read(dst, size); nonConstThis->fOffset = start; return bytesRead; }