Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: include/core/SkRefCnt.h

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkColorFilter.h ('k') | include/core/SkShader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 * This can be used for classes inheriting from SkRefCnt, but it also works for other 257 * This can be used for classes inheriting from SkRefCnt, but it also works for other
258 * classes that match the interface, but have different internal choices: e.g. the hosted class 258 * classes that match the interface, but have different internal choices: e.g. the hosted class
259 * may have its ref/unref be thread-safe, but that is not assumed/imposed by sk _sp. 259 * may have its ref/unref be thread-safe, but that is not assumed/imposed by sk _sp.
260 */ 260 */
261 template <typename T> class sk_sp { 261 template <typename T> class sk_sp {
262 /** Supports safe bool idiom. Obsolete with explicit operator bool. */ 262 /** Supports safe bool idiom. Obsolete with explicit operator bool. */
263 using unspecified_bool_type = T* sk_sp::*; 263 using unspecified_bool_type = T* sk_sp::*;
264 public: 264 public:
265 using element_type = T; 265 using element_type = T;
266 266
267 sk_sp() : fPtr(nullptr) {} 267 constexpr sk_sp() : fPtr(nullptr) {}
268 sk_sp(std::nullptr_t) : fPtr(nullptr) {} 268 constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {}
269 269
270 /** 270 /**
271 * Shares the underlying object by calling ref(), so that both the argument and the newly 271 * Shares the underlying object by calling ref(), so that both the argument and the newly
272 * created sk_sp both have a reference to it. 272 * created sk_sp both have a reference to it.
273 */ 273 */
274 sk_sp(const sk_sp<T>& that) : fPtr(SkSafeRef(that.get())) {} 274 sk_sp(const sk_sp<T>& that) : fPtr(SkSafeRef(that.get())) {}
275 template <typename U, typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>> 275 template <typename U, typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>>
276 sk_sp(const sk_sp<U>& that) : fPtr(SkSafeRef(that.get())) {} 276 sk_sp(const sk_sp<U>& that) : fPtr(SkSafeRef(that.get())) {}
277 277
278 /** 278 /**
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 * 460 *
461 * This function may be helpful while we convert callers from ptr-based to sk_s p-based parameters. 461 * This function may be helpful while we convert callers from ptr-based to sk_s p-based parameters.
462 */ 462 */
463 template <typename T> sk_sp<T> sk_ref_sp(T* obj) { 463 template <typename T> sk_sp<T> sk_ref_sp(T* obj) {
464 return sk_sp<T>(SkSafeRef(obj)); 464 return sk_sp<T>(SkSafeRef(obj));
465 } 465 }
466 466
467 #endif 467 #endif
468 468
469 #endif 469 #endif
OLDNEW
« no previous file with comments | « include/core/SkColorFilter.h ('k') | include/core/SkShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698