Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
skgpu::graphite::Buffer Class Referenceabstract

#include <Buffer.h>

Inheritance diagram for skgpu::graphite::Buffer:
skgpu::graphite::Resource skgpu::graphite::DawnBuffer skgpu::graphite::MtlBuffer skgpu::graphite::VulkanBuffer

Public Member Functions

size_t size () const
 
void * map ()
 
void asyncMap (GpuFinishedProc=nullptr, GpuFinishedContext=nullptr)
 
void unmap ()
 
bool isMapped () const
 
virtual bool isUnmappable () const
 
const char * getResourceType () const override
 
- Public Member Functions inherited from skgpu::graphite::Resource
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
Resourceoperator= (const Resource &)=delete
 
Resourceoperator= (Resource &&)=delete
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
Ownership ownership () const
 
skgpu::Budgeted budgeted () const
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
virtual const char * getResourceType () const =0
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
bool wasDestroyed () const
 
const GraphiteResourceKeykey () const
 
void setKey (const GraphiteResourceKey &key)
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual void prepareForReturnToCache (const std::function< void()> &takeRef)
 

Protected Member Functions

 Buffer (const SharedContext *sharedContext, size_t size, bool commandBufferRefsAsUsageRefs=false)
 
- Protected Member Functions inherited from skgpu::graphite::Resource
 Resource (const SharedContext *, Ownership, skgpu::Budgeted, size_t gpuMemorySize, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
virtual void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const
 
void setDeleteASAP ()
 

Protected Attributes

void * fMapPtr = nullptr
 

Private Member Functions

virtual void onMap ()=0
 
virtual void onAsyncMap (GpuFinishedProc, GpuFinishedContext)
 
virtual void onUnmap ()=0
 

Detailed Description

Definition at line 17 of file Buffer.h.

Constructor & Destructor Documentation

◆ Buffer()

skgpu::graphite::Buffer::Buffer ( const SharedContext sharedContext,
size_t  size,
bool  commandBufferRefsAsUsageRefs = false 
)
inlineprotected

Definition at line 38 of file Buffer.h.

44 size,
45 /*commandBufferRefsAsUsageRefs=*/commandBufferRefsAsUsageRefs)
46 , fSize(size) {}
size_t size() const
Definition: Buffer.h:19
Resource(const Resource &)=delete
const SharedContext * sharedContext() const
Definition: Resource.h:189

Member Function Documentation

◆ asyncMap()

void skgpu::graphite::Buffer::asyncMap ( GpuFinishedProc  proc = nullptr,
GpuFinishedContext  ctx = nullptr 
)

Definition at line 22 of file Buffer.cpp.

22 {
23 SkASSERT(this->sharedContext()->caps()->bufferMapsAreAsync());
24 this->onAsyncMap(proc, ctx);
25}
#define SkASSERT(cond)
Definition: SkAssert.h:116
virtual void onAsyncMap(GpuFinishedProc, GpuFinishedContext)
Definition: Buffer.cpp:35

◆ getResourceType()

const char * skgpu::graphite::Buffer::getResourceType ( ) const
inlineoverridevirtual

Implements skgpu::graphite::Resource.

Definition at line 35 of file Buffer.h.

35{ return "Buffer"; }

◆ isMapped()

bool skgpu::graphite::Buffer::isMapped ( ) const
inline

Definition at line 30 of file Buffer.h.

30{ return fMapPtr; }

◆ isUnmappable()

bool skgpu::graphite::Buffer::isUnmappable ( ) const
virtual

Reimplemented in skgpu::graphite::DawnBuffer.

Definition at line 33 of file Buffer.cpp.

33{ return isMapped(); }
bool isMapped() const
Definition: Buffer.h:30

◆ map()

void * skgpu::graphite::Buffer::map ( )

Definition at line 14 of file Buffer.cpp.

14 {
15 SkASSERT(this->isUnmappable() || !this->sharedContext()->caps()->bufferMapsAreAsync());
16 if (!this->isMapped()) {
17 this->onMap();
18 }
19 return fMapPtr;
20}
virtual void onMap()=0
virtual bool isUnmappable() const
Definition: Buffer.cpp:33

◆ onAsyncMap()

void skgpu::graphite::Buffer::onAsyncMap ( GpuFinishedProc  ,
GpuFinishedContext   
)
privatevirtual

Definition at line 35 of file Buffer.cpp.

35 {
36 SkASSERT(!this->sharedContext()->caps()->bufferMapsAreAsync());
37 SK_ABORT("Async buffer mapping not supported");
38}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ onMap()

virtual void skgpu::graphite::Buffer::onMap ( )
privatepure virtual

◆ onUnmap()

virtual void skgpu::graphite::Buffer::onUnmap ( )
privatepure virtual

◆ size()

size_t skgpu::graphite::Buffer::size ( ) const
inline

Definition at line 19 of file Buffer.h.

19{ return fSize; }

◆ unmap()

void skgpu::graphite::Buffer::unmap ( )

Definition at line 27 of file Buffer.cpp.

27 {
28 SkASSERT(this->isUnmappable());
29 this->onUnmap();
30 fMapPtr = nullptr;
31}
virtual void onUnmap()=0

Member Data Documentation

◆ fMapPtr

void* skgpu::graphite::Buffer::fMapPtr = nullptr
protected

Definition at line 48 of file Buffer.h.


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