aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkStream.h121
-rw-r--r--include/utils/SkFrontBufferedStream.h14
2 files changed, 15 insertions, 120 deletions
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 2d7a8c529d..5ef8519245 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -101,29 +101,10 @@ public:
*/
virtual bool rewind() { return false; }
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
/** Duplicates this stream. If this cannot be done, returns NULL.
* The returned stream will be positioned at the beginning of its data.
*/
virtual SkStreamRewindable* duplicate() const { return nullptr; }
- /** Duplicates this stream. If this cannot be done, returns NULL.
- * The returned stream will be positioned the same as this stream.
- */
- virtual SkStreamSeekable* fork() const { return nullptr; }
-#else
- /** Duplicates this stream. If this cannot be done, returns NULL.
- * The returned stream will be positioned at the beginning of its data.
- */
- std::unique_ptr<SkStream> duplicate() const {
- return std::unique_ptr<SkStream>(this->onDuplicate());
- }
- /** Duplicates this stream. If this cannot be done, returns NULL.
- * The returned stream will be positioned the same as this stream.
- */
- std::unique_ptr<SkStream> fork() const {
- return std::unique_ptr<SkStream>(this->onFork());
- }
-#endif
//SkStreamSeekable
/** Returns true if this stream can report it's current position. */
@@ -143,6 +124,11 @@ public:
*/
virtual bool move(long /*offset*/) { return false; }
+ /** Duplicates this stream. If this cannot be done, returns NULL.
+ * The returned stream will be positioned the same as this stream.
+ */
+ virtual SkStreamSeekable* fork() const { return nullptr; }
+
//SkStreamAsset
/** Returns true if this stream can report it's total length. */
virtual bool hasLength() const { return false; }
@@ -153,97 +139,44 @@ public:
/** Returns the starting address for the data. If this cannot be done, returns NULL. */
//TODO: replace with virtual const SkData* getData()
virtual const void* getMemoryBase() { return nullptr; }
-
-private:
-#ifndef SK_SUPPORT_LEGACY_STREAM_API
- virtual SkStream* onDuplicate() const { return nullptr; }
- virtual SkStream* onFork() const { return nullptr; }
-#endif
};
/** SkStreamRewindable is a SkStream for which rewind and duplicate are required. */
class SK_API SkStreamRewindable : public SkStream {
public:
bool rewind() override = 0;
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamRewindable* duplicate() const override = 0;
-#else
- std::unique_ptr<SkStreamRewindable> duplicate() const {
- return std::unique_ptr<SkStreamRewindable>(this->onDuplicate());
- }
-private:
- SkStreamRewindable* onDuplicate() const override = 0;
-#endif
};
/** SkStreamSeekable is a SkStreamRewindable for which position, seek, move, and fork are required. */
class SK_API SkStreamSeekable : public SkStreamRewindable {
public:
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamSeekable* duplicate() const override = 0;
-#else
- std::unique_ptr<SkStreamSeekable> duplicate() const {
- return std::unique_ptr<SkStreamSeekable>(this->onDuplicate());
- }
-#endif
bool hasPosition() const override { return true; }
size_t getPosition() const override = 0;
bool seek(size_t position) override = 0;
bool move(long offset) override = 0;
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamSeekable* fork() const override = 0;
-#else
- std::unique_ptr<SkStreamSeekable> fork() const {
- return std::unique_ptr<SkStreamSeekable>(this->onFork());
- }
-private:
- SkStreamSeekable* onDuplicate() const override = 0;
- SkStreamSeekable* onFork() const override = 0;
-#endif
};
/** SkStreamAsset is a SkStreamSeekable for which getLength is required. */
class SK_API SkStreamAsset : public SkStreamSeekable {
public:
- bool hasLength() const override { return true; }
- size_t getLength() const override = 0;
-
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamAsset* duplicate() const override = 0;
SkStreamAsset* fork() const override = 0;
-#else
- std::unique_ptr<SkStreamAsset> duplicate() const {
- return std::unique_ptr<SkStreamAsset>(this->onDuplicate());
- }
- std::unique_ptr<SkStreamAsset> fork() const {
- return std::unique_ptr<SkStreamAsset>(this->onFork());
- }
-private:
- SkStreamAsset* onDuplicate() const override = 0;
- SkStreamAsset* onFork() const override = 0;
-#endif
+
+ bool hasLength() const override { return true; }
+ size_t getLength() const override = 0;
};
/** SkStreamMemory is a SkStreamAsset for which getMemoryBase is required. */
class SK_API SkStreamMemory : public SkStreamAsset {
public:
- const void* getMemoryBase() override = 0;
-
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamMemory* duplicate() const override = 0;
SkStreamMemory* fork() const override = 0;
-#else
- std::unique_ptr<SkStreamMemory> duplicate() const {
- return std::unique_ptr<SkStreamMemory>(this->onDuplicate());
- }
- std::unique_ptr<SkStreamMemory> fork() const {
- return std::unique_ptr<SkStreamMemory>(this->onFork());
- }
-private:
- SkStreamMemory* onDuplicate() const override = 0;
- SkStreamMemory* onFork() const override = 0;
-#endif
+
+ const void* getMemoryBase() override = 0;
};
class SK_API SkWStream : SkNoncopyable {
@@ -345,24 +278,12 @@ public:
bool isAtEnd() const override;
bool rewind() override;
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamAsset* duplicate() const override;
-#else
- std::unique_ptr<SkStreamAsset> duplicate() const {
- return std::unique_ptr<SkStreamAsset>(this->onDuplicate());
- }
-#endif
size_t getPosition() const override;
bool seek(size_t position) override;
bool move(long offset) override;
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkStreamAsset* fork() const override;
-#else
- std::unique_ptr<SkStreamAsset> fork() const {
- return std::unique_ptr<SkStreamAsset>(this->onFork());
- }
-#endif
size_t getLength() const override;
@@ -370,11 +291,6 @@ private:
explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset);
explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset, size_t originalOffset);
-#ifndef SK_SUPPORT_LEGACY_STREAM_API
- SkStreamAsset* onDuplicate() const override;
- SkStreamAsset* onFork() const override;
-#endif
-
std::shared_ptr<FILE> fFILE;
// My own council will I keep on sizes and offsets.
size_t fSize;
@@ -430,35 +346,18 @@ public:
size_t peek(void* buffer, size_t size) const override;
bool rewind() override;
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkMemoryStream* duplicate() const override;
-#else
- std::unique_ptr<SkMemoryStream> duplicate() const {
- return std::unique_ptr<SkMemoryStream>(this->onDuplicate());
- }
-#endif
size_t getPosition() const override;
bool seek(size_t position) override;
bool move(long offset) override;
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
SkMemoryStream* fork() const override;
-#else
- std::unique_ptr<SkMemoryStream> fork() const {
- return std::unique_ptr<SkMemoryStream>(this->onFork());
- }
-#endif
size_t getLength() const override;
const void* getMemoryBase() override;
private:
-#ifndef SK_SUPPORT_LEGACY_STREAM_API
- SkMemoryStream* onDuplicate() const override;
- SkMemoryStream* onFork() const override;
-#endif
-
sk_sp<SkData> fData;
size_t fOffset;
diff --git a/include/utils/SkFrontBufferedStream.h b/include/utils/SkFrontBufferedStream.h
index a47acf8a06..3532fc5259 100644
--- a/include/utils/SkFrontBufferedStream.h
+++ b/include/utils/SkFrontBufferedStream.h
@@ -8,7 +8,10 @@
#ifndef SkFrontBufferedStream_DEFINED
#define SkFrontBufferedStream_DEFINED
-#include "SkStream.h"
+#include "SkTypes.h"
+
+class SkStream;
+class SkStreamRewindable;
/**
* Specialized stream that buffers the first X bytes of a stream,
@@ -33,13 +36,6 @@ public:
* NULL on failure. The caller is required to delete when finished with
* this object.
*/
- static std::unique_ptr<SkStreamRewindable> Make(std::unique_ptr<SkStream> stream,
- size_t minBufferSize);
-
-#ifdef SK_SUPPORT_LEGACY_STREAM_API
- static SkStreamRewindable* Create(SkStream* stream, size_t minBufferSize) {
- return Make(std::unique_ptr<SkStream>(stream), minBufferSize).release();
- }
-#endif
+ static SkStreamRewindable* Create(SkStream* stream, size_t minBufferSize);
};
#endif // SkFrontBufferedStream_DEFINED