Chromium Code Reviews| Index: include/utils/SkFrontBufferedStream.h |
| diff --git a/include/utils/SkFrontBufferedStream.h b/include/utils/SkFrontBufferedStream.h |
| index e3eb4dbad1acfc4d9d091c322027ac9d8ef7da44..0450032dcfd26e13f010c4a504422e87cb6bd5d0 100644 |
| --- a/include/utils/SkFrontBufferedStream.h |
| +++ b/include/utils/SkFrontBufferedStream.h |
| @@ -5,8 +5,10 @@ |
| * found in the LICENSE file. |
| */ |
| -#include "SkStream.h" |
| -#include "SkTemplates.h" |
| +#include "SkTypes.h" |
| + |
| +class SkStream; |
| +class SkStreamRewindable; |
| /** |
| * Specialized stream that only buffers the first X bytes of a stream, |
| @@ -16,8 +18,7 @@ |
| * knows that rewind will only be called from within X bytes (inclusive), |
| * and the wrapped stream is not necessarily able to rewind at all. |
| */ |
| -class SkFrontBufferedStream : public SkStreamRewindable { |
| -public: |
| +namespace SkFrontBufferedStream { |
|
reed1
2013/11/12 15:58:45
class is what we usually use here for skia, though
scroggo
2013/11/12 17:28:57
Done.
|
| /** |
| * Creates a new stream that wraps and buffers SkStream. |
| * @param stream SkStream to buffer. If NULL, NULL is returned. After |
| @@ -26,52 +27,5 @@ public: |
| * @param bufferSize Exact size of the buffer to be used. |
| * @return An SkStream that can buffer up to bufferSize. |
| */ |
| - static SkStreamRewindable* Create(SkStream* stream, size_t bufferSize); |
| - |
| - virtual size_t read(void* buffer, size_t size) SK_OVERRIDE; |
| - |
| - virtual bool isAtEnd() const SK_OVERRIDE; |
| - |
| - virtual bool rewind() SK_OVERRIDE; |
| - |
| - virtual bool hasPosition() const SK_OVERRIDE { return true; } |
| - |
| - virtual size_t getPosition() const SK_OVERRIDE { return fOffset; } |
| - |
| - virtual bool hasLength() const SK_OVERRIDE; |
| - |
| - virtual size_t getLength() const SK_OVERRIDE; |
| - |
| - virtual SkStreamRewindable* duplicate() const SK_OVERRIDE { return NULL; } |
| - |
| -private: |
| - SkAutoTUnref<SkStream> fStream; |
| - // Current offset into the stream. Always >= 0. |
| - size_t fOffset; |
| - // Amount that has been buffered by calls to read. Will always be less than |
| - // fBufferSize. |
| - size_t fBufferedSoFar; |
| - // Total size of the buffer. |
| - const size_t fBufferSize; |
| - SkAutoTMalloc<char> fBuffer; |
| - |
| - // Private. Use Create. |
| - SkFrontBufferedStream(SkStream*, size_t bufferSize); |
| - |
| - // Read up to size bytes from already buffered data, and copy to |
| - // dst, if non-NULL. Updates fOffset. Assumes that fOffset is less |
| - // than fBufferedSoFar. |
| - size_t readFromBuffer(char* dst, size_t size); |
| - |
| - // Buffer up to size bytes from the stream, and copy to dst if non- |
| - // NULL. Updates fOffset and fBufferedSoFar. Assumes that fOffset is |
| - // less than fBufferedSoFar, and size is greater than 0. |
| - size_t bufferAndWriteTo(char* dst, size_t size); |
| - |
| - // Read up to size bytes directly from the stream and into dst if non- |
| - // NULL. Updates fOffset. Assumes fOffset is at or beyond the buffered |
| - // data, and size is greater than 0. |
| - size_t readDirectlyFromStream(char* dst, size_t size); |
| - |
| - typedef SkStream INHERITED; |
| -}; |
| + SkStreamRewindable* Create(SkStream* stream, size_t bufferSize); |
| +} // namespace |