Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
blit_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#ifndef FLUTTER_IMPELLER_RENDERER_BLIT_PASS_H_
6#define FLUTTER_IMPELLER_RENDERER_BLIT_PASS_H_
7
8#include <string>
9
12
13namespace impeller {
14
15class HostBuffer;
16class Allocator;
17
18//------------------------------------------------------------------------------
19/// @brief Blit passes encode blit into the underlying command buffer.
20///
21/// Blit passes can be obtained from the command buffer in which
22/// the pass is meant to encode commands into.
23///
24/// @see `CommandBuffer`
25///
26class BlitPass {
27 public:
28 virtual ~BlitPass();
29
30 virtual bool IsValid() const = 0;
31
32 void SetLabel(std::string label);
33
34 //----------------------------------------------------------------------------
35 /// @brief Record a command to copy the contents of one texture to
36 /// another texture. The blit area is limited by the intersection
37 /// of the texture coverage with respect the source region and
38 /// destination origin.
39 /// No work is encoded into the command buffer at this time.
40 ///
41 /// @param[in] source The texture to read for copying.
42 /// @param[in] destination The texture to overwrite using the source
43 /// contents.
44 /// @param[in] source_region The optional region of the source texture
45 /// to use for copying. If not specified, the
46 /// full size of the source texture is used.
47 /// @param[in] destination_origin The origin to start writing to in the
48 /// destination texture.
49 /// @param[in] label The optional debug label to give the
50 /// command.
51 ///
52 /// @return If the command was valid for subsequent commitment.
53 ///
54 bool AddCopy(std::shared_ptr<Texture> source,
55 std::shared_ptr<Texture> destination,
56 std::optional<IRect> source_region = std::nullopt,
57 IPoint destination_origin = {},
58 std::string label = "");
59
60 //----------------------------------------------------------------------------
61 /// @brief Record a command to copy the contents of the buffer to
62 /// the texture.
63 /// No work is encoded into the command buffer at this time.
64 ///
65 /// @param[in] source The texture to read for copying.
66 /// @param[in] destination The buffer to overwrite using the source
67 /// contents.
68 /// @param[in] source_region The optional region of the source texture
69 /// to use for copying. If not specified, the
70 /// full size of the source texture is used.
71 /// @param[in] destination_origin The origin to start writing to in the
72 /// destination texture.
73 /// @param[in] label The optional debug label to give the
74 /// command.
75 ///
76 /// @return If the command was valid for subsequent commitment.
77 ///
78 bool AddCopy(std::shared_ptr<Texture> source,
79 std::shared_ptr<DeviceBuffer> destination,
80 std::optional<IRect> source_region = std::nullopt,
81 size_t destination_offset = 0,
82 std::string label = "");
83
84 //----------------------------------------------------------------------------
85 /// @brief Record a command to copy the contents of the buffer to
86 /// the texture.
87 /// No work is encoded into the command buffer at this time.
88 ///
89 /// @param[in] source The buffer view to read for copying.
90 /// @param[in] destination The texture to overwrite using the source
91 /// contents.
92 /// @param[in] destination_offset The offset to start writing to in the
93 /// destination buffer.
94 /// @param[in] label The optional debug label to give the
95 /// command.
96 ///
97 /// @return If the command was valid for subsequent commitment.
98 ///
100 std::shared_ptr<Texture> destination,
101 IPoint destination_origin = {},
102 std::string label = "");
103
104 //----------------------------------------------------------------------------
105 /// @brief Record a command to generate all mip levels for a texture.
106 /// No work is encoded into the command buffer at this time.
107 ///
108 /// @param[in] texture The texture to generate mipmaps for.
109 /// @param[in] label The optional debug label to give the command.
110 ///
111 /// @return If the command was valid for subsequent commitment.
112 ///
113 bool GenerateMipmap(std::shared_ptr<Texture> texture, std::string label = "");
114
115 //----------------------------------------------------------------------------
116 /// @brief Encode the recorded commands to the underlying command buffer.
117 ///
118 /// @param transients_allocator The transients allocator.
119 ///
120 /// @return If the commands were encoded to the underlying command
121 /// buffer.
122 ///
123 virtual bool EncodeCommands(
124 const std::shared_ptr<Allocator>& transients_allocator) const = 0;
125
126 protected:
127 explicit BlitPass();
128
129 virtual void OnSetLabel(std::string label) = 0;
130
132 std::shared_ptr<Texture> source,
133 std::shared_ptr<Texture> destination,
134 IRect source_region,
135 IPoint destination_origin,
136 std::string label) = 0;
137
139 std::shared_ptr<Texture> source,
140 std::shared_ptr<DeviceBuffer> destination,
141 IRect source_region,
142 size_t destination_offset,
143 std::string label) = 0;
144
147 std::shared_ptr<Texture> destination,
148 IPoint destination_origin,
149 std::string label) = 0;
150
151 virtual bool OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
152 std::string label) = 0;
153
154 private:
155 BlitPass(const BlitPass&) = delete;
156
157 BlitPass& operator=(const BlitPass&) = delete;
158};
159
160} // namespace impeller
161
162#endif // FLUTTER_IMPELLER_RENDERER_BLIT_PASS_H_
Blit passes encode blit into the underlying command buffer.
Definition blit_pass.h:26
virtual bool EncodeCommands(const std::shared_ptr< Allocator > &transients_allocator) const =0
Encode the recorded commands to the underlying command buffer.
virtual bool OnCopyTextureToBufferCommand(std::shared_ptr< Texture > source, std::shared_ptr< DeviceBuffer > destination, IRect source_region, size_t destination_offset, std::string label)=0
virtual bool OnCopyBufferToTextureCommand(BufferView source, std::shared_ptr< Texture > destination, IPoint destination_origin, std::string label)=0
bool AddCopy(std::shared_ptr< Texture > source, std::shared_ptr< Texture > destination, std::optional< IRect > source_region=std::nullopt, IPoint destination_origin={}, std::string label="")
Record a command to copy the contents of one texture to another texture. The blit area is limited by ...
Definition blit_pass.cc:26
bool GenerateMipmap(std::shared_ptr< Texture > texture, std::string label="")
Record a command to generate all mip levels for a texture. No work is encoded into the command buffer...
Definition blit_pass.cc:147
void SetLabel(std::string label)
Definition blit_pass.cc:19
virtual void OnSetLabel(std::string label)=0
virtual bool IsValid() const =0
virtual bool OnGenerateMipmapCommand(std::shared_ptr< Texture > texture, std::string label)=0
virtual bool OnCopyTextureToTextureCommand(std::shared_ptr< Texture > source, std::shared_ptr< Texture > destination, IRect source_region, IPoint destination_origin, std::string label)=0
SkBitmap source
Definition examples.cpp:28
FlTexture * texture