diff options
author | mtklein <mtklein@google.com> | 2016-01-24 19:49:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-24 19:49:24 -0800 |
commit | 1138be45eac9dd21b094c9774a6f9c612f9f8fa8 (patch) | |
tree | 5f87d06c8420e41f3b2595b5f401f7188367f3b3 /include/private/SkTemplates.h | |
parent | ccf1de0d9aa75f29829f1c4c462214b991fd8c9e (diff) |
Revert of skstd -> std for unique_ptr (patchset #24 id:460001 of https://codereview.chromium.org/1436033003/ )
Reason for revert:
Still need an answer for SkAdvancedTypefaceMetrics (at least for Google3 iOS build).
Original issue's description:
> skstd -> std for unique_ptr
>
> TBR=reed@google.com
> No public API changes.
>
> BUG=skia:4564
>
> Committed: https://skia.googlesource.com/skia/+/755c553c17b82bb5de3d9cc8d3b2a866ff9e9e50
>
> CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot,Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link-Trybot;client.skia:Perf-Mac10.9-Clang-MacMini6.2-CPU-AVX-x86_64-Release-Trybot,Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Release-Trybot
>
> Committed: https://skia.googlesource.com/skia/+/06189155d987db5c7e69015f6ea87c2168d6a065
>
> Committed: https://skia.googlesource.com/skia/+/70e8dfca4a7f5bce97b8021a6e378c4828b09c8c
>
> Committed: https://skia.googlesource.com/skia/+/dadfc245cc9a0279ff7b73da3344f2ca5d139907
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1436033003
>
> Committed: https://skia.googlesource.com/skia/+/ccf1de0d9aa75f29829f1c4c462214b991fd8c9e
TBR=bungeman@google.com,mtklein@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4564
Review URL: https://codereview.chromium.org/1626873004
Diffstat (limited to 'include/private/SkTemplates.h')
-rw-r--r-- | include/private/SkTemplates.h | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h index 9776a99631..496cf42733 100644 --- a/include/private/SkTemplates.h +++ b/include/private/SkTemplates.h @@ -13,8 +13,8 @@ #include "SkMath.h" #include "SkTLogic.h" #include "SkTypes.h" +#include "SkUniquePtr.h" #include <limits.h> -#include <memory> #include <new> /** \file SkTemplates.h @@ -57,18 +57,13 @@ template <typename R, typename T, R (*P)(T*)> struct SkFunctionWrapper { reference is null when the destructor is called, we do not call the function. */ -template <typename T, void (*P)(T*)> class SkAutoTCallVProc { +template <typename T, void (*P)(T*)> class SkAutoTCallVProc + : public skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>> { public: - SkAutoTCallVProc(T* obj) : fPtr(obj) {} + SkAutoTCallVProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {} - T* get() const { return fPtr.get(); } - operator T* () const { return fPtr.get(); } - T* operator->() const { return fPtr.get(); } - - T* detach() { return fPtr.release(); } - void reset(T* ptr = nullptr) { fPtr.reset(ptr); } -private: - std::unique_ptr<T, SkFunctionWrapper<void, T, P>> fPtr; + operator T*() const { return this->get(); } + T* detach() { return this->release(); } }; /** \class SkAutoTCallIProc @@ -79,18 +74,13 @@ If detach() is called, the object reference is set to null. If the object reference is null when the destructor is called, we do not call the function. */ -template <typename T, int (*P)(T*)> class SkAutoTCallIProc { +template <typename T, int (*P)(T*)> class SkAutoTCallIProc + : public skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>> { public: - SkAutoTCallIProc(T* obj) : fPtr(obj) {} + SkAutoTCallIProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {} - T* get() const { return fPtr.get(); } - operator T* () const { return fPtr.get(); } - T* operator->() const { return fPtr.get(); } - - T* detach() { return fPtr.release(); } - void reset(T* ptr = nullptr) { fPtr.reset(ptr); } -private: - std::unique_ptr<T, SkFunctionWrapper<int, T, P>> fPtr; + operator T*() const { return this->get(); } + T* detach() { return this->release(); } }; /** \class SkAutoTDelete @@ -103,27 +93,18 @@ private: The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) */ -template <typename T> class SkAutoTDelete { +template <typename T> class SkAutoTDelete : public skstd::unique_ptr<T> { public: - SkAutoTDelete(T* obj = NULL) : fPtr(obj) {} + SkAutoTDelete(T* obj = NULL) : skstd::unique_ptr<T>(obj) {} - void swap(SkAutoTDelete& other) { fPtr.swap(other.fPtr); } - - T* get() const { return fPtr.get(); } - operator T* () const { return fPtr.get(); } - T* operator->() const { return fPtr.get(); } - - void reset(T* ptr = nullptr) { fPtr.reset(ptr); } - void free() { fPtr.reset(nullptr); } - T* detach() { return fPtr.release(); } - T* release() { return fPtr.release(); } -private: - std::unique_ptr<T> fPtr; + operator T*() const { return this->get(); } + void free() { this->reset(nullptr); } + T* detach() { return this->release(); } }; -template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> { +template <typename T> class SkAutoTDeleteArray : public skstd::unique_ptr<T[]> { public: - SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {} + SkAutoTDeleteArray(T array[]) : skstd::unique_ptr<T[]>(array) {} void free() { this->reset(nullptr); } T* detach() { return this->release(); } |