Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::gpu::CommandBuffer Class Reference

#include <command_buffer.h>

Inheritance diagram for flutter::gpu::CommandBuffer:
flutter::RefCountedDartWrappable< CommandBuffer > fml::RefCountedThreadSafe< T > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 CommandBuffer (std::shared_ptr< impeller::Context > context, std::shared_ptr< impeller::CommandBuffer > command_buffer)
 
std::shared_ptr< impeller::CommandBufferGetCommandBuffer ()
 
void AddRenderPass (std::shared_ptr< impeller::RenderPass > render_pass)
 
bool AddCompletionCallback (impeller::CommandBuffer::CompletionCallback completion_callback)
 
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)
 
bool CopyTextureToBuffer (Texture &source, impeller::IRect source_region, DeviceBuffer &destination, size_t destination_offset)
 
bool CopyTextureToTexture (Texture &source, Texture &destination, impeller::IRect source_region, impeller::IPoint destination_origin)
 
bool Submit ()
 
bool Submit (const impeller::CommandBuffer::CompletionCallback &completion_callback)
 
 ~CommandBuffer () override
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< CommandBuffer >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< T >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex ,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< T >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 26 of file command_buffer.h.

Constructor & Destructor Documentation

◆ CommandBuffer()

flutter::gpu::CommandBuffer::CommandBuffer ( std::shared_ptr< impeller::Context context,
std::shared_ptr< impeller::CommandBuffer command_buffer 
)

Definition at line 20 of file command_buffer.cc.

23 : context_(std::move(context)),
24 command_buffer_(std::move(command_buffer)) {}
std::shared_ptr< ContextGLES > context
std::shared_ptr< CommandBuffer > command_buffer

◆ ~CommandBuffer()

flutter::gpu::CommandBuffer::~CommandBuffer ( )
overridedefault

References render_pass.

Member Function Documentation

◆ AddCompletionCallback()

bool flutter::gpu::CommandBuffer::AddCompletionCallback ( impeller::CommandBuffer::CompletionCallback  completion_callback)

Definition at line 107 of file command_buffer.cc.

108 {
109 if (submitted_) {
110 return false;
111 }
112 if (completion_callback) {
113 completion_callbacks_.push_back(std::move(completion_callback));
114 }
115 return true;
116}

◆ AddRenderPass()

void flutter::gpu::CommandBuffer::AddRenderPass ( std::shared_ptr< impeller::RenderPass render_pass)

Definition at line 42 of file command_buffer.cc.

43 {
44 Encodable encodable;
45 encodable.render_pass = std::move(render_pass);
46 encodables_.push_back(std::move(encodable));
47}
std::shared_ptr< RenderPass > render_pass

References render_pass.

◆ CopyBufferToTexture()

bool flutter::gpu::CommandBuffer::CopyBufferToTexture ( DeviceBuffer source,
size_t  source_offset,
size_t  source_length,
Texture destination,
impeller::IRect  destination_region,
uint32_t  mip_level,
uint32_t  slice 
)

Definition at line 63 of file command_buffer.cc.

69 {
70 auto blit_pass = GetOrCreateBlitPass();
71 if (!blit_pass) {
72 return false;
73 }
74 impeller::BufferView source_view(
75 source.GetBuffer(), impeller::Range(source_offset, source_length));
76 return blit_pass->AddCopy(
77 std::move(source_view), destination.GetTexture(), destination_region,
78 /*label=*/"CommandBuffer.copyBufferToTexture", mip_level, slice);
79}

References flutter::gpu::DeviceBuffer::GetBuffer(), and flutter::gpu::Texture::GetTexture().

◆ CopyTextureToBuffer()

bool flutter::gpu::CommandBuffer::CopyTextureToBuffer ( Texture source,
impeller::IRect  source_region,
DeviceBuffer destination,
size_t  destination_offset 
)

Definition at line 81 of file command_buffer.cc.

84 {
85 auto blit_pass = GetOrCreateBlitPass();
86 if (!blit_pass) {
87 return false;
88 }
89 return blit_pass->AddCopy(source.GetTexture(), destination.GetBuffer(),
90 source_region, destination_offset,
91 "CommandBuffer.copyTextureToBuffer");
92}

