OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRefCnt_DEFINED | 8 #ifndef SkRefCnt_DEFINED |
9 #define SkRefCnt_DEFINED | 9 #define SkRefCnt_DEFINED |
10 | 10 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 template <typename T> class SkAutoTUnref : public std::unique_ptr<T, SkTUnref<T>
> { | 193 template <typename T> class SkAutoTUnref : public std::unique_ptr<T, SkTUnref<T>
> { |
194 public: | 194 public: |
195 explicit SkAutoTUnref(T* obj = nullptr) : std::unique_ptr<T, SkTUnref<T>>(ob
j) {} | 195 explicit SkAutoTUnref(T* obj = nullptr) : std::unique_ptr<T, SkTUnref<T>>(ob
j) {} |
196 | 196 |
197 operator T*() const { return this->get(); } | 197 operator T*() const { return this->get(); } |
198 | 198 |
199 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | 199 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
200 // Need to update graphics/Shader.cpp. | 200 // Need to update graphics/Shader.cpp. |
201 T* detach() { return this->release(); } | 201 T* detach() { return this->release(); } |
202 #endif | 202 #endif |
203 | |
204 // Android's std::unique_ptr's operator bool() is sometimes not explicit... | |
205 // so override it with our own explcitly explicit version. | |
206 explicit operator bool() const { return this->get() != nullptr; } | |
207 }; | 203 }; |
208 // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because i
t's templated. :( | 204 // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because i
t's templated. :( |
209 | 205 |
210 class SkAutoUnref : public SkAutoTUnref<SkRefCnt> { | 206 class SkAutoUnref : public SkAutoTUnref<SkRefCnt> { |
211 public: | 207 public: |
212 SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {} | 208 SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {} |
213 }; | 209 }; |
214 #define SkAutoUnref(...) SK_REQUIRE_LOCAL_VAR(SkAutoUnref) | 210 #define SkAutoUnref(...) SK_REQUIRE_LOCAL_VAR(SkAutoUnref) |
215 | 211 |
216 // This is a variant of SkRefCnt that's Not Virtual, so weighs 4 bytes instead o
f 8 or 16. | 212 // This is a variant of SkRefCnt that's Not Virtual, so weighs 4 bytes instead o
f 8 or 16. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 * | 447 * |
452 * This function may be helpful while we convert callers from ptr-based to sk_s
p-based parameters. | 448 * This function may be helpful while we convert callers from ptr-based to sk_s
p-based parameters. |
453 */ | 449 */ |
454 template <typename T> sk_sp<T> sk_ref_sp(T* obj) { | 450 template <typename T> sk_sp<T> sk_ref_sp(T* obj) { |
455 return sk_sp<T>(SkSafeRef(obj)); | 451 return sk_sp<T>(SkSafeRef(obj)); |
456 } | 452 } |
457 | 453 |
458 #endif | 454 #endif |
459 | 455 |
460 #endif | 456 #endif |
OLD | NEW |