remove dead code for STREAM_API

Bug: skia:
Change-Id: I5c5a65710af443c60a3d13fb309ce31309be7f74
Reviewed-on: https://skia-review.googlesource.com/49460
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2017-09-20 15:37:14 -04:00 committed by Skia Commit-Bot
parent d4f100dad9
commit 0ca21466da
14 changed files with 17 additions and 152 deletions

View File

@ -53,11 +53,7 @@ protected:
SkFontArguments::VariationPosition position =
{ coordinates, SK_ARRAY_COUNT(coordinates) };
paint.setTypeface(sk_sp<SkTypeface>(fontMgr->createFromStream(
#ifdef SK_SUPPORT_LEGACY_STREAM_API
distortable->duplicate(),
#else
distortable->duplicate().release(),
#endif
SkFontArguments().setVariationDesignPosition(position))));
SkAutoCanvasRestore acr(canvas, true);

View File

@ -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<SkStream> fork() const {
return std::unique_ptr<SkStream>(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<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. */
@ -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<SkStreamAsset> duplicate() const {
return std::unique_ptr<SkStreamAsset>(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<SkStreamMemory> duplicate() const {
return std::unique_ptr<SkStreamMemory>(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<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,10 +329,8 @@ 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.
@ -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<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;

View File

@ -35,11 +35,5 @@ public:
*/
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
};
#endif // SkFrontBufferedStream_DEFINED

View File

@ -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<SkROBuffer> fBuffer;
SkROBuffer::Iter fIter;

View File

@ -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<SkMemoryStream> 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;

View File

@ -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());

View File

@ -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<SkFontData> onMakeFontData() const override {

View File

@ -60,11 +60,7 @@ SkTypeface_Stream::SkTypeface_Stream(std::unique_ptr<SkFontData> 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<SkFontData> SkTypeface_Stream::onMakeFontData() const {

View File

@ -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<SkFontData> onMakeFontData() const override {

View File

@ -86,11 +86,7 @@ HRESULT StreamFontFileLoader::CreateStreamFromKey(
IDWriteFontFileStream** fontFileStream)
{
SkTScopedComPtr<SkDWriteFontFileStreamWrapper> 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;
}

View File

@ -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<SkStream> fStream;
const bool fHasLength;

View File

@ -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<SkDWriteFontFileStream> that(this->duplicate());
that->seek(fPos);
return that.release();

View File

@ -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<SkDWriteFontFileStream> duplicate() const {
return std::unique_ptr<SkDWriteFontFileStream>(this->onDuplicate());
}
std::unique_ptr<SkDWriteFontFileStream> fork() const {
return std::unique_ptr<SkDWriteFontFileStream>(this->onFork());
}
#endif
private:
#ifndef SK_SUPPORT_LEGACY_STREAM_API
SkDWriteFontFileStream* onDuplicate() const override;
SkDWriteFontFileStream* onFork() const override;
#endif
SkTScopedComPtr<IDWriteFontFileStream> fFontFileStream;
size_t fPos;

View File

@ -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;