aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/win
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-09-15 21:39:47 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-16 02:04:23 +0000
commit98c5d92ee60f6d395f9591891922aa9852a497ee (patch)
tree239001c6ffe06559fd7425ba1549f30d9cbc1c37 /src/utils/win
parent7e4e99386fe6e7bf131ba8461dcb1990bf15e346 (diff)
Revert "Revert "use unique_ptr for stream api""
This reverts commit 7031b247c9fe0cb8fa32129f9bc24fea2043cee2. Bug: skia: Change-Id: I24c34bbee703f02994be8e206bcb9c10b5427d84 Reviewed-on: https://skia-review.googlesource.com/47541 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/utils/win')
-rw-r--r--src/utils/win/SkDWriteFontFileStream.cpp14
-rw-r--r--src/utils/win/SkDWriteFontFileStream.h20
2 files changed, 30 insertions, 4 deletions
diff --git a/src/utils/win/SkDWriteFontFileStream.cpp b/src/utils/win/SkDWriteFontFileStream.cpp
index 2bb7d0fb4e..a43e163481 100644
--- a/src/utils/win/SkDWriteFontFileStream.cpp
+++ b/src/utils/win/SkDWriteFontFileStream.cpp
@@ -86,7 +86,12 @@ bool SkDWriteFontFileStream::rewind() {
return true;
}
-SkDWriteFontFileStream* SkDWriteFontFileStream::duplicate() const {
+#ifdef SK_SUPPORT_LEGACY_STREAM_API
+SkDWriteFontFileStream* SkDWriteFontFileStream::duplicate() const
+#else
+SkDWriteFontFileStream* SkDWriteFontFileStream::onDuplicate() const
+#endif
+{
return new SkDWriteFontFileStream(fFontFileStream.get());
}
@@ -104,7 +109,12 @@ bool SkDWriteFontFileStream::move(long offset) {
return seek(fPos + offset);
}
-SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const {
+#ifdef SK_SUPPORT_LEGACY_STREAM_API
+SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const
+#else
+SkDWriteFontFileStream* SkDWriteFontFileStream::onFork() const
+#endif
+{
std::unique_ptr<SkDWriteFontFileStream> that(this->duplicate());
that->seek(fPos);
return that.release();
diff --git a/src/utils/win/SkDWriteFontFileStream.h b/src/utils/win/SkDWriteFontFileStream.h
index 25322c5657..9b65752382 100644
--- a/src/utils/win/SkDWriteFontFileStream.h
+++ b/src/utils/win/SkDWriteFontFileStream.h
@@ -28,15 +28,31 @@ public:
size_t read(void* buffer, size_t size) override;
bool isAtEnd() const override;
bool rewind() override;
- SkDWriteFontFileStream* duplicate() const override;
size_t getPosition() const override;
bool seek(size_t position) override;
bool move(long offset) override;
- SkDWriteFontFileStream* fork() const override;
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;
const void* fLockedMemory;