Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
GrCpuBuffer Class Referencefinal

#include <GrCpuBuffer.h>

Inheritance diagram for GrCpuBuffer:
GrNonAtomicRef< GrCpuBuffer > GrBuffer SkNoncopyable

Public Member Functions

void ref () const override
 
void unref () const override
 
size_t size () const override
 
bool isCpuBuffer () const override
 
char * data ()
 
const char * data () const
 
- Public Member Functions inherited from GrNonAtomicRef< GrCpuBuffer >
 GrNonAtomicRef ()
 
bool unique () const
 
int refCnt () const
 
void ref () const
 
void unref () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 
- Public Member Functions inherited from GrBuffer
 GrBuffer (const GrBuffer &)=delete
 
GrBufferoperator= (const GrBuffer &)=delete
 
virtual ~GrBuffer ()=default
 
virtual void ref () const =0
 
virtual void unref () const =0
 
virtual size_t size () const =0
 
virtual bool isCpuBuffer () const =0
 

Static Public Member Functions

static sk_sp< GrCpuBufferMake (size_t size)
 
static void operator delete (void *p)
 

Additional Inherited Members

- Protected Member Functions inherited from GrBuffer
 GrBuffer ()=default
 

Detailed Description

Definition at line 15 of file GrCpuBuffer.h.

Member Function Documentation

◆ data() [1/2]

char * GrCpuBuffer::data ( )
inline

Definition at line 36 of file GrCpuBuffer.h.

36{ return reinterpret_cast<char*>(fData); }

◆ data() [2/2]

const char * GrCpuBuffer::data ( ) const
inline

Definition at line 37 of file GrCpuBuffer.h.

37{ return reinterpret_cast<const char*>(fData); }

◆ isCpuBuffer()

bool GrCpuBuffer::isCpuBuffer ( ) const
inlineoverridevirtual

Is this an instance of GrCpuBuffer? Otherwise, an instance of GrGpuBuffer.

Implements GrBuffer.

Definition at line 34 of file GrCpuBuffer.h.

34{ return true; }

◆ Make()

static sk_sp< GrCpuBuffer > GrCpuBuffer::Make ( size_t  size)
inlinestatic

Definition at line 17 of file GrCpuBuffer.h.

17 {
18 SkASSERT(size > 0);
19 SkSafeMath sm;
20 size_t combinedSize = sm.add(sizeof(GrCpuBuffer), size);
21 if (!sm.ok()) {
22 SK_ABORT("Buffer size is too big.");
23 }
24 auto mem = ::operator new(combinedSize);
25 return sk_sp<GrCpuBuffer>(new (mem) GrCpuBuffer((char*)mem + sizeof(GrCpuBuffer), size));
26 }
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
#define SkASSERT(cond)
Definition: SkAssert.h:116
size_t size() const override
Definition: GrCpuBuffer.h:33
size_t add(size_t x, size_t y)
Definition: SkSafeMath.h:33
bool ok() const
Definition: SkSafeMath.h:26

◆ operator delete()

static void GrCpuBuffer::operator delete ( void *  p)
inlinestatic

Definition at line 29 of file GrCpuBuffer.h.

29{ ::operator delete(p); }

◆ ref()

void GrCpuBuffer::ref ( ) const
inlineoverridevirtual

Implements GrBuffer.

Definition at line 31 of file GrCpuBuffer.h.

◆ size()

size_t GrCpuBuffer::size ( ) const
inlineoverridevirtual

Size of the buffer in bytes.

Implements GrBuffer.

Definition at line 33 of file GrCpuBuffer.h.

33{ return fSize; }

◆ unref()

void GrCpuBuffer::unref ( ) const
inlineoverridevirtual

Implements GrBuffer.

Definition at line 32 of file GrCpuBuffer.h.


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