All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrIORef< DERIVED > Class Template Reference

Base class for GrGpuResource. More...

#include <GrGpuResource.h>

Inheritance diagram for GrIORef< DERIVED >:

Public Member Functions

void ref () const
void unref () const
void validate () const

Protected Types

enum  CntType { kRef_CntType, kPendingRead_CntType, kPendingWrite_CntType }

Protected Member Functions

bool isPurgeable () const
bool internalHasPendingRead () const
bool internalHasPendingWrite () const
bool internalHasPendingIO () const
bool internalHasRef () const

Private Member Functions

void addPendingRead () const
void completedRead () const
void addPendingWrite () const
void completedWrite () const
void didRemoveRefOrPendingIO (CntType cntTypeRemoved) const

Private Attributes

int32_t fRefCnt
int32_t fPendingReads
int32_t fPendingWrites


class GrIORefProxy
class GrGpuResourceRef
class GrResourceCache
template<typename , GrIOType >
class GrPendingIOResource
template<typename T >
void testingOnly_getIORefCnts (const T *, int *refCnt, int *readCnt, int *writeCnt)

Detailed Description

template<typename DERIVED>
class GrIORef< DERIVED >

Base class for GrGpuResource.

Handles the various types of refs we need. Separated out as a base class to isolate the ref-cnting behavior and provide friendship without exposing all of GrGpuResource.

Gpu resources can have three types of refs: 1) Normal ref (+ by ref(), - by unref()): These are used by code that is issuing draw calls that read and write the resource via GrOpList and by any object that must own a GrGpuResource and is itself owned (directly or indirectly) by Skia-client code. 2) Pending read (+ by addPendingRead(), - by completedRead()): GrContext has scheduled a read of the resource by the GPU as a result of a skia API call but hasn't executed it yet. 3) Pending write (+ by addPendingWrite(), - by completedWrite()): GrContext has scheduled a write to the resource by the GPU as a result of a skia API call but hasn't executed it yet.

The latter two ref types are private and intended only for Gr core code.

When all the ref/io counts reach zero DERIVED::notifyAllCntsAreZero() will be called (static poly morphism using CRTP). Similarly when the ref (but not necessarily pending read/write) count reaches 0 DERIVED::notifyRefCountIsZero() will be called. In the case when an unref() causes both the ref cnt to reach zero and the other counts are zero, notifyRefCountIsZero() will be called before notifyIsPurgeable(). Moreover, if notifyRefCountIsZero() returns false then notifyAllRefCntsAreZero() won't be called at all. notifyRefCountIsZero() must return false if the object may be deleted after notifyRefCntIsZero() returns.

GrIORef and GrGpuResource are separate classes for organizational reasons and to be able to give access via friendship to only the functions related to pending IO operations.

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