Flutter Engine
The Flutter Engine
TaskList.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
12
13namespace skgpu::graphite {
14
16
17template <typename Fn>
18Status TaskList::visitTasks(Fn fn) {
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}
37
39 ScratchResourceManager* scratchManager,
40 const RuntimeEffectDictionary* runtimeDict) {
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}
49
51 CommandBuffer* commandBuffer,
52 Task::ReplayTargetData replayData) {
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}
58
59} // namespace skgpu::graphite
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
Task::Status addCommands(Context *, CommandBuffer *, Task::ReplayTargetData)
Definition: TaskList.cpp:50
Task::Status prepareResources(ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *)
Definition: TaskList.cpp:38
virtual Status addCommands(Context *, CommandBuffer *, ReplayTargetData)=0
virtual Status prepareResources(ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *)=0
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:141