Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
skgpu::TClientMappedBufferManager< T, IDType > Class Template Reference

#include <AsyncReadTypes.h>

Classes

struct  BufferFinishedMessage
 

Public Types

using BufferFinishedMessageBus = SkMessageBus< BufferFinishedMessage, IDType, false >
 

Public Member Functions

 TClientMappedBufferManager (IDType ownerID)
 
 TClientMappedBufferManager (const TClientMappedBufferManager &)=delete
 
 TClientMappedBufferManager (TClientMappedBufferManager &&)=delete
 
 ~TClientMappedBufferManager ()
 
TClientMappedBufferManageroperator= (const TClientMappedBufferManager &)=delete
 
TClientMappedBufferManageroperator= (TClientMappedBufferManager &&)=delete
 
IDType ownerID () const
 
void insert (sk_sp< T > b)
 
void process ()
 
void abandon ()
 

Detailed Description

template<typename T, typename IDType>
class skgpu::TClientMappedBufferManager< T, IDType >

We sometimes hand clients objects that contain mapped buffers. The client may consume the mapped buffer on another thread. This object manages receiving messages that buffers are ready to be unmapped (on the owner's thread). It also handles cleaning up mapped buffers if the owner is destroyed before the client has finished with the buffer.

Buffers are first registered using insert() before being passed the client. process() should be called periodically on the owner's thread to poll for messages and process them.

Definition at line 34 of file AsyncReadTypes.h.

Member Typedef Documentation

◆ BufferFinishedMessageBus

template<typename T , typename IDType >
using skgpu::TClientMappedBufferManager< T, IDType >::BufferFinishedMessageBus = SkMessageBus<BufferFinishedMessage, IDType, false>

Definition at line 52 of file AsyncReadTypes.h.

Constructor & Destructor Documentation

◆ TClientMappedBufferManager() [1/3]

template<typename T , typename IDType >
skgpu::TClientMappedBufferManager< T, IDType >::TClientMappedBufferManager ( IDType  ownerID)
inline

Definition at line 56 of file AsyncReadTypes.h.

57 : fFinishedBufferInbox(ownerID) {}

◆ TClientMappedBufferManager() [2/3]

template<typename T , typename IDType >
skgpu::TClientMappedBufferManager< T, IDType >::TClientMappedBufferManager ( const TClientMappedBufferManager< T, IDType > &  )
delete

◆ TClientMappedBufferManager() [3/3]

template<typename T , typename IDType >
skgpu::TClientMappedBufferManager< T, IDType >::TClientMappedBufferManager ( TClientMappedBufferManager< T, IDType > &&  )
delete

◆ ~TClientMappedBufferManager()

template<typename T , typename IDType >
skgpu::TClientMappedBufferManager< T, IDType >::~TClientMappedBufferManager ( )
inline

Definition at line 61 of file AsyncReadTypes.h.

61 {
62 this->process();
63 if (!fAbandoned) {
64 // If we're going down before we got the messages we go ahead and unmap all the buffers.
65 // It's up to the client to ensure that they aren't being accessed on another thread
66 // while this is happening (or afterwards on any thread).
67 for (auto& b : fClientHeldBuffers) {
68 b->unmap();
69 }
70 }
71 }
static bool b

Member Function Documentation

◆ abandon()

template<typename T , typename IDType >
void skgpu::TClientMappedBufferManager< T, IDType >::abandon ( )
inline

Notifies the manager that the context has been abandoned. No more unmaps() will occur.

Definition at line 106 of file AsyncReadTypes.h.

106 {
107 fAbandoned = true;
108 fClientHeldBuffers.clear();
109 }

◆ insert()

template<typename T , typename IDType >
void skgpu::TClientMappedBufferManager< T, IDType >::insert ( sk_sp< T b)
inline

Let the manager know to expect a message with buffer 'b'. It's illegal for a buffer to be inserted again before it is unmapped by process().

Definition at line 87 of file AsyncReadTypes.h.

87 {
88 SkDEBUGCODE(auto end = fClientHeldBuffers.end());
89 SkASSERT(std::find(fClientHeldBuffers.begin(), end, b) == end);
90 fClientHeldBuffers.emplace_front(std::move(b));
91 }
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
glong glong end

◆ operator=() [1/2]

template<typename T , typename IDType >
TClientMappedBufferManager & skgpu::TClientMappedBufferManager< T, IDType >::operator= ( const TClientMappedBufferManager< T, IDType > &  )
delete

◆ operator=() [2/2]

template<typename T , typename IDType >
TClientMappedBufferManager & skgpu::TClientMappedBufferManager< T, IDType >::operator= ( TClientMappedBufferManager< T, IDType > &&  )
delete

◆ ownerID()

template<typename T , typename IDType >
IDType skgpu::TClientMappedBufferManager< T, IDType >::ownerID ( ) const
inline

Initialize BufferFinishedMessage::fIntendedRecipient to this value. It is the unique ID of the object that owns this buffer manager.

Definition at line 79 of file AsyncReadTypes.h.

79 {
80 return fFinishedBufferInbox.uniqueID();
81 }
IDType uniqueID() const

◆ process()

template<typename T , typename IDType >
void skgpu::TClientMappedBufferManager< T, IDType >::process ( )
inline

Poll for messages and unmap any incoming buffers.

Definition at line 94 of file AsyncReadTypes.h.

94 {
96 fFinishedBufferInbox.poll(&messages);
97 if (!fAbandoned) {
98 for (auto& m : messages) {
99 this->remove(m.fBuffer);
100 m.fBuffer->unmap();
101 }
102 }
103 }
void poll(skia_private::TArray< Message > *out)

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