227 auto context = context_.lock();
232 if (requires_blit_) {
233 if (!(source_texture_ && destination_texture_)) {
237 auto blit_command_buffer = context->CreateCommandBuffer();
238 if (!blit_command_buffer) {
241 auto blit_pass = blit_command_buffer->CreateBlitPass();
242 if (!clip_rect_.has_value()) {
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()) {
253 #ifdef IMPELLER_DEBUG
255 #endif // IMPELLER_DEBUG
258 id<MTLCommandBuffer> command_buffer =
262 id<CAMetalDrawable> metal_drawable =
263 reinterpret_cast<id<CAMetalDrawable>
>(drawable_);
265 [(id<FlutterMetalDrawable>)metal_drawable
266 flutterPrepareForPresent:command_buffer];
273 #if defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
274 constexpr
bool alwaysWaitForScheduling =
true;
276 constexpr
bool alwaysWaitForScheduling =
false;
277 #endif // defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
282 if ([[NSThread currentThread] isMainThread] ||
283 [[MTLCaptureManager sharedCaptureManager] isCapturing] ||
284 alwaysWaitForScheduling) {
285 TRACE_EVENT0(
"flutter",
"waitUntilScheduled");
286 [command_buffer commit];
287 #if defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
288 [command_buffer waitUntilCompleted];
290 [command_buffer waitUntilScheduled];
291 #endif // defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
296 id<CAMetalDrawable>
drawable = drawable_;
297 [command_buffer addScheduledHandler:^(id<MTLCommandBuffer> buffer) {
300 [command_buffer commit];