Flutter Impeller
render_pass.h
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 #pragma once
6 
7 #include <string>
8 
12 
13 namespace impeller {
14 
15 class HostBuffer;
16 class Allocator;
17 
18 //------------------------------------------------------------------------------
19 /// @brief Render passes encode render commands directed as one specific
20 /// render target into an underlying command buffer.
21 ///
22 /// Render passes can be obtained from the command buffer in which
23 /// the pass is meant to encode commands into.
24 ///
25 /// @see `CommandBuffer`
26 ///
27 class RenderPass {
28  public:
29  virtual ~RenderPass();
30 
31  const RenderTarget& GetRenderTarget() const;
32 
33  ISize GetRenderTargetSize() const;
34 
35  virtual bool IsValid() const = 0;
36 
37  void SetLabel(std::string label);
38 
40 
41  //----------------------------------------------------------------------------
42  /// @brief Record a command for subsequent encoding to the underlying
43  /// command buffer. No work is encoded into the command buffer at
44  /// this time.
45  ///
46  /// @param[in] command The command
47  ///
48  /// @return If the command was valid for subsequent commitment.
49  ///
50  bool AddCommand(Command&& command);
51 
52  //----------------------------------------------------------------------------
53  /// @brief Encode the recorded commands to the underlying command buffer.
54  ///
55  /// @return If the commands were encoded to the underlying command
56  /// buffer.
57  ///
58  bool EncodeCommands() const;
59 
60  //----------------------------------------------------------------------------
61  /// @brief Accessor for the current Commands.
62  ///
63  /// @details Visible for testing.
64  ///
65  const std::vector<Command>& GetCommands() const { return commands_; }
66 
67  protected:
68  const std::weak_ptr<const Context> context_;
70  std::shared_ptr<HostBuffer> transients_buffer_;
71  std::vector<Command> commands_;
72 
73  RenderPass(std::weak_ptr<const Context> context, const RenderTarget& target);
74 
75  const std::weak_ptr<const Context>& GetContext() const;
76 
77  virtual void OnSetLabel(std::string label) = 0;
78 
79  virtual bool OnEncodeCommands(const Context& context) const = 0;
80 
81  private:
82  FML_DISALLOW_COPY_AND_ASSIGN(RenderPass);
83 };
84 
85 } // namespace impeller
impeller::Command
An object used to specify work to the GPU along with references to resources the GPU will used when d...
Definition: command.h:99
impeller::RenderPass::GetRenderTarget
const RenderTarget & GetRenderTarget() const
Definition: render_pass.cc:26
impeller::HostBuffer
Definition: host_buffer.h:20
impeller::RenderPass::GetCommands
const std::vector< Command > & GetCommands() const
Accessor for the current Commands.
Definition: render_pass.h:65
impeller::RenderPass::RenderPass
RenderPass(std::weak_ptr< const Context > context, const RenderTarget &target)
Definition: render_pass.cc:9
impeller::RenderPass::EncodeCommands
bool EncodeCommands() const
Encode the recorded commands to the underlying command buffer.
Definition: render_pass.cc:77
command.h
impeller::RenderPass::GetRenderTargetSize
ISize GetRenderTargetSize() const
Definition: render_pass.cc:30
impeller::TSize< int64_t >
impeller::RenderPass::OnEncodeCommands
virtual bool OnEncodeCommands(const Context &context) const =0
impeller::RenderTarget
Definition: render_target.h:48
impeller::RenderPass::render_target_
const RenderTarget render_target_
Definition: render_pass.h:69
impeller::RenderPass::~RenderPass
virtual ~RenderPass()
Definition: render_pass.cc:19
impeller::RenderPass::commands_
std::vector< Command > commands_
Definition: render_pass.h:71
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:27
command_buffer.h
impeller::RenderPass::SetLabel
void SetLabel(std::string label)
Definition: render_pass.cc:38
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:47
impeller::RenderPass::OnSetLabel
virtual void OnSetLabel(std::string label)=0
render_target.h
impeller::RenderPass::IsValid
virtual bool IsValid() const =0
impeller::RenderPass::GetContext
const std::weak_ptr< const Context > & GetContext() const
Definition: render_pass.cc:86
impeller::RenderPass::AddCommand
bool AddCommand(Command &&command)
Record a command for subsequent encoding to the underlying command buffer. No work is encoded into th...
Definition: render_pass.cc:46
impeller
Definition: aiks_context.cc:10
impeller::RenderPass::context_
const std::weak_ptr< const Context > context_
Definition: render_pass.h:68
impeller::RenderPass::GetTransientsBuffer
HostBuffer & GetTransientsBuffer()
Definition: render_pass.cc:34
impeller::RenderPass::transients_buffer_
std::shared_ptr< HostBuffer > transients_buffer_
Definition: render_pass.h:70