References flutter::gpu::DeviceBuffer::GetBuffer(), and flutter::gpu::Texture::GetTexture().

◆ CopyTextureToTexture()

bool flutter::gpu::CommandBuffer::CopyTextureToTexture ( Texture source,
Texture destination,
impeller::IRect  source_region,
impeller::IPoint  destination_origin 
)

Definition at line 94 of file command_buffer.cc.

97 {
98 auto blit_pass = GetOrCreateBlitPass();
99 if (!blit_pass) {
100 return false;
101 }
102 return blit_pass->AddCopy(source.GetTexture(), destination.GetTexture(),
103 source_region, destination_origin,
104 "CommandBuffer.copyTextureToTexture");
105}

References flutter::gpu::Texture::GetTexture().

◆ GetCommandBuffer()

std::shared_ptr< impeller::CommandBuffer > flutter::gpu::CommandBuffer::GetCommandBuffer ( )

Definition at line 38 of file command_buffer.cc.

38 {
39 return command_buffer_;
40}

◆ Submit() [1/2]

bool flutter::gpu::CommandBuffer::Submit ( )

Definition at line 118 of file command_buffer.cc.

118 {
119 return CommandBuffer::Submit({});
120}

References Submit().

Referenced by InternalFlutterGpu_CommandBuffer_Submit(), and Submit().

◆ Submit() [2/2]

bool flutter::gpu::CommandBuffer::Submit ( const impeller::CommandBuffer::CompletionCallback completion_callback)

Definition at line 122 of file command_buffer.cc.

123 {
124 if (submitted_) {
125 return false;
126 }
127 submitted_ = true;
128
129 std::vector<impeller::CommandBuffer::CompletionCallback> callbacks =
130 std::move(completion_callbacks_);
131 if (completion_callback) {
132 callbacks.push_back(completion_callback);
133 }
134 impeller::CommandBuffer::CompletionCallback combined_completion_callback;
135 if (!callbacks.empty()) {
136 combined_completion_callback =
137 [callbacks = std::move(callbacks)](
138 impeller::CommandBuffer::Status status) mutable {
139 for (auto& callback : callbacks) {
140 callback(status);
141 }
142 };
143 }
144
145 // For the GLES backend, command queue submission just flushes the reactor,
146 // which needs to happen on the raster thread.
147 if (context_->GetBackendType() == impeller::Context::BackendType::kOpenGLES) {
148 auto dart_state = flutter::UIDartState::Current();
149 auto& task_runners = dart_state->GetTaskRunners();
150
151 task_runners.GetRasterTaskRunner()->PostTask(
152 fml::MakeCopyable([context = context_, command_buffer = command_buffer_,
153 completion_callback = combined_completion_callback,
154 encodables = encodables_]() mutable {
155 for (auto& encodable : encodables) {
156 if (!encodable.EncodeCommands()) {
157 if (completion_callback) {
158 completion_callback(impeller::CommandBuffer::Status::kError);
159 }
160 context->DisposeThreadLocalCachedResources();
161 return;
162 }
163 }
164
165 auto status = context->GetCommandQueue()->Submit({command_buffer},
166 completion_callback);
167 if (!status.ok() && completion_callback) {
168 completion_callback(impeller::CommandBuffer::Status::kError);
169 }
170 context->DisposeThreadLocalCachedResources();
171 }));
172 return true;
173 }
174
175 for (auto& encodable : encodables_) {
176 if (!encodable.EncodeCommands()) {
177 return false;
178 }
179 }
180
181 auto status = context_->GetCommandQueue()->Submit(
182 {command_buffer_}, combined_completion_callback);
183 context_->DisposeThreadLocalCachedResources();
184 if (!status.ok() && combined_completion_callback) {
185 combined_completion_callback(impeller::CommandBuffer::Status::kError);
186 }
187 return status.ok();
188}
static UIDartState * Current()
std::function< void(Status)> CompletionCallback
FlutterDesktopBinaryReply callback
internal::CopyableLambda< T > MakeCopyable(T lambda)

References callback, command_buffer, context, flutter::UIDartState::Current(), impeller::CommandBuffer::kError, impeller::Context::kOpenGLES, and fml::MakeCopyable().


The documentation for this class was generated from the following files: