From 9b752790f4d25ab238576c719208d7a38c6293f3 Mon Sep 17 00:00:00 2001 From: Ren You Date: Fri, 16 Oct 2020 18:25:13 -0400 Subject: [PATCH] Revert "[fuchsia] External view embedder will be shared with platform view (#21850)" (#21924) This reverts commit 1bc025d6cbf1136c2e96c6fb041d24202ea47ff0. --- flow/layers/child_scene_layer.cc | 4 +- flow/layers/child_scene_layer.h | 2 +- flow/layers/clip_path_layer.cc | 2 +- flow/layers/clip_path_layer.h | 2 +- flow/layers/clip_rect_layer.cc | 2 +- flow/layers/clip_rect_layer.h | 2 +- flow/layers/clip_rrect_layer.cc | 2 +- flow/layers/clip_rrect_layer.h | 2 +- flow/layers/container_layer.cc | 7 +- flow/layers/container_layer.h | 4 +- flow/layers/fuchsia_layer_unittests.cc | 12 ++-- flow/layers/layer.cc | 4 +- flow/layers/layer.h | 2 +- flow/layers/layer_tree.cc | 6 +- flow/layers/layer_tree.h | 2 +- flow/layers/opacity_layer.cc | 8 +-- flow/layers/opacity_layer.h | 2 +- flow/layers/platform_view_layer.cc | 5 +- flow/layers/platform_view_layer.h | 2 +- flow/layers/transform_layer.cc | 2 +- flow/layers/transform_layer.h | 2 +- flow/scene_update_context.cc | 70 +++++++++---------- flow/scene_update_context.h | 16 ++--- .../fuchsia/flutter/compositor_context.cc | 8 +-- .../fuchsia/flutter/compositor_context.h | 9 ++- shell/platform/fuchsia/flutter/engine.cc | 36 ++++------ shell/platform/fuchsia/flutter/engine.h | 6 +- .../platform/fuchsia/flutter/platform_view.cc | 3 - .../platform/fuchsia/flutter/platform_view.h | 4 -- .../fuchsia/flutter/platform_view_unittest.cc | 17 +---- shell/platform/fuchsia/flutter/surface.cc | 4 +- shell/platform/fuchsia/flutter/surface.h | 4 +- 32 files changed, 107 insertions(+), 146 deletions(-) diff --git a/flow/layers/child_scene_layer.cc b/flow/layers/child_scene_layer.cc index f15173c06..9ba5eff3c 100644 --- a/flow/layers/child_scene_layer.cc +++ b/flow/layers/child_scene_layer.cc @@ -26,10 +26,10 @@ void ChildSceneLayer::Paint(PaintContext& context) const { FML_NOTREACHED(); } -void ChildSceneLayer::UpdateScene(std::shared_ptr context) { +void ChildSceneLayer::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "ChildSceneLayer::UpdateScene"); FML_DCHECK(needs_system_composite()); - context->UpdateView(layer_id_, offset_, size_, hit_testable_); + context.UpdateView(layer_id_, offset_, size_, hit_testable_); } } // namespace flutter diff --git a/flow/layers/child_scene_layer.h b/flow/layers/child_scene_layer.h index 0ec7f3b16..cad47db00 100644 --- a/flow/layers/child_scene_layer.h +++ b/flow/layers/child_scene_layer.h @@ -26,7 +26,7 @@ class ChildSceneLayer : public Layer { void Paint(PaintContext& context) const override; - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; private: zx_koid_t layer_id_ = ZX_KOID_INVALID; diff --git a/flow/layers/clip_path_layer.cc b/flow/layers/clip_path_layer.cc index 0b714392b..038ead12a 100644 --- a/flow/layers/clip_path_layer.cc +++ b/flow/layers/clip_path_layer.cc @@ -41,7 +41,7 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { #if defined(LEGACY_FUCHSIA_EMBEDDER) -void ClipPathLayer::UpdateScene(std::shared_ptr context) { +void ClipPathLayer::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "ClipPathLayer::UpdateScene"); FML_DCHECK(needs_system_composite()); diff --git a/flow/layers/clip_path_layer.h b/flow/layers/clip_path_layer.h index eac015db9..ce2e4e54d 100644 --- a/flow/layers/clip_path_layer.h +++ b/flow/layers/clip_path_layer.h @@ -22,7 +22,7 @@ class ClipPathLayer : public ContainerLayer { } #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif private: diff --git a/flow/layers/clip_rect_layer.cc b/flow/layers/clip_rect_layer.cc index cd4443b5c..fbd36dab6 100644 --- a/flow/layers/clip_rect_layer.cc +++ b/flow/layers/clip_rect_layer.cc @@ -36,7 +36,7 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { #if defined(LEGACY_FUCHSIA_EMBEDDER) -void ClipRectLayer::UpdateScene(std::shared_ptr context) { +void ClipRectLayer::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "ClipRectLayer::UpdateScene"); FML_DCHECK(needs_system_composite()); diff --git a/flow/layers/clip_rect_layer.h b/flow/layers/clip_rect_layer.h index 9c57861d8..b52a95122 100644 --- a/flow/layers/clip_rect_layer.h +++ b/flow/layers/clip_rect_layer.h @@ -21,7 +21,7 @@ class ClipRectLayer : public ContainerLayer { } #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif private: diff --git a/flow/layers/clip_rrect_layer.cc b/flow/layers/clip_rrect_layer.cc index 32ed1a390..b3ff833c4 100644 --- a/flow/layers/clip_rrect_layer.cc +++ b/flow/layers/clip_rrect_layer.cc @@ -37,7 +37,7 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { #if defined(LEGACY_FUCHSIA_EMBEDDER) -void ClipRRectLayer::UpdateScene(std::shared_ptr context) { +void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "ClipRRectLayer::UpdateScene"); FML_DCHECK(needs_system_composite()); diff --git a/flow/layers/clip_rrect_layer.h b/flow/layers/clip_rrect_layer.h index 1422615c5..314886a1f 100644 --- a/flow/layers/clip_rrect_layer.h +++ b/flow/layers/clip_rrect_layer.h @@ -22,7 +22,7 @@ class ClipRRectLayer : public ContainerLayer { } #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif private: diff --git a/flow/layers/container_layer.cc b/flow/layers/container_layer.cc index a6ad98ba1..825826b70 100644 --- a/flow/layers/container_layer.cc +++ b/flow/layers/container_layer.cc @@ -98,19 +98,18 @@ void ContainerLayer::CheckForChildLayerBelow(PrerollContext* context) { // All ContainerLayers make the check in PrerollChildren. } -void ContainerLayer::UpdateScene(std::shared_ptr context) { +void ContainerLayer::UpdateScene(SceneUpdateContext& context) { UpdateSceneChildren(context); } -void ContainerLayer::UpdateSceneChildren( - std::shared_ptr context) { +void ContainerLayer::UpdateSceneChildren(SceneUpdateContext& context) { FML_DCHECK(needs_system_composite()); std::optional frame; if (child_layer_exists_below_) { frame.emplace( context, SkRRect::MakeRect(paint_bounds()), SK_ColorTRANSPARENT, - SkScalarRoundToInt(context->alphaf() * 255), "flutter::ContainerLayer"); + SkScalarRoundToInt(context.alphaf() * 255), "flutter::ContainerLayer"); frame->AddPaintLayer(this); } diff --git a/flow/layers/container_layer.h b/flow/layers/container_layer.h index 11eae5f3f..0e5b27d70 100644 --- a/flow/layers/container_layer.h +++ b/flow/layers/container_layer.h @@ -21,7 +21,7 @@ class ContainerLayer : public Layer { void Paint(PaintContext& context) const override; #if defined(LEGACY_FUCHSIA_EMBEDDER) void CheckForChildLayerBelow(PrerollContext* context) override; - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif const std::vector>& layers() const { return layers_; } @@ -33,7 +33,7 @@ class ContainerLayer : public Layer { void PaintChildren(PaintContext& context) const; #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateSceneChildren(std::shared_ptr context); + void UpdateSceneChildren(SceneUpdateContext& context); #endif // Try to prepare the raster cache for a given layer. diff --git a/flow/layers/fuchsia_layer_unittests.cc b/flow/layers/fuchsia_layer_unittests.cc index 85278b8c6..df8f8e746 100644 --- a/flow/layers/fuchsia_layer_unittests.cc +++ b/flow/layers/fuchsia_layer_unittests.cc @@ -261,7 +261,7 @@ struct TestContext { std::unique_ptr mock_session_wrapper; // SceneUpdateContext. - std::shared_ptr scene_update_context; + std::unique_ptr scene_update_context; // PrerollContext. MutatorsStack unused_stack; @@ -286,7 +286,7 @@ std::unique_ptr InitTest() { std::make_unique(std::move(session_ptr)); // Init SceneUpdateContext. - context->scene_update_context = std::make_shared( + context->scene_update_context = std::make_unique( "fuchsia_layer_unittest", fuchsia::ui::views::ViewToken(), scenic::ViewRefPair::New(), *(context->mock_session_wrapper)); @@ -410,7 +410,7 @@ TEST_F(FuchsiaLayerTest, DISABLED_PhysicalShapeLayersAndChildSceneLayers) { // Create another frame to be the "real" root. Required because // UpdateScene() traversal expects there to already be a top node. - SceneUpdateContext::Frame frame(test_context->scene_update_context, + SceneUpdateContext::Frame frame(*(test_context->scene_update_context), SkRRect::MakeRect(SkRect::MakeWH(100, 100)), SK_ColorTRANSPARENT, SK_AlphaOPAQUE, "fuchsia test root"); @@ -555,7 +555,7 @@ TEST_F(FuchsiaLayerTest, DISABLED_PhysicalShapeLayersAndChildSceneLayers) { // Finally, UpdateScene(). The MockSession will check the emitted commands // against the list above. - root->UpdateScene(test_context->scene_update_context); + root->UpdateScene(*(test_context->scene_update_context)); test_context->mock_session_wrapper->Present(); @@ -626,7 +626,7 @@ TEST_F(FuchsiaLayerTest, DISABLED_OpacityAndTransformLayer) { // Create another frame to be the "real" root. Required because // UpdateScene() traversal expects there to already be a top node. - SceneUpdateContext::Frame frame(test_context->scene_update_context, + SceneUpdateContext::Frame frame(*(test_context->scene_update_context), SkRRect::MakeRect(SkRect::MakeWH(100, 100)), SK_ColorTRANSPARENT, SK_AlphaOPAQUE, "fuchsia test root"); @@ -737,7 +737,7 @@ TEST_F(FuchsiaLayerTest, DISABLED_OpacityAndTransformLayer) { // Finally, UpdateScene(). The MockSession will check the emitted // commands against the list above. - root->UpdateScene(test_context->scene_update_context); + root->UpdateScene(*(test_context->scene_update_context)); test_context->mock_session_wrapper->Present(); diff --git a/flow/layers/layer.cc b/flow/layers/layer.cc index 006f5cb84..a242f977c 100644 --- a/flow/layers/layer.cc +++ b/flow/layers/layer.cc @@ -67,13 +67,13 @@ void Layer::CheckForChildLayerBelow(PrerollContext* context) { } } -void Layer::UpdateScene(std::shared_ptr context) { +void Layer::UpdateScene(SceneUpdateContext& context) { FML_DCHECK(needs_system_composite()); FML_DCHECK(child_layer_exists_below_); SceneUpdateContext::Frame frame( context, SkRRect::MakeRect(paint_bounds()), SK_ColorTRANSPARENT, - SkScalarRoundToInt(context->alphaf() * 255), "flutter::Layer"); + SkScalarRoundToInt(context.alphaf() * 255), "flutter::Layer"); frame.AddPaintLayer(this); } diff --git a/flow/layers/layer.h b/flow/layers/layer.h index 0ce351db6..eeffabacb 100644 --- a/flow/layers/layer.h +++ b/flow/layers/layer.h @@ -154,7 +154,7 @@ class Layer { #if defined(LEGACY_FUCHSIA_EMBEDDER) // Updates the system composited scene. - virtual void UpdateScene(std::shared_ptr context); + virtual void UpdateScene(SceneUpdateContext& context); virtual void CheckForChildLayerBelow(PrerollContext* context); #endif diff --git a/flow/layers/layer_tree.cc b/flow/layers/layer_tree.cc index d669591da..e0ac5157f 100644 --- a/flow/layers/layer_tree.cc +++ b/flow/layers/layer_tree.cc @@ -62,11 +62,11 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame, } #if defined(LEGACY_FUCHSIA_EMBEDDER) -void LayerTree::UpdateScene(std::shared_ptr context) { +void LayerTree::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "LayerTree::UpdateScene"); // Reset for a new Scene. - context->Reset(); + context.Reset(); const float inv_dpr = 1.0f / device_pixel_ratio_; SceneUpdateContext::Transform transform(context, inv_dpr, inv_dpr, 1.0f); @@ -82,7 +82,7 @@ void LayerTree::UpdateScene(std::shared_ptr context) { if (root_layer_->needs_painting()) { frame.AddPaintLayer(root_layer_.get()); } - context->root_node().AddChild(transform.entity_node()); + context.root_node().AddChild(transform.entity_node()); } #endif diff --git a/flow/layers/layer_tree.h b/flow/layers/layer_tree.h index b59f27829..b9cd8d37d 100644 --- a/flow/layers/layer_tree.h +++ b/flow/layers/layer_tree.h @@ -32,7 +32,7 @@ class LayerTree { bool ignore_raster_cache = false); #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context); + void UpdateScene(SceneUpdateContext& context); #endif void Paint(CompositorContext::ScopedFrame& frame, diff --git a/flow/layers/opacity_layer.cc b/flow/layers/opacity_layer.cc index 9e8001d6e..131b1d9f2 100644 --- a/flow/layers/opacity_layer.cc +++ b/flow/layers/opacity_layer.cc @@ -85,11 +85,11 @@ void OpacityLayer::Paint(PaintContext& context) const { #if defined(LEGACY_FUCHSIA_EMBEDDER) -void OpacityLayer::UpdateScene(std::shared_ptr context) { - float saved_alpha = context->alphaf(); - context->set_alphaf(context->alphaf() * (alpha_ / 255.f)); +void OpacityLayer::UpdateScene(SceneUpdateContext& context) { + float saved_alpha = context.alphaf(); + context.set_alphaf(context.alphaf() * (alpha_ / 255.f)); ContainerLayer::UpdateScene(context); - context->set_alphaf(saved_alpha); + context.set_alphaf(saved_alpha); } #endif diff --git a/flow/layers/opacity_layer.h b/flow/layers/opacity_layer.h index 25f1c7944..ed5f0283a 100644 --- a/flow/layers/opacity_layer.h +++ b/flow/layers/opacity_layer.h @@ -32,7 +32,7 @@ class OpacityLayer : public MergedContainerLayer { void Paint(PaintContext& context) const override; #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif private: diff --git a/flow/layers/platform_view_layer.cc b/flow/layers/platform_view_layer.cc index 0971f93db..80514b521 100644 --- a/flow/layers/platform_view_layer.cc +++ b/flow/layers/platform_view_layer.cc @@ -47,11 +47,10 @@ void PlatformViewLayer::Paint(PaintContext& context) const { } #if defined(LEGACY_FUCHSIA_EMBEDDER) -void PlatformViewLayer::UpdateScene( - std::shared_ptr context) { +void PlatformViewLayer::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "PlatformViewLayer::UpdateScene"); FML_DCHECK(needs_system_composite()); - context->UpdateView(view_id_, offset_, size_); + context.UpdateView(view_id_, offset_, size_); } #endif diff --git a/flow/layers/platform_view_layer.h b/flow/layers/platform_view_layer.h index e9d6fac42..a75c69689 100644 --- a/flow/layers/platform_view_layer.h +++ b/flow/layers/platform_view_layer.h @@ -19,7 +19,7 @@ class PlatformViewLayer : public Layer { void Paint(PaintContext& context) const override; #if defined(LEGACY_FUCHSIA_EMBEDDER) // Updates the system composited scene. - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif private: diff --git a/flow/layers/transform_layer.cc b/flow/layers/transform_layer.cc index 3e26e525a..8fe5dd32e 100644 --- a/flow/layers/transform_layer.cc +++ b/flow/layers/transform_layer.cc @@ -54,7 +54,7 @@ void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { #if defined(LEGACY_FUCHSIA_EMBEDDER) -void TransformLayer::UpdateScene(std::shared_ptr context) { +void TransformLayer::UpdateScene(SceneUpdateContext& context) { TRACE_EVENT0("flutter", "TransformLayer::UpdateScene"); FML_DCHECK(needs_system_composite()); diff --git a/flow/layers/transform_layer.h b/flow/layers/transform_layer.h index 7956e3906..63a212f92 100644 --- a/flow/layers/transform_layer.h +++ b/flow/layers/transform_layer.h @@ -20,7 +20,7 @@ class TransformLayer : public ContainerLayer { void Paint(PaintContext& context) const override; #if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; + void UpdateScene(SceneUpdateContext& context) override; #endif private: diff --git a/flow/scene_update_context.cc b/flow/scene_update_context.cc index 141e2caaf..3edd9c4d9 100644 --- a/flow/scene_update_context.cc +++ b/flow/scene_update_context.cc @@ -215,30 +215,29 @@ void SceneUpdateContext::DestroyView(int64_t view_id) { ViewHolder::Destroy(view_id); } -SceneUpdateContext::Entity::Entity(std::shared_ptr context) +SceneUpdateContext::Entity::Entity(SceneUpdateContext& context) : context_(context), - previous_entity_(context->top_entity_), - entity_node_(context->session_.get()) { - context->top_entity_ = this; + previous_entity_(context.top_entity_), + entity_node_(context.session_.get()) { + context.top_entity_ = this; } SceneUpdateContext::Entity::~Entity() { if (previous_entity_) { previous_entity_->embedder_node().AddChild(entity_node_); } else { - context_->root_node_.AddChild(entity_node_); + context_.root_node_.AddChild(entity_node_); } - FML_DCHECK(context_->top_entity_ == this); - context_->top_entity_ = previous_entity_; + FML_DCHECK(context_.top_entity_ == this); + context_.top_entity_ = previous_entity_; } -SceneUpdateContext::Transform::Transform( - std::shared_ptr context, - const SkMatrix& transform) +SceneUpdateContext::Transform::Transform(SceneUpdateContext& context, + const SkMatrix& transform) : Entity(context), - previous_scale_x_(context->top_scale_x_), - previous_scale_y_(context->top_scale_y_) { + previous_scale_x_(context.top_scale_x_), + previous_scale_y_(context.top_scale_y_) { entity_node().SetLabel("flutter::Transform"); if (!transform.isIdentity()) { // TODO(SCN-192): The perspective and shear components in the matrix @@ -256,8 +255,8 @@ SceneUpdateContext::Transform::Transform( decomposition.scale().y, // 1.f // ); - context->top_scale_x_ *= decomposition.scale().x; - context->top_scale_y_ *= decomposition.scale().y; + context.top_scale_x_ *= decomposition.scale().x; + context.top_scale_y_ *= decomposition.scale().y; entity_node().SetRotation(decomposition.rotation().x, // decomposition.rotation().y, // @@ -268,46 +267,45 @@ SceneUpdateContext::Transform::Transform( } } -SceneUpdateContext::Transform::Transform( - std::shared_ptr context, - float scale_x, - float scale_y, - float scale_z) +SceneUpdateContext::Transform::Transform(SceneUpdateContext& context, + float scale_x, + float scale_y, + float scale_z) : Entity(context), - previous_scale_x_(context->top_scale_x_), - previous_scale_y_(context->top_scale_y_) { + previous_scale_x_(context.top_scale_x_), + previous_scale_y_(context.top_scale_y_) { entity_node().SetLabel("flutter::Transform"); if (scale_x != 1.f || scale_y != 1.f || scale_z != 1.f) { entity_node().SetScale(scale_x, scale_y, scale_z); - context->top_scale_x_ *= scale_x; - context->top_scale_y_ *= scale_y; + context.top_scale_x_ *= scale_x; + context.top_scale_y_ *= scale_y; } } SceneUpdateContext::Transform::~Transform() { - context()->top_scale_x_ = previous_scale_x_; - context()->top_scale_y_ = previous_scale_y_; + context().top_scale_x_ = previous_scale_x_; + context().top_scale_y_ = previous_scale_y_; } -SceneUpdateContext::Frame::Frame(std::shared_ptr context, +SceneUpdateContext::Frame::Frame(SceneUpdateContext& context, const SkRRect& rrect, SkColor color, SkAlpha opacity, std::string label) : Entity(context), - previous_elevation_(context->top_elevation_), + previous_elevation_(context.top_elevation_), rrect_(rrect), color_(color), opacity_(opacity), - opacity_node_(context->session_.get()), + opacity_node_(context.session_.get()), paint_bounds_(SkRect::MakeEmpty()) { // Increment elevation trackers before calculating any local elevation. - // |UpdateView| can modify context->next_elevation_, which is why it is + // |UpdateView| can modify context.next_elevation_, which is why it is // neccesary to track this addtional state. - context->top_elevation_ += kScenicZElevationBetweenLayers; - context->next_elevation_ += kScenicZElevationBetweenLayers; + context.top_elevation_ += kScenicZElevationBetweenLayers; + context.next_elevation_ += kScenicZElevationBetweenLayers; - float local_elevation = context->next_elevation_ - previous_elevation_; + float local_elevation = context.next_elevation_ - previous_elevation_; entity_node().SetTranslation(0.f, 0.f, -local_elevation); entity_node().SetLabel(label); entity_node().AddChild(opacity_node_); @@ -320,11 +318,11 @@ SceneUpdateContext::Frame::Frame(std::shared_ptr context, } SceneUpdateContext::Frame::~Frame() { - context()->top_elevation_ = previous_elevation_; + context().top_elevation_ = previous_elevation_; // Add a part which represents the frame's geometry for clipping purposes - context()->CreateFrame(entity_node(), rrect_, color_, opacity_, paint_bounds_, - std::move(paint_layers_)); + context().CreateFrame(entity_node(), rrect_, color_, opacity_, paint_bounds_, + std::move(paint_layers_)); } void SceneUpdateContext::Frame::AddPaintLayer(Layer* layer) { @@ -333,7 +331,7 @@ void SceneUpdateContext::Frame::AddPaintLayer(Layer* layer) { paint_bounds_.join(layer->paint_bounds()); } -SceneUpdateContext::Clip::Clip(std::shared_ptr context, +SceneUpdateContext::Clip::Clip(SceneUpdateContext& context, const SkRect& shape_bounds) : Entity(context) { entity_node().SetLabel("flutter::Clip"); diff --git a/flow/scene_update_context.h b/flow/scene_update_context.h index d95513bc2..f15c59fa7 100644 --- a/flow/scene_update_context.h +++ b/flow/scene_update_context.h @@ -46,15 +46,15 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder { public: class Entity { public: - Entity(std::shared_ptr context); + Entity(SceneUpdateContext& context); virtual ~Entity(); - std::shared_ptr context() { return context_; } + SceneUpdateContext& context() { return context_; } scenic::EntityNode& entity_node() { return entity_node_; } virtual scenic::ContainerNode& embedder_node() { return entity_node_; } private: - std::shared_ptr context_; + SceneUpdateContext& context_; Entity* const previous_entity_; scenic::EntityNode entity_node_; @@ -62,9 +62,8 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder { class Transform : public Entity { public: - Transform(std::shared_ptr context, - const SkMatrix& transform); - Transform(std::shared_ptr context, + Transform(SceneUpdateContext& context, const SkMatrix& transform); + Transform(SceneUpdateContext& context, float scale_x, float scale_y, float scale_z); @@ -80,7 +79,7 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder { // When layer is not nullptr, the frame is associated with a layer subtree // rooted with that layer. The frame may then create a surface that will be // retained for that layer. - Frame(std::shared_ptr context, + Frame(SceneUpdateContext& context, const SkRRect& rrect, SkColor color, SkAlpha opacity, @@ -105,8 +104,7 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder { class Clip : public Entity { public: - Clip(std::shared_ptr context, - const SkRect& shape_bounds); + Clip(SceneUpdateContext& context, const SkRect& shape_bounds); ~Clip() = default; }; diff --git a/shell/platform/fuchsia/flutter/compositor_context.cc b/shell/platform/fuchsia/flutter/compositor_context.cc index 2f2a83eba..005a9cca0 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.cc +++ b/shell/platform/fuchsia/flutter/compositor_context.cc @@ -23,7 +23,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { fml::RefPtr raster_thread_merger, SessionConnection& session_connection, VulkanSurfaceProducer& surface_producer, - std::shared_ptr scene_update_context) + flutter::SceneUpdateContext& scene_update_context) : flutter::CompositorContext::ScopedFrame(context, surface_producer.gr_context(), canvas, @@ -39,7 +39,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { private: SessionConnection& session_connection_; VulkanSurfaceProducer& surface_producer_; - std::shared_ptr scene_update_context_; + flutter::SceneUpdateContext& scene_update_context_; flutter::RasterStatus Raster(flutter::LayerTree& layer_tree, bool ignore_raster_cache) override { @@ -64,7 +64,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { // Flush all pending session ops: create surfaces and enqueue session // Image ops for the frame's paint tasks, then Present. TRACE_EVENT0("flutter", "SessionPresent"); - frame_paint_tasks = scene_update_context_->GetPaintTasks(); + frame_paint_tasks = scene_update_context_.GetPaintTasks(); for (auto& task : frame_paint_tasks) { SkISize physical_size = SkISize::Make(layer_tree.device_pixel_ratio() * task.scale_x * @@ -142,7 +142,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { CompositorContext::CompositorContext( SessionConnection& session_connection, VulkanSurfaceProducer& surface_producer, - std::shared_ptr scene_update_context) + flutter::SceneUpdateContext& scene_update_context) : session_connection_(session_connection), surface_producer_(surface_producer), scene_update_context_(scene_update_context) {} diff --git a/shell/platform/fuchsia/flutter/compositor_context.h b/shell/platform/fuchsia/flutter/compositor_context.h index 4a943a499..542e5d314 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.h +++ b/shell/platform/fuchsia/flutter/compositor_context.h @@ -21,17 +21,16 @@ namespace flutter_runner { // Fuchsia. class CompositorContext final : public flutter::CompositorContext { public: - CompositorContext( - SessionConnection& session_connection, - VulkanSurfaceProducer& surface_producer, - std::shared_ptr scene_update_context); + CompositorContext(SessionConnection& session_connection, + VulkanSurfaceProducer& surface_producer, + flutter::SceneUpdateContext& scene_update_context); ~CompositorContext() override; private: SessionConnection& session_connection_; VulkanSurfaceProducer& surface_producer_; - std::shared_ptr scene_update_context_; + flutter::SceneUpdateContext& scene_update_context_; // |flutter::CompositorContext| std::unique_ptr AcquireFrame( diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index 0ef28c356..a7d85630c 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc @@ -9,7 +9,6 @@ #include #include "../runtime/dart/utils/files.h" -#include "flow/embedded_views.h" #include "flutter/common/task_runners.h" #include "flutter/fml/make_copyable.h" #include "flutter/fml/synchronization/waitable_event.h" @@ -139,18 +138,15 @@ Engine::Engine(Delegate& delegate, surface_producer_.emplace(session_connection_->get()); #if defined(LEGACY_FUCHSIA_EMBEDDER) if (use_legacy_renderer_) { - legacy_external_view_embedder_ = - std::make_shared( - thread_label_, std::move(view_token), - std::move(view_ref_pair), session_connection_.value()); + legacy_external_view_embedder_.emplace( + thread_label_, std::move(view_token), std::move(view_ref_pair), + session_connection_.value()); } else #endif { - external_view_embedder_ = - std::make_shared( - thread_label_, std::move(view_token), - std::move(view_ref_pair), session_connection_.value(), - surface_producer_.value()); + external_view_embedder_.emplace( + thread_label_, std::move(view_token), std::move(view_ref_pair), + session_connection_.value(), surface_producer_.value()); } })); @@ -210,7 +206,6 @@ Engine::Engine(Delegate& delegate, on_update_view_callback = std::move(on_update_view_callback), on_destroy_view_callback = std::move(on_destroy_view_callback), on_create_surface_callback = std::move(on_create_surface_callback), - external_view_embedder = GetExternalViewEmbedder(), vsync_offset = product_config.get_vsync_offset(), vsync_handle = vsync_event_.get()](flutter::Shell& shell) mutable { return std::make_unique( @@ -228,7 +223,6 @@ Engine::Engine(Delegate& delegate, std::move(on_update_view_callback), std::move(on_destroy_view_callback), std::move(on_create_surface_callback), - external_view_embedder, // external view embedder std::move(vsync_offset), // vsync offset vsync_handle); }); @@ -245,7 +239,7 @@ Engine::Engine(Delegate& delegate, auto compositor_context = std::make_unique( session_connection_.value(), surface_producer_.value(), - legacy_external_view_embedder_); + legacy_external_view_embedder_.value()); return std::make_unique( shell, std::move(compositor_context)); } else { @@ -584,28 +578,22 @@ void Engine::DestroyView(int64_t view_id) { } std::unique_ptr Engine::CreateSurface() { - return std::make_unique(thread_label_, GetExternalViewEmbedder(), - surface_producer_->gr_context()); -} - -std::shared_ptr -Engine::GetExternalViewEmbedder() { - std::shared_ptr external_view_embedder = - nullptr; + flutter::ExternalViewEmbedder* external_view_embedder = nullptr; #if defined(LEGACY_FUCHSIA_EMBEDDER) if (use_legacy_renderer_) { FML_CHECK(legacy_external_view_embedder_); - external_view_embedder = legacy_external_view_embedder_; + external_view_embedder = &legacy_external_view_embedder_.value(); } else #endif { FML_CHECK(external_view_embedder_); - external_view_embedder = external_view_embedder_; + external_view_embedder = &external_view_embedder_.value(); } FML_CHECK(external_view_embedder); - return external_view_embedder; + return std::make_unique(thread_label_, external_view_embedder, + surface_producer_->gr_context()); } #if !defined(DART_PRODUCT) diff --git a/shell/platform/fuchsia/flutter/engine.h b/shell/platform/fuchsia/flutter/engine.h index a1335c59c..4fc29e7cf 100644 --- a/shell/platform/fuchsia/flutter/engine.h +++ b/shell/platform/fuchsia/flutter/engine.h @@ -16,7 +16,6 @@ #include #include -#include "flow/embedded_views.h" #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/shell/common/shell.h" @@ -72,9 +71,9 @@ class Engine final { std::optional session_connection_; std::optional surface_producer_; - std::shared_ptr external_view_embedder_; + std::optional external_view_embedder_; #if defined(LEGACY_FUCHSIA_EMBEDDER) - std::shared_ptr legacy_external_view_embedder_; + std::optional legacy_external_view_embedder_; #endif std::unique_ptr isolate_configurator_; @@ -100,7 +99,6 @@ class Engine final { void CreateView(int64_t view_id, bool hit_testable, bool focusable); void UpdateView(int64_t view_id, bool hit_testable, bool focusable); void DestroyView(int64_t view_id); - std::shared_ptr GetExternalViewEmbedder(); std::unique_ptr CreateSurface(); diff --git a/shell/platform/fuchsia/flutter/platform_view.cc b/shell/platform/fuchsia/flutter/platform_view.cc index fa7e9a77c..db227ffd3 100644 --- a/shell/platform/fuchsia/flutter/platform_view.cc +++ b/shell/platform/fuchsia/flutter/platform_view.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flow/embedded_views.h" #define RAPIDJSON_HAS_STDSTRING 1 #include "platform_view.h" @@ -67,7 +66,6 @@ PlatformView::PlatformView( OnUpdateView on_update_view_callback, OnDestroyView on_destroy_view_callback, OnCreateSurface on_create_surface_callback, - std::shared_ptr external_view_embedder, fml::TimeDelta vsync_offset, zx_handle_t vsync_event_handle) : flutter::PlatformView(delegate, std::move(task_runners)), @@ -82,7 +80,6 @@ PlatformView::PlatformView( on_update_view_callback_(std::move(on_update_view_callback)), on_destroy_view_callback_(std::move(on_destroy_view_callback)), on_create_surface_callback_(std::move(on_create_surface_callback)), - external_view_embedder_(external_view_embedder), ime_client_(this), vsync_offset_(std::move(vsync_offset)), vsync_event_handle_(vsync_event_handle) { diff --git a/shell/platform/fuchsia/flutter/platform_view.h b/shell/platform/fuchsia/flutter/platform_view.h index 9f29b3397..a888298f9 100644 --- a/shell/platform/fuchsia/flutter/platform_view.h +++ b/shell/platform/fuchsia/flutter/platform_view.h @@ -14,13 +14,11 @@ #include #include -#include "flow/embedded_views.h" #include "flutter/fml/macros.h" #include "flutter/fml/time/time_delta.h" #include "flutter/shell/common/platform_view.h" #include "accessibility_bridge.h" -#include "shell/platform/fuchsia/flutter/fuchsia_external_view_embedder.h" namespace flutter_runner { @@ -63,7 +61,6 @@ class PlatformView final : public flutter::PlatformView, OnUpdateView on_update_view_callback, OnDestroyView on_destroy_view_callback, OnCreateSurface on_create_surface_callback, - std::shared_ptr view_embedder, fml::TimeDelta vsync_offset, zx_handle_t vsync_event_handle); @@ -172,7 +169,6 @@ class PlatformView final : public flutter::PlatformView, OnUpdateView on_update_view_callback_; OnDestroyView on_destroy_view_callback_; OnCreateSurface on_create_surface_callback_; - std::shared_ptr external_view_embedder_; int current_text_input_client_ = 0; fidl::Binding ime_client_; diff --git a/shell/platform/fuchsia/flutter/platform_view_unittest.cc b/shell/platform/fuchsia/flutter/platform_view_unittest.cc index 38f771ce2..63f010ed6 100644 --- a/shell/platform/fuchsia/flutter/platform_view_unittest.cc +++ b/shell/platform/fuchsia/flutter/platform_view_unittest.cc @@ -184,11 +184,10 @@ TEST_F(PlatformViewTests, CreateSurfaceTest) { // Test create surface callback function. sk_sp gr_context = GrDirectContext::MakeMock(nullptr, GrContextOptions()); - std::shared_ptr view_embedder = - std::make_shared(); + MockExternalViewEmbedder view_embedder; auto CreateSurfaceCallback = [&view_embedder, gr_context]() { return std::make_unique( - "PlatformViewTest", view_embedder, gr_context.get()); + "PlatformViewTest", &view_embedder, gr_context.get()); }; auto platform_view = flutter_runner::PlatformView( @@ -206,7 +205,6 @@ TEST_F(PlatformViewTests, CreateSurfaceTest) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, CreateSurfaceCallback, // on_create_surface_callback, - view_embedder, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -215,7 +213,7 @@ TEST_F(PlatformViewTests, CreateSurfaceTest) { RunLoopUntilIdle(); EXPECT_EQ(gr_context.get(), delegate.surface()->GetContext()); - EXPECT_EQ(view_embedder.get(), delegate.surface()->GetExternalViewEmbedder()); + EXPECT_EQ(&view_embedder, delegate.surface()->GetExternalViewEmbedder()); } // This test makes sure that the PlatformView correctly registers Scenic @@ -250,7 +248,6 @@ TEST_F(PlatformViewTests, SetViewportMetrics) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -383,7 +380,6 @@ TEST_F(PlatformViewTests, ChangesAccessibilitySettings) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -434,7 +430,6 @@ TEST_F(PlatformViewTests, EnableWireframeTest) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -496,7 +491,6 @@ TEST_F(PlatformViewTests, CreateViewTest) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -560,7 +554,6 @@ TEST_F(PlatformViewTests, UpdateViewTest) { UpdateViewCallback, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -624,7 +617,6 @@ TEST_F(PlatformViewTests, DestroyViewTest) { nullptr, // on_update_view_callback, DestroyViewCallback, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -685,7 +677,6 @@ TEST_F(PlatformViewTests, ViewEventsTest) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -768,7 +759,6 @@ TEST_F(PlatformViewTests, RequestFocusTest) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); @@ -845,7 +835,6 @@ TEST_F(PlatformViewTests, RequestFocusFailTest) { nullptr, // on_update_view_callback, nullptr, // on_destroy_view_callback, nullptr, // on_create_surface_callback, - nullptr, // external_view_embedder, fml::TimeDelta::Zero(), // vsync_offset ZX_HANDLE_INVALID // vsync_event_handle ); diff --git a/shell/platform/fuchsia/flutter/surface.cc b/shell/platform/fuchsia/flutter/surface.cc index 27753721b..61f2d2587 100644 --- a/shell/platform/fuchsia/flutter/surface.cc +++ b/shell/platform/fuchsia/flutter/surface.cc @@ -14,7 +14,7 @@ namespace flutter_runner { Surface::Surface(std::string debug_label, - std::shared_ptr view_embedder, + flutter::ExternalViewEmbedder* view_embedder, GrDirectContext* gr_context) : debug_label_(std::move(debug_label)), view_embedder_(view_embedder), @@ -53,7 +53,7 @@ SkMatrix Surface::GetRootTransformation() const { // |flutter::GetViewEmbedder| flutter::ExternalViewEmbedder* Surface::GetExternalViewEmbedder() { - return view_embedder_.get(); + return view_embedder_; } } // namespace flutter_runner diff --git a/shell/platform/fuchsia/flutter/surface.h b/shell/platform/fuchsia/flutter/surface.h index bc95d88cc..96222c0f2 100644 --- a/shell/platform/fuchsia/flutter/surface.h +++ b/shell/platform/fuchsia/flutter/surface.h @@ -16,14 +16,14 @@ namespace flutter_runner { class Surface final : public flutter::Surface { public: Surface(std::string debug_label, - std::shared_ptr view_embedder, + flutter::ExternalViewEmbedder* view_embedder, GrDirectContext* gr_context); ~Surface() override; private: const std::string debug_label_; - std::shared_ptr view_embedder_; + flutter::ExternalViewEmbedder* view_embedder_; GrDirectContext* gr_context_; // |flutter::Surface| -- GitLab