673 TRACE_EVENT0(
"flutter",
"FlutterPlatformViewsController::SubmitFrame");
676 FML_DCHECK([[NSThread currentThread] isMainThread]);
677 if (flutter_view_ ==
nullptr) {
678 return frame->Submit();
683 DlCanvas* background_canvas = frame->Canvas();
686 background_canvas->Flush();
690 DlAutoCanvasRestore save(background_canvas,
true);
693 LayersMap platform_view_layers;
695 auto did_submit =
true;
696 auto num_platform_views = composition_order_.size();
700 for (
size_t i = 0; i < num_platform_views; i++) {
701 int64_t platform_view_id = composition_order_[i];
702 EmbedderViewSlice* slice = slices_[platform_view_id].get();
703 slice->end_recording();
707 for (
size_t j = i + 1; j > 0; j--) {
708 int64_t current_platform_view_id = composition_order_[j - 1];
710 std::vector<SkIRect> intersection_rects = slice->region(platform_view_rect).getRects();
711 const SkIRect rounded_in_platform_view_rect = platform_view_rect.roundIn();
722 for (
auto it = intersection_rects.begin(); it != intersection_rects.end(); ) {
725 if (!SkIRect::Intersects(*it, rounded_in_platform_view_rect)) {
726 it = intersection_rects.erase(it);
732 auto allocation_size = intersection_rects.size();
736 auto overlay_id = platform_view_layers[current_platform_view_id].size();
743 if (allocation_size > kMaxLayerAllocations) {
744 SkIRect joined_rect = SkIRect::MakeEmpty();
745 for (
const SkIRect& rect : intersection_rects) {
746 joined_rect.join(rect);
750 intersection_rects.clear();
751 intersection_rects.push_back(joined_rect);
753 for (SkIRect& joined_rect : intersection_rects) {
756 joined_rect.intersect(platform_view_rect.roundOut());
759 background_canvas->ClipRect(SkRect::Make(joined_rect), DlCanvas::ClipOp::kDifference);
761 std::shared_ptr<FlutterPlatformViewLayer> layer =
766 current_platform_view_id,
770 did_submit &= layer->did_submit_last_frame;
771 platform_view_layers[current_platform_view_id].push_back(layer);
775 slice->render_into(background_canvas);
783 RemoveUnusedLayers();
785 BringLayersIntoView(platform_view_layers);
787 layer_pool_->RecycleLayers();
789 did_submit &= frame->Submit();
794 CommitCATransactionIfNeeded();