diff options
author | Hal Canary <halcanary@google.com> | 2018-04-24 13:58:37 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-24 19:13:56 +0000 |
commit | 6736236fafb93080cc8954c0016c05afcf9824a0 (patch) | |
tree | a4d55c6b9da9185539f55fd336f7ceeb1f067ffb /src/pdf | |
parent | 849dce1d7bc10b532c3d8f81a503416caf5f444e (diff) |
include/private/SkTemplates: Cleanup bare pointers.
include/private:
- SkAutoTArray, SkAutoTMalloc no longer use bare pointers to owned memory,
- SkTHash and SkAutoTArray are now std::move()able.
- SkAutoTArray::swap no longer neccesary.
- SkAutoTMalloc::operator=() defined.
src/pdf:
- SkPDFCanon and SkPDFObjectSerializer are now std::move()able.
- `template <class T> static void renew(T* t) { t->~T(); new (t) T; }` is gone.
Change-Id: I2f36a0780c47d1427a85da240121c898387fb4cf
Reviewed-on: https://skia-review.googlesource.com/123401
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/SkPDFCanon.cpp | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFCanon.h | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.cpp | 9 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.h | 3 |
4 files changed, 12 insertions, 4 deletions
diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp index 53a00443a8..ec750da386 100644 --- a/src/pdf/SkPDFCanon.cpp +++ b/src/pdf/SkPDFCanon.cpp @@ -12,5 +12,7 @@ SkPDFCanon::~SkPDFCanon() {} SkPDFCanon::SkPDFCanon() {} +SkPDFCanon::SkPDFCanon(SkPDFCanon&&) = default; +SkPDFCanon& SkPDFCanon::operator=(SkPDFCanon&&) = default; diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h index 3c0e87bb1c..99d8ab8a0d 100644 --- a/src/pdf/SkPDFCanon.h +++ b/src/pdf/SkPDFCanon.h @@ -26,7 +26,9 @@ class SkPDFCanon { public: ~SkPDFCanon(); SkPDFCanon(); + SkPDFCanon(SkPDFCanon&&); SkPDFCanon(const SkPDFCanon&) = delete; + SkPDFCanon& operator=(SkPDFCanon&&); SkPDFCanon& operator=(const SkPDFCanon&) = delete; SkTHashMap<SkPDFImageShaderKey, sk_sp<SkPDFObject>> fImageShaderMap; diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index 5668f29d2c..16f0c11a40 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -16,13 +16,14 @@ SkPDFObjectSerializer::SkPDFObjectSerializer() : fBaseOffset(0), fNextToBeSerialized(0) {} -template <class T> static void renew(T* t) { t->~T(); new (t) T; } - SkPDFObjectSerializer::~SkPDFObjectSerializer() { for (int i = 0; i < fObjNumMap.objects().count(); ++i) { fObjNumMap.objects()[i]->drop(); } } +SkPDFObjectSerializer::SkPDFObjectSerializer(SkPDFObjectSerializer&&) = default; +SkPDFObjectSerializer& SkPDFObjectSerializer::operator=(SkPDFObjectSerializer&&) = default; + void SkPDFObjectSerializer::addObjectRecursively(const sk_sp<SkPDFObject>& object) { fObjNumMap.addObjectRecursively(object.get()); @@ -242,8 +243,8 @@ void SkPDFDocument::onAbort() { void SkPDFDocument::reset() { fCanvas.reset(nullptr); fPages.reset(); - renew(&fCanon); - renew(&fObjectSerializer); + fCanon = SkPDFCanon(); + fObjectSerializer = SkPDFObjectSerializer(); fFonts.reset(); } diff --git a/src/pdf/SkPDFDocument.h b/src/pdf/SkPDFDocument.h index ed92554bdf..069bd0f2ba 100644 --- a/src/pdf/SkPDFDocument.h +++ b/src/pdf/SkPDFDocument.h @@ -38,6 +38,9 @@ struct SkPDFObjectSerializer : SkNoncopyable { SkPDFObjectSerializer(); ~SkPDFObjectSerializer(); + SkPDFObjectSerializer(SkPDFObjectSerializer&&); + SkPDFObjectSerializer& operator=(SkPDFObjectSerializer&&); + void addObjectRecursively(const sk_sp<SkPDFObject>&); void serializeHeader(SkWStream*, const SkDocument::PDFMetadata&); void serializeObjects(SkWStream*); |