Flutter Impeller
command_buffer_gles.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 
7 #include "impeller/base/config.h"
10 
11 namespace impeller {
12 
13 CommandBufferGLES::CommandBufferGLES(std::weak_ptr<const Context> context,
14  std::shared_ptr<ReactorGLES> reactor)
15  : CommandBuffer(std::move(context)),
16  reactor_(std::move(reactor)),
17  is_valid_(reactor_ && reactor_->IsValid()) {}
18 
19 CommandBufferGLES::~CommandBufferGLES() = default;
20 
21 // |CommandBuffer|
22 void CommandBufferGLES::SetLabel(std::string_view label) const {
23  // Cannot support.
24 }
25 
26 // |CommandBuffer|
27 bool CommandBufferGLES::IsValid() const {
28  return is_valid_;
29 }
30 
31 // |CommandBuffer|
32 bool CommandBufferGLES::OnSubmitCommands(CompletionCallback callback) {
33  const auto result = reactor_->React();
34  if (callback) {
35  callback(result ? CommandBuffer::Status::kCompleted
36  : CommandBuffer::Status::kError);
37  }
38  return result;
39 }
40 
41 // |CommandBuffer|
42 void CommandBufferGLES::OnWaitUntilCompleted() {
43  reactor_->GetProcTable().Finish();
44 }
45 
46 // |CommandBuffer|
47 void CommandBufferGLES::OnWaitUntilScheduled() {
48  reactor_->GetProcTable().Flush();
49 }
50 
51 // |CommandBuffer|
52 std::shared_ptr<RenderPass> CommandBufferGLES::OnCreateRenderPass(
53  RenderTarget target) {
54  if (!IsValid()) {
55  return nullptr;
56  }
57  auto context = context_.lock();
58  if (!context) {
59  return nullptr;
60  }
61  auto pass = std::shared_ptr<RenderPassGLES>(
62  new RenderPassGLES(context, target, reactor_));
63  if (!pass->IsValid()) {
64  return nullptr;
65  }
66  return pass;
67 }
68 
69 // |CommandBuffer|
70 std::shared_ptr<BlitPass> CommandBufferGLES::OnCreateBlitPass() {
71  if (!IsValid()) {
72  return nullptr;
73  }
74  auto pass = std::shared_ptr<BlitPassGLES>(new BlitPassGLES(reactor_));
75  if (!pass->IsValid()) {
76  return nullptr;
77  }
78  return pass;
79 }
80 
81 // |CommandBuffer|
82 std::shared_ptr<ComputePass> CommandBufferGLES::OnCreateComputePass() {
83  // Compute passes aren't supported until GLES 3.2, at which point Vulkan is
84  // available anyway.
85  return nullptr;
86 }
87 
88 } // namespace impeller
Definition: comparable.h:95