Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
gr_sp< T, Ref, Unref > Class Template Reference

#include <GpuRefCnt.h>

Public Types

using element_type = T
 

Public Member Functions

constexpr gr_sp ()
 
constexpr gr_sp (std::nullptr_t)
 
 gr_sp (const gr_sp< T, Ref, Unref > &that)
 
template<typename U , typename = typename std::enable_if<std::is_convertible<U*, T*>::value>::type>
 gr_sp (const gr_sp< U, Ref, Unref > &that)
 
 gr_sp (const sk_sp< T > &that)
 
 gr_sp (gr_sp< T, Ref, Unref > &&that)
 
 gr_sp (sk_sp< T > &&that)
 
 gr_sp (T *obj)
 
 ~gr_sp ()
 
gr_spoperator= (std::nullptr_t)
 
gr_spoperator= (const gr_sp< T, Ref, Unref > &that)
 
gr_spoperator= (const sk_sp< T > &that)
 
gr_spoperator= (gr_sp< T, Ref, Unref > &&that)
 
gr_spoperator= (sk_sp< T > &&that)
 
Toperator* () const
 
 operator bool () const
 
Tget () const
 
Toperator-> () const
 
void reset (T *ptr=nullptr)
 

Detailed Description

template<typename T, auto Ref, auto Unref>
class gr_sp< T, Ref, Unref >

Definition at line 22 of file GpuRefCnt.h.

Member Typedef Documentation

◆ element_type

template<typename T , auto Ref, auto Unref>
using gr_sp< T, Ref, Unref >::element_type = T

Definition at line 38 of file GpuRefCnt.h.

Constructor & Destructor Documentation

◆ gr_sp() [1/8]

template<typename T , auto Ref, auto Unref>
constexpr gr_sp< T, Ref, Unref >::gr_sp ( )
inlineconstexpr

Definition at line 40 of file GpuRefCnt.h.

40: fPtr(nullptr) {}

◆ gr_sp() [2/8]

template<typename T , auto Ref, auto Unref>
constexpr gr_sp< T, Ref, Unref >::gr_sp ( std::nullptr_t  )
inlineconstexpr

Definition at line 41 of file GpuRefCnt.h.

41: fPtr(nullptr) {}

◆ gr_sp() [3/8]

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::gr_sp ( const gr_sp< T, Ref, Unref > &  that)
inline

Shares the underlying object by calling Ref(), so that both the argument and the newly created gr_sp both have a reference to it.

Definition at line 47 of file GpuRefCnt.h.

47: fPtr(SafeRef(that.get())) {}
T * get() const
Definition: GpuRefCnt.h:135

◆ gr_sp() [4/8]

template<typename T , auto Ref, auto Unref>
template<typename U , typename = typename std::enable_if<std::is_convertible<U*, T*>::value>::type>
gr_sp< T, Ref, Unref >::gr_sp ( const gr_sp< U, Ref, Unref > &  that)
inline

Definition at line 50 of file GpuRefCnt.h.

50: fPtr(SafeRef(that.get())) {}

◆ gr_sp() [5/8]

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::gr_sp ( const sk_sp< T > &  that)
inline

Definition at line 52 of file GpuRefCnt.h.

52: fPtr(SafeRef(that.get())) {}
T * get() const
Definition: SkRefCnt.h:303

◆ gr_sp() [6/8]

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::gr_sp ( gr_sp< T, Ref, Unref > &&  that)
inline

Move the underlying object from the argument to the newly created gr_sp. Afterwards only the new gr_sp will have a reference to the object, and the argument will point to null. No call to Ref() or Unref() will be made.

Definition at line 60 of file GpuRefCnt.h.

60: fPtr(that.release()) {}

◆ gr_sp() [7/8]

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::gr_sp ( sk_sp< T > &&  that)
inline

Copies the underlying object pointer from the argument to the gr_sp. It will then call Ref() on the new object.

Definition at line 66 of file GpuRefCnt.h.

66: fPtr(SafeRef(that.get())) {}

◆ gr_sp() [8/8]

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::gr_sp ( T obj)
inlineexplicit

Adopt the bare pointer into the newly created gr_sp. No call to Ref() or Unref() will be made.

Definition at line 72 of file GpuRefCnt.h.

72: fPtr(obj) {}

