Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skgpu::graphite::TaskList Class Reference

#include <TaskList.h>

Public Member Functions

 TaskList ()=default
 
void add (TaskList &&tasks)
 
void add (sk_sp< Task > task)
 
void reset ()
 
int size () const
 
bool hasTasks () const
 
Task::Status prepareResources (ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *)
 
Task::Status addCommands (Context *, CommandBuffer *, Task::ReplayTargetData)
 
template<typename Fn >
Status visitTasks (Fn fn)
 

Detailed Description

Definition at line 21 of file TaskList.h.

Constructor & Destructor Documentation

◆ TaskList()

skgpu::graphite::TaskList::TaskList ( )
default

Member Function Documentation

◆ add() [1/2]

void skgpu::graphite::TaskList::add ( sk_sp< Task task)
inline

Definition at line 26 of file TaskList.h.

26{ fTasks.emplace_back(std::move(task)); }

◆ add() [2/2]

void skgpu::graphite::TaskList::add ( TaskList &&  tasks)
inline

Definition at line 25 of file TaskList.h.

25{ fTasks.move_back(tasks.fTasks); }

◆ addCommands()

Status skgpu::graphite::TaskList::addCommands ( Context context,
CommandBuffer commandBuffer,
Task::ReplayTargetData  replayData 
)

Definition at line 50 of file TaskList.cpp.

52 {
53 TRACE_EVENT1("skia.gpu", TRACE_FUNC, "# tasks", fTasks.size());
54 return this->visitTasks([&](Task* task) {
55 return task->addCommands(context, commandBuffer, replayData);
56 });
57}
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
Definition: DM.cpp:1161
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:141

◆ hasTasks()

bool skgpu::graphite::TaskList::hasTasks ( ) const
inline

Definition at line 30 of file TaskList.h.

30{ return !fTasks.empty(); }

◆ prepareResources()

Status skgpu::graphite::TaskList::prepareResources ( ResourceProvider resourceProvider,
ScratchResourceManager scratchManager,
const RuntimeEffectDictionary runtimeDict 
)

Definition at line 38 of file TaskList.cpp.

40 {
41 TRACE_EVENT1("skia.gpu", TRACE_FUNC, "# tasks", fTasks.size());
42 scratchManager->pushScope();
43 Status status = this->visitTasks([&](Task* task) {
44 return task->prepareResources(resourceProvider, scratchManager, runtimeDict);
45 });
46 scratchManager->popScope();
47 return status;
48}
Task::Status Status
Definition: TaskList.cpp:15

◆ reset()

void skgpu::graphite::TaskList::reset ( )
inline

Definition at line 27 of file TaskList.h.

27{ fTasks.clear(); }

◆ size()

int skgpu::graphite::TaskList::size ( ) const
inline

Definition at line 29 of file TaskList.h.

29{ return fTasks.size(); }

◆ visitTasks()

template<typename Fn >
Status skgpu::graphite::TaskList::visitTasks ( Fn  fn)

Definition at line 18 of file TaskList.cpp.

18 {
19 int discardCount = 0;
20 for (sk_sp<Task>& task: fTasks) {
21 if (!task) {
22 discardCount++;
23 continue; // Skip over discarded tasks
24 }
25
26 Status status = fn(task.get());
27 if (status == Status::kFail) {
28 return Status::kFail;
29 } else if (status == Status::kDiscard) {
30 task.reset();
31 discardCount++;
32 }
33 }
34
35 return discardCount == fTasks.size() ? Status::kDiscard : Status::kSuccess;
36}

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