Flutter Engine
The Flutter Engine
DrawTask.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 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
8#ifndef skgpu_graphite_task_DrawTask_DEFINED
9#define skgpu_graphite_task_DrawTask_DEFINED
10
14
15namespace skgpu::graphite {
16
17class TextureProxy;
18
19/**
20 * DrawTask is a collection of subtasks that are executed in order to produce some intended
21 * image in the DrawTask's target. As such, at least one of its subtasks will either be a
22 * RenderPassTask, ComputeTask or CopyXToTextureTask that directly modify the target.
23*/
25public:
27 ~DrawTask() override;
28
31 const RuntimeEffectDictionary*) override;
32
34
35private:
36 friend class DrawContext; // for "addTask"
37
38 // DrawTask is modified directly by DrawContext for efficiency, but its task list will be
39 // fixed once DrawContext snaps the task.
40 void addTask(sk_sp<Task> task) { fChildTasks.add(std::move(task)); }
41 bool hasTasks() const { return fChildTasks.hasTasks(); }
42
43 void onUseCompleted(ScratchResourceManager*) override;
44
45 sk_sp<TextureProxy> fTarget;
46 TaskList fChildTasks;
47
48 // Once there is one DrawTask for a scratch device, whether or not the target is instantaited
49 // will be equivalent to whether or not prepareResources() has been called already if the task
50 // is referenced multiple times in a Recording. Right now, however, a scratch device can still
51 // produce several DrawTasks (in which case they will see an instantiated proxy so should still
52 // prepare their own resources instead of discarding themselves).
53 bool fPrepared = false;
54};
55
56} // namespace skgpu::graphite
57
58#endif // skgpu_graphite_task_DrawTask_DEFINED
Status prepareResources(ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *) override
Definition: DrawTask.cpp:20
DrawTask(sk_sp< TextureProxy > target)
Definition: DrawTask.cpp:16
Status addCommands(Context *, CommandBuffer *, ReplayTargetData) override
Definition: DrawTask.cpp:65
bool hasTasks() const
Definition: TaskList.h:30
void add(TaskList &&tasks)
Definition: TaskList.h:25
uint32_t * target