Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
SkRefCnt.h File Reference
#include "include/core/SkTypes.h"
#include "include/private/base/SkDebug.h"
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <iosfwd>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

class  SkRefCntBase
 
class  SkRefCnt
 
class  SkNVRefCnt< Derived >
 
class  sk_sp< T >
 

Functions

template<typename T >
static TSkRef (T *obj)
 
template<typename T >
static TSkSafeRef (T *obj)
 
template<typename T >
static void SkSafeUnref (T *obj)
 
template<typename T >
void swap (sk_sp< T > &a, sk_sp< T > &b)
 
template<typename T , typename U >
bool operator== (const sk_sp< T > &a, const sk_sp< U > &b)
 
template<typename T >
bool operator== (const sk_sp< T > &a, std::nullptr_t)
 
template<typename T >
bool operator== (std::nullptr_t, const sk_sp< T > &b)
 
template<typename T , typename U >
bool operator!= (const sk_sp< T > &a, const sk_sp< U > &b)
 
template<typename T >
bool operator!= (const sk_sp< T > &a, std::nullptr_t)
 
template<typename T >
bool operator!= (std::nullptr_t, const sk_sp< T > &b)
 
template<typename C , typename CT , typename T >
auto operator<< (std::basic_ostream< C, CT > &os, const sk_sp< T > &sp) -> decltype(os<< sp.get())
 
template<typename T , typename... Args>
sk_sp< Tsk_make_sp (Args &&... args)
 
template<typename T >
sk_sp< Tsk_ref_sp (T *obj)
 
template<typename T >
sk_sp< Tsk_ref_sp (const T *obj)
 

Function Documentation

◆ operator!=() [1/3]

template<typename T , typename U >
bool operator!= ( const sk_sp< T > &  a,
const sk_sp< U > &  b 
)
inline

Definition at line 355 of file SkRefCnt.h.

355 {
356 return a.get() != b.get();
357}
static bool b
struct MyStruct a[10]

◆ operator!=() [2/3]

template<typename T >
bool operator!= ( const sk_sp< T > &  a,
std::nullptr_t   
)
inline

Definition at line 358 of file SkRefCnt.h.

358 {
359 return static_cast<bool>(a);
360}

◆ operator!=() [3/3]

template<typename T >
bool operator!= ( std::nullptr_t  ,
const sk_sp< T > &  b 
)
inline

Definition at line 361 of file SkRefCnt.h.

361 {
362 return static_cast<bool>(b);
363}

◆ operator<<()

template<typename C , typename CT , typename T >
auto operator<< ( std::basic_ostream< C, CT > &  os,
const sk_sp< T > &  sp 
) -> decltype(os << sp.get())

Definition at line 366 of file SkRefCnt.h.

366 {
367 return os << sp.get();
368}
T * get() const
Definition SkRefCnt.h:303

◆ operator==() [1/3]

template<typename T , typename U >
bool operator== ( const sk_sp< T > &  a,
const sk_sp< U > &  b 
)
inline

Definition at line 345 of file SkRefCnt.h.

345 {
346 return a.get() == b.get();
347}

◆ operator==() [2/3]

template<typename T >
bool operator== ( const sk_sp< T > &  a,
std::nullptr_t   
)
inline

Definition at line 348 of file SkRefCnt.h.

348 {
349 return !a;
350}

◆ operator==() [3/3]

template<typename T >
bool operator== ( std::nullptr_t  ,
const sk_sp< T > &  b 
)
inline

Definition at line 351 of file SkRefCnt.h.

351 {
352 return !b;
353}

◆ sk_make_sp()

template<typename T , typename... Args>
sk_sp< T > sk_make_sp ( Args &&...  args)

Definition at line 371 of file SkRefCnt.h.

371 {
372 return sk_sp<T>(new T(std::forward<Args>(args)...));
373}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define T

◆ sk_ref_sp() [1/2]

template<typename T >
sk_sp< T > sk_ref_sp ( const T obj)

Definition at line 385 of file SkRefCnt.h.

385 {
386 return sk_sp<T>(const_cast<T*>(SkSafeRef(obj)));
387}
static T * SkSafeRef(T *obj)
Definition SkRefCnt.h:140

◆ sk_ref_sp() [2/2]

template<typename T >
sk_sp< T > sk_ref_sp ( T obj)

Definition at line 381 of file SkRefCnt.h.

381 {
382 return sk_sp<T>(SkSafeRef(obj));
383}

◆ SkRef()

template<typename T >
static T * SkRef ( T obj)
inlinestatic

Call obj->ref() and return obj. The obj must not be nullptr.

Definition at line 132 of file SkRefCnt.h.

132 {
133 SkASSERT(obj);
134 obj->ref();
135 return obj;
136}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ SkSafeRef()

template<typename T >
static T * SkSafeRef ( T obj)
inlinestatic

Check if the argument is non-null, and if so, call obj->ref() and return obj.

Definition at line 140 of file SkRefCnt.h.

140 {
141 if (obj) {
142 obj->ref();
143 }
144 return obj;
145}

◆ SkSafeUnref()

template<typename T >
static void SkSafeUnref ( T obj)
inlinestatic

Check if the argument is non-null, and if so, call obj->unref()

Definition at line 149 of file SkRefCnt.h.

149 {
150 if (obj) {
151 obj->unref();
152 }
153}

◆ swap()

template<typename T >
void swap ( sk_sp< T > &  a,
sk_sp< T > &  b 
)
inline

Definition at line 341 of file SkRefCnt.h.

341 {
342 a.swap(b);
343}