663 TRACE_EVENT0(
"flutter",
"FlutterPlatformViewsController::SubmitFrame");
666 FML_DCHECK([[NSThread currentThread] isMainThread]);
667 if (flutter_view_ ==
nullptr) {
668 return frame->Submit();
673 DlCanvas* background_canvas = frame->Canvas();
676 background_canvas->Flush();
680 DlAutoCanvasRestore save(background_canvas,
true);
683 LayersMap platform_view_layers;
685 auto did_submit =
true;
686 auto num_platform_views = composition_order_.size();
690 for (
size_t i = 0; i < num_platform_views; i++) {
691 int64_t platform_view_id = composition_order_[i];
692 EmbedderViewSlice* slice = slices_[platform_view_id].get();
693 slice->end_recording();
697 for (
size_t j = i + 1; j > 0; j--) {
698 int64_t current_platform_view_id = composition_order_[j - 1];
700 std::vector<SkIRect> intersection_rects = slice->region(platform_view_rect).getRects();
701 const SkIRect rounded_in_platform_view_rect = platform_view_rect.roundIn();
712 for (
auto it = intersection_rects.begin(); it != intersection_rects.end(); ) {
715 if (!SkIRect::Intersects(*it, rounded_in_platform_view_rect)) {
716 it = intersection_rects.erase(it);
722 auto allocation_size = intersection_rects.size();
726 auto overlay_id = platform_view_layers[current_platform_view_id].size();
733 if (allocation_size > kMaxLayerAllocations) {
734 SkIRect joined_rect = SkIRect::MakeEmpty();
735 for (
const SkIRect& rect : intersection_rects) {
736 joined_rect.join(rect);
740 intersection_rects.clear();
741 intersection_rects.push_back(joined_rect);
743 for (SkIRect& joined_rect : intersection_rects) {
746 joined_rect.intersect(platform_view_rect.roundOut());
749 background_canvas->ClipRect(SkRect::Make(joined_rect), DlCanvas::ClipOp::kDifference);
751 std::shared_ptr<FlutterPlatformViewLayer> layer =
756 current_platform_view_id,
760 did_submit &= layer->did_submit_last_frame;
761 platform_view_layers[current_platform_view_id].push_back(layer);
765 slice->render_into(background_canvas);
773 RemoveUnusedLayers();
775 BringLayersIntoView(platform_view_layers);
777 layer_pool_->RecycleLayers();
779 did_submit &= frame->Submit();
784 CommitCATransactionIfNeeded();