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 
6 
10 
11 namespace impeller {
12 
13 CommandBuffer::CommandBuffer(std::weak_ptr<const Context> context)
14  : context_(std::move(context)) {}
15 
17 
18 bool CommandBuffer::SubmitCommands(bool block_on_schedule,
19  const CompletionCallback& callback) {
20  if (!IsValid()) {
21  // Already committed or was never valid. Either way, this is caller error.
22  if (callback) {
23  callback(Status::kError);
24  }
25  return false;
26  }
27  return OnSubmitCommands(block_on_schedule, callback);
28 }
29 
30 bool CommandBuffer::SubmitCommands(bool block_on_schedule) {
31  return SubmitCommands(block_on_schedule, nullptr);
32 }
33 
35  return OnWaitUntilCompleted();
36 }
37 
39  return OnWaitUntilScheduled();
40 }
41 
42 std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
43  const RenderTarget& render_target) {
44  auto pass = OnCreateRenderPass(render_target);
45  if (pass && pass->IsValid()) {
46  pass->SetLabel("RenderPass");
47  return pass;
48  }
49  return nullptr;
50 }
51 
52 std::shared_ptr<BlitPass> CommandBuffer::CreateBlitPass() {
53  auto pass = OnCreateBlitPass();
54  if (pass && pass->IsValid()) {
55  pass->SetLabel("BlitPass");
56  return pass;
57  }
58  return nullptr;
59 }
60 
61 std::shared_ptr<ComputePass> CommandBuffer::CreateComputePass() {
62  if (!IsValid()) {
63  return nullptr;
64  }
65  auto pass = OnCreateComputePass();
66  if (pass && pass->IsValid()) {
67  pass->SetLabel("ComputePass");
68  return pass;
69  }
70  return nullptr;
71 }
72 
73 } // namespace impeller
std::shared_ptr< BlitPass > CreateBlitPass()
Create a blit pass to record blit commands into.
virtual void OnWaitUntilCompleted()=0
std::shared_ptr< ComputePass > CreateComputePass()
Create a compute pass to record compute commands into.
CommandBuffer(std::weak_ptr< const Context > context)
virtual bool OnSubmitCommands(bool block_on_schedule, CompletionCallback callback)=0
Submit the command buffer to the GPU for execution.
virtual bool IsValid() const =0
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0
virtual std::shared_ptr< RenderPass > OnCreateRenderPass(RenderTarget render_target)=0
void WaitUntilCompleted()
Block the current thread until the GPU has completed execution of the commands.
std::shared_ptr< RenderPass > CreateRenderPass(const RenderTarget &render_target)
Create a render pass to record render commands into.
virtual void OnWaitUntilScheduled()=0
virtual std::shared_ptr< BlitPass > OnCreateBlitPass()=0
void WaitUntilScheduled()
Block the current thread until the GPU has completed scheduling execution of the commands.
Definition: comparable.h:95