◆ ~gr_sp()

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::~gr_sp ( )
inline

Calls Unref() on the underlying object pointer.

Definition at line 77 of file GpuRefCnt.h.

77 {
78 SafeUnref(fPtr);
79 SkDEBUGCODE(fPtr = nullptr);
80 }
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()

Member Function Documentation

◆ get()

template<typename T , auto Ref, auto Unref>
T * gr_sp< T, Ref, Unref >::get ( ) const
inline

Definition at line 135 of file GpuRefCnt.h.

135{ return fPtr; }

◆ operator bool()

template<typename T , auto Ref, auto Unref>
gr_sp< T, Ref, Unref >::operator bool ( ) const
inlineexplicit

Definition at line 133 of file GpuRefCnt.h.

133{ return this->get() != nullptr; }

◆ operator*()

template<typename T , auto Ref, auto Unref>
T & gr_sp< T, Ref, Unref >::operator* ( ) const
inline

Definition at line 128 of file GpuRefCnt.h.

128 {
129 SkASSERT(this->get() != nullptr);
130 return *this->get();
131 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ operator->()

template<typename T , auto Ref, auto Unref>
T * gr_sp< T, Ref, Unref >::operator-> ( ) const
inline

Definition at line 136 of file GpuRefCnt.h.

136{ return fPtr; }

◆ operator=() [1/5]

template<typename T , auto Ref, auto Unref>
gr_sp & gr_sp< T, Ref, Unref >::operator= ( const gr_sp< T, Ref, Unref > &  that)
inline

Shares the underlying object referenced by the argument by calling Ref() on it. If this gr_sp previously had a reference to an object (i.e. not null) it will call Unref() on that object.

Definition at line 91 of file GpuRefCnt.h.

91 {
92 if (this != &that) {
93 this->reset(SafeRef(that.get()));
94 }
95 return *this;
96 }
void reset(T *ptr=nullptr)
Definition: GpuRefCnt.h:142

◆ operator=() [2/5]

template<typename T , auto Ref, auto Unref>
gr_sp & gr_sp< T, Ref, Unref >::operator= ( const sk_sp< T > &  that)
inline

Copies the underlying object pointer from the argument to the gr_sp. If the gr_sp previously held a reference to another object, Unref() will be called on that object. It will then call Ref() on the new object.

Definition at line 103 of file GpuRefCnt.h.

103 {
104 this->reset(SafeRef(that.get()));
105 return *this;
106 }

◆ operator=() [3/5]

template<typename T , auto Ref, auto Unref>
gr_sp & gr_sp< T, Ref, Unref >::operator= ( gr_sp< T, Ref, Unref > &&  that)
inline

Move the underlying object from the argument to the gr_sp. If the gr_sp previously held a reference to another object, Unref() will be called on that object. No call to Ref() will be made.

Definition at line 113 of file GpuRefCnt.h.

113 {
114 this->reset(that.release());
115 return *this;
116 }

◆ operator=() [4/5]

template<typename T , auto Ref, auto Unref>
gr_sp & gr_sp< T, Ref, Unref >::operator= ( sk_sp< T > &&  that)
inline

Copies the underlying object pointer from the argument to the gr_sp. If the gr_sp previously held a reference to another object, Unref() will be called on that object. It will then call Ref() on the new object.

Definition at line 123 of file GpuRefCnt.h.

123 {
124 this->reset(SafeRef(that.get()));
125 return *this;
126 }

◆ operator=() [5/5]

template<typename T , auto Ref, auto Unref>
gr_sp & gr_sp< T, Ref, Unref >::operator= ( std::nullptr_t  )
inline

Definition at line 82 of file GpuRefCnt.h.

82 {
83 this->reset();
84 return *this;
85 }

◆ reset()

template<typename T , auto Ref, auto Unref>
void gr_sp< T, Ref, Unref >::reset ( T ptr = nullptr)
inline

Adopt the new bare pointer, and call Unref() on any previously held object (if not null). No call to Ref() will be made.

Definition at line 142 of file GpuRefCnt.h.

142 {
143 T* oldPtr = fPtr;
144 fPtr = ptr;
145 SafeUnref(oldPtr);
146 }
#define T
Definition: precompiler.cc:65

The documentation for this class was generated from the following file: