From 0ca21466da7441baf471966be8c628d408752a72 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Wed, 20 Sep 2017 15:37:14 -0400 Subject: [PATCH] remove dead code for STREAM_API Bug: skia: Change-Id: I5c5a65710af443c60a3d13fb309ce31309be7f74 Reviewed-on: https://skia-review.googlesource.com/49460 Reviewed-by: Ben Wagner Commit-Queue: Mike Reed --- gm/fontscalerdistortable.cpp | 4 -- include/core/SkStream.h | 59 ++------------------- include/utils/SkFrontBufferedStream.h | 6 --- src/core/SkRWBuffer.cpp | 19 ++----- src/core/SkStream.cpp | 29 +++------- src/ports/SkFontMgr_FontConfigInterface.cpp | 4 -- src/ports/SkFontMgr_android.cpp | 4 -- src/ports/SkFontMgr_custom.cpp | 4 -- src/ports/SkFontMgr_fontconfig.cpp | 4 -- src/ports/SkFontMgr_win_dw.cpp | 4 -- src/utils/SkFrontBufferedStream.cpp | 6 --- src/utils/win/SkDWriteFontFileStream.cpp | 14 +---- src/utils/win/SkDWriteFontFileStream.h | 8 --- tests/StreamTest.cpp | 4 -- 14 files changed, 17 insertions(+), 152 deletions(-) diff --git a/gm/fontscalerdistortable.cpp b/gm/fontscalerdistortable.cpp index 30352e4b7d..e3fb99c879 100644 --- a/gm/fontscalerdistortable.cpp +++ b/gm/fontscalerdistortable.cpp @@ -53,11 +53,7 @@ protected: SkFontArguments::VariationPosition position = { coordinates, SK_ARRAY_COUNT(coordinates) }; paint.setTypeface(sk_sp(fontMgr->createFromStream( -#ifdef SK_SUPPORT_LEGACY_STREAM_API - distortable->duplicate(), -#else distortable->duplicate().release(), -#endif SkFontArguments().setVariationDesignPosition(position)))); SkAutoCanvasRestore acr(canvas, true); diff --git a/include/core/SkStream.h b/include/core/SkStream.h index 2d7a8c529d..e9e88811f3 100644 --- a/include/core/SkStream.h +++ b/include/core/SkStream.h @@ -101,16 +101,6 @@ 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. */ @@ -123,7 +113,6 @@ public: std::unique_ptr fork() const { return std::unique_ptr(this->onFork()); } -#endif //SkStreamSeekable /** Returns true if this stream can report it's current position. */ @@ -155,52 +144,39 @@ public: 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 duplicate() const { return std::unique_ptr(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 duplicate() const { return std::unique_ptr(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 fork() const { return std::unique_ptr(this->onFork()); } private: SkStreamSeekable* onDuplicate() const override = 0; SkStreamSeekable* onFork() const override = 0; -#endif }; /** SkStreamAsset is a SkStreamSeekable for which getLength is required. */ @@ -209,10 +185,6 @@ 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 duplicate() const { return std::unique_ptr(this->onDuplicate()); } @@ -222,7 +194,6 @@ public: private: SkStreamAsset* onDuplicate() const override = 0; SkStreamAsset* onFork() const override = 0; -#endif }; /** SkStreamMemory is a SkStreamAsset for which getMemoryBase is required. */ @@ -230,10 +201,6 @@ 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 duplicate() const { return std::unique_ptr(this->onDuplicate()); } @@ -243,7 +210,6 @@ public: private: SkStreamMemory* onDuplicate() const override = 0; SkStreamMemory* onFork() const override = 0; -#endif }; class SK_API SkWStream : SkNoncopyable { @@ -345,24 +311,17 @@ public: bool isAtEnd() const override; bool rewind() override; -#ifdef SK_SUPPORT_LEGACY_STREAM_API - SkStreamAsset* duplicate() const override; -#else std::unique_ptr duplicate() const { return std::unique_ptr(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 fork() const { return std::unique_ptr(this->onFork()); } -#endif size_t getLength() const override; @@ -370,10 +329,8 @@ private: explicit SkFILEStream(std::shared_ptr, size_t size, size_t offset); explicit SkFILEStream(std::shared_ptr, 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 fFILE; // My own council will I keep on sizes and offsets. @@ -430,34 +387,26 @@ 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 duplicate() const { return std::unique_ptr(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 fork() const { return std::unique_ptr(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 fData; size_t fOffset; diff --git a/include/utils/SkFrontBufferedStream.h b/include/utils/SkFrontBufferedStream.h index a47acf8a06..228c6cbab1 100644 --- a/include/utils/SkFrontBufferedStream.h +++ b/include/utils/SkFrontBufferedStream.h @@ -35,11 +35,5 @@ public: */ static std::unique_ptr Make(std::unique_ptr stream, size_t minBufferSize); - -#ifdef SK_SUPPORT_LEGACY_STREAM_API - static SkStreamRewindable* Create(SkStream* stream, size_t minBufferSize) { - return Make(std::unique_ptr(stream), minBufferSize).release(); - } -#endif }; #endif // SkFrontBufferedStream_DEFINED diff --git a/src/core/SkRWBuffer.cpp b/src/core/SkRWBuffer.cpp index 8ec2baafac..b90d617b0b 100644 --- a/src/core/SkRWBuffer.cpp +++ b/src/core/SkRWBuffer.cpp @@ -315,10 +315,6 @@ public: return fBuffer->size() == fGlobalOffset; } -#ifdef SK_SUPPORT_LEGACY_STREAM_API - SkStreamAsset* duplicate() const override { return new SkROBufferStreamAsset(fBuffer); } -#endif - size_t getPosition() const override { return fGlobalOffset; } @@ -343,23 +339,16 @@ public: return true; } -#ifdef SK_SUPPORT_LEGACY_STREAM_API - SkStreamAsset* fork() const override { - SkStreamAsset* clone = this->duplicate(); - clone->seek(this->getPosition()); - return clone; - } -#endif - private: -#ifndef SK_SUPPORT_LEGACY_STREAM_API - SkStreamAsset* onDuplicate() const override { return new SkROBufferStreamAsset(fBuffer); } + SkStreamAsset* onDuplicate() const override { + return new SkROBufferStreamAsset(fBuffer); + } + SkStreamAsset* onFork() const override { auto clone = this->duplicate(); clone->seek(this->getPosition()); return clone.release(); } -#endif sk_sp fBuffer; SkROBuffer::Iter fIter; diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp index bc638c249a..2c5e9eba2f 100644 --- a/src/core/SkStream.cpp +++ b/src/core/SkStream.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ - #include "SkStream.h" #include "SkStreamPriv.h" #include "SkData.h" @@ -15,17 +14,8 @@ #include "SkOSFile.h" #include "SkTypes.h" -#ifdef SK_SUPPORT_LEGACY_STREAM_API -#define DUP_NAME duplicate -#define FORK_NAME fork -#else -#define DUP_NAME onDuplicate -#define FORK_NAME onFork -#endif - /////////////////////////////////////////////////////////////////////////////// - int8_t SkStream::readS8() { int8_t value; SkDEBUGCODE(size_t len =) this->read(&value, 1); @@ -224,7 +214,7 @@ bool SkFILEStream::rewind() { return true; } -SkStreamAsset* SkFILEStream::DUP_NAME() const { +SkStreamAsset* SkFILEStream::onDuplicate() const { // TODO: fOriginalOffset instead of 0. return new SkFILEStream(fFILE, fSize, 0, fOriginalOffset); } @@ -242,7 +232,7 @@ bool SkFILEStream::move(long offset) { return this->seek(fOffset + offset); } -SkStreamAsset* SkFILEStream::FORK_NAME() const { +SkStreamAsset* SkFILEStream::onFork() const { return new SkFILEStream(fFILE, fSize, fOffset, fOriginalOffset); } @@ -350,12 +340,7 @@ bool SkMemoryStream::rewind() { return true; } -#ifdef SK_SUPPORT_LEGACY_STREAM_API -SkMemoryStream* SkMemoryStream::duplicate() const -#else -SkMemoryStream* SkMemoryStream::onDuplicate() const -#endif -{ +SkMemoryStream* SkMemoryStream::onDuplicate() const { return new SkMemoryStream(fData); } @@ -374,7 +359,7 @@ bool SkMemoryStream::move(long offset) { return this->seek(fOffset + offset); } -SkMemoryStream* SkMemoryStream::FORK_NAME() const { +SkMemoryStream* SkMemoryStream::onFork() const { std::unique_ptr that(this->duplicate()); that->seek(fOffset); return that.release(); @@ -746,7 +731,7 @@ public: return true; } - SkBlockMemoryStream* DUP_NAME() const override { + SkBlockMemoryStream* onDuplicate() const override { return new SkBlockMemoryStream(fBlockMemory, fSize); } @@ -775,8 +760,8 @@ public: return seek(fOffset + offset); } - SkBlockMemoryStream* FORK_NAME() const override { - SkBlockMemoryStream* that = this->DUP_NAME(); + SkBlockMemoryStream* onFork() const override { + SkBlockMemoryStream* that = this->onDuplicate(); that->fCurrent = this->fCurrent; that->fOffset = this->fOffset; that->fCurrentOffset = this->fCurrentOffset; diff --git a/src/ports/SkFontMgr_FontConfigInterface.cpp b/src/ports/SkFontMgr_FontConfigInterface.cpp index aec76af685..bfc600e74e 100644 --- a/src/ports/SkFontMgr_FontConfigInterface.cpp +++ b/src/ports/SkFontMgr_FontConfigInterface.cpp @@ -26,11 +26,7 @@ SkStreamAsset* SkTypeface_FCI::onOpenStream(int* ttcIndex) const { if (!stream) { return nullptr; } -#ifdef SK_SUPPORT_LEGACY_STREAM_API - return stream->duplicate(); -#else return stream->duplicate().release(); -#endif } return fFCI->openStream(this->getIdentity()); diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp index 0ec2edba6a..637d2f3182 100644 --- a/src/ports/SkFontMgr_android.cpp +++ b/src/ports/SkFontMgr_android.cpp @@ -129,11 +129,7 @@ public: SkStreamAsset* onOpenStream(int* ttcIndex) const override { *ttcIndex = fData->getIndex(); -#ifdef SK_SUPPORT_LEGACY_STREAM_API - return fData->getStream()->duplicate(); -#else return fData->getStream()->duplicate().release(); -#endif } std::unique_ptr onMakeFontData() const override { diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp index b38f48c322..f5aa7a3aa5 100644 --- a/src/ports/SkFontMgr_custom.cpp +++ b/src/ports/SkFontMgr_custom.cpp @@ -60,11 +60,7 @@ SkTypeface_Stream::SkTypeface_Stream(std::unique_ptr fontData, SkStreamAsset* SkTypeface_Stream::onOpenStream(int* ttcIndex) const { *ttcIndex = fData->getIndex(); -#ifdef SK_SUPPORT_LEGACY_STREAM_API - return fData->getStream()->duplicate(); -#else return fData->getStream()->duplicate().release(); -#endif } std::unique_ptr SkTypeface_Stream::onMakeFontData() const { diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp index 8b3a058e9e..1524fc9f98 100644 --- a/src/ports/SkFontMgr_fontconfig.cpp +++ b/src/ports/SkFontMgr_fontconfig.cpp @@ -435,11 +435,7 @@ public: SkStreamAsset* onOpenStream(int* ttcIndex) const override { *ttcIndex = fData->getIndex(); -#ifdef SK_SUPPORT_LEGACY_STREAM_API - return fData->getStream()->duplicate(); -#else return fData->getStream()->duplicate().release(); -#endif } std::unique_ptr onMakeFontData() const override { diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp index b349c833a0..eca20d94b7 100644 --- a/src/ports/SkFontMgr_win_dw.cpp +++ b/src/ports/SkFontMgr_win_dw.cpp @@ -86,11 +86,7 @@ HRESULT StreamFontFileLoader::CreateStreamFromKey( IDWriteFontFileStream** fontFileStream) { SkTScopedComPtr stream; -#ifdef SK_SUPPORT_LEGACY_STREAM_API - HR(SkDWriteFontFileStreamWrapper::Create(fStream->duplicate(), &stream)); -#else HR(SkDWriteFontFileStreamWrapper::Create(fStream->duplicate().release(), &stream)); -#endif *fontFileStream = stream.release(); return S_OK; } diff --git a/src/utils/SkFrontBufferedStream.cpp b/src/utils/SkFrontBufferedStream.cpp index 77c484af64..9205d104a3 100644 --- a/src/utils/SkFrontBufferedStream.cpp +++ b/src/utils/SkFrontBufferedStream.cpp @@ -26,14 +26,8 @@ public: size_t getLength() const override { return fLength; } -#ifdef SK_SUPPORT_LEGACY_STREAM_API - SkStreamRewindable* duplicate() const override { return nullptr; } -#endif - private: -#ifndef SK_SUPPORT_LEGACY_STREAM_API SkStreamRewindable* onDuplicate() const override { return nullptr; } -#endif std::unique_ptr fStream; const bool fHasLength; diff --git a/src/utils/win/SkDWriteFontFileStream.cpp b/src/utils/win/SkDWriteFontFileStream.cpp index a43e163481..54ec7c7159 100644 --- a/src/utils/win/SkDWriteFontFileStream.cpp +++ b/src/utils/win/SkDWriteFontFileStream.cpp @@ -86,12 +86,7 @@ bool SkDWriteFontFileStream::rewind() { return true; } -#ifdef SK_SUPPORT_LEGACY_STREAM_API -SkDWriteFontFileStream* SkDWriteFontFileStream::duplicate() const -#else -SkDWriteFontFileStream* SkDWriteFontFileStream::onDuplicate() const -#endif -{ +SkDWriteFontFileStream* SkDWriteFontFileStream::onDuplicate() const { return new SkDWriteFontFileStream(fFontFileStream.get()); } @@ -109,12 +104,7 @@ bool SkDWriteFontFileStream::move(long offset) { return seek(fPos + offset); } -#ifdef SK_SUPPORT_LEGACY_STREAM_API -SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const -#else -SkDWriteFontFileStream* SkDWriteFontFileStream::onFork() const -#endif -{ +SkDWriteFontFileStream* SkDWriteFontFileStream::onFork() const { std::unique_ptr that(this->duplicate()); that->seek(fPos); return that.release(); diff --git a/src/utils/win/SkDWriteFontFileStream.h b/src/utils/win/SkDWriteFontFileStream.h index 9b65752382..680b3ab8a8 100644 --- a/src/utils/win/SkDWriteFontFileStream.h +++ b/src/utils/win/SkDWriteFontFileStream.h @@ -34,24 +34,16 @@ public: size_t getLength() const override; const void* getMemoryBase() override; -#ifdef SK_SUPPORT_LEGACY_STREAM_API - SkDWriteFontFileStream* duplicate() const override; - SkDWriteFontFileStream* fork() const override; -#else std::unique_ptr duplicate() const { return std::unique_ptr(this->onDuplicate()); } std::unique_ptr fork() const { return std::unique_ptr(this->onFork()); } -#endif - private: -#ifndef SK_SUPPORT_LEGACY_STREAM_API SkDWriteFontFileStream* onDuplicate() const override; SkDWriteFontFileStream* onFork() const override; -#endif SkTScopedComPtr fFontFileStream; size_t fPos; diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp index 2e8078e337..26fea37f9e 100644 --- a/tests/StreamTest.cpp +++ b/tests/StreamTest.cpp @@ -249,11 +249,7 @@ static void test_peeking_front_buffered_stream(skiatest::Reporter* r, } // Test that attempting to peek beyond the length of the buffer does not prevent rewinding. -#ifdef SK_SUPPORT_LEGACY_STREAM_API - bufferedStream.reset(SkFrontBufferedStream::Create(original.duplicate(), bufferSize)); -#else bufferedStream = SkFrontBufferedStream::Make(original.duplicate(), bufferSize); -#endif REPORTER_ASSERT(r, bufferedStream != nullptr); const size_t bytesToPeek = bufferSize + 1;