Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
GrGLFinishCallbacks Class Reference

#include <GrGLFinishCallbacks.h>

Public Member Functions

 GrGLFinishCallbacks (GrGLGpu *gpu)
 
 ~GrGLFinishCallbacks ()
 
void callAll (bool doDelete)
 
void add (GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
 
void check ()
 
bool empty () const
 

Detailed Description

Maintains a list of callbacks to be called when work on the GPU is complete.

Definition at line 22 of file GrGLFinishCallbacks.h.

Constructor & Destructor Documentation

◆ GrGLFinishCallbacks()

GrGLFinishCallbacks::GrGLFinishCallbacks ( GrGLGpu gpu)

Definition at line 11 of file GrGLFinishCallbacks.cpp.

11: fGpu(gpu) {}

◆ ~GrGLFinishCallbacks()

GrGLFinishCallbacks::~GrGLFinishCallbacks ( )

Definition at line 13 of file GrGLFinishCallbacks.cpp.

13 {
14 this->callAll(true);
15}
void callAll(bool doDelete)

Member Function Documentation

◆ add()

void GrGLFinishCallbacks::add ( GrGpuFinishedProc  finishedProc,
GrGpuFinishedContext  finishedContext 
)

Add a new callback to the list.

Parameters
finishedProcThe function to call when GPU work is complete.
finishedContextThe context object to pass back to the callback.

Definition at line 17 of file GrGLFinishCallbacks.cpp.

18 {
19 SkASSERT(finishedProc);
20 FinishCallback callback;
21 callback.fCallback = finishedProc;
22 callback.fContext = finishedContext;
23 callback.fFence = fGpu->insertFence();
24 fCallbacks.push_back(callback);
25}
#define SkASSERT(cond)
Definition SkAssert.h:116
GrGLsync insertFence()
Definition GrGLGpu.cpp:4286
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ callAll()

void GrGLFinishCallbacks::callAll ( bool  doDelete)

Call all the callbacks in the list. This will block until all work is done.

Parameters
doDeletedelete the contained fence object.

Definition at line 41 of file GrGLFinishCallbacks.cpp.

41 {
42 while (!fCallbacks.empty()) {
43 // While we are processing a proc we need to make sure to remove it from the callback list
44 // before calling it. This is because the client could trigger a call (e.g. calling
45 // flushAndSubmit(/*sync=*/true)) that has us process the finished callbacks. We also must
46 // process deleting the fence before a client may abandon the context.
47 auto finishCallback = fCallbacks.front();
48 if (doDelete) {
49 fGpu->deleteFence(finishCallback.fFence);
50 }
51 fCallbacks.pop_front();
52 finishCallback.fCallback(finishCallback.fContext);
53 }
54}
void deleteFence(GrGLsync)
Definition GrGLGpu.cpp:4335

◆ check()

void GrGLFinishCallbacks::check ( )

Check if any GPU work is complete, and call the associated callbacks. This call is non-blocking.

Definition at line 27 of file GrGLFinishCallbacks.cpp.

27 {
28 // Bail after the first unfinished sync since we expect they signal in the order inserted.
29 while (!fCallbacks.empty() && fGpu->waitFence(fCallbacks.front().fFence)) {
30 // While we are processing a proc we need to make sure to remove it from the callback list
31 // before calling it. This is because the client could trigger a call (e.g. calling
32 // flushAndSubmit(/*sync=*/true)) that has us process the finished callbacks. We also must
33 // process deleting the fence before a client may abandon the context.
34 auto finishCallback = fCallbacks.front();
35 fGpu->deleteFence(finishCallback.fFence);
36 fCallbacks.pop_front();
37 finishCallback.fCallback(finishCallback.fContext);
38 }
39}
bool waitFence(GrGLsync)
Definition GrGLGpu.cpp:4328

◆ empty()

bool GrGLFinishCallbacks::empty ( ) const
inline

Returns true if the callback list is empty.

Definition at line 51 of file GrGLFinishCallbacks.h.

51{ return fCallbacks.empty(); }

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