Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
10
11namespace skgpu::graphite {
12
14
15template <typename Fn>
16Status TaskList::visitTasks(Fn fn) {
17 int discardCount = 0;
18 for (sk_sp<Task>& task: fTasks) {
19 if (!task) {
20 discardCount++;
21 continue; // Skip over discarded tasks
22 }
23
24 Status status = fn(task.get());
25 if (status == Status::kFail) {
26 return Status::kFail;
27 } else if (status == Status::kDiscard) {
28 task.reset();
29 discardCount++;
30 }
31 }
32
33 return discardCount == fTasks.size() ? Status::kDiscard : Status::kSuccess;
34}
35
37 const RuntimeEffectDictionary* runtimeDict) {
38 TRACE_EVENT1("skia.gpu", TRACE_FUNC, "# tasks", fTasks.size());
39 return this->visitTasks([&](Task* task) {
40 return task->prepareResources(resourceProvider, runtimeDict);
41 });
42}
43
45 CommandBuffer* commandBuffer,
46 Task::ReplayTargetData replayData) {
47 TRACE_EVENT1("skia.gpu", TRACE_FUNC, "# tasks", fTasks.size());
48 return this->visitTasks([&](Task* task) {
49 return task->addCommands(context, commandBuffer, replayData);
50 });
51}
52
53} // namespace skgpu::graphite
#define TRACE_FUNC
Task::Status addCommands(Context *, CommandBuffer *, Task::ReplayTargetData)
Definition TaskList.cpp:44
Task::Status prepareResources(ResourceProvider *, const RuntimeEffectDictionary *)
Definition TaskList.cpp:36
virtual Status addCommands(Context *, CommandBuffer *, ReplayTargetData)=0
virtual Status prepareResources(ResourceProvider *, const RuntimeEffectDictionary *)=0
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)