diff options
author | halcanary <halcanary@google.com> | 2016-09-02 11:29:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-02 11:29:46 -0700 |
commit | 022c2bd37a3d5b1611928b67e0be1c30a1a0946f (patch) | |
tree | 7b7d317361d1a0c10633575081c662b2a79502d8 /src/pdf | |
parent | 233eb0adc7df47ac38eac20231f4b04e90cb0d8d (diff) |
SkMakeUnique.h defines skstd::make_unique<T>(Args...)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2293963002
Review-Url: https://codereview.chromium.org/2293963002
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/SkDeflate.cpp | 3 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 11 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.cpp | 4 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.cpp | 4 |
4 files changed, 12 insertions, 10 deletions
diff --git a/src/pdf/SkDeflate.cpp b/src/pdf/SkDeflate.cpp index 2c5a3caffe..c2b85fccb3 100644 --- a/src/pdf/SkDeflate.cpp +++ b/src/pdf/SkDeflate.cpp @@ -8,6 +8,7 @@ #include "SkData.h" #include "SkDeflate.h" +#include "SkMakeUnique.h" #include "zlib.h" @@ -62,7 +63,7 @@ struct SkDeflateWStream::Impl { SkDeflateWStream::SkDeflateWStream(SkWStream* out, int compressionLevel, bool gzip) - : fImpl(new SkDeflateWStream::Impl) { + : fImpl(skstd::make_unique<SkDeflateWStream::Impl>()) { fImpl->fOut = out; fImpl->fInBufferIndex = 0; if (!fImpl->fOut) { diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 24df879a9d..e92990317c 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -13,6 +13,7 @@ #include "SkColorFilter.h" #include "SkDraw.h" #include "SkGlyphCache.h" +#include "SkMakeUnique.h" #include "SkPath.h" #include "SkPathEffect.h" #include "SkPathOps.h" @@ -1344,11 +1345,11 @@ std::unique_ptr<SkStreamAsset> SkPDFDevice::content() const { entry.fContent.writeToStream(&buffer); } gsState.drainStack(); - - return std::unique_ptr<SkStreamAsset>( - buffer.bytesWritten() > 0 - ? buffer.detachAsStream() - : new SkMemoryStream); + if (buffer.bytesWritten() > 0) { + return std::unique_ptr<SkStreamAsset>(buffer.detachAsStream()); + } else { + return skstd::make_unique<SkMemoryStream>(); + } } /* Draws an inverse filled path by using Path Ops to compute the positive diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index 75c5de91e3..6122dbd565 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "SkMakeUnique.h" #include "SkPDFCanon.h" #include "SkPDFCanvas.h" #include "SkPDFDevice.h" @@ -167,7 +168,6 @@ static sk_sp<SkPDFDict> generate_page_tree(SkTArray<sk_sp<SkPDFDict>>* pages) { return std::move(curNodes[0]); } -template <typename T> static T* clone(const T* o) { return o ? new T(*o) : nullptr; } //////////////////////////////////////////////////////////////////////////////// SkPDFDocument::SkPDFDocument(SkWStream* stream, @@ -466,7 +466,7 @@ sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream, sk_sp<SkDocument> SkDocument::MakePDF(const char path[], SkScalar dpi) { auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; - std::unique_ptr<SkFILEWStream> stream(new SkFILEWStream(path)); + auto stream = skstd::make_unique<SkFILEWStream>(path); return stream->isValid() ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, SkDocument::PDFMetadata(), nullptr, diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp index 838b5efeb9..7a1e0a48f5 100644 --- a/src/pdf/SkPDFTypes.cpp +++ b/src/pdf/SkPDFTypes.cpp @@ -7,6 +7,7 @@ #include "SkData.h" #include "SkDeflate.h" +#include "SkMakeUnique.h" #include "SkPDFTypes.h" #include "SkPDFUtils.h" #include "SkStream.h" @@ -506,8 +507,7 @@ void SkPDFSharedStream::addResources( //////////////////////////////////////////////////////////////////////////////// SkPDFStream:: SkPDFStream(sk_sp<SkData> data) { - this->setData(std::unique_ptr<SkStreamAsset>( - new SkMemoryStream(std::move(data)))); + this->setData(skstd::make_unique<SkMemoryStream>(std::move(data))); } SkPDFStream::SkPDFStream(std::unique_ptr<SkStreamAsset> stream) { |