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(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 
34  return OnWaitUntilCompleted();
35 }
36 
38  return OnWaitUntilScheduled();
39 }
40 
41 std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
42  const RenderTarget& render_target) {
43  auto pass = OnCreateRenderPass(render_target);
44  if (pass && pass->IsValid()) {
45  pass->SetLabel("RenderPass");
46  return pass;
47  }
48  return nullptr;
49 }
50 
51 std::shared_ptr<BlitPass> CommandBuffer::CreateBlitPass() {
52  auto pass = OnCreateBlitPass();
53  if (pass && pass->IsValid()) {
54  pass->SetLabel("BlitPass");
55  return pass;
56  }
57  return nullptr;
58 }
59 
60 std::shared_ptr<ComputePass> CommandBuffer::CreateComputePass() {
61  if (!IsValid()) {
62  return nullptr;
63  }
64  auto pass = OnCreateComputePass();
65  if (pass && pass->IsValid()) {
66  pass->SetLabel("ComputePass");
67  return pass;
68  }
69  return nullptr;
70 }
71 
72 } // 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 IsValid() const =0
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0
virtual bool OnSubmitCommands(CompletionCallback callback)=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