Add size_t bytesWritten() const to SkWStream.
BUG=skia:
R=reed@google.com, mtklein@google.com, robertphillips@google.com, bungeman@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/187653003
git-svn-id: http://skia.googlecode.com/svn/trunk@13684 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 29aac13..516b036 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -189,6 +189,8 @@
virtual void newline();
virtual void flush();
+ virtual size_t bytesWritten() const = 0;
+
// helpers
bool write8(U8CPU);
@@ -369,9 +371,9 @@
*/
bool isValid() const { return fFILE != NULL; }
- size_t bytesWritten() const;
virtual bool write(const void* buffer, size_t size) SK_OVERRIDE;
virtual void flush() SK_OVERRIDE;
+ virtual size_t bytesWritten() const SK_OVERRIDE;
private:
SkFILE* fFILE;
@@ -385,7 +387,7 @@
SkMemoryWStream(void* buffer, size_t size);
virtual bool write(const void* buffer, size_t size) SK_OVERRIDE;
- size_t bytesWritten() const { return fBytesWritten; }
+ virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; }
private:
char* fBuffer;
@@ -403,12 +405,12 @@
virtual ~SkDynamicMemoryWStream();
virtual bool write(const void* buffer, size_t size) SK_OVERRIDE;
+ virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; }
// random access write
// modifies stream and returns true if offset + size is less than or equal to getOffset()
bool write(const void* buffer, size_t offset, size_t size);
bool read(void* buffer, size_t offset, size_t size);
size_t getOffset() const { return fBytesWritten; }
- size_t bytesWritten() const { return fBytesWritten; }
// copy what has been written to the stream into dst
void copyTo(void* dst) const;
@@ -444,13 +446,16 @@
class SK_API SkDebugWStream : public SkWStream {
public:
+ SkDebugWStream() : fBytesWritten(0) {}
SK_DECLARE_INST_COUNT(SkDebugWStream)
// overrides
virtual bool write(const void* buffer, size_t size) SK_OVERRIDE;
virtual void newline() SK_OVERRIDE;
+ virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; }
private:
+ size_t fBytesWritten;
typedef SkWStream INHERITED;
};