From cb618036300981b2892a91dccff82da9d9ed7ff2 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 2 Jul 2019 14:27:21 -0700 Subject: [PATCH 1/6] refactoring to move the mutator stack handling to preroll --- flow/embedded_views.h | 6 ++--- flow/layers/clip_path_layer.cc | 4 +-- flow/layers/clip_rect_layer.cc | 4 +-- flow/layers/clip_rrect_layer.cc | 4 +-- flow/layers/layer.h | 2 +- flow/layers/layer_tree.cc | 6 ++--- .../performance_overlay_layer_unittests.cc | 3 +-- flow/layers/physical_shape_layer_unittests.cc | 2 ++ flow/layers/platform_view_layer.cc | 17 +++++------- flow/layers/transform_layer.cc | 5 ++-- flow/raster_cache.cc | 2 -- flow/scene_update_context.cc | 2 -- .../framework/Source/FlutterPlatformViews.mm | 26 ++++++++++++------- .../Source/FlutterPlatformViews_Internal.h | 8 ++++-- shell/platform/darwin/ios/ios_surface_gl.h | 5 ++-- shell/platform/darwin/ios/ios_surface_gl.mm | 10 +++---- .../darwin/ios/ios_surface_software.h | 5 ++-- .../darwin/ios/ios_surface_software.mm | 10 +++---- 18 files changed, 64 insertions(+), 57 deletions(-) diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 337ebb4a567a9..a6a6721383798 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -185,13 +185,13 @@ class ExternalViewEmbedder { virtual void BeginFrame(SkISize frame_size) = 0; - virtual void PrerollCompositeEmbeddedView(int view_id) = 0; + virtual void PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params) = 0; virtual std::vector GetCurrentCanvases() = 0; // Must be called on the UI thread. - virtual SkCanvas* CompositeEmbeddedView(int view_id, - const EmbeddedViewParams& params) = 0; + virtual SkCanvas* CompositeEmbeddedView(int view_id) = 0; virtual bool SubmitFrame(GrContext* context); diff --git a/flow/layers/clip_path_layer.cc b/flow/layers/clip_path_layer.cc index 5739172a20c11..54c57d71fdccf 100644 --- a/flow/layers/clip_path_layer.cc +++ b/flow/layers/clip_path_layer.cc @@ -22,6 +22,7 @@ ClipPathLayer::~ClipPathLayer() = default; void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; SkRect clip_path_bounds = clip_path_.getBounds(); + context->mutators_stack.pushClipPath(clip_path_); if (context->cull_rect.intersect(clip_path_bounds)) { SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); @@ -31,6 +32,7 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { } } context->cull_rect = previous_cull_rect; + context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) @@ -60,7 +62,6 @@ void ClipPathLayer::Paint(PaintContext& context) const { SkAutoCanvasRestore save(context.internal_nodes_canvas, true); context.internal_nodes_canvas->clipPath(clip_path_, clip_behavior_ != Clip::hardEdge); - context.mutators_stack.pushClipPath(clip_path_); if (clip_behavior_ == Clip::antiAliasWithSaveLayer) { context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr); @@ -69,7 +70,6 @@ void ClipPathLayer::Paint(PaintContext& context) const { if (clip_behavior_ == Clip::antiAliasWithSaveLayer) { context.internal_nodes_canvas->restore(); } - context.mutators_stack.pop(); } } // namespace flutter diff --git a/flow/layers/clip_rect_layer.cc b/flow/layers/clip_rect_layer.cc index 31562649e1829..2f74dce1ef445 100644 --- a/flow/layers/clip_rect_layer.cc +++ b/flow/layers/clip_rect_layer.cc @@ -15,6 +15,7 @@ ClipRectLayer::~ClipRectLayer() = default; void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; + context->mutators_stack.pushClipRect(clip_rect_); if (context->cull_rect.intersect(clip_rect_)) { SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); @@ -24,6 +25,7 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { } } context->cull_rect = previous_cull_rect; + context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) @@ -50,7 +52,6 @@ void ClipRectLayer::Paint(PaintContext& context) const { SkAutoCanvasRestore save(context.internal_nodes_canvas, true); context.internal_nodes_canvas->clipRect(clip_rect_, clip_behavior_ != Clip::hardEdge); - context.mutators_stack.pushClipRect(clip_rect_); if (clip_behavior_ == Clip::antiAliasWithSaveLayer) { context.internal_nodes_canvas->saveLayer(clip_rect_, nullptr); @@ -59,7 +60,6 @@ void ClipRectLayer::Paint(PaintContext& context) const { if (clip_behavior_ == Clip::antiAliasWithSaveLayer) { context.internal_nodes_canvas->restore(); } - context.mutators_stack.pop(); } } // namespace flutter diff --git a/flow/layers/clip_rrect_layer.cc b/flow/layers/clip_rrect_layer.cc index 5308b806a1e88..d2d9cff999309 100644 --- a/flow/layers/clip_rrect_layer.cc +++ b/flow/layers/clip_rrect_layer.cc @@ -16,6 +16,7 @@ ClipRRectLayer::~ClipRRectLayer() = default; void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; SkRect clip_rrect_bounds = clip_rrect_.getBounds(); + context->mutators_stack.pushClipRRect(clip_rrect_); if (context->cull_rect.intersect(clip_rrect_bounds)) { SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); @@ -25,6 +26,7 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { } } context->cull_rect = previous_cull_rect; + context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) @@ -58,7 +60,6 @@ void ClipRRectLayer::Paint(PaintContext& context) const { SkAutoCanvasRestore save(context.internal_nodes_canvas, true); context.internal_nodes_canvas->clipRRect(clip_rrect_, clip_behavior_ != Clip::hardEdge); - context.mutators_stack.pushClipRRect(clip_rrect_); if (clip_behavior_ == Clip::antiAliasWithSaveLayer) { context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr); @@ -67,7 +68,6 @@ void ClipRRectLayer::Paint(PaintContext& context) const { if (clip_behavior_ == Clip::antiAliasWithSaveLayer) { context.internal_nodes_canvas->restore(); } - context.mutators_stack.pop(); } } // namespace flutter diff --git a/flow/layers/layer.h b/flow/layers/layer.h index 5e30a50c907f9..da2dcd8b21ce3 100644 --- a/flow/layers/layer.h +++ b/flow/layers/layer.h @@ -48,6 +48,7 @@ struct PrerollContext { RasterCache* raster_cache; GrContext* gr_context; ExternalViewEmbedder* view_embedder; + MutatorsStack& mutators_stack; SkColorSpace* dst_color_space; SkRect cull_rect; @@ -83,7 +84,6 @@ class Layer { SkCanvas* leaf_nodes_canvas; GrContext* gr_context; ExternalViewEmbedder* view_embedder; - MutatorsStack& mutators_stack; const Stopwatch& raster_time; const Stopwatch& ui_time; TextureRegistry& texture_registry; diff --git a/flow/layers/layer_tree.cc b/flow/layers/layer_tree.cc index 57bc87838980b..eeab848349848 100644 --- a/flow/layers/layer_tree.cc +++ b/flow/layers/layer_tree.cc @@ -31,10 +31,12 @@ void LayerTree::Preroll(CompositorContext::ScopedFrame& frame, frame.canvas() ? frame.canvas()->imageInfo().colorSpace() : nullptr; frame.context().raster_cache().SetCheckboardCacheImages( checkerboard_raster_cache_images_); + MutatorsStack stack; PrerollContext context = { ignore_raster_cache ? nullptr : &frame.context().raster_cache(), frame.gr_context(), frame.view_embedder(), + stack, color_space, kGiantRect, frame.context().raster_time(), @@ -83,13 +85,11 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame, } } - MutatorsStack stack; Layer::PaintContext context = { (SkCanvas*)&internal_nodes_canvas, frame.canvas(), frame.gr_context(), frame.view_embedder(), - stack, frame.context().raster_time(), frame.context().ui_time(), frame.context().texture_registry(), @@ -121,6 +121,7 @@ sk_sp LayerTree::Flatten(const SkRect& bounds) { nullptr, // raster_cache (don't consult the cache) nullptr, // gr_context (used for the raster cache) nullptr, // external view embedder + unused_stack, // mutator stack nullptr, // SkColorSpace* dst_color_space kGiantRect, // SkRect cull_rect unused_stopwatch, // frame time (dont care) @@ -138,7 +139,6 @@ sk_sp LayerTree::Flatten(const SkRect& bounds) { canvas, // canvas nullptr, nullptr, - unused_stack, unused_stopwatch, // frame time (dont care) unused_stopwatch, // engine time (dont care) unused_texture_registry, // texture registry (not supported) diff --git a/flow/layers/performance_overlay_layer_unittests.cc b/flow/layers/performance_overlay_layer_unittests.cc index f82b0e2963869..3de743e3aa1a4 100644 --- a/flow/layers/performance_overlay_layer_unittests.cc +++ b/flow/layers/performance_overlay_layer_unittests.cc @@ -47,11 +47,10 @@ TEST(PerformanceOverlayLayer, Gold) { ASSERT_TRUE(surface != nullptr); flutter::TextureRegistry unused_texture_registry; - flutter::MutatorsStack unused_stack; flutter::Layer::PaintContext paintContext = { nullptr, surface->getCanvas(), nullptr, nullptr, - unused_stack, mock_stopwatch, + mock_stopwatch, mock_stopwatch, unused_texture_registry, nullptr, false}; diff --git a/flow/layers/physical_shape_layer_unittests.cc b/flow/layers/physical_shape_layer_unittests.cc index 5c2506f74784e..972424a2fec6d 100644 --- a/flow/layers/physical_shape_layer_unittests.cc +++ b/flow/layers/physical_shape_layer_unittests.cc @@ -28,10 +28,12 @@ TEST(PhysicalShapeLayer, TotalElevation) { const Stopwatch unused_stopwatch; TextureRegistry unused_texture_registry; + MutatorsStack unused_stack; PrerollContext preroll_context{ nullptr, // raster_cache (don't consult the cache) nullptr, // gr_context (used for the raster cache) nullptr, // external view embedder + unused_stack, // mutator stack nullptr, // SkColorSpace* dst_color_space kGiantRect, // SkRect cull_rect unused_stopwatch, // frame time (dont care) diff --git a/flow/layers/platform_view_layer.cc b/flow/layers/platform_view_layer.cc index c7845a867de61..361c56f9aad9d 100644 --- a/flow/layers/platform_view_layer.cc +++ b/flow/layers/platform_view_layer.cc @@ -23,7 +23,12 @@ void PlatformViewLayer::Preroll(PrerollContext* context, "does not support embedding"; return; } - context->view_embedder->PrerollCompositeEmbeddedView(view_id_); + EmbeddedViewParams params; + params.offsetPixels = + SkPoint::Make(matrix.getTranslateX(), matrix.getTranslateY()); + params.sizePoints = size_; + params.mutatorsStack = context->mutators_stack; + context->view_embedder->PrerollCompositeEmbeddedView(view_id_, params); } void PlatformViewLayer::Paint(PaintContext& context) const { @@ -32,15 +37,7 @@ void PlatformViewLayer::Paint(PaintContext& context) const { "does not support embedding"; return; } - EmbeddedViewParams params; - SkMatrix transform = context.leaf_nodes_canvas->getTotalMatrix(); - params.offsetPixels = - SkPoint::Make(transform.getTranslateX(), transform.getTranslateY()); - params.sizePoints = size_; - params.mutatorsStack = context.mutators_stack; - - SkCanvas* canvas = - context.view_embedder->CompositeEmbeddedView(view_id_, params); + SkCanvas* canvas = context.view_embedder->CompositeEmbeddedView(view_id_); context.leaf_nodes_canvas = canvas; } } // namespace flutter diff --git a/flow/layers/transform_layer.cc b/flow/layers/transform_layer.cc index 1a63ff8a48431..f1c2b013dfba5 100644 --- a/flow/layers/transform_layer.cc +++ b/flow/layers/transform_layer.cc @@ -29,7 +29,7 @@ TransformLayer::~TransformLayer() = default; void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkMatrix child_matrix; child_matrix.setConcat(matrix, transform_); - + context->mutators_stack.pushTransform(transform_); SkRect previous_cull_rect = context->cull_rect; SkMatrix inverse_transform_; // Perspective projections don't produce rectangles that are useful for @@ -47,6 +47,7 @@ void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { set_paint_bounds(child_paint_bounds); context->cull_rect = previous_cull_rect; + context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) @@ -66,10 +67,8 @@ void TransformLayer::Paint(PaintContext& context) const { SkAutoCanvasRestore save(context.internal_nodes_canvas, true); context.internal_nodes_canvas->concat(transform_); - context.mutators_stack.pushTransform(transform_); PaintChildren(context); - context.mutators_stack.pop(); } } // namespace flutter diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index be0c88d5cc7e8..4ad18adf172e4 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -159,7 +159,6 @@ void RasterCache::Prepare(PrerollContext* context, entry.image = Rasterize(context->gr_context, ctm, context->dst_color_space, checkerboard_images_, layer->paint_bounds(), [layer, context](SkCanvas* canvas) { - MutatorsStack stack; SkISize canvas_size = canvas->getBaseLayerSize(); SkNWayCanvas internal_nodes_canvas( canvas_size.width(), canvas_size.height()); @@ -169,7 +168,6 @@ void RasterCache::Prepare(PrerollContext* context, canvas, context->gr_context, nullptr, - stack, context->raster_time, context->ui_time, context->texture_registry, diff --git a/flow/scene_update_context.cc b/flow/scene_update_context.cc index 5a27f3a74609a..d1fe2a94fa262 100644 --- a/flow/scene_update_context.cc +++ b/flow/scene_update_context.cc @@ -198,12 +198,10 @@ SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) { for (auto& task : paint_tasks_) { FML_DCHECK(task.surface); SkCanvas* canvas = task.surface->GetSkiaSurface()->getCanvas(); - flutter::MutatorsStack stack; Layer::PaintContext context = {canvas, canvas, frame.gr_context(), nullptr, - stack, frame.context().raster_time(), frame.context().ui_time(), frame.context().texture_registry(), diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 08ace583d48ab..a5dd502dc993c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -160,11 +160,20 @@ frame_size_ = frame_size; } -void FlutterPlatformViewsController::PrerollCompositeEmbeddedView(int view_id) { +void FlutterPlatformViewsController::PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params) { picture_recorders_[view_id] = std::make_unique(); picture_recorders_[view_id]->beginRecording(SkRect::Make(frame_size_)); picture_recorders_[view_id]->getRecordingCanvas()->clear(SK_ColorTRANSPARENT); composition_order_.push_back(view_id); + + if (current_composition_params_.count(view_id) == 1 && + current_composition_params_[view_id] == params) { + // Do nothing if the params didn't change. + return; + } + current_composition_params_[view_id] = EmbeddedViewParams(params); + views_need_recomposite.insert(view_id); } NSObject* FlutterPlatformViewsController::GetPlatformViewByID(int view_id) { @@ -296,19 +305,16 @@ } SkCanvas* FlutterPlatformViewsController::CompositeEmbeddedView( - int view_id, - const flutter::EmbeddedViewParams& params) { + int view_id) { // TODO(amirh): assert that this is running on the platform thread once we support the iOS // embedded views thread configuration. - // Do nothing if the params didn't change. - if (current_composition_params_.count(view_id) == 1 && - current_composition_params_[view_id] == params) { + // Do nothing if the view doesn't need to be composited. + if (views_need_recomposite.count(view_id) == 0) { return picture_recorders_[view_id]->getRecordingCanvas(); } - current_composition_params_[view_id] = EmbeddedViewParams(params); - CompositeWithParams(view_id, params); - + CompositeWithParams(view_id, current_composition_params_[view_id]); + views_need_recomposite.erase(view_id); return picture_recorders_[view_id]->getRecordingCanvas(); } @@ -324,6 +330,7 @@ picture_recorders_.clear(); current_composition_params_.clear(); clip_count_.clear(); + views_need_recomposite.clear(); } bool FlutterPlatformViewsController::SubmitFrame(bool gl_rendering, @@ -415,6 +422,7 @@ overlays_.erase(viewId); current_composition_params_.erase(viewId); clip_count_.erase(viewId); + views_need_recomposite.erase(viewId); } views_to_dispose_.clear(); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 61ecc4637ca34..d115cc48192ca 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -79,7 +79,8 @@ class FlutterPlatformViewsController { void SetFrameSize(SkISize frame_size); - void PrerollCompositeEmbeddedView(int view_id); + void PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params); // Returns the `FlutterPlatformView` object associated with the view_id. // @@ -90,7 +91,7 @@ class FlutterPlatformViewsController { std::vector GetCurrentCanvases(); - SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params); + SkCanvas* CompositeEmbeddedView(int view_id); // Discards all platform views instances and auxiliary resources. void Reset(); @@ -137,6 +138,9 @@ class FlutterPlatformViewsController { // The latest composition order that was presented in Present(). std::vector active_composition_order_; + // Only compoiste platform views in this set. + std::unordered_set views_need_recomposite; + std::map> picture_recorders_; void OnCreate(FlutterMethodCall* call, FlutterResult& result); diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index 0090634a99033..05239c24aee94 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -55,13 +55,14 @@ class IOSSurfaceGL final : public IOSSurface, void BeginFrame(SkISize frame_size) override; // |flutter::ExternalViewEmbedder| - void PrerollCompositeEmbeddedView(int view_id) override; + void PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params) override; // |flutter::ExternalViewEmbedder| std::vector GetCurrentCanvases() override; // |flutter::ExternalViewEmbedder| - SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params) override; + SkCanvas* CompositeEmbeddedView(int view_id) override; // |flutter::ExternalViewEmbedder| bool SubmitFrame(GrContext* context) override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index f9279cc5116fe..216c3218a5c55 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -89,10 +89,11 @@ [CATransaction begin]; } -void IOSSurfaceGL::PrerollCompositeEmbeddedView(int view_id) { + void IOSSurfaceGL::PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - platform_views_controller->PrerollCompositeEmbeddedView(view_id); + platform_views_controller->PrerollCompositeEmbeddedView(view_id, params); } std::vector IOSSurfaceGL::GetCurrentCanvases() { @@ -101,11 +102,10 @@ return platform_views_controller->GetCurrentCanvases(); } -SkCanvas* IOSSurfaceGL::CompositeEmbeddedView(int view_id, - const flutter::EmbeddedViewParams& params) { +SkCanvas* IOSSurfaceGL::CompositeEmbeddedView(int view_id) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - return platform_views_controller->CompositeEmbeddedView(view_id, params); + return platform_views_controller->CompositeEmbeddedView(view_id); } bool IOSSurfaceGL::SubmitFrame(GrContext* context) { diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index bcb5b6210bf6b..da967aad5190b 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -49,13 +49,14 @@ class IOSSurfaceSoftware final : public IOSSurface, void BeginFrame(SkISize frame_size) override; // |flutter::ExternalViewEmbedder| - void PrerollCompositeEmbeddedView(int view_id) override; + void PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params) override; // |flutter::ExternalViewEmbedder| std::vector GetCurrentCanvases() override; // |flutter::ExternalViewEmbedder| - SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params) override; + SkCanvas* CompositeEmbeddedView(int view_id) override; // |flutter::ExternalViewEmbedder| bool SubmitFrame(GrContext* context) override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 32cb5a2bbeef1..c4d49bf0f28a6 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -141,10 +141,11 @@ platform_views_controller->SetFrameSize(frame_size); } -void IOSSurfaceSoftware::PrerollCompositeEmbeddedView(int view_id) { + void IOSSurfaceSoftware::PrerollCompositeEmbeddedView(int view_id, + const flutter::EmbeddedViewParams& params) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - platform_views_controller->PrerollCompositeEmbeddedView(view_id); + platform_views_controller->PrerollCompositeEmbeddedView(view_id, params); } std::vector IOSSurfaceSoftware::GetCurrentCanvases() { @@ -153,11 +154,10 @@ return platform_views_controller->GetCurrentCanvases(); } -SkCanvas* IOSSurfaceSoftware::CompositeEmbeddedView(int view_id, - const flutter::EmbeddedViewParams& params) { +SkCanvas* IOSSurfaceSoftware::CompositeEmbeddedView(int view_id) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - return platform_views_controller->CompositeEmbeddedView(view_id, params); + return platform_views_controller->CompositeEmbeddedView(view_id); } bool IOSSurfaceSoftware::SubmitFrame(GrContext* context) { From cd048b3137e4fc8da8950f7141404832423baeae Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 2 Jul 2019 15:50:34 -0700 Subject: [PATCH 2/6] more review fixes --- flow/layers/clip_path_layer.cc | 4 ++-- flow/layers/clip_rect_layer.cc | 4 ++-- flow/layers/clip_rrect_layer.cc | 4 ++-- .../ios/framework/Source/FlutterPlatformViews.mm | 10 +++++----- .../framework/Source/FlutterPlatformViews_Internal.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flow/layers/clip_path_layer.cc b/flow/layers/clip_path_layer.cc index 54c57d71fdccf..cb7c8454e4743 100644 --- a/flow/layers/clip_path_layer.cc +++ b/flow/layers/clip_path_layer.cc @@ -22,17 +22,17 @@ ClipPathLayer::~ClipPathLayer() = default; void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; SkRect clip_path_bounds = clip_path_.getBounds(); - context->mutators_stack.pushClipPath(clip_path_); if (context->cull_rect.intersect(clip_path_bounds)) { + context->mutators_stack.pushClipPath(clip_path_); SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); if (child_paint_bounds.intersect(clip_path_bounds)) { set_paint_bounds(child_paint_bounds); } + context->mutators_stack.pop(); } context->cull_rect = previous_cull_rect; - context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) diff --git a/flow/layers/clip_rect_layer.cc b/flow/layers/clip_rect_layer.cc index 2f74dce1ef445..3f6cda5954be0 100644 --- a/flow/layers/clip_rect_layer.cc +++ b/flow/layers/clip_rect_layer.cc @@ -15,17 +15,17 @@ ClipRectLayer::~ClipRectLayer() = default; void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; - context->mutators_stack.pushClipRect(clip_rect_); if (context->cull_rect.intersect(clip_rect_)) { + context->mutators_stack.pushClipRect(clip_rect_); SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); if (child_paint_bounds.intersect(clip_rect_)) { set_paint_bounds(child_paint_bounds); } + context->mutators_stack.pop(); } context->cull_rect = previous_cull_rect; - context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) diff --git a/flow/layers/clip_rrect_layer.cc b/flow/layers/clip_rrect_layer.cc index d2d9cff999309..7cd7dd24d1ee7 100644 --- a/flow/layers/clip_rrect_layer.cc +++ b/flow/layers/clip_rrect_layer.cc @@ -16,17 +16,17 @@ ClipRRectLayer::~ClipRRectLayer() = default; void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; SkRect clip_rrect_bounds = clip_rrect_.getBounds(); - context->mutators_stack.pushClipRRect(clip_rrect_); if (context->cull_rect.intersect(clip_rrect_bounds)) { + context->mutators_stack.pushClipRRect(clip_rrect_); SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); if (child_paint_bounds.intersect(clip_rrect_bounds)) { set_paint_bounds(child_paint_bounds); } + context->mutators_stack.pop(); } context->cull_rect = previous_cull_rect; - context->mutators_stack.pop(); } #if defined(OS_FUCHSIA) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 368159b15b231..b717e41e00a3c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -174,7 +174,7 @@ return; } current_composition_params_[view_id] = EmbeddedViewParams(*params.get()); - views_need_recomposite.insert(view_id); + views_to_recomposite_.insert(view_id); } NSObject* FlutterPlatformViewsController::GetPlatformViewByID(int view_id) { @@ -308,11 +308,11 @@ // embedded views thread configuration. // Do nothing if the view doesn't need to be composited. - if (views_need_recomposite.count(view_id) == 0) { + if (views_to_recomposite_.count(view_id) == 0) { return picture_recorders_[view_id]->getRecordingCanvas(); } CompositeWithParams(view_id, current_composition_params_[view_id]); - views_need_recomposite.erase(view_id); + views_to_recomposite_.erase(view_id); return picture_recorders_[view_id]->getRecordingCanvas(); } @@ -328,7 +328,7 @@ picture_recorders_.clear(); current_composition_params_.clear(); clip_count_.clear(); - views_need_recomposite.clear(); + views_to_recomposite_.clear(); } bool FlutterPlatformViewsController::SubmitFrame(bool gl_rendering, @@ -420,7 +420,7 @@ overlays_.erase(viewId); current_composition_params_.erase(viewId); clip_count_.erase(viewId); - views_need_recomposite.erase(viewId); + views_to_recomposite_.erase(viewId); } views_to_dispose_.clear(); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 4391f30109af9..9f04de5e0bfca 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -139,7 +139,7 @@ class FlutterPlatformViewsController { std::vector active_composition_order_; // Only compoiste platform views in this set. - std::unordered_set views_need_recomposite; + std::unordered_set views_to_recomposite_; std::map> picture_recorders_; From c14c832b3b6f7981dd48b5dc80fc8a7bf62c2786 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Tue, 2 Jul 2019 16:36:05 -0700 Subject: [PATCH 3/6] Add support for external view embedded to know if it has changed --- flow/compositor_context.cc | 3 +++ flow/embedded_views.h | 4 ++++ .../framework/Source/FlutterPlatformViews.mm | 23 +++++++++++++++++++ .../Source/FlutterPlatformViews_Internal.h | 7 ++++++ shell/platform/darwin/ios/ios_surface_gl.h | 6 +++++ shell/platform/darwin/ios/ios_surface_gl.mm | 12 ++++++++++ .../darwin/ios/ios_surface_software.h | 6 +++++ .../darwin/ios/ios_surface_software.mm | 12 ++++++++++ 8 files changed, 73 insertions(+) diff --git a/flow/compositor_context.cc b/flow/compositor_context.cc index bf38894b10813..351eb71f9b5e0 100644 --- a/flow/compositor_context.cc +++ b/flow/compositor_context.cc @@ -62,6 +62,9 @@ CompositorContext::ScopedFrame::~ScopedFrame() { bool CompositorContext::ScopedFrame::Raster(flutter::LayerTree& layer_tree, bool ignore_raster_cache) { + if (view_embedder_) { + view_embedder_->ResetEmbeddedViewsMutated(); + } layer_tree.Preroll(*this, ignore_raster_cache); // Clearing canvas after preroll reduces one render target switch when preroll // paints some raster cache. diff --git a/flow/embedded_views.h b/flow/embedded_views.h index d320504d29f63..fec59be5abf51 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -183,6 +183,10 @@ class ExternalViewEmbedder { public: ExternalViewEmbedder() = default; + virtual void ResetEmbeddedViewsMutated() = 0; + + virtual bool HaveEmbeddedViewsMutated() = 0; + virtual void BeginFrame(SkISize frame_size) = 0; virtual void PrerollCompositeEmbeddedView( diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index b717e41e00a3c..8b3aaaf02d5a8 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -160,6 +160,24 @@ frame_size_ = frame_size; } +bool FlutterPlatformViewsController::HaveEmbeddedViewsMutated() { + return embedded_views_mutated_; +} + +// This gets called prior to pre-roll. +void FlutterPlatformViewsController::ResetEmbeddedViewsMutated() { + embedded_views_mutated_ = false; + // pre-roll will populate the composition order. + composition_order_.clear(); +} + +static void CheckElementEquals(std::vector v1, std::vector v2, size_t index) { + if (v1.size() <= index || v2.size() <= index) { + return false; + } + return v1[index] == v2[index]; +} + void FlutterPlatformViewsController::PrerollCompositeEmbeddedView( int view_id, std::unique_ptr params) { @@ -168,11 +186,16 @@ picture_recorders_[view_id]->getRecordingCanvas()->clear(SK_ColorTRANSPARENT); composition_order_.push_back(view_id); + // check if the composition order has changed. + embedded_views_mutated_ |= CheckElementEquals(composition_order_, active_composition_order_, + composition_order_.size() - 1); + if (current_composition_params_.count(view_id) == 1 && current_composition_params_[view_id] == *params.get()) { // Do nothing if the params didn't change. return; } + embedded_views_mutated_ = true; current_composition_params_[view_id] = EmbeddedViewParams(*params.get()); views_to_recomposite_.insert(view_id); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 9f04de5e0bfca..1113c060ae426 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -79,6 +79,10 @@ class FlutterPlatformViewsController { void SetFrameSize(SkISize frame_size); + void ResetEmbeddedViewsMutated(); + + bool HaveEmbeddedViewsMutated(); + void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr params); @@ -141,6 +145,9 @@ class FlutterPlatformViewsController { // Only compoiste platform views in this set. std::unordered_set views_to_recomposite_; + // After |PrerollCompositeEmbeddedView| this is true if the embedded views have mutated. + bool embedded_views_mutated_; + std::map> picture_recorders_; void OnCreate(FlutterMethodCall* call, FlutterResult& result); diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index c337b896517f6..03c5b7bb8795d 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -51,6 +51,12 @@ class IOSSurfaceGL final : public IOSSurface, // |GPUSurfaceGLDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; + // |flutter::ExternalViewEmbedder| + void ResetEmbeddedViewsMutated() override; + + // |flutter::ExternalViewEmbedder| + bool HaveEmbeddedViewsMutated() override; + // |flutter::ExternalViewEmbedder| void BeginFrame(SkISize frame_size) override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index e2f4135e342bf..68aff26e1b7df 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -82,6 +82,18 @@ } } +void IOSSurfaceGL::ResetEmbeddedViewsMutated() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + platform_views_controller->ResetEmbeddedViewsMutated(); +} + +bool IOSSurfaceGL::HaveEmbeddedViewsMutated() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + return platform_views_controller->HaveEmbeddedViewsMutated(); +} + void IOSSurfaceGL::BeginFrame(SkISize frame_size) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index a4c2dd9af6764..ec62536423d2b 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -45,6 +45,12 @@ class IOSSurfaceSoftware final : public IOSSurface, // |GPUSurfaceSoftwareDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; + // |flutter::ExternalViewEmbedder| + void ResetEmbeddedViewsMutated() override; + + // |flutter::ExternalViewEmbedder| + bool HaveEmbeddedViewsMutated() override; + // |flutter::ExternalViewEmbedder| void BeginFrame(SkISize frame_size) override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 289785a200374..851adb7ed651f 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -135,6 +135,18 @@ } } +void IOSSurfaceSoftware::ResetEmbeddedViewsMutated() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + platform_views_controller->ResetEmbeddedViewsMutated(); +} + +bool IOSSurfaceSoftware::HaveEmbeddedViewsMutated() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + return platform_views_controller->HaveEmbeddedViewsMutated(); +} + void IOSSurfaceSoftware::BeginFrame(SkISize frame_size) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); From 556d83f6d508b39d8cd19ecb138cf0566b49195f Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Tue, 2 Jul 2019 16:48:31 -0700 Subject: [PATCH 4/6] remove the need to reset --- flow/compositor_context.cc | 3 -- flow/embedded_views.h | 2 -- .../framework/Source/FlutterPlatformViews.mm | 30 +++++++------------ .../Source/FlutterPlatformViews_Internal.h | 5 ---- shell/platform/darwin/ios/ios_surface_gl.h | 3 -- shell/platform/darwin/ios/ios_surface_gl.mm | 6 ---- .../darwin/ios/ios_surface_software.h | 3 -- .../darwin/ios/ios_surface_software.mm | 6 ---- 8 files changed, 11 insertions(+), 47 deletions(-) diff --git a/flow/compositor_context.cc b/flow/compositor_context.cc index 351eb71f9b5e0..bf38894b10813 100644 --- a/flow/compositor_context.cc +++ b/flow/compositor_context.cc @@ -62,9 +62,6 @@ CompositorContext::ScopedFrame::~ScopedFrame() { bool CompositorContext::ScopedFrame::Raster(flutter::LayerTree& layer_tree, bool ignore_raster_cache) { - if (view_embedder_) { - view_embedder_->ResetEmbeddedViewsMutated(); - } layer_tree.Preroll(*this, ignore_raster_cache); // Clearing canvas after preroll reduces one render target switch when preroll // paints some raster cache. diff --git a/flow/embedded_views.h b/flow/embedded_views.h index fec59be5abf51..89983e95668dd 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -183,8 +183,6 @@ class ExternalViewEmbedder { public: ExternalViewEmbedder() = default; - virtual void ResetEmbeddedViewsMutated() = 0; - virtual bool HaveEmbeddedViewsMutated() = 0; virtual void BeginFrame(SkISize frame_size) = 0; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 8b3aaaf02d5a8..cf6884a7ab3cb 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -161,21 +161,18 @@ } bool FlutterPlatformViewsController::HaveEmbeddedViewsMutated() { - return embedded_views_mutated_; -} - -// This gets called prior to pre-roll. -void FlutterPlatformViewsController::ResetEmbeddedViewsMutated() { - embedded_views_mutated_ = false; - // pre-roll will populate the composition order. - composition_order_.clear(); -} - -static void CheckElementEquals(std::vector v1, std::vector v2, size_t index) { - if (v1.size() <= index || v2.size() <= index) { - return false; + if (!views_to_recomposite_.empty()) { + return true; } - return v1[index] == v2[index]; + if (active_composition_order_.size() != composition_order_.size()) { + return true; + } + for (size_t i = 0; i < composition_order_.size(); i++) { + if (composition_order_[i] != active_composition_order_[i]) { + return true; + } + } + return false; } void FlutterPlatformViewsController::PrerollCompositeEmbeddedView( @@ -186,16 +183,11 @@ static void CheckElementEquals(std::vector v1, std::vector v2, picture_recorders_[view_id]->getRecordingCanvas()->clear(SK_ColorTRANSPARENT); composition_order_.push_back(view_id); - // check if the composition order has changed. - embedded_views_mutated_ |= CheckElementEquals(composition_order_, active_composition_order_, - composition_order_.size() - 1); - if (current_composition_params_.count(view_id) == 1 && current_composition_params_[view_id] == *params.get()) { // Do nothing if the params didn't change. return; } - embedded_views_mutated_ = true; current_composition_params_[view_id] = EmbeddedViewParams(*params.get()); views_to_recomposite_.insert(view_id); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 1113c060ae426..177ee791ff4a1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -79,8 +79,6 @@ class FlutterPlatformViewsController { void SetFrameSize(SkISize frame_size); - void ResetEmbeddedViewsMutated(); - bool HaveEmbeddedViewsMutated(); void PrerollCompositeEmbeddedView(int view_id, @@ -145,9 +143,6 @@ class FlutterPlatformViewsController { // Only compoiste platform views in this set. std::unordered_set views_to_recomposite_; - // After |PrerollCompositeEmbeddedView| this is true if the embedded views have mutated. - bool embedded_views_mutated_; - std::map> picture_recorders_; void OnCreate(FlutterMethodCall* call, FlutterResult& result); diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index 03c5b7bb8795d..4d2c59f72ff73 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -51,9 +51,6 @@ class IOSSurfaceGL final : public IOSSurface, // |GPUSurfaceGLDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; - // |flutter::ExternalViewEmbedder| - void ResetEmbeddedViewsMutated() override; - // |flutter::ExternalViewEmbedder| bool HaveEmbeddedViewsMutated() override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index 68aff26e1b7df..36f297408ee0c 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -82,12 +82,6 @@ } } -void IOSSurfaceGL::ResetEmbeddedViewsMutated() { - FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); - FML_CHECK(platform_views_controller != nullptr); - platform_views_controller->ResetEmbeddedViewsMutated(); -} - bool IOSSurfaceGL::HaveEmbeddedViewsMutated() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index ec62536423d2b..4e3d5e16b3570 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -45,9 +45,6 @@ class IOSSurfaceSoftware final : public IOSSurface, // |GPUSurfaceSoftwareDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; - // |flutter::ExternalViewEmbedder| - void ResetEmbeddedViewsMutated() override; - // |flutter::ExternalViewEmbedder| bool HaveEmbeddedViewsMutated() override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 851adb7ed651f..cd9682c6029e4 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -135,12 +135,6 @@ } } -void IOSSurfaceSoftware::ResetEmbeddedViewsMutated() { - FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); - FML_CHECK(platform_views_controller != nullptr); - platform_views_controller->ResetEmbeddedViewsMutated(); -} - bool IOSSurfaceSoftware::HaveEmbeddedViewsMutated() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); From de884bc305e653f02b5d994908dbc93fbb524eb9 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Tue, 2 Jul 2019 17:45:52 -0700 Subject: [PATCH 5/6] address comments --- flow/embedded_views.h | 2 ++ .../ios/framework/Source/FlutterPlatformViews.mm | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 89983e95668dd..b7ea4bfdeca3a 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -183,6 +183,8 @@ class ExternalViewEmbedder { public: ExternalViewEmbedder() = default; + // This will return true after pre-roll if any of the embedded views + // have mutated for last layer tree. virtual bool HaveEmbeddedViewsMutated() = 0; virtual void BeginFrame(SkISize frame_size) = 0; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index cf6884a7ab3cb..f2fefb5cdcde6 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -164,15 +164,7 @@ if (!views_to_recomposite_.empty()) { return true; } - if (active_composition_order_.size() != composition_order_.size()) { - return true; - } - for (size_t i = 0; i < composition_order_.size(); i++) { - if (composition_order_[i] != active_composition_order_[i]) { - return true; - } - } - return false; + return active_composition_order_ != composition_order_; } void FlutterPlatformViewsController::PrerollCompositeEmbeddedView( From 49c7eef5e9ac5402e347e872a815bf9fb73414d1 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Tue, 2 Jul 2019 18:24:42 -0700 Subject: [PATCH 6/6] Rename to HasPendingViewOperations --- flow/embedded_views.h | 2 +- .../darwin/ios/framework/Source/FlutterPlatformViews.mm | 2 +- .../ios/framework/Source/FlutterPlatformViews_Internal.h | 2 +- shell/platform/darwin/ios/ios_surface_gl.h | 2 +- shell/platform/darwin/ios/ios_surface_gl.mm | 4 ++-- shell/platform/darwin/ios/ios_surface_software.h | 2 +- shell/platform/darwin/ios/ios_surface_software.mm | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flow/embedded_views.h b/flow/embedded_views.h index b7ea4bfdeca3a..50d09ed928859 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -185,7 +185,7 @@ class ExternalViewEmbedder { // This will return true after pre-roll if any of the embedded views // have mutated for last layer tree. - virtual bool HaveEmbeddedViewsMutated() = 0; + virtual bool HasPendingViewOperations() = 0; virtual void BeginFrame(SkISize frame_size) = 0; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index f2fefb5cdcde6..aa2e2ab0bf4b3 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -160,7 +160,7 @@ frame_size_ = frame_size; } -bool FlutterPlatformViewsController::HaveEmbeddedViewsMutated() { +bool FlutterPlatformViewsController::HasPendingViewOperations() { if (!views_to_recomposite_.empty()) { return true; } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 177ee791ff4a1..40ea6333dff23 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -79,7 +79,7 @@ class FlutterPlatformViewsController { void SetFrameSize(SkISize frame_size); - bool HaveEmbeddedViewsMutated(); + bool HasPendingViewOperations(); void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr params); diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index 4d2c59f72ff73..8999669c6a0a9 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -52,7 +52,7 @@ class IOSSurfaceGL final : public IOSSurface, flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; // |flutter::ExternalViewEmbedder| - bool HaveEmbeddedViewsMutated() override; + bool HasPendingViewOperations() override; // |flutter::ExternalViewEmbedder| void BeginFrame(SkISize frame_size) override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index 36f297408ee0c..5f4185a07bf69 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -82,10 +82,10 @@ } } -bool IOSSurfaceGL::HaveEmbeddedViewsMutated() { +bool IOSSurfaceGL::HasPendingViewOperations() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - return platform_views_controller->HaveEmbeddedViewsMutated(); + return platform_views_controller->HasPendingViewOperations(); } void IOSSurfaceGL::BeginFrame(SkISize frame_size) { diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index 4e3d5e16b3570..7b0c2a0b0db9c 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -46,7 +46,7 @@ class IOSSurfaceSoftware final : public IOSSurface, flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; // |flutter::ExternalViewEmbedder| - bool HaveEmbeddedViewsMutated() override; + bool HasPendingViewOperations() override; // |flutter::ExternalViewEmbedder| void BeginFrame(SkISize frame_size) override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index cd9682c6029e4..2977ed792c34c 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -135,10 +135,10 @@ } } -bool IOSSurfaceSoftware::HaveEmbeddedViewsMutated() { +bool IOSSurfaceSoftware::HasPendingViewOperations() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - return platform_views_controller->HaveEmbeddedViewsMutated(); + return platform_views_controller->HasPendingViewOperations(); } void IOSSurfaceSoftware::BeginFrame(SkISize frame_size) {