226 {
227 auto context = context_.lock();
228 if (!context) {
229 return false;
230 }
231
232 if (requires_blit_) {
233 if (!(source_texture_ && destination_texture_)) {
234 return false;
235 }
236
237 auto blit_command_buffer = context->CreateCommandBuffer();
238 if (!blit_command_buffer) {
239 return false;
240 }
241 auto blit_pass = blit_command_buffer->CreateBlitPass();
242 if (!clip_rect_.has_value()) {
244 return false;
245 }
246 blit_pass->AddCopy(source_texture_, destination_texture_, std::nullopt,
247 clip_rect_->GetOrigin());
248 blit_pass->EncodeCommands(context->GetResourceAllocator());
249 if (!context->GetCommandQueue()->Submit({blit_command_buffer}).ok()) {
250 return false;
251 }
252 }
253#ifdef IMPELLER_DEBUG
255#endif
256
257 if (drawable_) {
258 id<MTLCommandBuffer> command_buffer =
261
262 id<CAMetalDrawable> metal_drawable =
263 reinterpret_cast<id<CAMetalDrawable>>(drawable_);
265 [(id<FlutterMetalDrawable>)metal_drawable
266 flutterPrepareForPresent:command_buffer];
267 }
268
269
270
271
272
273#if defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
274 constexpr bool alwaysWaitForScheduling = true;
275#else
276 constexpr bool alwaysWaitForScheduling = false;
277#endif
278
279
280
281
282 if ([[NSThread currentThread] isMainThread] ||
283 [[MTLCaptureManager sharedCaptureManager] isCapturing] ||
284 alwaysWaitForScheduling) {
286 [command_buffer commit];
287#if defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
288 [command_buffer waitUntilCompleted];
289#else
290 [command_buffer waitUntilScheduled];
291#endif
292 [drawable_ present];
293 } else {
294
295
296 id<CAMetalDrawable>
drawable = drawable_;
297 [command_buffer addScheduledHandler:^(id<MTLCommandBuffer>
buffer) {
299 }];
300 [command_buffer commit];
301 }
302 }
303
304 return true;
305}
static ContextMTL & Cast(Context &base)
id< MTLCommandBuffer > CreateMTLCommandBuffer(const std::string &label) const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer