Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
command_buffer.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_LIB_GPU_COMMAND_BUFFER_H_
6#define FLUTTER_LIB_GPU_COMMAND_BUFFER_H_
7
8#include <memory>
9#include <vector>
10
22
23namespace flutter {
24namespace gpu {
25
26class CommandBuffer : public RefCountedDartWrappable<CommandBuffer> {
27 DEFINE_WRAPPERTYPEINFO();
29
30 public:
31 CommandBuffer(std::shared_ptr<impeller::Context> context,
32 std::shared_ptr<impeller::CommandBuffer> command_buffer);
33
34 std::shared_ptr<impeller::CommandBuffer> GetCommandBuffer();
35
36 void AddRenderPass(std::shared_ptr<impeller::RenderPass> render_pass);
37
40
42 size_t source_offset,
43 size_t source_length,
44 Texture& destination,
45 impeller::IRect destination_region,
46 uint32_t mip_level,
47 uint32_t slice);
48
49 bool CopyTextureToBuffer(Texture& source,
50 impeller::IRect source_region,
51 DeviceBuffer& destination,
52 size_t destination_offset);
53
54 bool CopyTextureToTexture(Texture& source,
55 Texture& destination,
56 impeller::IRect source_region,
57 impeller::IPoint destination_origin);
58
59 bool Submit();
60 bool Submit(
61 const impeller::CommandBuffer::CompletionCallback& completion_callback);
62
63 ~CommandBuffer() override;
64
65 private:
66 std::shared_ptr<impeller::Context> context_;
67 std::shared_ptr<impeller::CommandBuffer> command_buffer_;
68
69 struct Encodable {
70 std::shared_ptr<impeller::RenderPass> render_pass;
71 std::shared_ptr<impeller::BlitPass> blit_pass;
72
73 bool EncodeCommands() const;
74 };
75
76 std::shared_ptr<impeller::BlitPass> GetOrCreateBlitPass();
77
78 std::vector<Encodable> encodables_;
79 std::vector<impeller::CommandBuffer::CompletionCallback>
80 completion_callbacks_;
81 bool submitted_ = false;
82
84};
85
86} // namespace gpu
87} // namespace flutter
88
89//----------------------------------------------------------------------------
90/// Exports
91///
92
93extern "C" {
94
97 Dart_Handle wrapper,
98 flutter::gpu::Context* contextWrapper);
99
103 Dart_Handle completion_callback);
104
109 int source_offset_in_bytes,
110 int source_length_in_bytes,
111 flutter::gpu::Texture* destination,
112 int destination_x,
113 int destination_y,
114 int destination_width,
115 int destination_height,
116 int mip_level,
117 int slice);
118
122 flutter::gpu::Texture* source,
123 int source_x,
124 int source_y,
125 int source_width,
126 int source_height,
127 flutter::gpu::DeviceBuffer* destination,
128 int destination_offset_in_bytes);
129
133 flutter::gpu::Texture* source,
134 flutter::gpu::Texture* destination,
135 int source_x,
136 int source_y,
137 int source_width,
138 int source_height,
139 int destination_x,
140 int destination_y);
141
142} // extern "C"
143
144#endif // FLUTTER_LIB_GPU_COMMAND_BUFFER_H_
bool CopyBufferToTexture(DeviceBuffer &source, size_t source_offset, size_t source_length, Texture &destination, impeller::IRect destination_region, uint32_t mip_level, uint32_t slice)
std::shared_ptr< impeller::CommandBuffer > GetCommandBuffer()
bool CopyTextureToTexture(Texture &source, Texture &destination, impeller::IRect source_region, impeller::IPoint destination_origin)
void AddRenderPass(std::shared_ptr< impeller::RenderPass > render_pass)
bool AddCompletionCallback(impeller::CommandBuffer::CompletionCallback completion_callback)
bool CopyTextureToBuffer(Texture &source, impeller::IRect source_region, DeviceBuffer &destination, size_t destination_offset)
std::function< void(Status)> CompletionCallback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_CommandBuffer_CopyTextureToBuffer(flutter::gpu::CommandBuffer *wrapper, flutter::gpu::Texture *source, int source_x, int source_y, int source_width, int source_height, flutter::gpu::DeviceBuffer *destination, int destination_offset_in_bytes)
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_CommandBuffer_CopyBufferToTexture(flutter::gpu::CommandBuffer *wrapper, flutter::gpu::DeviceBuffer *source, int source_offset_in_bytes, int source_length_in_bytes, flutter::gpu::Texture *destination, int destination_x, int destination_y, int destination_width, int destination_height, int mip_level, int slice)
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_CommandBuffer_Initialize(Dart_Handle wrapper, flutter::gpu::Context *contextWrapper)
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_CommandBuffer_Submit(flutter::gpu::CommandBuffer *wrapper, Dart_Handle completion_callback)
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_CommandBuffer_CopyTextureToTexture(flutter::gpu::CommandBuffer *wrapper, flutter::gpu::Texture *source, flutter::gpu::Texture *destination, int source_x, int source_y, int source_width, int source_height, int destination_x, int destination_y)
#define FLUTTER_GPU_EXPORT
Definition export.h:13
#define FML_FRIEND_MAKE_REF_COUNTED(T)
std::shared_ptr< ContextGLES > context
std::shared_ptr< RenderPass > render_pass
std::shared_ptr< CommandBuffer > command_buffer