| Flutter Impeller |

command_buffer.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/renderer/command_buffer.h"
6
7 #include "impeller/renderer/compute_pass.h"
8 #include "impeller/renderer/render_pass.h"
9 #include "impeller/renderer/render_target.h"
10
11 namespace impeller {
12
13 CommandBuffer::CommandBuffer(std::weak_ptr<const Context> context)
14 : context_(std::move(context)) {}
15
16 CommandBuffer::~CommandBuffer() = default;
17
18 bool CommandBuffer::SubmitCommands(const CompletionCallback& callback) {
19 if (!IsValid()) {
20 // Already committed or was never valid. Either way, this is caller error.
21 if (callback) {
22 callback(Status::kError);
23 }
24 return false;
25 }
26 return OnSubmitCommands(callback);
27 }
28
29 bool CommandBuffer::SubmitCommands() {
30 return SubmitCommands(nullptr);
31 }
32
33 void CommandBuffer::WaitUntilScheduled() {
34 return OnWaitUntilScheduled();
35 }
36
37 std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
38 const RenderTarget& render_target) {
39 auto pass = OnCreateRenderPass(render_target);
40 if (pass && pass->IsValid()) {
41 pass->SetLabel("RenderPass");
42 return pass;
43 }
44 return nullptr;
45 }
46
47 std::shared_ptr<BlitPass> CommandBuffer::CreateBlitPass() {
48 auto pass = OnCreateBlitPass();
49 if (pass && pass->IsValid()) {
50 pass->SetLabel("BlitPass");
51 return pass;
52 }
53 return nullptr;
54 }
55
56 std::shared_ptr<ComputePass> CommandBuffer::CreateComputePass() {
57 if (!IsValid()) {
58 return nullptr;
59 }
60 auto pass = OnCreateComputePass();
61 if (pass && pass->IsValid()) {
62 pass->SetLabel("ComputePass");
63 return pass;
64 }
65 return nullptr;
66 }
67
68 } // namespace impeller
impeller::CommandBuffer::Status::kError
@ kError
impeller::CommandBuffer::OnSubmitCommands
virtual bool OnSubmitCommands(CompletionCallback callback)=0
impeller::CommandBuffer::CreateRenderPass
std::shared_ptr< RenderPass > CreateRenderPass(const RenderTarget &render_target)
Create a render pass to record render commands into.
Definition: command_buffer.cc:37
impeller::CommandBuffer::OnCreateRenderPass
virtual std::shared_ptr< RenderPass > OnCreateRenderPass(RenderTarget render_target)=0
impeller::CommandBuffer::OnCreateComputePass
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0
impeller::CommandBuffer::CreateComputePass
std::shared_ptr< ComputePass > CreateComputePass()
Create a compute pass to record compute commands into.
Definition: command_buffer.cc:56
render_pass.h
impeller::CommandBuffer::WaitUntilScheduled
void WaitUntilScheduled()
Force execution of pending GPU commands.
Definition: command_buffer.cc:33
impeller::CommandBuffer::IsValid
virtual bool IsValid() const =0
impeller::RenderTarget
Definition: render_target.h:38
impeller::CommandBuffer::OnCreateBlitPass
virtual std::shared_ptr< BlitPass > OnCreateBlitPass()=0
command_buffer.h
impeller::CommandBuffer::OnWaitUntilScheduled
virtual void OnWaitUntilScheduled()=0
impeller::CommandBuffer::CreateBlitPass
std::shared_ptr< BlitPass > CreateBlitPass()
Create a blit pass to record blit commands into.
Definition: command_buffer.cc:47
std
Definition: comparable.h:95
impeller::CommandBuffer::CommandBuffer
CommandBuffer(std::weak_ptr< const Context > context)
Definition: command_buffer.cc:13
render_target.h
compute_pass.h
impeller
Definition: aiks_blur_unittests.cc:20
impeller::CommandBuffer::~CommandBuffer
virtual ~CommandBuffer()