From d1b56f96a2387392d1edfb4245dee21e2bd8ccad Mon Sep 17 00:00:00 2001 From: David Worsham Date: Wed, 30 Jun 2021 15:43:21 -0700 Subject: [PATCH] Reland "fuchsia: Delete all the legacy code! (#26422)" (#27075) This reverts commit bb3c49a9c3edf931a5601f0245faa85f5e077cb4. --- BUILD.gn | 8 - ci/licenses_golden/licenses_flutter | 11 - common/config.gni | 3 - flow/BUILD.gn | 24 - .../layers/backdrop_filter_layer_unittests.cc | 3 +- .../checkerboard_layertree_unittests.cc | 10 - flow/layers/child_scene_layer.cc | 33 - flow/layers/child_scene_layer.h | 42 - flow/layers/clip_path_layer.cc | 17 - flow/layers/clip_path_layer.h | 4 - flow/layers/clip_path_layer_unittests.cc | 2 +- flow/layers/clip_rect_layer.cc | 13 - flow/layers/clip_rect_layer.h | 4 - flow/layers/clip_rect_layer_unittests.cc | 2 +- flow/layers/clip_rrect_layer.cc | 13 - flow/layers/clip_rrect_layer.h | 4 - flow/layers/clip_rrect_layer_unittests.cc | 2 +- flow/layers/color_filter_layer_unittests.cc | 3 +- flow/layers/container_layer.cc | 51 -- flow/layers/container_layer.h | 8 - flow/layers/container_layer_unittests.cc | 20 +- flow/layers/fuchsia_layer_unittests.cc | 747 ------------------ flow/layers/image_filter_layer_unittests.cc | 3 +- flow/layers/layer.cc | 26 - flow/layers/layer.h | 28 - flow/layers/layer_tree.cc | 21 - flow/layers/layer_tree.h | 4 - flow/layers/layer_tree_unittests.cc | 12 +- flow/layers/opacity_layer.cc | 11 - flow/layers/opacity_layer.h | 4 - flow/layers/opacity_layer_unittests.cc | 2 +- flow/layers/physical_shape_layer_unittests.cc | 15 +- flow/layers/picture_layer.cc | 4 - flow/layers/picture_layer_unittests.cc | 2 - flow/layers/platform_view_layer.cc | 16 - flow/layers/platform_view_layer.h | 4 - flow/layers/platform_view_layer_unittests.cc | 10 - flow/layers/shader_mask_layer.cc | 4 - flow/layers/shader_mask_layer_unittests.cc | 2 +- flow/layers/texture_layer.cc | 4 - flow/layers/transform_layer.cc | 16 - flow/layers/transform_layer.h | 4 - flow/scene_update_context.cc | 383 --------- flow/scene_update_context.h | 220 ------ flow/testing/mock_layer.cc | 3 - flow/testing/mock_layer.h | 2 - flow/testing/mock_layer_unittests.cc | 11 - flow/view_holder.cc | 177 ----- flow/view_holder.h | 93 --- lib/ui/BUILD.gn | 13 - lib/ui/compositing.dart | 63 -- lib/ui/compositing/scene_builder.cc | 31 +- lib/ui/compositing/scene_builder.h | 13 - lib/ui/compositing/scene_host.cc | 251 ------ lib/ui/compositing/scene_host.h | 73 -- lib/ui/dart_ui.cc | 7 - .../engine/canvaskit/layer_scene_builder.dart | 11 - .../lib/src/engine/html/scene_builder.dart | 24 - lib/web_ui/lib/src/ui/compositing.dart | 28 - shell/common/rasterizer.cc | 33 +- shell/common/rasterizer.h | 15 - shell/platform/fuchsia/flutter/BUILD.gn | 6 - .../fuchsia/flutter/compositor_context.cc | 176 ----- .../fuchsia/flutter/compositor_context.h | 51 -- .../flutter/default_session_connection.h | 11 +- shell/platform/fuchsia/flutter/engine.cc | 134 +--- shell/platform/fuchsia/flutter/engine.h | 10 - .../flutter_runner_product_configuration.cc | 7 - .../flutter_runner_product_configuration.h | 8 +- .../platform/fuchsia/flutter/platform_view.cc | 27 - tools/gn | 3 - 71 files changed, 47 insertions(+), 3053 deletions(-) delete mode 100644 flow/layers/child_scene_layer.cc delete mode 100644 flow/layers/child_scene_layer.h delete mode 100644 flow/layers/fuchsia_layer_unittests.cc delete mode 100644 flow/scene_update_context.cc delete mode 100644 flow/scene_update_context.h delete mode 100644 flow/view_holder.cc delete mode 100644 flow/view_holder.h delete mode 100644 lib/ui/compositing/scene_host.cc delete mode 100644 lib/ui/compositing/scene_host.h delete mode 100644 shell/platform/fuchsia/flutter/compositor_context.cc delete mode 100644 shell/platform/fuchsia/flutter/compositor_context.h diff --git a/BUILD.gn b/BUILD.gn index 470c8c2d7a126..aaececfeb13d4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -23,14 +23,6 @@ config("config") { defines = [] - # This define is transitional and will be removed after the embedder API - # transition is complete. - # - # TODO(bugs.fuchsia.dev/54041): Remove when no longer necessary. - if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) { - defines += [ "LEGACY_FUCHSIA_EMBEDDER" ] - } - if (is_debug) { defines += [ "FLUTTER_ENABLE_DIFF_CONTEXT" ] } diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index bfdd3e2ceb939..7ba3273d60c11 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -52,8 +52,6 @@ FILE: ../../../flutter/flow/layers/backdrop_filter_layer.cc FILE: ../../../flutter/flow/layers/backdrop_filter_layer.h FILE: ../../../flutter/flow/layers/backdrop_filter_layer_unittests.cc FILE: ../../../flutter/flow/layers/checkerboard_layertree_unittests.cc -FILE: ../../../flutter/flow/layers/child_scene_layer.cc -FILE: ../../../flutter/flow/layers/child_scene_layer.h FILE: ../../../flutter/flow/layers/clip_path_layer.cc FILE: ../../../flutter/flow/layers/clip_path_layer.h FILE: ../../../flutter/flow/layers/clip_path_layer_unittests.cc @@ -69,7 +67,6 @@ FILE: ../../../flutter/flow/layers/color_filter_layer_unittests.cc FILE: ../../../flutter/flow/layers/container_layer.cc FILE: ../../../flutter/flow/layers/container_layer.h FILE: ../../../flutter/flow/layers/container_layer_unittests.cc -FILE: ../../../flutter/flow/layers/fuchsia_layer_unittests.cc FILE: ../../../flutter/flow/layers/image_filter_layer.cc FILE: ../../../flutter/flow/layers/image_filter_layer.h FILE: ../../../flutter/flow/layers/image_filter_layer_unittests.cc @@ -118,8 +115,6 @@ FILE: ../../../flutter/flow/raster_cache_unittests.cc FILE: ../../../flutter/flow/rtree.cc FILE: ../../../flutter/flow/rtree.h FILE: ../../../flutter/flow/rtree_unittests.cc -FILE: ../../../flutter/flow/scene_update_context.cc -FILE: ../../../flutter/flow/scene_update_context.h FILE: ../../../flutter/flow/skia_gpu_object.cc FILE: ../../../flutter/flow/skia_gpu_object.h FILE: ../../../flutter/flow/skia_gpu_object_unittests.cc @@ -128,8 +123,6 @@ FILE: ../../../flutter/flow/surface.h FILE: ../../../flutter/flow/surface_frame.cc FILE: ../../../flutter/flow/surface_frame.h FILE: ../../../flutter/flow/texture_unittests.cc -FILE: ../../../flutter/flow/view_holder.cc -FILE: ../../../flutter/flow/view_holder.h FILE: ../../../flutter/fml/ascii_trie.cc FILE: ../../../flutter/fml/ascii_trie.h FILE: ../../../flutter/fml/ascii_trie_unittests.cc @@ -312,8 +305,6 @@ FILE: ../../../flutter/lib/ui/compositing/scene.h FILE: ../../../flutter/lib/ui/compositing/scene_builder.cc FILE: ../../../flutter/lib/ui/compositing/scene_builder.h FILE: ../../../flutter/lib/ui/compositing/scene_builder_unittests.cc -FILE: ../../../flutter/lib/ui/compositing/scene_host.cc -FILE: ../../../flutter/lib/ui/compositing/scene_host.h FILE: ../../../flutter/lib/ui/dart_runtime_hooks.cc FILE: ../../../flutter/lib/ui/dart_runtime_hooks.h FILE: ../../../flutter/lib/ui/dart_ui.cc @@ -1342,8 +1333,6 @@ FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unitt FILE: ../../../flutter/shell/platform/fuchsia/flutter/component.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/component.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/component_unittest.cc -FILE: ../../../flutter/shell/platform/fuchsia/flutter/compositor_context.cc -FILE: ../../../flutter/shell/platform/fuchsia/flutter/compositor_context.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/default_session_connection.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/default_session_connection.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/engine.cc diff --git a/common/config.gni b/common/config.gni index 6d1cecb76fb6c..b74e25a616a91 100644 --- a/common/config.gni +++ b/common/config.gni @@ -19,9 +19,6 @@ declare_args() { # Whether to use the Skia text shaper module for all text rendering flutter_always_use_skshaper = false - - # Whether to use the legacy embedder when building for Fuchsia. - flutter_enable_legacy_fuchsia_embedder = true } # feature_defines_list --------------------------------------------------------- diff --git a/flow/BUILD.gn b/flow/BUILD.gn index 1efd32e6cb622..29df9651107a5 100644 --- a/flow/BUILD.gn +++ b/flow/BUILD.gn @@ -80,24 +80,6 @@ source_set("flow") { "//flutter/fml", "//third_party/skia", ] - - if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) { - sources += [ - "layers/child_scene_layer.cc", - "layers/child_scene_layer.h", - "scene_update_context.cc", - "scene_update_context.h", - "view_holder.cc", - "view_holder.h", - ] - - public_deps = [ - "$fuchsia_sdk_root/fidl:fuchsia.ui.app", - "$fuchsia_sdk_root/fidl:fuchsia.ui.gfx", - "$fuchsia_sdk_root/fidl:fuchsia.ui.views", - "$fuchsia_sdk_root/pkg:scenic_cpp", - ] - } } if (enable_unittests) { @@ -194,11 +176,5 @@ if (enable_unittests) { # Required for M_PI and others. defines += [ "_USE_MATH_DEFINES" ] } - - if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) { - sources += [ "layers/fuchsia_layer_unittests.cc" ] - - deps += [ "//build/fuchsia/pkg:sys_cpp_testing" ] - } } } diff --git a/flow/layers/backdrop_filter_layer_unittests.cc b/flow/layers/backdrop_filter_layer_unittests.cc index 461841773cb52..b01137c4b5410 100644 --- a/flow/layers/backdrop_filter_layer_unittests.cc +++ b/flow/layers/backdrop_filter_layer_unittests.cc @@ -30,7 +30,6 @@ TEST_F(BackdropFilterLayerTest, PaintingEmptyLayerDies) { parent->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), kEmptyRect); EXPECT_FALSE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "needs_painting\\(context\\)"); @@ -263,7 +262,7 @@ TEST_F(BackdropFilterLayerTest, Readback) { // BDF with no filter blocks child with readback auto mock_layer = - std::make_shared(SkPath(), SkPaint(), false, false, true); + std::make_shared(SkPath(), SkPaint(), false, true); layer2->Add(mock_layer); preroll_context()->surface_needs_readback = false; layer2->Preroll(preroll_context(), initial_transform); diff --git a/flow/layers/checkerboard_layertree_unittests.cc b/flow/layers/checkerboard_layertree_unittests.cc index 0f12b079ee897..15fd4310b3557 100644 --- a/flow/layers/checkerboard_layertree_unittests.cc +++ b/flow/layers/checkerboard_layertree_unittests.cc @@ -297,12 +297,8 @@ TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerNotCheckBoard) { PhysicalShapeLayer::ComputeShadowBounds(layer_path.getBounds(), initial_elevation, 1.0f)); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(layer->elevation(), initial_elevation); - // The Fuchsia system compositor handles all elevated PhysicalShapeLayers and - // their shadows , so we do not use the direct |Paint()| path there. -#if !defined(LEGACY_FUCHSIA_EMBEDDER) const SkRect paint_bounds = SkRect::MakeXYWH(0, 0, 8, 8); const SkPaint clip_paint; SkPaint layer_paint; @@ -323,7 +319,6 @@ TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerNotCheckBoard) { MockCanvas::DrawCall{2, MockCanvas::DrawPaint{layer_paint}}, MockCanvas::DrawCall{2, MockCanvas::RestoreData{1}}, MockCanvas::DrawCall{1, MockCanvas::RestoreData{0}}})); -#endif } TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerCheckBoard) { @@ -341,12 +336,8 @@ TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerCheckBoard) { PhysicalShapeLayer::ComputeShadowBounds(layer_path.getBounds(), initial_elevation, 1.0f)); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(layer->elevation(), initial_elevation); - // The Fuchsia system compositor handles all elevated PhysicalShapeLayers and - // their shadows , so we do not use the direct |Paint()| path there. -#if !defined(LEGACY_FUCHSIA_EMBEDDER) const SkRect paint_bounds = SkRect::MakeXYWH(0, 0, 8, 8); const SkPaint clip_paint; SkPaint layer_paint; @@ -367,7 +358,6 @@ TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerCheckBoard) { MockCanvas::DrawCall{2, MockCanvas::DrawPaint{layer_paint}}, MockCanvas::DrawCall{2, MockCanvas::RestoreData{1}}, MockCanvas::DrawCall{1, MockCanvas::RestoreData{0}}})); -#endif } #endif diff --git a/flow/layers/child_scene_layer.cc b/flow/layers/child_scene_layer.cc deleted file mode 100644 index 3408f7b4367d2..0000000000000 --- a/flow/layers/child_scene_layer.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/flow/layers/child_scene_layer.h" - -namespace flutter { - -ChildSceneLayer::ChildSceneLayer(zx_koid_t layer_id, - const SkPoint& offset, - const SkSize& size, - bool hit_testable) - : layer_id_(layer_id), - offset_(offset), - size_(size), - hit_testable_(hit_testable) {} - -void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { - TRACE_EVENT0("flutter", "ChildSceneLayer::Preroll"); - - context->child_scene_layer_exists_below = true; - CheckForChildLayerBelow(context); -} - -void ChildSceneLayer::Paint(PaintContext& context) const {} - -void ChildSceneLayer::UpdateScene(std::shared_ptr context) { - TRACE_EVENT0("flutter", "ChildSceneLayer::UpdateScene"); - FML_DCHECK(needs_system_composite()); - 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 deleted file mode 100644 index 0ec7f3b16efb1..0000000000000 --- a/flow/layers/child_scene_layer.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_ -#define FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_ - -#include "flutter/flow/layers/layer.h" -#include "flutter/flow/scene_update_context.h" -#include "third_party/skia/include/core/SkMatrix.h" -#include "third_party/skia/include/core/SkPoint.h" -#include "third_party/skia/include/core/SkSize.h" - -namespace flutter { - -// Layer that represents an embedded child. -class ChildSceneLayer : public Layer { - public: - ChildSceneLayer(zx_koid_t layer_id, - const SkPoint& offset, - const SkSize& size, - bool hit_testable); - ~ChildSceneLayer() override = default; - - void Preroll(PrerollContext* context, const SkMatrix& matrix) override; - - void Paint(PaintContext& context) const override; - - void UpdateScene(std::shared_ptr context) override; - - private: - zx_koid_t layer_id_ = ZX_KOID_INVALID; - SkPoint offset_; - SkSize size_; - bool hit_testable_ = true; - - FML_DISALLOW_COPY_AND_ASSIGN(ChildSceneLayer); -}; - -} // namespace flutter - -#endif // FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_ diff --git a/flow/layers/clip_path_layer.cc b/flow/layers/clip_path_layer.cc index 99a675fc35703..c895f6611be1e 100644 --- a/flow/layers/clip_path_layer.cc +++ b/flow/layers/clip_path_layer.cc @@ -5,10 +5,6 @@ #include "flutter/flow/layers/clip_path_layer.h" #include "flutter/flow/paint_utils.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "lib/ui/scenic/cpp/commands.h" -#endif - namespace flutter { ClipPathLayer::ClipPathLayer(const SkPath& clip_path, Clip clip_behavior) @@ -58,19 +54,6 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { context->cull_rect = previous_cull_rect; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - -void ClipPathLayer::UpdateScene(std::shared_ptr context) { - TRACE_EVENT0("flutter", "ClipPathLayer::UpdateScene"); - FML_DCHECK(needs_system_composite()); - - // TODO(liyuqian): respect clip_behavior_ - SceneUpdateContext::Clip clip(context, clip_path_.getBounds()); - UpdateSceneChildren(context); -} - -#endif - void ClipPathLayer::Paint(PaintContext& context) const { TRACE_EVENT0("flutter", "ClipPathLayer::Paint"); FML_DCHECK(needs_painting(context)); diff --git a/flow/layers/clip_path_layer.h b/flow/layers/clip_path_layer.h index b22bed957048c..bed8c9609f2d5 100644 --- a/flow/layers/clip_path_layer.h +++ b/flow/layers/clip_path_layer.h @@ -27,10 +27,6 @@ class ClipPathLayer : public ContainerLayer { return clip_behavior_ == Clip::antiAliasWithSaveLayer; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; -#endif - private: SkPath clip_path_; Clip clip_behavior_; diff --git a/flow/layers/clip_path_layer_unittests.cc b/flow/layers/clip_path_layer_unittests.cc index 68ac35383292d..3cbbf0f055476 100644 --- a/flow/layers/clip_path_layer_unittests.cc +++ b/flow/layers/clip_path_layer_unittests.cc @@ -222,7 +222,7 @@ TEST_F(ClipPathLayerTest, Readback) { const Clip save_layer = Clip::antiAliasWithSaveLayer; std::shared_ptr nochild; - auto reader = std::make_shared(path, paint, false, false, true); + auto reader = std::make_shared(path, paint, false, true); auto nonreader = std::make_shared(path, paint); // No children, no prior readback -> no readback after diff --git a/flow/layers/clip_rect_layer.cc b/flow/layers/clip_rect_layer.cc index a230b38fa0893..3c885a472ce97 100644 --- a/flow/layers/clip_rect_layer.cc +++ b/flow/layers/clip_rect_layer.cc @@ -53,19 +53,6 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { context->cull_rect = previous_cull_rect; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - -void ClipRectLayer::UpdateScene(std::shared_ptr context) { - TRACE_EVENT0("flutter", "ClipRectLayer::UpdateScene"); - FML_DCHECK(needs_system_composite()); - - // TODO(liyuqian): respect clip_behavior_ - SceneUpdateContext::Clip clip(context, clip_rect_); - UpdateSceneChildren(context); -} - -#endif - void ClipRectLayer::Paint(PaintContext& context) const { TRACE_EVENT0("flutter", "ClipRectLayer::Paint"); FML_DCHECK(needs_painting(context)); diff --git a/flow/layers/clip_rect_layer.h b/flow/layers/clip_rect_layer.h index 54c319ef1d16c..e37227fbe21b3 100644 --- a/flow/layers/clip_rect_layer.h +++ b/flow/layers/clip_rect_layer.h @@ -26,10 +26,6 @@ class ClipRectLayer : public ContainerLayer { return clip_behavior_ == Clip::antiAliasWithSaveLayer; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; -#endif - private: SkRect clip_rect_; Clip clip_behavior_; diff --git a/flow/layers/clip_rect_layer_unittests.cc b/flow/layers/clip_rect_layer_unittests.cc index ae5dfec16f23e..13c90d76e8f4e 100644 --- a/flow/layers/clip_rect_layer_unittests.cc +++ b/flow/layers/clip_rect_layer_unittests.cc @@ -220,7 +220,7 @@ TEST_F(ClipRectLayerTest, Readback) { const Clip save_layer = Clip::antiAliasWithSaveLayer; std::shared_ptr nochild; - auto reader = std::make_shared(path, paint, false, false, true); + auto reader = std::make_shared(path, paint, false, true); auto nonreader = std::make_shared(path, paint); // No children, no prior readback -> no readback after diff --git a/flow/layers/clip_rrect_layer.cc b/flow/layers/clip_rrect_layer.cc index e5abc5fc32984..225c110abda04 100644 --- a/flow/layers/clip_rrect_layer.cc +++ b/flow/layers/clip_rrect_layer.cc @@ -54,19 +54,6 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { context->cull_rect = previous_cull_rect; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - -void ClipRRectLayer::UpdateScene(std::shared_ptr context) { - TRACE_EVENT0("flutter", "ClipRRectLayer::UpdateScene"); - FML_DCHECK(needs_system_composite()); - - // TODO(liyuqian): respect clip_behavior_ - SceneUpdateContext::Clip clip(context, clip_rrect_.getBounds()); - UpdateSceneChildren(context); -} - -#endif - void ClipRRectLayer::Paint(PaintContext& context) const { TRACE_EVENT0("flutter", "ClipRRectLayer::Paint"); FML_DCHECK(needs_painting(context)); diff --git a/flow/layers/clip_rrect_layer.h b/flow/layers/clip_rrect_layer.h index e5045bfa45d0c..85626b0d2a9c3 100644 --- a/flow/layers/clip_rrect_layer.h +++ b/flow/layers/clip_rrect_layer.h @@ -27,10 +27,6 @@ class ClipRRectLayer : public ContainerLayer { return clip_behavior_ == Clip::antiAliasWithSaveLayer; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; -#endif - private: SkRRect clip_rrect_; Clip clip_behavior_; diff --git a/flow/layers/clip_rrect_layer_unittests.cc b/flow/layers/clip_rrect_layer_unittests.cc index 538cc22e37c9d..b2adb2253747c 100644 --- a/flow/layers/clip_rrect_layer_unittests.cc +++ b/flow/layers/clip_rrect_layer_unittests.cc @@ -225,7 +225,7 @@ TEST_F(ClipRRectLayerTest, Readback) { const Clip save_layer = Clip::antiAliasWithSaveLayer; std::shared_ptr nochild; - auto reader = std::make_shared(path, paint, false, false, true); + auto reader = std::make_shared(path, paint, false, true); auto nonreader = std::make_shared(path, paint); // No children, no prior readback -> no readback after diff --git a/flow/layers/color_filter_layer_unittests.cc b/flow/layers/color_filter_layer_unittests.cc index 0932700044e4d..a48ca56409619 100644 --- a/flow/layers/color_filter_layer_unittests.cc +++ b/flow/layers/color_filter_layer_unittests.cc @@ -23,7 +23,6 @@ TEST_F(ColorFilterLayerTest, PaintingEmptyLayerDies) { layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), kEmptyRect); EXPECT_FALSE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "needs_painting\\(context\\)"); @@ -207,7 +206,7 @@ TEST_F(ColorFilterLayerTest, Readback) { // ColorFilterLayer blocks child with readback auto mock_layer = - std::make_shared(SkPath(), SkPaint(), false, false, true); + std::make_shared(SkPath(), SkPaint(), false, true); layer->Add(mock_layer); preroll_context()->surface_needs_readback = false; layer->Preroll(preroll_context(), initial_transform); diff --git a/flow/layers/container_layer.cc b/flow/layers/container_layer.cc index 91ce868a624a5..2a62359ba4dc8 100644 --- a/flow/layers/container_layer.cc +++ b/flow/layers/container_layer.cc @@ -127,14 +127,6 @@ void ContainerLayer::Paint(PaintContext& context) const { void ContainerLayer::PrerollChildren(PrerollContext* context, const SkMatrix& child_matrix, SkRect* child_paint_bounds) { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - // If there is embedded Fuchsia content in the scene (a ChildSceneLayer), - // Layers that appear above the embedded content will be turned into their own - // Scenic layers. - child_layer_exists_below_ = context->child_scene_layer_exists_below; - context->child_scene_layer_exists_below = false; -#endif - // Platform views have no children, so context->has_platform_view should // always be false. FML_DCHECK(!context->has_platform_view); @@ -147,10 +139,6 @@ void ContainerLayer::PrerollChildren(PrerollContext* context, context->has_platform_view = false; layer->Preroll(context, child_matrix); - - if (layer->needs_system_composite()) { - set_needs_system_composite(true); - } child_paint_bounds->join(layer->paint_bounds()); child_has_platform_view = @@ -162,14 +150,6 @@ void ContainerLayer::PrerollChildren(PrerollContext* context, context->has_platform_view = child_has_platform_view; context->has_texture_layer = child_has_texture_layer; set_subtree_has_platform_view(child_has_platform_view); - -#if defined(LEGACY_FUCHSIA_EMBEDDER) - if (child_layer_exists_below_) { - set_needs_system_composite(true); - } - context->child_scene_layer_exists_below = - context->child_scene_layer_exists_below || child_layer_exists_below_; -#endif } void ContainerLayer::PaintChildren(PaintContext& context) const { @@ -198,37 +178,6 @@ void ContainerLayer::TryToPrepareRasterCache(PrerollContext* context, } } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - -void ContainerLayer::CheckForChildLayerBelow(PrerollContext* context) { - // All ContainerLayers make the check in PrerollChildren. -} - -void ContainerLayer::UpdateScene(std::shared_ptr context) { - UpdateSceneChildren(context); -} - -void ContainerLayer::UpdateSceneChildren( - std::shared_ptr 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::Layer"); - frame->AddPaintLayer(this); - } - - for (auto& layer : layers_) { - if (layer->needs_system_composite()) { - layer->UpdateScene(context); - } - } -} - -#endif - MergedContainerLayer::MergedContainerLayer() { // Ensure the layer has only one direct child. // diff --git a/flow/layers/container_layer.h b/flow/layers/container_layer.h index de1548fb17c98..699cf4d61b530 100644 --- a/flow/layers/container_layer.h +++ b/flow/layers/container_layer.h @@ -26,10 +26,6 @@ class ContainerLayer : public Layer { void Preroll(PrerollContext* context, const SkMatrix& matrix) override; void Paint(PaintContext& context) const override; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void CheckForChildLayerBelow(PrerollContext* context) override; - void UpdateScene(std::shared_ptr context) override; -#endif const std::vector>& layers() const { return layers_; } @@ -46,10 +42,6 @@ class ContainerLayer : public Layer { SkRect* child_paint_bounds); void PaintChildren(PaintContext& context) const; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateSceneChildren(std::shared_ptr context); -#endif - // Try to prepare the raster cache for a given layer. // // The raster cache would fail if either of the followings is true: diff --git a/flow/layers/container_layer_unittests.cc b/flow/layers/container_layer_unittests.cc index 42745b571dbc9..aa34048bf2b89 100644 --- a/flow/layers/container_layer_unittests.cc +++ b/flow/layers/container_layer_unittests.cc @@ -30,7 +30,6 @@ TEST_F(ContainerLayerTest, PaintingEmptyLayerDies) { layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty()); EXPECT_FALSE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "needs_painting\\(context\\)"); @@ -65,8 +64,6 @@ TEST_F(ContainerLayerTest, Simple) { EXPECT_EQ(layer->paint_bounds(), child_path.getBounds()); EXPECT_TRUE(mock_layer->needs_painting(paint_context())); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(mock_layer->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer->parent_cull_rect(), kGiantRect); @@ -102,9 +99,6 @@ TEST_F(ContainerLayerTest, Multiple) { EXPECT_TRUE(mock_layer1->needs_painting(paint_context())); EXPECT_TRUE(mock_layer2->needs_painting(paint_context())); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); @@ -141,9 +135,6 @@ TEST_F(ContainerLayerTest, MultipleWithEmpty) { EXPECT_TRUE(mock_layer1->needs_painting(paint_context())); EXPECT_FALSE(mock_layer2->needs_painting(paint_context())); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); @@ -165,8 +156,7 @@ TEST_F(ContainerLayerTest, NeedsSystemComposite) { SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f); auto mock_layer1 = std::make_shared( - child_path1, child_paint1, false /* fake_has_platform_view */, - true /* fake_needs_system_composite */); + child_path1, child_paint1, false /* fake_has_platform_view */); auto mock_layer2 = std::make_shared(child_path2, child_paint2); auto layer = std::make_shared(); layer->Add(mock_layer1); @@ -182,9 +172,6 @@ TEST_F(ContainerLayerTest, NeedsSystemComposite) { EXPECT_TRUE(mock_layer1->needs_painting(paint_context())); EXPECT_TRUE(mock_layer2->needs_painting(paint_context())); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_TRUE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_TRUE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); @@ -215,8 +202,6 @@ TEST_F(ContainerLayerTest, MergedOneChild) { EXPECT_EQ(layer->paint_bounds(), child_path.getBounds()); EXPECT_TRUE(mock_layer->needs_painting(paint_context())); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(mock_layer->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer->parent_cull_rect(), kGiantRect); @@ -251,9 +236,6 @@ TEST_F(ContainerLayerTest, MergedMultipleChildren) { EXPECT_TRUE(mock_layer1->needs_painting(paint_context())); EXPECT_TRUE(mock_layer2->needs_painting(paint_context())); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); diff --git a/flow/layers/fuchsia_layer_unittests.cc b/flow/layers/fuchsia_layer_unittests.cc deleted file mode 100644 index ee8b86bfa7ae5..0000000000000 --- a/flow/layers/fuchsia_layer_unittests.cc +++ /dev/null @@ -1,747 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "flutter/flow/layers/child_scene_layer.h" -#include "flutter/flow/layers/container_layer.h" -#include "flutter/flow/layers/opacity_layer.h" -#include "flutter/flow/layers/physical_shape_layer.h" -#include "flutter/flow/layers/transform_layer.h" -#include "flutter/flow/view_holder.h" -#include "gtest/gtest.h" - -namespace flutter { -namespace testing { - -using FuchsiaLayerTest = ::testing::Test; - -class MockSession : public fuchsia::ui::scenic::testing::Session_TestBase { - public: - MockSession() : binding_(this) {} - - void NotImplemented_(const std::string& name) final {} - - void Bind(fidl::InterfaceRequest<::fuchsia::ui::scenic::Session> request, - ::fuchsia::ui::scenic::SessionListenerPtr listener) { - binding_.Bind(std::move(request)); - listener_ = std::move(listener); - } - - static std::string Vec3ValueToString(fuchsia::ui::gfx::Vector3Value value) { - return "{" + std::to_string(value.value.x) + ", " + - std::to_string(value.value.y) + ", " + - std::to_string(value.value.z) + "}"; - } - - static std::string QuaternionValueToString( - fuchsia::ui::gfx::QuaternionValue value) { - return "{" + std::to_string(value.value.x) + ", " + - std::to_string(value.value.y) + ", " + - std::to_string(value.value.z) + ", " + - std::to_string(value.value.w) + "}"; - } - - static std::string GfxCreateResourceCmdToString( - const fuchsia::ui::gfx::CreateResourceCmd& cmd) { - std::string id = " id: " + std::to_string(cmd.id); - switch (cmd.resource.Which()) { - case fuchsia::ui::gfx::ResourceArgs::Tag::kRectangle: - return "Rectangle" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kRoundedRectangle: - return "RoundedRectangle" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kViewHolder: - return "ViewHolder" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kOpacityNode: - return "OpacityNode" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kEntityNode: - return "EntityNode" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kShapeNode: - return "ShapeNode" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kMaterial: - return "Material" + id; - case fuchsia::ui::gfx::ResourceArgs::Tag::kImage: - return "Image" + id + ", memory_id: " + - std::to_string(cmd.resource.image().memory_id) + - ", memory_offset: " + - std::to_string(cmd.resource.image().memory_offset); - default: - return "Unhandled CreateResource command" + - std::to_string(cmd.resource.Which()); - } - } - - static std::string GfxCmdToString(const fuchsia::ui::gfx::Command& cmd) { - switch (cmd.Which()) { - case fuchsia::ui::gfx::Command::Tag::kCreateResource: - return "CreateResource: " + - GfxCreateResourceCmdToString(cmd.create_resource()); - case fuchsia::ui::gfx::Command::Tag::kReleaseResource: - return "ReleaseResource id: " + - std::to_string(cmd.release_resource().id); - case fuchsia::ui::gfx::Command::Tag::kAddChild: - return "AddChild id: " + std::to_string(cmd.add_child().node_id) + - " child_id: " + std::to_string(cmd.add_child().child_id); - case fuchsia::ui::gfx::Command::Tag::kSetTranslation: - return "SetTranslation id: " + - std::to_string(cmd.set_translation().id) + - " value: " + Vec3ValueToString(cmd.set_translation().value); - case fuchsia::ui::gfx::Command::Tag::kSetScale: - return "SetScale id: " + std::to_string(cmd.set_scale().id) + - " value: " + Vec3ValueToString(cmd.set_scale().value); - case fuchsia::ui::gfx::Command::Tag::kSetRotation: - return "SetRotation id: " + std::to_string(cmd.set_rotation().id) + - " value: " + QuaternionValueToString(cmd.set_rotation().value); - case fuchsia::ui::gfx::Command::Tag::kSetOpacity: - return "SetOpacity id: " + std::to_string(cmd.set_opacity().node_id) + - ", opacity: " + std::to_string(cmd.set_opacity().opacity); - case fuchsia::ui::gfx::Command::Tag::kSetColor: - return "SetColor id: " + std::to_string(cmd.set_color().material_id) + - ", rgba: (" + std::to_string(cmd.set_color().color.value.red) + - ", " + std::to_string(cmd.set_color().color.value.green) + ", " + - std::to_string(cmd.set_color().color.value.blue) + ", " + - std::to_string(cmd.set_color().color.value.alpha) + ")"; - case fuchsia::ui::gfx::Command::Tag::kSetLabel: - return "SetLabel id: " + std::to_string(cmd.set_label().id) + " " + - cmd.set_label().label; - case fuchsia::ui::gfx::Command::Tag::kSetHitTestBehavior: - return "SetHitTestBehavior node_id: " + - std::to_string(cmd.set_hit_test_behavior().node_id); - case fuchsia::ui::gfx::Command::Tag::kSetClipPlanes: - return "SetClipPlanes node_id: " + - std::to_string(cmd.set_clip_planes().node_id); - case fuchsia::ui::gfx::Command::Tag::kSetShape: - return "SetShape node_id: " + std::to_string(cmd.set_shape().node_id) + - ", shape_id: " + std::to_string(cmd.set_shape().shape_id); - case fuchsia::ui::gfx::Command::Tag::kSetMaterial: - return "SetMaterial node_id: " + - std::to_string(cmd.set_material().node_id) + ", material_id: " + - std::to_string(cmd.set_material().material_id); - case fuchsia::ui::gfx::Command::Tag::kSetTexture: - return "SetTexture material_id: " + - std::to_string(cmd.set_texture().material_id) + - ", texture_id: " + std::to_string(cmd.set_texture().texture_id); - - default: - return "Unhandled gfx command" + std::to_string(cmd.Which()); - } - } - - static std::string ScenicCmdToString( - const fuchsia::ui::scenic::Command& cmd) { - if (cmd.Which() != fuchsia::ui::scenic::Command::Tag::kGfx) { - return "Unhandled non-gfx command: " + std::to_string(cmd.Which()); - } - return GfxCmdToString(cmd.gfx()); - } - - // |fuchsia::ui::scenic::Session| - void Enqueue(std::vector cmds) override { - for (const auto& cmd : cmds) { - num_enqueued_commands_++; - EXPECT_FALSE(expected_.empty()) - << "Received more commands than expected; command: <" - << ScenicCmdToString(cmd) - << ">, num_enqueued_commands: " << num_enqueued_commands_; - if (!expected_.empty()) { - EXPECT_TRUE(AreCommandsEqual(expected_.front(), cmd)) - << "actual command: <" << ScenicCmdToString(cmd) - << ">, expected command: <" << ScenicCmdToString(expected_.front()) - << ">, num_enqueued_commands: " << num_enqueued_commands_; - expected_.pop_front(); - } - } - } - - void SetExpectedCommands(std::vector gfx_cmds) { - std::deque scenic_commands; - for (auto it = gfx_cmds.begin(); it != gfx_cmds.end(); it++) { - scenic_commands.push_back(scenic::NewCommand(std::move((*it)))); - } - expected_ = std::move(scenic_commands); - num_enqueued_commands_ = 0; - } - - size_t num_enqueued_commands() { return num_enqueued_commands_; } - - private: - static bool IsGfxCommand(const fuchsia::ui::scenic::Command& cmd, - fuchsia::ui::gfx::Command::Tag tag) { - return cmd.Which() == fuchsia::ui::scenic::Command::Tag::kGfx && - cmd.gfx().Which() == tag; - } - - static bool IsCreateResourceCommand(const fuchsia::ui::scenic::Command& cmd, - fuchsia::ui::gfx::ResourceArgs::Tag tag) { - return IsGfxCommand(cmd, fuchsia::ui::gfx::Command::Tag::kCreateResource) && - cmd.gfx().create_resource().resource.Which() == tag; - } - - static bool AreCommandsEqual(const fuchsia::ui::scenic::Command& command1, - const fuchsia::ui::scenic::Command& command2) { - // For CreateViewHolderCommand, just compare the id and ignore the - // view_holder_token. - if (IsCreateResourceCommand( - command1, fuchsia::ui::gfx::ResourceArgs::Tag::kViewHolder)) { - return IsCreateResourceCommand( - command2, fuchsia::ui::gfx::ResourceArgs::Tag::kViewHolder) && - command1.gfx().create_resource().id == - command2.gfx().create_resource().id; - } - // For CreateImageCommand, just compare the id and memory_id. - if (IsCreateResourceCommand(command1, - fuchsia::ui::gfx::ResourceArgs::Tag::kImage)) { - return IsCreateResourceCommand( - command2, fuchsia::ui::gfx::ResourceArgs::Tag::kImage) && - command1.gfx().create_resource().id == - command2.gfx().create_resource().id && - command1.gfx().create_resource().resource.image().memory_id == - command2.gfx().create_resource().resource.image().memory_id; - } - // For SetHitTestBehaviorCommand, just compare the node_id. - if (IsGfxCommand(command1, - fuchsia::ui::gfx::Command::Tag::kSetHitTestBehavior)) { - return IsGfxCommand( - command2, - fuchsia::ui::gfx::Command::Tag::kSetHitTestBehavior) && - command1.gfx().set_hit_test_behavior().node_id == - command2.gfx().set_hit_test_behavior().node_id; - } - // For SetHitTestBehaviorCommand, just compare the node_id. - if (IsGfxCommand(command1, - fuchsia::ui::gfx::Command::Tag::kSetClipPlanes)) { - return IsGfxCommand(command2, - fuchsia::ui::gfx::Command::Tag::kSetClipPlanes) && - command1.gfx().set_clip_planes().node_id == - command2.gfx().set_clip_planes().node_id; - } - return fidl::Equals(command1, command2); - } - - std::deque expected_; - size_t num_enqueued_commands_ = 0; - fidl::Binding binding_; - fuchsia::ui::scenic::SessionListenerPtr listener_; -}; - -class MockSessionWrapper : public flutter::SessionWrapper { - public: - MockSessionWrapper(fuchsia::ui::scenic::SessionPtr session_ptr) - : session_(std::move(session_ptr)) {} - ~MockSessionWrapper() override = default; - - scenic::Session* get() override { return &session_; } - void Present() override { session_.Flush(); } - - private: - scenic::Session session_; -}; - -struct TestContext { - // Session. - fidl::InterfaceRequest listener_request; - MockSession mock_session; - std::unique_ptr mock_session_wrapper; - - // SceneUpdateContext. - std::shared_ptr scene_update_context; - - // PrerollContext. - MutatorsStack unused_stack; - const Stopwatch unused_stopwatch; - TextureRegistry unused_texture_registry; - std::unique_ptr preroll_context; -}; - -std::unique_ptr InitTest() { - std::unique_ptr context = std::make_unique(); - - // Init Session. - fuchsia::ui::scenic::SessionPtr session_ptr; - fuchsia::ui::scenic::SessionListenerPtr listener; - context->listener_request = listener.NewRequest(); - context->mock_session.Bind(session_ptr.NewRequest(), std::move(listener)); - context->mock_session_wrapper = - std::make_unique(std::move(session_ptr)); - - // Init SceneUpdateContext. - context->scene_update_context = std::make_shared( - "fuchsia_layer_unittest", fuchsia::ui::views::ViewToken(), - scenic::ViewRefPair::New(), *(context->mock_session_wrapper)); - - // Init PrerollContext. - context->preroll_context = std::unique_ptr(new PrerollContext{ - nullptr, // raster_cache (don't consult the cache) - nullptr, // gr_context (used for the raster cache) - nullptr, // external view embedder - context->unused_stack, // mutator stack - nullptr, // SkColorSpace* dst_color_space - kGiantRect, // SkRect cull_rect - false, // layer reads from surface - context->unused_stopwatch, // frame time (dont care) - context->unused_stopwatch, // engine time (dont care) - context->unused_texture_registry, // texture registry (not - // supported) - false, // checkerboard_offscreen_layers - 1.f // ratio between logical and physical - }); - - return context; -} - -zx_koid_t GetChildLayerId() { - static zx_koid_t sChildLayerId = 17324; - return sChildLayerId++; -} - -class AutoDestroyChildLayerId { - public: - AutoDestroyChildLayerId(zx_koid_t id) : id_(id) {} - ~AutoDestroyChildLayerId() { ViewHolder::Destroy(id_, nullptr); } - - private: - zx_koid_t id_; -}; - -// Create a hierarchy with PhysicalShapeLayers and ChildSceneLayers, and -// inspect the commands sent to Scenic. -// -// -// What we expect: -// -// The Scenic elevations of the PhysicalShapeLayers are monotically -// increasing, even though the elevations we gave them when creating them are -// decreasing. The two should not have any correlation; we're merely mirror -// the paint order using Scenic elevation. -// -// PhysicalShapeLayers created before/below a ChildView do not get their own -// node; PhysicalShapeLayers created afterward do. -// -// Nested PhysicalShapeLayers are collapsed. -// -// This test has been temporarily disabled: fxb/52028 -TEST_F(FuchsiaLayerTest, DISABLED_PhysicalShapeLayersAndChildSceneLayers) { - auto test_context = InitTest(); - - // Root. - auto root = std::make_shared(); - SkPath path; - path.addRect(SkRect::MakeWH(10.f, 10.f)); - - // Child #1: PhysicalShapeLayer. - auto physical_shape1 = std::make_shared( - /*color=*/SK_ColorCYAN, - /*shadow_color=*/SK_ColorBLACK, - /*elevation*/ 23.f, path, Clip::antiAlias); - root->Add(physical_shape1); - - // Child #2: ChildSceneLayer. - const zx_koid_t kChildLayerId1 = GetChildLayerId(); - auto [unused_view_token1, unused_view_holder_token1] = - scenic::ViewTokenPair::New(); - ViewHolder::Create( - kChildLayerId1, - /*bind_callback=*/[](scenic::ResourceId id) {}, - std::move(unused_view_holder_token1)); - // Will destroy only when we go out of scope (i.e. end of the test). - AutoDestroyChildLayerId auto_destroy1(kChildLayerId1); - auto child_view1 = std::make_shared( - kChildLayerId1, SkPoint::Make(1, 1), SkSize::Make(10, 10), - /*hit_testable=*/false); - root->Add(child_view1); - - // Child #3: PhysicalShapeLayer - auto physical_shape2 = std::make_shared( - /*color=*/SK_ColorCYAN, - /*shadow_color=*/SK_ColorBLACK, - /*elevation*/ 21.f, path, Clip::antiAlias); - root->Add(physical_shape2); - - // Grandchild (child of #3): PhysicalShapeLayer - auto physical_shape3 = std::make_shared( - /*color=*/SK_ColorCYAN, - /*shadow_color=*/SK_ColorBLACK, - /*elevation*/ 19.f, path, Clip::antiAlias); - physical_shape2->Add(physical_shape3); - - // Child #4: ChildSceneLayer - const zx_koid_t kChildLayerId2 = GetChildLayerId(); - auto [unused_view_token2, unused_view_holder_token2] = - scenic::ViewTokenPair::New(); - ViewHolder::Create( - kChildLayerId2, - /*bind_callback=*/[](scenic::ResourceId id) {}, - std::move(unused_view_holder_token2)); - // Will destroy only when we go out of scope (i.e. end of the test). - AutoDestroyChildLayerId auto_destroy2(kChildLayerId2); - auto child_view2 = std::make_shared( - kChildLayerId2, SkPoint::Make(1, 1), SkSize::Make(10, 10), - /*hit_testable=*/false); - root->Add(child_view2); - - // Child #5: PhysicalShapeLayer - auto physical_shape4 = std::make_shared( - /*color=*/SK_ColorCYAN, - /*shadow_color=*/SK_ColorBLACK, - /*elevation*/ 17.f, path, Clip::antiAlias); - root->Add(physical_shape4); - - // Preroll. - root->Preroll(test_context->preroll_context.get(), SkMatrix()); - - // 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, - SkRRect::MakeRect(SkRect::MakeWH(100, 100)), - SK_ColorTRANSPARENT, SK_AlphaOPAQUE, - "fuchsia test root"); - - // Submit the list of command we will expect Scenic to see. - // - // Some things we expect: - // - // The Scenic elevations of the PhysicalShapeLayers are monotically - // increasing, even though the elevations we gave them when creating them are - // decreasing. The two should not have any correlation; we're merely mirror - // the paint order using Scenic elevation. - // - // PhysicalShapeLayers created before/below a ChildView do not get their own - // node; PhysicalShapeLayers created afterward do. - // - // Nested PhysicalShapeLayers are collapsed. - - std::vector expected; - - // - // Test root. - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/1)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/2)); - expected.push_back(scenic::NewSetLabelCmd(/*id=*/1, "fuchsia test root")); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/1, {0, 0})); - expected.push_back(scenic::NewAddChildCmd(/*id=*/1, /*child_id=*/2)); - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/2, kOneMinusEpsilon)); - - // - // Child #1: PhysicalShapeLayer - // - // Expect no new commands! Should be composited into base layer. - - // - // Child #2: ChildSceneLayer. - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/3)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/4)); - auto [view_token1, view_holder_token1] = scenic::ViewTokenPair::New(); - expected.push_back(scenic::NewCreateViewHolderCmd( - /*id=*/5, std::move(view_holder_token1), "")); - expected.push_back(scenic::NewAddChildCmd(/*id=*/4, /*child_id=*/3)); - expected.push_back(scenic::NewSetLabelCmd(/*id=*/4, "flutter::ViewHolder")); - expected.push_back(scenic::NewAddChildCmd(/*id=*/3, /*child_id=*/5)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/2, /*child_id=*/4)); - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/4, 1.f)); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/3, {1, 1, -0.1})); - expected.push_back(scenic::NewSetHitTestBehaviorCmd( - /*id=*/3, /*ignored*/ fuchsia::ui::gfx::HitTestBehavior::kSuppress)); - - // - // Child #3: PhysicalShapeLayer - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/6)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/2, /*child_id=*/6)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/7)); - expected.push_back( - scenic::NewSetLabelCmd(/*id=*/6, "flutter::PhysicalShapeLayer")); - expected.push_back(scenic::NewSetTranslationCmd( - /*id=*/6, {0, 0, -kScenicZElevationBetweenLayers})); - expected.push_back(scenic::NewAddChildCmd(/*id=*/6, /*child_id=*/7)); - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/7, kOneMinusEpsilon)); - expected.push_back(scenic::NewSetClipPlanesCmd(/*id=*/6, /*ignored*/ {})); - expected.push_back(scenic::NewCreateShapeNodeCmd(/*id=*/8)); - expected.push_back(scenic::NewCreateRectangleCmd( - /*id=*/9, /*width=*/10, /*height=*/10)); - expected.push_back(scenic::NewSetShapeCmd(/*id=*/8, /*shape_id=*/9)); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/8, {5, 5, 0})); - expected.push_back(scenic::NewCreateMaterialCmd(/*id=*/10)); - expected.push_back(scenic::NewSetMaterialCmd(/*id=*/8, /*material_id=*/10)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/6, /*child_id=*/8)); - - expected.push_back(scenic::NewCreateImageCmd(/*id=*/11, 0, 0, {})); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/6)); - expected.push_back(scenic::NewSetColorCmd(/*id=*/10, /*r*/ 255, /*g*/ 255, - /*b*/ 255, /*a*/ 255)); - expected.push_back( - scenic::NewSetTextureCmd(/*material_id=*/10, /*texture_id=*/11)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/10)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/9)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/8)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/7)); - - // - // Grandchild (child of #3): PhysicalShapeLayer - // - // Expect no new commands! Should be composited into parent. - - // - // Child #4: ChildSceneLayer - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/12)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/13)); - auto [view_token2, view_holder_token2] = scenic::ViewTokenPair::New(); - expected.push_back(scenic::NewCreateViewHolderCmd( - /*id=*/14, std::move(view_holder_token2), "")); - expected.push_back(scenic::NewAddChildCmd(/*id=*/13, /*child_id=*/12)); - expected.push_back(scenic::NewSetLabelCmd(/*id=*/13, "flutter::ViewHolder")); - expected.push_back(scenic::NewAddChildCmd(/*id=*/12, /*child_id=*/14)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/2, /*child_id=*/13)); - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/13, 1.f)); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/12, {1, 1, -0.1})); - expected.push_back(scenic::NewSetHitTestBehaviorCmd( - /*id=*/12, /*ignored*/ fuchsia::ui::gfx::HitTestBehavior::kSuppress)); - - // - // Child #5: PhysicalShapeLayer - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/15)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/2, /*child_id=*/15)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/16)); - expected.push_back( - scenic::NewSetLabelCmd(/*id=*/15, "flutter::PhysicalShapeLayer")); - expected.push_back(scenic::NewSetTranslationCmd( - /*id=*/15, {0, 0, -2 * kScenicZElevationBetweenLayers})); - expected.push_back(scenic::NewAddChildCmd(/*id=*/15, /*child_id=*/16)); - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/16, kOneMinusEpsilon)); - expected.push_back(scenic::NewSetClipPlanesCmd(/*id=*/15, /*ignored*/ {})); - expected.push_back(scenic::NewCreateShapeNodeCmd(/*id=*/17)); - expected.push_back(scenic::NewCreateRectangleCmd( - /*id=*/18, /*width=*/10, /*height=*/10)); - expected.push_back(scenic::NewSetShapeCmd(/*id=*/17, /*shape_id=*/18)); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/17, {5, 5, 0})); - expected.push_back(scenic::NewCreateMaterialCmd(/*id=*/19)); - expected.push_back(scenic::NewSetMaterialCmd(/*id=*/17, /*material_id=*/19)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/15, /*child_id=*/17)); - - expected.push_back(scenic::NewCreateImageCmd(/*id=*/20, 0, 0, {})); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/15)); - expected.push_back(scenic::NewSetColorCmd(/*id=*/19, /*r*/ 255, /*g*/ 255, - /*b*/ 255, /*a*/ 255)); - expected.push_back( - scenic::NewSetTextureCmd(/*material_id=*/19, /*texture_id=*/20)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/19)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/18)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/17)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/16)); - - test_context->mock_session.SetExpectedCommands(std::move(expected)); - - // Finally, UpdateScene(). The MockSession will check the emitted commands - // against the list above. - root->UpdateScene(test_context->scene_update_context); - - test_context->mock_session_wrapper->Present(); - - // Run loop until idle, so that the Session receives and processes - // its method calls. - async_loop_run_until_idle( - async_loop_from_dispatcher(async_get_default_dispatcher())); - - // Ensure we saw enough commands. - EXPECT_EQ(72u, test_context->mock_session.num_enqueued_commands()); -} - -// Create a hierarchy with OpacityLayers, TransformLayer, PhysicalShapeLayers -// and ChildSceneLayers, and inspect the commands sent to Scenic. -// -// We are interested in verifying that the opacity values of children are -// correct, and the transform values as well. -// -// This test has been temporarily disabled: fxb/52028 -TEST_F(FuchsiaLayerTest, DISABLED_OpacityAndTransformLayer) { - auto test_context = InitTest(); - - // Root. - auto root = std::make_shared(); - SkPath path; - path.addRect(SkRect::MakeWH(10.f, 10.f)); - - // OpacityLayer #1 - auto opacity_layer1 = - std::make_shared(127, SkPoint::Make(0, 0)); - root->Add(opacity_layer1); - - // OpacityLayer #2 - auto opacity_layer2 = - std::make_shared(127, SkPoint::Make(0, 0)); - opacity_layer1->Add(opacity_layer2); - - // TransformLayer - SkMatrix translate_and_scale; - translate_and_scale.setScaleTranslate(1.1f, 1.1f, 2.f, 2.f); - auto transform_layer = std::make_shared(translate_and_scale); - opacity_layer2->Add(transform_layer); - - // TransformLayer Child #1: ChildSceneLayer. - const zx_koid_t kChildLayerId1 = GetChildLayerId(); - auto [unused_view_token1, unused_view_holder_token1] = - scenic::ViewTokenPair::New(); - - ViewHolder::Create( - kChildLayerId1, - /*bind_callback=*/[](scenic::ResourceId id) {}, - std::move(unused_view_holder_token1)); - // Will destroy only when we go out of scope (i.e. end of the test). - AutoDestroyChildLayerId auto_destroy1(kChildLayerId1); - auto child_view1 = std::make_shared( - kChildLayerId1, SkPoint::Make(1, 1), SkSize::Make(10, 10), - /*hit_testable=*/false); - transform_layer->Add(child_view1); - - // TransformLayer Child #2: PhysicalShapeLayer. - auto physical_shape1 = std::make_shared( - /*color=*/SK_ColorCYAN, - /*shadow_color=*/SK_ColorBLACK, - /*elevation*/ 23.f, path, Clip::antiAlias); - transform_layer->Add(physical_shape1); - - // Preroll. - root->Preroll(test_context->preroll_context.get(), SkMatrix()); - - // 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, - SkRRect::MakeRect(SkRect::MakeWH(100, 100)), - SK_ColorTRANSPARENT, SK_AlphaOPAQUE, - "fuchsia test root"); - - // Submit the list of command we will expect Scenic to see. - // - // We are interested in verifying that the opacity values of children are - // correct. - - std::vector expected; - - // - // Test root. - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/1)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/2)); - expected.push_back(scenic::NewSetLabelCmd(/*id=*/1, "fuchsia test root")); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/1, {0, 0, 0})); - expected.push_back(scenic::NewAddChildCmd(/*id=*/1, /*child_id=*/2)); - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/2, kOneMinusEpsilon)); - - // - // OpacityLayer #1 - // - // Expect no new commands for this. - - // - // OpacityLayer #2 - // - // Expect no new commands for this. - - // - // TransformLayer - // - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/3)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/2, /*child_id=*/3)); - expected.push_back(scenic::NewSetLabelCmd(/*id=*/3, "flutter::Transform")); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/3, {2.f, 2.f, 0.f})); - expected.push_back(scenic::NewSetScaleCmd(/*id=*/3, {1.1f, 1.1f, 1.f})); - expected.push_back(scenic::NewSetRotationCmd(/*id=*/3, {0.f, 0.f, 0.f, 1.f})); - - // - // TransformLayer Child #1: ChildSceneLayer. - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/4)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/5)); - auto [view_token1, view_holder_token1] = scenic::ViewTokenPair::New(); - expected.push_back(scenic::NewCreateViewHolderCmd( - /*id=*/6, std::move(view_holder_token1), "")); - expected.push_back(scenic::NewAddChildCmd(/*id=*/5, /*child_id=*/4)); - expected.push_back(scenic::NewSetLabelCmd(/*id=*/5, "flutter::ViewHolder")); - expected.push_back(scenic::NewAddChildCmd(/*id=*/4, /*child_id=*/6)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/3, /*child_id=*/5)); - - // Check opacity value. Extra rounding required because we pass alpha as - // a uint/SkAlpha to SceneUpdateContext::Frame. - float opacity1 = kOneMinusEpsilon * (127 / 255.f) * (127 / 255.f); - opacity1 = SkScalarRoundToInt(opacity1 * 255) / 255.f; - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/5, opacity1)); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/4, {1, 1, -0.1})); - expected.push_back(scenic::NewSetHitTestBehaviorCmd( - /*id=*/4, /*ignored*/ fuchsia::ui::gfx::HitTestBehavior::kSuppress)); - - // - // TransformLayer Child #2: PhysicalShapeLayer - // - expected.push_back(scenic::NewCreateEntityNodeCmd(/*id=*/7)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/3, /*child_id=*/7)); - expected.push_back(scenic::NewCreateOpacityNodeCmdHACK(/*id=*/8)); - expected.push_back( - scenic::NewSetLabelCmd(/*id=*/7, "flutter::PhysicalShapeLayer")); - expected.push_back(scenic::NewSetTranslationCmd( - /*id=*/7, {0, 0, -kScenicZElevationBetweenLayers})); - expected.push_back(scenic::NewAddChildCmd(/*id=*/7, /*child_id=*/8)); - - // Check opacity value. Extra rounding required because we pass alpha as - // a uint/SkAlpha to SceneUpdateContext::Frame. - float opacity2 = kOneMinusEpsilon * (127 / 255.f) * (127 / 255.f); - opacity2 = SkScalarRoundToInt(opacity2 * 255) / 255.f; - expected.push_back(scenic::NewSetOpacityCmd(/*id=*/8, opacity2)); - expected.push_back(scenic::NewSetClipPlanesCmd(/*id=*/7, /*ignored*/ {})); - expected.push_back(scenic::NewCreateShapeNodeCmd(/*id=*/9)); - expected.push_back(scenic::NewCreateRectangleCmd( - /*id=*/10, /*width=*/10, /*height=*/10)); - expected.push_back(scenic::NewSetShapeCmd(/*id=*/9, /*shape_id=*/10)); - expected.push_back(scenic::NewSetTranslationCmd(/*id=*/9, {5, 5, 0})); - expected.push_back(scenic::NewCreateMaterialCmd(/*id=*/11)); - expected.push_back(scenic::NewSetMaterialCmd(/*id=*/9, - /*material_id=*/11)); - expected.push_back(scenic::NewAddChildCmd(/*id=*/7, - /*child_id=*/9)); - - expected.push_back(scenic::NewCreateImageCmd(/*id=*/12, 0, 0, {})); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/7)); - expected.push_back(scenic::NewSetColorCmd(/*id=*/11, /*r*/ 255, - /*g*/ 255, - /*b*/ 255, /*a*/ 63)); - expected.push_back( - scenic::NewSetTextureCmd(/*material_id=*/11, /*texture_id=*/12)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/11)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/10)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/9)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/8)); - expected.push_back(scenic::NewReleaseResourceCmd(/*id=*/3)); - - test_context->mock_session.SetExpectedCommands(std::move(expected)); - - // Finally, UpdateScene(). The MockSession will check the emitted - // commands against the list above. - root->UpdateScene(test_context->scene_update_context); - - test_context->mock_session_wrapper->Present(); - - // Run loop until idle, so that the Session receives and processes - // its method calls. - async_loop_run_until_idle( - async_loop_from_dispatcher(async_get_default_dispatcher())); - - // Ensure we saw enough commands. - EXPECT_EQ(46u, test_context->mock_session.num_enqueued_commands()); -} - -} // namespace testing -} // namespace flutter diff --git a/flow/layers/image_filter_layer_unittests.cc b/flow/layers/image_filter_layer_unittests.cc index e3f26f421b6a1..61dcdc18fcb63 100644 --- a/flow/layers/image_filter_layer_unittests.cc +++ b/flow/layers/image_filter_layer_unittests.cc @@ -24,7 +24,6 @@ TEST_F(ImageFilterLayerTest, PaintingEmptyLayerDies) { layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), kEmptyRect); EXPECT_FALSE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "needs_painting\\(context\\)"); @@ -261,7 +260,7 @@ TEST_F(ImageFilterLayerTest, Readback) { // ImageFilterLayer blocks child with readback auto mock_layer = - std::make_shared(SkPath(), SkPaint(), false, false, true); + std::make_shared(SkPath(), SkPaint(), false, true); layer->Add(mock_layer); preroll_context()->surface_needs_readback = false; layer->Preroll(preroll_context(), initial_transform); diff --git a/flow/layers/layer.cc b/flow/layers/layer.cc index c04c0756528e4..06a5ae438b367 100644 --- a/flow/layers/layer.cc +++ b/flow/layers/layer.cc @@ -13,7 +13,6 @@ Layer::Layer() : paint_bounds_(SkRect::MakeEmpty()), unique_id_(NextUniqueID()), original_layer_id_(unique_id_), - needs_system_composite_(false), subtree_has_platform_view_(false) {} Layer::~Layer() = default; @@ -57,31 +56,6 @@ Layer::AutoPrerollSaveLayerState::~AutoPrerollSaveLayerState() { } } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - -void Layer::CheckForChildLayerBelow(PrerollContext* context) { - // If there is embedded Fuchsia content in the scene (a ChildSceneLayer), - // PhysicalShapeLayers that appear above the embedded content will be turned - // into their own Scenic layers. - child_layer_exists_below_ = context->child_scene_layer_exists_below; - if (child_layer_exists_below_) { - set_needs_system_composite(true); - } -} - -void Layer::UpdateScene(std::shared_ptr 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"); - - frame.AddPaintLayer(this); -} - -#endif - Layer::AutoSaveLayer::AutoSaveLayer(const PaintContext& paint_context, const SkRect& bounds, const SkPaint* paint) diff --git a/flow/layers/layer.h b/flow/layers/layer.h index 78625cea90e6a..ec7c00d6247fb 100644 --- a/flow/layers/layer.h +++ b/flow/layers/layer.h @@ -28,12 +28,6 @@ #include "third_party/skia/include/core/SkRect.h" #include "third_party/skia/include/utils/SkNWayCanvas.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "flutter/flow/scene_update_context.h" //nogncheck -#include "lib/ui/scenic/cpp/resources.h" //nogncheck -#include "lib/ui/scenic/cpp/session.h" //nogncheck -#endif - namespace flutter { namespace testing { @@ -64,11 +58,6 @@ struct PrerollContext { // These allow us to track properties like elevation, opacity, and the // prescence of a platform view during Preroll. bool has_platform_view = false; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - // True if, during the traversal so far, we have seen a child_scene_layer. - // Informs whether a layer needs to be system composited. - bool child_scene_layer_exists_below = false; -#endif // These allow us to track properties like elevation, opacity, and the // prescence of a texture layer during Preroll. bool has_texture_layer = false; @@ -191,17 +180,6 @@ class Layer { virtual void Paint(PaintContext& context) const = 0; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - // Updates the system composited scene. - virtual void UpdateScene(std::shared_ptr context); - virtual void CheckForChildLayerBelow(PrerollContext* context); -#endif - - bool needs_system_composite() const { return needs_system_composite_; } - void set_needs_system_composite(bool value) { - needs_system_composite_ = value; - } - bool subtree_has_platform_view() const { return subtree_has_platform_view_; } void set_subtree_has_platform_view(bool value) { subtree_has_platform_view_ = value; @@ -269,16 +247,10 @@ class Layer { #endif // FLUTTER_ENABLE_DIFF_CONTEXT - protected: -#if defined(LEGACY_FUCHSIA_EMBEDDER) - bool child_layer_exists_below_ = false; -#endif - private: SkRect paint_bounds_; uint64_t unique_id_; uint64_t original_layer_id_; - bool needs_system_composite_; bool subtree_has_platform_view_; static uint64_t NextUniqueID(); diff --git a/flow/layers/layer_tree.cc b/flow/layers/layer_tree.cc index 2fa755f511453..58205ae64590f 100644 --- a/flow/layers/layer_tree.cc +++ b/flow/layers/layer_tree.cc @@ -54,27 +54,6 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame, return context.surface_needs_readback; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) -void LayerTree::UpdateScene(std::shared_ptr context) { - TRACE_EVENT0("flutter", "LayerTree::UpdateScene"); - - // Reset for a new Scene. - context->Reset(frame_size_, device_pixel_ratio_); - - SceneUpdateContext::Frame frame( - context, - SkRRect::MakeRect( - SkRect::MakeWH(frame_size_.width(), frame_size_.height())), - SK_ColorTRANSPARENT, SK_AlphaOPAQUE, "flutter::Layer"); - if (root_layer_->needs_system_composite()) { - root_layer_->UpdateScene(context); - } - if (!root_layer_->is_empty()) { - frame.AddPaintLayer(root_layer_.get()); - } -} -#endif - void LayerTree::Paint(CompositorContext::ScopedFrame& frame, bool ignore_raster_cache) const { TRACE_EVENT0("flutter", "LayerTree::Paint"); diff --git a/flow/layers/layer_tree.h b/flow/layers/layer_tree.h index 67a32ca6b3c5c..6e4a202deaf76 100644 --- a/flow/layers/layer_tree.h +++ b/flow/layers/layer_tree.h @@ -31,10 +31,6 @@ class LayerTree { bool Preroll(CompositorContext::ScopedFrame& frame, bool ignore_raster_cache = false); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context); -#endif - void Paint(CompositorContext::ScopedFrame& frame, bool ignore_raster_cache = false) const; diff --git a/flow/layers/layer_tree_unittests.cc b/flow/layers/layer_tree_unittests.cc index ba0429f5427ae..2c70149a2ccdb 100644 --- a/flow/layers/layer_tree_unittests.cc +++ b/flow/layers/layer_tree_unittests.cc @@ -113,9 +113,6 @@ TEST_F(LayerTreeTest, Multiple) { EXPECT_FALSE(mock_layer1->is_empty()); EXPECT_FALSE(mock_layer2->is_empty()); EXPECT_FALSE(layer->is_empty()); - EXPECT_FALSE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), root_transform()); EXPECT_EQ(mock_layer2->parent_matrix(), root_transform()); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); @@ -149,9 +146,6 @@ TEST_F(LayerTreeTest, MultipleWithEmpty) { EXPECT_FALSE(mock_layer1->is_empty()); EXPECT_TRUE(mock_layer2->is_empty()); EXPECT_FALSE(layer->is_empty()); - EXPECT_FALSE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), root_transform()); EXPECT_EQ(mock_layer2->parent_matrix(), root_transform()); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); @@ -169,8 +163,7 @@ TEST_F(LayerTreeTest, NeedsSystemComposite) { const SkPaint child_paint1(SkColors::kGray); const SkPaint child_paint2(SkColors::kGreen); auto mock_layer1 = std::make_shared( - child_path1, child_paint1, false /* fake_has_platform_view */, - true /* fake_needs_system_composite */); + child_path1, child_paint1, false /* fake_has_platform_view */); auto mock_layer2 = std::make_shared(child_path2, child_paint2); auto layer = std::make_shared(); layer->Add(mock_layer1); @@ -186,9 +179,6 @@ TEST_F(LayerTreeTest, NeedsSystemComposite) { EXPECT_FALSE(mock_layer1->is_empty()); EXPECT_FALSE(mock_layer2->is_empty()); EXPECT_FALSE(layer->is_empty()); - EXPECT_TRUE(mock_layer1->needs_system_composite()); - EXPECT_FALSE(mock_layer2->needs_system_composite()); - EXPECT_TRUE(layer->needs_system_composite()); EXPECT_EQ(mock_layer1->parent_matrix(), root_transform()); EXPECT_EQ(mock_layer2->parent_matrix(), root_transform()); EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect); diff --git a/flow/layers/opacity_layer.cc b/flow/layers/opacity_layer.cc index 5ab3f79cde220..0d19c9c5d6151 100644 --- a/flow/layers/opacity_layer.cc +++ b/flow/layers/opacity_layer.cc @@ -101,15 +101,4 @@ void OpacityLayer::Paint(PaintContext& context) const { PaintChildren(context); } -#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)); - ContainerLayer::UpdateScene(context); - context->set_alphaf(saved_alpha); -} - -#endif - } // namespace flutter diff --git a/flow/layers/opacity_layer.h b/flow/layers/opacity_layer.h index 3821dba531ef3..52010ce895ff1 100644 --- a/flow/layers/opacity_layer.h +++ b/flow/layers/opacity_layer.h @@ -37,10 +37,6 @@ class OpacityLayer : public MergedContainerLayer { void Paint(PaintContext& context) const override; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; -#endif - private: SkAlpha alpha_; SkPoint offset_; diff --git a/flow/layers/opacity_layer_unittests.cc b/flow/layers/opacity_layer_unittests.cc index 9f4d981942edc..80c16052f8ecb 100644 --- a/flow/layers/opacity_layer_unittests.cc +++ b/flow/layers/opacity_layer_unittests.cc @@ -407,7 +407,7 @@ TEST_F(OpacityLayerTest, Readback) { // OpacityLayer blocks child with readback auto mock_layer = - std::make_shared(SkPath(), SkPaint(), false, false, true); + std::make_shared(SkPath(), SkPaint(), false, true); layer->Add(mock_layer); preroll_context()->surface_needs_readback = false; layer->Preroll(preroll_context(), initial_transform); diff --git a/flow/layers/physical_shape_layer_unittests.cc b/flow/layers/physical_shape_layer_unittests.cc index 10a027cc3696d..6b64ade3bcb03 100644 --- a/flow/layers/physical_shape_layer_unittests.cc +++ b/flow/layers/physical_shape_layer_unittests.cc @@ -24,7 +24,6 @@ TEST_F(PhysicalShapeLayerTest, PaintingEmptyLayerDies) { layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty()); EXPECT_FALSE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "needs_painting\\(context\\)"); @@ -55,7 +54,6 @@ TEST_F(PhysicalShapeLayerTest, NonEmptyLayer) { layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), layer_path.getBounds()); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); SkPaint layer_paint; layer_paint.setColor(SK_ColorGREEN); @@ -94,7 +92,6 @@ TEST_F(PhysicalShapeLayerTest, ChildrenLargerThanPath) { EXPECT_EQ(layer->paint_bounds(), layer_path.getBounds()); EXPECT_NE(layer->paint_bounds(), child_paint_bounds); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); SkPaint layer_paint; layer_paint.setColor(SK_ColorGREEN); @@ -130,12 +127,8 @@ TEST_F(PhysicalShapeLayerTest, ElevationSimple) { PhysicalShapeLayer::ComputeShadowBounds(layer_path.getBounds(), initial_elevation, 1.0f)); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(layer->elevation(), initial_elevation); - // The Fuchsia system compositor handles all elevated PhysicalShapeLayers and - // their shadows , so we do not use the direct |Paint()| path there. -#if !defined(LEGACY_FUCHSIA_EMBEDDER) SkPaint layer_paint; layer_paint.setColor(SK_ColorGREEN); layer_paint.setAntiAlias(true); @@ -146,7 +139,6 @@ TEST_F(PhysicalShapeLayerTest, ElevationSimple) { {MockCanvas::DrawCall{0, MockCanvas::DrawShadowData{layer_path}}, MockCanvas::DrawCall{ 0, MockCanvas::DrawPathData{layer_path, layer_paint}}})); -#endif } TEST_F(PhysicalShapeLayerTest, ElevationComplex) { @@ -185,12 +177,8 @@ TEST_F(PhysicalShapeLayerTest, ElevationComplex) { layer_path.getBounds(), initial_elevations[i], 1.0f /* pixel_ratio */))); EXPECT_TRUE(layers[i]->needs_painting(paint_context())); - EXPECT_FALSE(layers[i]->needs_system_composite()); } - // The Fuchsia system compositor handles all elevated PhysicalShapeLayers and - // their shadows , so we do not use the direct |Paint()| path there. -#if !defined(LEGACY_FUCHSIA_EMBEDDER) SkPaint layer_paint; layer_paint.setColor(SK_ColorBLACK); layer_paint.setAntiAlias(true); @@ -210,7 +198,6 @@ TEST_F(PhysicalShapeLayerTest, ElevationComplex) { MockCanvas::DrawCall{0, MockCanvas::DrawShadowData{layer_path}}, MockCanvas::DrawCall{ 0, MockCanvas::DrawPathData{layer_path, layer_paint}}})); -#endif } static bool ReadbackResult(PrerollContext* context, @@ -242,7 +229,7 @@ TEST_F(PhysicalShapeLayerTest, Readback) { const Clip save_layer = Clip::antiAliasWithSaveLayer; std::shared_ptr nochild; - auto reader = std::make_shared(path, paint, false, false, true); + auto reader = std::make_shared(path, paint, false, true); auto nonreader = std::make_shared(path, paint); // No children, no prior readback -> no readback after diff --git a/flow/layers/picture_layer.cc b/flow/layers/picture_layer.cc index fcb95933a8b0a..702aaff7a0821 100644 --- a/flow/layers/picture_layer.cc +++ b/flow/layers/picture_layer.cc @@ -109,10 +109,6 @@ sk_sp PictureLayer::SerializedPicture() const { void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { TRACE_EVENT0("flutter", "PictureLayer::Preroll"); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - CheckForChildLayerBelow(context); -#endif - SkPicture* sk_picture = picture(); if (auto* cache = context->raster_cache) { diff --git a/flow/layers/picture_layer_unittests.cc b/flow/layers/picture_layer_unittests.cc index a2e964104a16e..cdd6e6b75fc2b 100644 --- a/flow/layers/picture_layer_unittests.cc +++ b/flow/layers/picture_layer_unittests.cc @@ -53,7 +53,6 @@ TEST_F(PictureLayerTest, PaintingEmptyLayerDies) { layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty()); EXPECT_FALSE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "needs_painting\\(context\\)"); @@ -83,7 +82,6 @@ TEST_F(PictureLayerTest, SimplePicture) { picture_bounds.makeOffset(layer_offset.fX, layer_offset.fY)); EXPECT_EQ(layer->picture(), mock_picture.get()); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); layer->Paint(paint_context()); auto expected_draw_calls = std::vector( diff --git a/flow/layers/platform_view_layer.cc b/flow/layers/platform_view_layer.cc index d846c401a143e..285db390cc91d 100644 --- a/flow/layers/platform_view_layer.cc +++ b/flow/layers/platform_view_layer.cc @@ -13,11 +13,6 @@ PlatformViewLayer::PlatformViewLayer(const SkPoint& offset, void PlatformViewLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - context->child_scene_layer_exists_below = true; - CheckForChildLayerBelow(context); -#endif - set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(), size_.height())); @@ -37,23 +32,12 @@ void PlatformViewLayer::Preroll(PrerollContext* context, void PlatformViewLayer::Paint(PaintContext& context) const { if (context.view_embedder == nullptr) { -#if !defined(LEGACY_FUCHSIA_EMBEDDER) FML_LOG(ERROR) << "Trying to embed a platform view but the PaintContext " "does not support embedding"; -#endif return; } SkCanvas* canvas = context.view_embedder->CompositeEmbeddedView(view_id_); context.leaf_nodes_canvas = canvas; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) -void PlatformViewLayer::UpdateScene( - std::shared_ptr context) { - TRACE_EVENT0("flutter", "PlatformViewLayer::UpdateScene"); - FML_DCHECK(needs_system_composite()); - context->UpdateView(view_id_, offset_, size_); -} -#endif - } // namespace flutter diff --git a/flow/layers/platform_view_layer.h b/flow/layers/platform_view_layer.h index e9d6fac42eb23..242b3734dd3b1 100644 --- a/flow/layers/platform_view_layer.h +++ b/flow/layers/platform_view_layer.h @@ -17,10 +17,6 @@ class PlatformViewLayer : public Layer { void Preroll(PrerollContext* context, const SkMatrix& matrix) override; void Paint(PaintContext& context) const override; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - // Updates the system composited scene. - void UpdateScene(std::shared_ptr context) override; -#endif private: SkPoint offset_; diff --git a/flow/layers/platform_view_layer_unittests.cc b/flow/layers/platform_view_layer_unittests.cc index 56b90dd1b3dd3..58a791d7acca8 100644 --- a/flow/layers/platform_view_layer_unittests.cc +++ b/flow/layers/platform_view_layer_unittests.cc @@ -29,11 +29,6 @@ TEST_F(PlatformViewLayerTest, NullViewEmbedderDoesntPrerollCompositeOrPaint) { SkRect::MakeSize(layer_size) .makeOffset(layer_offset.fX, layer_offset.fY)); EXPECT_TRUE(layer->needs_painting(paint_context())); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - EXPECT_TRUE(layer->needs_system_composite()); -#else - EXPECT_FALSE(layer->needs_system_composite()); -#endif // LEGACY_FUCHSIA_EMBEDDER EXPECT_FALSE(layer->subtree_has_platform_view()); layer->Paint(paint_context()); @@ -67,11 +62,6 @@ TEST_F(PlatformViewLayerTest, ClippedPlatformViewPrerollsAndPaintsNothing) { EXPECT_TRUE(layer->needs_painting(paint_context())); EXPECT_TRUE(child_clip_layer->needs_painting(paint_context())); EXPECT_TRUE(parent_clip_layer->needs_painting(paint_context())); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - EXPECT_TRUE(layer->needs_system_composite()); -#else - EXPECT_FALSE(layer->needs_system_composite()); -#endif // LEGACY_FUCHSIA_EMBEDDER EXPECT_TRUE(layer->subtree_has_platform_view()); EXPECT_TRUE(child_clip_layer->subtree_has_platform_view()); EXPECT_TRUE(parent_clip_layer->subtree_has_platform_view()); diff --git a/flow/layers/shader_mask_layer.cc b/flow/layers/shader_mask_layer.cc index 190bf68e06f92..5106d2b3d8251 100644 --- a/flow/layers/shader_mask_layer.cc +++ b/flow/layers/shader_mask_layer.cc @@ -32,10 +32,6 @@ void ShaderMaskLayer::Diff(DiffContext* context, const Layer* old_layer) { #endif // FLUTTER_ENABLE_DIFF_CONTEXT void ShaderMaskLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - CheckForChildLayerBelow(context); -#endif - Layer::AutoPrerollSaveLayerState save = Layer::AutoPrerollSaveLayerState::Create(context); ContainerLayer::Preroll(context, matrix); diff --git a/flow/layers/shader_mask_layer_unittests.cc b/flow/layers/shader_mask_layer_unittests.cc index 750d540bba26c..c979d54278c62 100644 --- a/flow/layers/shader_mask_layer_unittests.cc +++ b/flow/layers/shader_mask_layer_unittests.cc @@ -268,7 +268,7 @@ TEST_F(ShaderMaskLayerTest, Readback) { // ShaderMaskLayer blocks child with readback auto mock_layer = - std::make_shared(SkPath(), SkPaint(), false, false, true); + std::make_shared(SkPath(), SkPaint(), false, true); layer->Add(mock_layer); preroll_context()->surface_needs_readback = false; layer->Preroll(preroll_context(), initial_transform); diff --git a/flow/layers/texture_layer.cc b/flow/layers/texture_layer.cc index 0608bf2034ed0..7197d52296be9 100644 --- a/flow/layers/texture_layer.cc +++ b/flow/layers/texture_layer.cc @@ -40,10 +40,6 @@ void TextureLayer::Diff(DiffContext* context, const Layer* old_layer) { void TextureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { TRACE_EVENT0("flutter", "TextureLayer::Preroll"); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - CheckForChildLayerBelow(context); -#endif - set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(), size_.height())); context->has_texture_layer = true; diff --git a/flow/layers/transform_layer.cc b/flow/layers/transform_layer.cc index 8363a55ab3a91..aff4710c23f37 100644 --- a/flow/layers/transform_layer.cc +++ b/flow/layers/transform_layer.cc @@ -70,22 +70,6 @@ void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { context->mutators_stack.Pop(); } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - -void TransformLayer::UpdateScene(std::shared_ptr context) { - TRACE_EVENT0("flutter", "TransformLayer::UpdateScene"); - FML_DCHECK(needs_system_composite()); - - std::optional transform; - if (!transform_.isIdentity()) { - transform.emplace(context, transform_); - } - - UpdateSceneChildren(context); -} - -#endif - void TransformLayer::Paint(PaintContext& context) const { TRACE_EVENT0("flutter", "TransformLayer::Paint"); FML_DCHECK(needs_painting(context)); diff --git a/flow/layers/transform_layer.h b/flow/layers/transform_layer.h index f628edbc34a33..69757975df122 100644 --- a/flow/layers/transform_layer.h +++ b/flow/layers/transform_layer.h @@ -25,10 +25,6 @@ class TransformLayer : public ContainerLayer { void Paint(PaintContext& context) const override; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void UpdateScene(std::shared_ptr context) override; -#endif - private: SkMatrix transform_; diff --git a/flow/scene_update_context.cc b/flow/scene_update_context.cc deleted file mode 100644 index 5c1eb96684db8..0000000000000 --- a/flow/scene_update_context.cc +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/flow/scene_update_context.h" - -#include -#include - -#include "flutter/flow/layers/layer.h" -#include "flutter/flow/matrix_decomposition.h" -#include "flutter/flow/view_holder.h" -#include "flutter/fml/trace_event.h" -#include "include/core/SkColor.h" - -namespace flutter { -namespace { - -void SetEntityNodeClipPlanes(scenic::EntityNode& entity_node, - const SkRect& bounds) { - const float top = bounds.top(); - const float bottom = bounds.bottom(); - const float left = bounds.left(); - const float right = bounds.right(); - - // We will generate 4 oriented planes, one for each edge of the bounding rect. - std::vector clip_planes; - clip_planes.resize(4); - - // Top plane. - clip_planes[0].dist = top; - clip_planes[0].dir.x = 0.f; - clip_planes[0].dir.y = 1.f; - clip_planes[0].dir.z = 0.f; - - // Bottom plane. - clip_planes[1].dist = -bottom; - clip_planes[1].dir.x = 0.f; - clip_planes[1].dir.y = -1.f; - clip_planes[1].dir.z = 0.f; - - // Left plane. - clip_planes[2].dist = left; - clip_planes[2].dir.x = 1.f; - clip_planes[2].dir.y = 0.f; - clip_planes[2].dir.z = 0.f; - - // Right plane. - clip_planes[3].dist = -right; - clip_planes[3].dir.x = -1.f; - clip_planes[3].dir.y = 0.f; - clip_planes[3].dir.z = 0.f; - - entity_node.SetClipPlanes(std::move(clip_planes)); -} - -void SetMaterialColor(scenic::Material& material, - SkColor color, - SkAlpha opacity) { - const SkAlpha color_alpha = static_cast( - ((float)SkColorGetA(color) * (float)opacity) / 255.0f); - material.SetColor(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color), - color_alpha); -} - -} // namespace - -SceneUpdateContext::SceneUpdateContext(std::string debug_label, - fuchsia::ui::views::ViewToken view_token, - scenic::ViewRefPair view_ref_pair, - SessionWrapper& session, - bool intercept_all_input) - : session_(session), - root_view_(session_.get(), - std::move(view_token), - std::move(view_ref_pair.control_ref), - std::move(view_ref_pair.view_ref), - debug_label), - metrics_node_(session.get()), - layer_tree_node_(session_.get()) { - layer_tree_node_.SetLabel("Flutter::LayerTree"); - metrics_node_.SetLabel("Flutter::MetricsWatcher"); - metrics_node_.SetEventMask(fuchsia::ui::gfx::kMetricsEventMask); - metrics_node_.AddChild(layer_tree_node_); - root_view_.AddChild(metrics_node_); - - // Set up the input interceptor at the top of the scene, if applicable. It - // will capture all input, and any unwanted input will be reinjected into - // embedded views. - if (intercept_all_input) { - input_interceptor_node_.emplace(session_.get()); - input_interceptor_node_->SetLabel("Flutter::InputInterceptor"); - input_interceptor_node_->SetHitTestBehavior( - fuchsia::ui::gfx::HitTestBehavior::kDefault); - input_interceptor_node_->SetSemanticVisibility(false); - - metrics_node_.AddChild(input_interceptor_node_.value()); - } - - session_.Present(); -} - -std::vector SceneUpdateContext::GetPaintTasks() { - std::vector frame_paint_tasks = std::move(paint_tasks_); - - paint_tasks_.clear(); - - return frame_paint_tasks; -} - -void SceneUpdateContext::EnableWireframe(bool enable) { - session_.get()->Enqueue( - scenic::NewSetEnableDebugViewBoundsCmd(root_view_.id(), enable)); -} - -void SceneUpdateContext::Reset(const SkISize& frame_size, - float device_pixel_ratio) { - paint_tasks_.clear(); - top_entity_ = nullptr; - top_scale_x_ = 1.f; - top_scale_y_ = 1.f; - top_elevation_ = 0.f; - next_elevation_ = 0.f; - alpha_ = 1.f; - - // Adjust scene scaling to match the device pixel ratio. - const float inv_dpr = 1.0f / device_pixel_ratio; - layer_tree_node_.SetScale(inv_dpr, inv_dpr, 1.0f); - - // Set up the input interceptor at the top of the scene, if applicable. - if (input_interceptor_node_.has_value()) { - // TODO(fxb/): Don't hardcode elevation. - input_interceptor_node_->SetTranslation(frame_size.width() * 0.5f, - frame_size.height() * 0.5f, -100.f); - input_interceptor_node_->SetShape(scenic::Rectangle( - session_.get(), frame_size.width(), frame_size.height())); - } - - // We are going to be sending down a fresh node hierarchy every frame. So just - // enqueue a detach op on the layer tree node. - layer_tree_node_.DetachChildren(); -} - -void SceneUpdateContext::CreateFrame(scenic::EntityNode& entity_node, - const SkRRect& rrect, - SkColor color, - SkAlpha opacity, - const SkRect& paint_bounds, - std::vector paint_layers) { - // We don't need a shape if the frame is zero size. - if (rrect.isEmpty()) - return; - - // Frames always clip their children. - SkRect shape_bounds = rrect.getBounds(); - SetEntityNodeClipPlanes(entity_node, shape_bounds); - - // TODO(SCN-137): Need to be able to express the radii as vectors. - scenic::ShapeNode shape_node(session_.get()); - scenic::Rectangle shape(session_.get(), rrect.width(), rrect.height()); - shape_node.SetShape(shape); - shape_node.SetTranslation(shape_bounds.width() * 0.5f + shape_bounds.left(), - shape_bounds.height() * 0.5f + shape_bounds.top(), - 0.f); - - // Check whether the painted layers will be visible. - if (paint_bounds.isEmpty() || !paint_bounds.intersects(shape_bounds)) - paint_layers.clear(); - - scenic::Material material(session_.get()); - shape_node.SetMaterial(material); - entity_node.AddChild(shape_node); - - // Check whether a solid color will suffice. - if (paint_layers.empty()) { - SetMaterialColor(material, color, opacity); - } else { - // The final shape's color is material_color * texture_color. The passed in - // material color was already used as a background when generating the - // texture, so set the model color to |SK_ColorWHITE| in order to allow - // using the texture's color unmodified. - SetMaterialColor(material, SK_ColorWHITE, opacity); - - // Enqueue a paint task for these layers, to apply a texture to the whole - // shape. - // - // The task uses the |shape_bounds| as its rendering bounds instead of the - // |paint_bounds|. If the paint_bounds is large than the shape_bounds it - // will be clipped. - paint_tasks_.emplace_back(PaintTask{.paint_bounds = shape_bounds, - .scale_x = top_scale_x_, - .scale_y = top_scale_y_, - .background_color = color, - .material = std::move(material), - .layers = std::move(paint_layers)}); - } -} - -void SceneUpdateContext::UpdateView(int64_t view_id, - const SkPoint& offset, - const SkSize& size, - std::optional override_hit_testable) { - auto* view_holder = ViewHolder::FromId(view_id); - if (view_holder == nullptr) { - FML_LOG(ERROR) << "UpdateView did not find view holder for: " << view_id; - return; - } - - if (override_hit_testable.has_value()) { - view_holder->set_hit_testable(*override_hit_testable); - } - view_holder->set_size(size); - view_holder->UpdateScene(session_.get(), top_entity_->embedder_node(), offset, - SkScalarRoundToInt(alphaf() * 255)); - - // Assume embedded views are 10 "layers" wide. - next_elevation_ += 10 * kScenicZElevationBetweenLayers; -} - -void SceneUpdateContext::CreateView(int64_t view_id, - ViewCallback on_view_created, - ViewHolder::ViewIdCallback on_view_bound, - bool hit_testable, - bool focusable) { - FML_LOG(INFO) << "CreateView for view holder: " << view_id; - zx_handle_t handle = (zx_handle_t)view_id; - flutter::ViewHolder::Create(handle, std::move(on_view_bound), - scenic::ToViewHolderToken(zx::eventpair(handle))); - on_view_created(); - - auto* view_holder = ViewHolder::FromId(view_id); - FML_DCHECK(view_holder); - view_holder->set_hit_testable(hit_testable); - view_holder->set_focusable(focusable); -} - -void SceneUpdateContext::UpdateView(int64_t view_id, - const SkRect& view_occlusion_hint, - bool hit_testable, - bool focusable) { - auto* view_holder = ViewHolder::FromId(view_id); - if (view_holder == nullptr) { - FML_LOG(ERROR) << "UpdateView did not find view holder for: " << view_id; - return; - } - - view_holder->set_hit_testable(hit_testable); - view_holder->set_focusable(focusable); - view_holder->set_occlusion_hint(view_occlusion_hint); -} - -void SceneUpdateContext::DestroyView( - int64_t view_id, - ViewHolder::ViewIdCallback on_view_destroyed) { - ViewHolder::Destroy(view_id, std::move(on_view_destroyed)); -} - -SceneUpdateContext::Entity::Entity(std::shared_ptr context) - : context_(context), - 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_->layer_tree_node_.AddChild(entity_node_); - } - - FML_DCHECK(context_->top_entity_ == this); - context_->top_entity_ = previous_entity_; -} - -SceneUpdateContext::Transform::Transform( - std::shared_ptr context, - const SkMatrix& transform) - : Entity(context), - 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 - // are not handled correctly. - MatrixDecomposition decomposition(transform); - if (decomposition.IsValid()) { - // Don't allow clients to control the z dimension; we control that - // instead to make sure layers appear in proper order. - entity_node().SetTranslation(decomposition.translation().x, // - decomposition.translation().y, // - 0.f // - ); - - entity_node().SetScale(decomposition.scale().x, // - decomposition.scale().y, // - 1.f // - ); - context->top_scale_x_ *= decomposition.scale().x; - context->top_scale_y_ *= decomposition.scale().y; - - entity_node().SetRotation(decomposition.rotation().x, // - decomposition.rotation().y, // - decomposition.rotation().z, // - decomposition.rotation().w // - ); - } - } -} - -SceneUpdateContext::Transform::Transform( - std::shared_ptr 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_) { - 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; - } -} - -SceneUpdateContext::Transform::~Transform() { - context()->top_scale_x_ = previous_scale_x_; - context()->top_scale_y_ = previous_scale_y_; -} - -SceneUpdateContext::Frame::Frame(std::shared_ptr context, - const SkRRect& rrect, - SkColor color, - SkAlpha opacity, - std::string label) - : Entity(context), - previous_elevation_(context->top_elevation_), - rrect_(rrect), - color_(color), - opacity_(opacity), - 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 - // necessary to track this additional state. - context->top_elevation_ += kScenicZElevationBetweenLayers; - context->next_elevation_ += kScenicZElevationBetweenLayers; - - 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_); - - // Scenic currently lacks an API to enable rendering of alpha channel; alpha - // channels are only rendered if there is a OpacityNode higher in the tree - // with opacity != 1. For now, clamp to a infinitesimally smaller value than - // 1, which does not cause visual problems in practice. - opacity_node_.SetOpacity(std::min(kOneMinusEpsilon, opacity_ / 255.0f)); -} - -SceneUpdateContext::Frame::~Frame() { - 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_)); -} - -void SceneUpdateContext::Frame::AddPaintLayer(Layer* layer) { - FML_DCHECK(!layer->is_empty()); - paint_layers_.push_back(layer); - paint_bounds_.join(layer->paint_bounds()); -} - -SceneUpdateContext::Clip::Clip(std::shared_ptr context, - const SkRect& shape_bounds) - : Entity(context) { - entity_node().SetLabel("flutter::Clip"); - SetEntityNodeClipPlanes(entity_node(), shape_bounds); -} - -} // namespace flutter diff --git a/flow/scene_update_context.h b/flow/scene_update_context.h deleted file mode 100644 index 96e1ec323ed1e..0000000000000 --- a/flow/scene_update_context.h +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_FLOW_SCENE_UPDATE_CONTEXT_H_ -#define FLUTTER_FLOW_SCENE_UPDATE_CONTEXT_H_ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "flutter/flow/embedded_views.h" -#include "flutter/flow/view_holder.h" -#include "flutter/fml/logging.h" -#include "flutter/fml/macros.h" -#include "third_party/skia/include/core/SkRect.h" -#include "third_party/skia/include/core/SkSurface.h" - -namespace flutter { - -class Layer; - -// Scenic currently lacks an API to enable rendering of alpha channel; this only -// happens if there is a OpacityNode higher in the tree with opacity != 1. For -// now, clamp to a infinitesimally smaller value than 1, which does not cause -// visual problems in practice. -constexpr float kOneMinusEpsilon = 1 - FLT_EPSILON; - -// How much layers are separated in Scenic z elevation. -constexpr float kScenicZElevationBetweenLayers = 10.f; - -class SessionWrapper { - public: - virtual ~SessionWrapper() {} - - virtual scenic::Session* get() = 0; - virtual void Present() = 0; -}; - -class SceneUpdateContext : public flutter::ExternalViewEmbedder { - public: - class Entity { - public: - Entity(std::shared_ptr context); - virtual ~Entity(); - - std::shared_ptr context() { return context_; } - scenic::EntityNode& entity_node() { return entity_node_; } - virtual scenic::ContainerNode& embedder_node() { return entity_node_; } - - private: - std::shared_ptr context_; - Entity* const previous_entity_; - - scenic::EntityNode entity_node_; - }; - - class Transform : public Entity { - public: - Transform(std::shared_ptr context, - const SkMatrix& transform); - Transform(std::shared_ptr context, - float scale_x, - float scale_y, - float scale_z); - virtual ~Transform(); - - private: - float const previous_scale_x_; - float const previous_scale_y_; - }; - - class Frame : public Entity { - public: - // 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, - const SkRRect& rrect, - SkColor color, - SkAlpha opacity, - std::string label); - virtual ~Frame(); - - scenic::ContainerNode& embedder_node() override { return opacity_node_; } - - void AddPaintLayer(Layer* layer); - - private: - const float previous_elevation_; - - const SkRRect rrect_; - SkColor const color_; - SkAlpha const opacity_; - - scenic::OpacityNodeHACK opacity_node_; - std::vector paint_layers_; - SkRect paint_bounds_; - }; - - class Clip : public Entity { - public: - Clip(std::shared_ptr context, - const SkRect& shape_bounds); - ~Clip() = default; - }; - - struct PaintTask { - SkRect paint_bounds; - SkScalar scale_x; - SkScalar scale_y; - SkColor background_color; - scenic::Material material; - std::vector layers; - }; - - using ViewCallback = std::function; - - SceneUpdateContext(std::string debug_label, - fuchsia::ui::views::ViewToken view_token, - scenic::ViewRefPair view_ref_pair, - SessionWrapper& session, - bool intercept_all_input = false); - ~SceneUpdateContext() = default; - - // The cumulative alpha value based on all the parent OpacityLayers. - void set_alphaf(float alpha) { alpha_ = alpha; } - float alphaf() { return alpha_; } - - // Returns all `PaintTask`s generated for the current frame. - std::vector GetPaintTasks(); - - // Enable/disable wireframe rendering around the root view bounds. - void EnableWireframe(bool enable); - - // Reset state for a new frame. - void Reset(const SkISize& frame_size, float device_pixel_ratio); - - // |ExternalViewEmbedder| - SkCanvas* GetRootCanvas() override { return nullptr; } - - // |ExternalViewEmbedder| - void CancelFrame() override {} - - // |ExternalViewEmbedder| - void BeginFrame( - SkISize frame_size, - GrDirectContext* context, - double device_pixel_ratio, - fml::RefPtr raster_thread_merger) override {} - - // |ExternalViewEmbedder| - void PrerollCompositeEmbeddedView( - int view_id, - std::unique_ptr params) override {} - - // |ExternalViewEmbedder| - std::vector GetCurrentCanvases() override { - return std::vector(); - } - - // |ExternalViewEmbedder| - virtual SkCanvas* CompositeEmbeddedView(int view_id) override { - return nullptr; - } - - // View manipulation. - void CreateView(int64_t view_id, - ViewCallback on_view_created, - ViewHolder::ViewIdCallback on_view_bound, - bool hit_testable, - bool focusable); - void DestroyView(int64_t view_id, - ViewHolder::ViewIdCallback on_view_destroyed); - void UpdateView(int64_t view_id, - const SkRect& view_occlusion_hint, - bool hit_testable, - bool focusable); - void UpdateView(int64_t view_id, - const SkPoint& offset, - const SkSize& size, - std::optional override_hit_testable = std::nullopt); - - private: - void CreateFrame(scenic::EntityNode& entity_node, - const SkRRect& rrect, - SkColor color, - SkAlpha opacity, - const SkRect& paint_bounds, - std::vector paint_layers); - - SessionWrapper& session_; - - scenic::View root_view_; - scenic::EntityNode metrics_node_; - scenic::EntityNode layer_tree_node_; - std::optional input_interceptor_node_; - - std::vector paint_tasks_; - - Entity* top_entity_ = nullptr; - float top_scale_x_ = 1.f; - float top_scale_y_ = 1.f; - float top_elevation_ = 0.f; - - float next_elevation_ = 0.f; - float alpha_ = 1.f; - - FML_DISALLOW_COPY_AND_ASSIGN(SceneUpdateContext); -}; - -} // namespace flutter - -#endif // FLUTTER_FLOW_SCENE_UPDATE_CONTEXT_H_ diff --git a/flow/testing/mock_layer.cc b/flow/testing/mock_layer.cc index c70b86ee4a6c6..0c6ef36e899c6 100644 --- a/flow/testing/mock_layer.cc +++ b/flow/testing/mock_layer.cc @@ -10,12 +10,10 @@ namespace testing { MockLayer::MockLayer(SkPath path, SkPaint paint, bool fake_has_platform_view, - bool fake_needs_system_composite, bool fake_reads_surface) : fake_paint_path_(path), fake_paint_(paint), fake_has_platform_view_(fake_has_platform_view), - fake_needs_system_composite_(fake_needs_system_composite), fake_reads_surface_(fake_reads_surface) {} #ifdef FLUTTER_ENABLE_DIFF_CONTEXT @@ -45,7 +43,6 @@ void MockLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { context->has_platform_view = fake_has_platform_view_; set_paint_bounds(fake_paint_path_.getBounds()); - set_needs_system_composite(fake_needs_system_composite_); if (fake_reads_surface_) { context->surface_needs_readback = true; } diff --git a/flow/testing/mock_layer.h b/flow/testing/mock_layer.h index ed123f9640e3f..aa41fe59faed1 100644 --- a/flow/testing/mock_layer.h +++ b/flow/testing/mock_layer.h @@ -19,7 +19,6 @@ class MockLayer : public Layer { MockLayer(SkPath path, SkPaint paint = SkPaint(), bool fake_has_platform_view = false, - bool fake_needs_system_composite = false, bool fake_reads_surface = false); void Preroll(PrerollContext* context, const SkMatrix& matrix) override; @@ -46,7 +45,6 @@ class MockLayer : public Layer { SkPaint fake_paint_; bool parent_has_platform_view_ = false; bool fake_has_platform_view_ = false; - bool fake_needs_system_composite_ = false; bool fake_reads_surface_ = false; FML_DISALLOW_COPY_AND_ASSIGN(MockLayer); diff --git a/flow/testing/mock_layer_unittests.cc b/flow/testing/mock_layer_unittests.cc index aeba2510c7288..d1df446c258e4 100644 --- a/flow/testing/mock_layer_unittests.cc +++ b/flow/testing/mock_layer_unittests.cc @@ -49,7 +49,6 @@ TEST_F(MockLayerTest, SimpleParams) { EXPECT_EQ(preroll_context()->has_platform_view, false); EXPECT_EQ(layer->paint_bounds(), path.getBounds()); EXPECT_TRUE(layer->needs_painting(paint_context())); - EXPECT_FALSE(layer->needs_system_composite()); EXPECT_EQ(layer->parent_mutators(), std::vector{Mutator(scale_matrix)}); EXPECT_EQ(layer->parent_matrix(), start_matrix); EXPECT_EQ(layer->parent_cull_rect(), cull_rect); @@ -70,15 +69,5 @@ TEST_F(MockLayerTest, FakePlatformView) { EXPECT_EQ(preroll_context()->has_platform_view, true); } -TEST_F(MockLayerTest, FakeSystemComposite) { - auto layer = std::make_shared( - SkPath(), SkPaint(), false /* fake_has_platform_view */, - true /* fake_needs_system_composite */); - EXPECT_EQ(layer->needs_system_composite(), false); - - layer->Preroll(preroll_context(), SkMatrix()); - EXPECT_EQ(layer->needs_system_composite(), true); -} - } // namespace testing } // namespace flutter diff --git a/flow/view_holder.cc b/flow/view_holder.cc deleted file mode 100644 index cafe9b475c8e1..0000000000000 --- a/flow/view_holder.cc +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/flow/view_holder.h" - -#include - -#include "flutter/fml/thread_local.h" - -namespace { - -using ViewHolderBindings = - std::unordered_map>; - -FML_THREAD_LOCAL fml::ThreadLocalUniquePtr - tls_view_holder_bindings; - -// Rather than expend the effort to compute the proper amount of "airspace" to -// give to the child view, just pick an arbitrarily large number. This works -// fine in all current production cases, and the hack of using depth to order -// things in Z is going away with Flatland. -constexpr float kArbitraryLargeDepth = -1000.f; - -} // namespace - -namespace flutter { - -void ViewHolder::Create(zx_koid_t id, - ViewIdCallback on_view_created, - fuchsia::ui::views::ViewHolderToken view_holder_token) { - // This raster thread contains at least 1 ViewHolder. Initialize the - // per-thread bindings. - if (tls_view_holder_bindings.get() == nullptr) { - tls_view_holder_bindings.reset(new ViewHolderBindings()); - } - - auto* bindings = tls_view_holder_bindings.get(); - FML_DCHECK(bindings); - FML_DCHECK(bindings->find(id) == bindings->end()); - - auto view_holder = std::unique_ptr( - new ViewHolder(std::move(view_holder_token), std::move(on_view_created))); - bindings->emplace(id, std::move(view_holder)); -} - -void ViewHolder::Destroy(zx_koid_t id, ViewIdCallback on_view_destroyed) { - auto* bindings = tls_view_holder_bindings.get(); - FML_DCHECK(bindings); - auto binding = bindings->find(id); - FML_DCHECK(binding != bindings->end()); - - if (binding->second->view_holder_ && on_view_destroyed) { - on_view_destroyed(binding->second->view_holder_->id()); - } - bindings->erase(id); -} - -ViewHolder* ViewHolder::FromId(zx_koid_t id) { - auto* bindings = tls_view_holder_bindings.get(); - if (!bindings) { - return nullptr; - } - - auto binding = bindings->find(id); - if (binding == bindings->end()) { - return nullptr; - } - - return binding->second.get(); -} - -ViewHolder::ViewHolder(fuchsia::ui::views::ViewHolderToken view_holder_token, - ViewIdCallback on_view_created) - : pending_view_holder_token_(std::move(view_holder_token)), - on_view_created_(std::move(on_view_created)) { - FML_DCHECK(pending_view_holder_token_.value); -} - -void ViewHolder::UpdateScene(scenic::Session* session, - scenic::ContainerNode& container_node, - const SkPoint& offset, - SkAlpha opacity) { - if (pending_view_holder_token_.value) { - entity_node_ = std::make_unique(session); - opacity_node_ = std::make_unique(session); - view_holder_ = std::make_unique( - session, std::move(pending_view_holder_token_), "Flutter SceneHost"); - opacity_node_->AddChild(*entity_node_); - opacity_node_->SetLabel("flutter::ViewHolder"); - entity_node_->Attach(*view_holder_); - - // Inform the rest of Flutter about the view being created. - // As long as we do this before calling `Present` on the session, - // View-related messages sent to the UI thread will never be processed - // before this internal message is delivered to the UI thread. - if (on_view_created_) { - on_view_created_(view_holder_->id()); - } - } - FML_DCHECK(entity_node_); - FML_DCHECK(opacity_node_); - FML_DCHECK(view_holder_); - - container_node.AddChild(*opacity_node_); - opacity_node_->SetOpacity(opacity / 255.0f); - entity_node_->SetTranslation(offset.x(), offset.y(), -0.1f); - entity_node_->SetHitTestBehavior(hit_test_behavior_); - if (view_properties_changed_) { - view_holder_->SetViewProperties(view_properties_); - view_properties_changed_ = false; - } -} - -void ViewHolder::SetProperties(double width, - double height, - double insetTop, - double insetRight, - double insetBottom, - double insetLeft, - bool focusable) { - set_size(SkSize::Make(width, height)); - set_occlusion_hint( - SkRect::MakeLTRB(insetLeft, insetTop, insetRight, insetBottom)); - set_focusable(focusable); -} - -void ViewHolder::set_hit_testable(bool value) { - hit_test_behavior_ = value ? fuchsia::ui::gfx::HitTestBehavior::kDefault - : fuchsia::ui::gfx::HitTestBehavior::kSuppress; -} - -void ViewHolder::set_focusable(bool value) { - if (view_properties_.focus_change != value) { - view_properties_.focus_change = value; - view_properties_changed_ = true; - } -} - -void ViewHolder::set_size(const SkSize& size) { - if (size.width() > 0.f && size.height() > 0.f) { - if (view_properties_.bounding_box.max.x != size.width()) { - view_properties_.bounding_box.max.x = size.width(); - view_properties_changed_ = true; - } - if (view_properties_.bounding_box.max.y != size.height()) { - view_properties_.bounding_box.max.y = size.height(); - view_properties_changed_ = true; - } - } - - // TODO(dworsham): The Z-bound should be derived from elevation. We should be - // able to Z-limit the view's box but otherwise it uses all of the available - // airspace. - view_properties_.bounding_box.min.z = kArbitraryLargeDepth; -} - -void ViewHolder::set_occlusion_hint(const SkRect& occlusion_hint) { - if (view_properties_.inset_from_min.x != occlusion_hint.fLeft) { - view_properties_.inset_from_min.x = occlusion_hint.fLeft; - view_properties_changed_ = true; - } - if (view_properties_.inset_from_min.y != occlusion_hint.fTop) { - view_properties_.inset_from_min.y = occlusion_hint.fTop; - view_properties_changed_ = true; - } - if (view_properties_.inset_from_max.x != occlusion_hint.fRight) { - view_properties_.inset_from_max.x = occlusion_hint.fRight; - view_properties_changed_ = true; - } - if (view_properties_.inset_from_max.y != occlusion_hint.fBottom) { - view_properties_.inset_from_max.y = occlusion_hint.fBottom; - view_properties_changed_ = true; - } -} - -} // namespace flutter diff --git a/flow/view_holder.h b/flow/view_holder.h deleted file mode 100644 index 54c4f922a6568..0000000000000 --- a/flow/view_holder.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_FLOW_VIEW_HOLDER_H_ -#define FLUTTER_FLOW_VIEW_HOLDER_H_ - -#include -#include -#include -#include -#include -#include - -#include - -#include "flutter/fml/macros.h" -#include "flutter/fml/memory/ref_counted.h" -#include "flutter/fml/task_runner.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkPoint.h" -#include "third_party/skia/include/core/SkRect.h" -#include "third_party/skia/include/core/SkSize.h" - -namespace flutter { - -// Represents a Scenic |ViewHolder| resource that imports a |View| from another -// session. -// -// This object is created and destroyed on the |Rasterizer|'s thread. -class ViewHolder { - public: - using ViewIdCallback = std::function; - - // `Create`, `Destroy`, and `FromId` must be executed on the raster thread or - // errors will occur. - // - // `on_bind_callback` and `on_unbind_callback` will likewise execute on the - // raster thread; clients are responsible for re-threading the callback if - // needed. - static void Create(zx_koid_t id, - ViewIdCallback on_view_created, - fuchsia::ui::views::ViewHolderToken view_holder_token); - static void Destroy(zx_koid_t id, ViewIdCallback on_view_destroyed); - static ViewHolder* FromId(zx_koid_t id); - - ~ViewHolder() = default; - - // Sets the properties of the child view by issuing a Scenic command. - void SetProperties(double width, - double height, - double insetTop, - double insetRight, - double insetBottom, - double insetLeft, - bool focusable); - - // Creates or updates the contained ViewHolder resource using the specified - // |SceneUpdateContext|. - void UpdateScene(scenic::Session* session, - scenic::ContainerNode& container_node, - const SkPoint& offset, - SkAlpha opacity); - - // Alters various apsects of the ViewHolder's ViewProperties. The updates - // are applied to Scenic on the new |UpdateScene| call. - void set_hit_testable(bool value); - void set_focusable(bool value); - void set_size(const SkSize& size); - void set_occlusion_hint(const SkRect& occlusion_hint); - - private: - ViewHolder(fuchsia::ui::views::ViewHolderToken view_holder_token, - ViewIdCallback on_view_created); - - std::unique_ptr entity_node_; - std::unique_ptr opacity_node_; - std::unique_ptr view_holder_; - - fuchsia::ui::views::ViewHolderToken pending_view_holder_token_; - ViewIdCallback on_view_created_; - - fuchsia::ui::gfx::HitTestBehavior hit_test_behavior_ = - fuchsia::ui::gfx::HitTestBehavior::kDefault; - fuchsia::ui::gfx::ViewProperties view_properties_; - bool view_properties_changed_ = false; - - FML_DISALLOW_COPY_AND_ASSIGN(ViewHolder); -}; - -} // namespace flutter - -#endif // FLUTTER_FLOW_VIEW_HOLDER_H_ diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index a0f6d9ac92500..917cacdd56d81 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -152,19 +152,6 @@ source_set("ui") { # Required for M_PI and others. defines += [ "_USE_MATH_DEFINES" ] } - - if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) { - sources += [ - "compositing/scene_host.cc", - "compositing/scene_host.h", - ] - - public_deps += [ - "$fuchsia_sdk_root/pkg:async-cpp", - "//flutter/shell/platform/fuchsia/dart-pkg/fuchsia", - "//flutter/shell/platform/fuchsia/dart-pkg/zircon", - ] - } } if (enable_unittests) { diff --git a/lib/ui/compositing.dart b/lib/ui/compositing.dart index 0376cf8133581..792d50c1bf0f3 100644 --- a/lib/ui/compositing.dart +++ b/lib/ui/compositing.dart @@ -780,21 +780,6 @@ class SceneBuilder extends NativeFieldWrapperClass2 { void _addPlatformView(double dx, double dy, double width, double height, int viewId) native 'SceneBuilder_addPlatformView'; - /// (Fuchsia-only) Adds a scene rendered by another application to the scene - /// for this application. - void addChildScene({ - Offset offset = Offset.zero, - double width = 0.0, - double height = 0.0, - required SceneHost sceneHost, - bool hitTestable = true, - }) { - _addChildScene(offset.dx, offset.dy, width, height, sceneHost, hitTestable); - } - - void _addChildScene(double dx, double dy, double width, double height, SceneHost sceneHost, - bool hitTestable) native 'SceneBuilder_addChildScene'; - /// Sets a threshold after which additional debugging information should be recorded. /// /// Currently this interface is difficult to use by end-developers. If you're @@ -845,51 +830,3 @@ class SceneBuilder extends NativeFieldWrapperClass2 { void _build(Scene outScene) native 'SceneBuilder_build'; } - -/// (Fuchsia-only) Hosts content provided by another application. -class SceneHost extends NativeFieldWrapperClass2 { - /// Creates a host for a child scene's content. - /// - /// The ViewHolder token is bound to a ViewHolder scene graph node which acts - /// as a container for the child's content. The creator of the SceneHost is - /// responsible for sending the corresponding ViewToken to the child. - /// - /// The ViewHolder token is a dart:zircon Handle, but that type isn't - /// available here. This is called by ChildViewConnection in - /// //topaz/public/dart/fuchsia_scenic_flutter/. - /// - /// The SceneHost takes ownership of the provided ViewHolder token. - SceneHost( - dynamic viewHolderToken, - void Function()? viewConnectedCallback, - void Function()? viewDisconnectedCallback, - void Function(bool)? viewStateChangedCallback, - ) { - _constructor( - viewHolderToken, viewConnectedCallback, viewDisconnectedCallback, viewStateChangedCallback); - } - - void _constructor( - dynamic viewHolderToken, - void Function()? viewConnectedCallback, - void Function()? viewDisconnectedCallback, - void Function(bool)? viewStateChangedCallbac, - ) native 'SceneHost_constructor'; - - /// Releases the resources associated with the SceneHost. - /// - /// After calling this function, the SceneHost cannot be used further. - void dispose() native 'SceneHost_dispose'; - - /// Set properties on the linked scene. These properties include its bounds, - /// as well as whether it can be the target of focus events or not. - void setProperties( - double width, - double height, - double insetTop, - double insetRight, - double insetBottom, - double insetLeft, - bool focusable, - ) native 'SceneHost_setProperties'; -} diff --git a/lib/ui/compositing/scene_builder.cc b/lib/ui/compositing/scene_builder.cc index 2d8708029f894..c3e5377287697 100644 --- a/lib/ui/compositing/scene_builder.cc +++ b/lib/ui/compositing/scene_builder.cc @@ -30,10 +30,6 @@ #include "third_party/tonic/dart_binding_macros.h" #include "third_party/tonic/dart_library_natives.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "flutter/flow/layers/child_scene_layer.h" // nogncheck -#endif - namespace flutter { static void SceneBuilder_constructor(Dart_NativeArguments args) { @@ -67,18 +63,11 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, SceneBuilder); V(SceneBuilder, build) FOR_EACH_BINDING(DART_NATIVE_CALLBACK) -#if defined(LEGACY_FUCHSIA_EMBEDDER) -DART_NATIVE_CALLBACK(SceneBuilder, addChildScene) -#endif void SceneBuilder::RegisterNatives(tonic::DartLibraryNatives* natives) { - natives->Register({ - {"SceneBuilder_constructor", SceneBuilder_constructor, 1, true}, - FOR_EACH_BINDING(DART_REGISTER_NATIVE) -#if defined(LEGACY_FUCHSIA_EMBEDDER) - DART_REGISTER_NATIVE(SceneBuilder, addChildScene) -#endif - }); + natives->Register( + {{"SceneBuilder_constructor", SceneBuilder_constructor, 1, true}, + FOR_EACH_BINDING(DART_REGISTER_NATIVE)}); } SceneBuilder::SceneBuilder() { @@ -306,20 +295,6 @@ void SceneBuilder::addPlatformView(double dx, AddLayer(std::move(layer)); } -#if defined(LEGACY_FUCHSIA_EMBEDDER) -void SceneBuilder::addChildScene(double dx, - double dy, - double width, - double height, - SceneHost* sceneHost, - bool hitTestable) { - auto layer = std::make_unique( - sceneHost->id(), SkPoint::Make(dx, dy), SkSize::Make(width, height), - hitTestable); - AddLayer(std::move(layer)); -} -#endif - void SceneBuilder::addPerformanceOverlay(uint64_t enabledOptions, double left, double right, diff --git a/lib/ui/compositing/scene_builder.h b/lib/ui/compositing/scene_builder.h index b98bbfb22bf8d..fe9d3c76cbe05 100644 --- a/lib/ui/compositing/scene_builder.h +++ b/lib/ui/compositing/scene_builder.h @@ -21,10 +21,6 @@ #include "flutter/lib/ui/painting/shader.h" #include "third_party/tonic/typed_data/typed_list.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "flutter/lib/ui/compositing/scene_host.h" // nogncheck -#endif - namespace flutter { class SceneBuilder : public RefCountedDartWrappable { @@ -117,15 +113,6 @@ class SceneBuilder : public RefCountedDartWrappable { double height, int64_t viewId); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - void addChildScene(double dx, - double dy, - double width, - double height, - SceneHost* sceneHost, - bool hitTestable); -#endif - void setRasterizerTracingThreshold(uint32_t frameInterval); void setCheckerboardRasterCacheImages(bool checkerboard); void setCheckerboardOffscreenLayers(bool checkerboard); diff --git a/lib/ui/compositing/scene_host.cc b/lib/ui/compositing/scene_host.cc deleted file mode 100644 index 81d4e0594e24f..0000000000000 --- a/lib/ui/compositing/scene_host.cc +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/lib/ui/compositing/scene_host.h" - -#include -#include - -#include "flutter/flow/view_holder.h" -#include "flutter/fml/thread_local.h" -#include "flutter/lib/ui/ui_dart_state.h" -#include "third_party/dart/runtime/include/dart_api.h" -#include "third_party/tonic/dart_args.h" -#include "third_party/tonic/dart_binding_macros.h" -#include "third_party/tonic/logging/dart_invoke.h" - -namespace { - -struct SceneHostBindingKey { - std::string isolate_service_id; - scenic::ResourceId resource_id; - - SceneHostBindingKey(const std::string isolate_service_id, - scenic::ResourceId resource_id) { - this->isolate_service_id = isolate_service_id; - this->resource_id = resource_id; - } - - bool operator==(const SceneHostBindingKey& other) const { - return isolate_service_id == other.isolate_service_id && - resource_id == other.resource_id; - } -}; - -struct SceneHostBindingKeyHasher { - std::size_t operator()(const SceneHostBindingKey& key) const { - std::size_t isolate_hash = std::hash()(key.isolate_service_id); - std::size_t resource_id_hash = - std::hash()(key.resource_id); - return isolate_hash ^ resource_id_hash; - } -}; - -using SceneHostBindings = std::unordered_map; - -static SceneHostBindings scene_host_bindings; - -void SceneHost_constructor(Dart_NativeArguments args) { - flutter::UIDartState::ThrowIfUIOperationsProhibited(); - tonic::DartCallConstructor(&flutter::SceneHost::Create, args); -} - -flutter::SceneHost* GetSceneHost(scenic::ResourceId id, - std::string isolate_service_id) { - auto binding = - scene_host_bindings.find(SceneHostBindingKey(isolate_service_id, id)); - if (binding == scene_host_bindings.end()) { - return nullptr; - } else { - return binding->second; - } -} - -flutter::SceneHost* GetSceneHostForCurrentIsolate(scenic::ResourceId id) { - auto isolate = Dart_CurrentIsolate(); - if (!isolate) { - return nullptr; - } else { - std::string isolate_service_id = Dart_IsolateServiceId(isolate); - return GetSceneHost(id, isolate_service_id); - } -} - -void InvokeDartClosure(const tonic::DartPersistentValue& closure) { - auto dart_state = closure.dart_state().lock(); - if (!dart_state) { - return; - } - - tonic::DartState::Scope scope(dart_state); - auto dart_handle = closure.value(); - - FML_DCHECK(dart_handle && !Dart_IsNull(dart_handle) && - Dart_IsClosure(dart_handle)); - tonic::DartInvoke(dart_handle, {}); -} - -template -void InvokeDartFunction(const tonic::DartPersistentValue& function, T& arg) { - auto dart_state = function.dart_state().lock(); - if (!dart_state) { - return; - } - - tonic::DartState::Scope scope(dart_state); - auto dart_handle = function.value(); - - FML_DCHECK(dart_handle && !Dart_IsNull(dart_handle) && - Dart_IsClosure(dart_handle)); - tonic::DartInvoke(dart_handle, {tonic::ToDart(arg)}); -} - -zx_koid_t GetKoid(zx_handle_t handle) { - zx_info_handle_basic_t info; - zx_status_t status = zx_object_get_info(handle, ZX_INFO_HANDLE_BASIC, &info, - sizeof(info), nullptr, nullptr); - return status == ZX_OK ? info.koid : ZX_KOID_INVALID; -} - -} // namespace - -namespace flutter { - -IMPLEMENT_WRAPPERTYPEINFO(ui, SceneHost); - -#define FOR_EACH_BINDING(V) \ - V(SceneHost, dispose) \ - V(SceneHost, setProperties) - -FOR_EACH_BINDING(DART_NATIVE_CALLBACK) - -void SceneHost::RegisterNatives(tonic::DartLibraryNatives* natives) { - natives->Register({{"SceneHost_constructor", SceneHost_constructor, 5, true}, - FOR_EACH_BINDING(DART_REGISTER_NATIVE)}); -} - -fml::RefPtr SceneHost::Create( - fml::RefPtr viewHolderToken, - Dart_Handle viewConnectedCallback, - Dart_Handle viewDisconnectedCallback, - Dart_Handle viewStateChangedCallback) { - return fml::MakeRefCounted(viewHolderToken, viewConnectedCallback, - viewDisconnectedCallback, - viewStateChangedCallback); -} - -void SceneHost::OnViewConnected(scenic::ResourceId id) { - auto* scene_host = GetSceneHostForCurrentIsolate(id); - - if (scene_host && !scene_host->view_connected_callback_.is_empty()) { - InvokeDartClosure(scene_host->view_connected_callback_); - } -} - -void SceneHost::OnViewDisconnected(scenic::ResourceId id) { - auto* scene_host = GetSceneHostForCurrentIsolate(id); - - if (scene_host && !scene_host->view_disconnected_callback_.is_empty()) { - InvokeDartClosure(scene_host->view_disconnected_callback_); - } -} - -void SceneHost::OnViewStateChanged(scenic::ResourceId id, bool state) { - auto* scene_host = GetSceneHostForCurrentIsolate(id); - - if (scene_host && !scene_host->view_state_changed_callback_.is_empty()) { - InvokeDartFunction(scene_host->view_state_changed_callback_, state); - } -} - -SceneHost::SceneHost(fml::RefPtr viewHolderToken, - Dart_Handle viewConnectedCallback, - Dart_Handle viewDisconnectedCallback, - Dart_Handle viewStateChangedCallback) - : raster_task_runner_( - UIDartState::Current()->GetTaskRunners().GetRasterTaskRunner()), - koid_(GetKoid(viewHolderToken->handle())), - weak_factory_(this) { - auto dart_state = UIDartState::Current(); - isolate_service_id_ = Dart_IsolateServiceId(Dart_CurrentIsolate()); - - // Initialize callbacks it they are non-null in Dart. - if (!Dart_IsNull(viewConnectedCallback)) { - view_connected_callback_.Set(dart_state, viewConnectedCallback); - } - if (!Dart_IsNull(viewDisconnectedCallback)) { - view_disconnected_callback_.Set(dart_state, viewDisconnectedCallback); - } - if (!Dart_IsNull(viewStateChangedCallback)) { - view_state_changed_callback_.Set(dart_state, viewStateChangedCallback); - } - - // This callback is invoked on the raster thread when the |scenic::ViewHolder| - // resource is created and given an id. - auto bind_callback = [weak = weak_factory_.GetWeakPtr(), - ui_task_runner = - dart_state->GetTaskRunners().GetUITaskRunner()]( - scenic::ResourceId id) { - ui_task_runner->PostTask([weak, id]() { - if (!weak) { - FML_LOG(WARNING) << "ViewHolder bound to SceneHost after SceneHost was " - "destroyed; ignoring."; - return; - } - - FML_DCHECK(weak->resource_id_ == 0); - weak->resource_id_ = id; - - const auto key = - SceneHostBindingKey(weak->isolate_service_id_, weak->resource_id_); - scene_host_bindings.emplace(std::make_pair(key, weak.get())); - }); - }; - - // Pass the raw handle to the raster thread; destroying a - // |zircon::dart::Handle| on that thread can cause a race condition. - raster_task_runner_->PostTask([koid = koid_, - raw_handle = viewHolderToken->ReleaseHandle(), - bind_callback = std::move(bind_callback)]() { - flutter::ViewHolder::Create( - koid, std::move(bind_callback), - scenic::ToViewHolderToken(zx::eventpair(raw_handle))); - }); -} - -SceneHost::~SceneHost() { - if (resource_id_ != 0) { - scene_host_bindings.erase( - SceneHostBindingKey(isolate_service_id_, resource_id_)); - } - - raster_task_runner_->PostTask( - [koid = koid_]() { flutter::ViewHolder::Destroy(koid, nullptr); }); -} - -void SceneHost::dispose() { - ClearDartWrapper(); -} - -void SceneHost::setProperties(double width, - double height, - double insetTop, - double insetRight, - double insetBottom, - double insetLeft, - bool focusable) { - raster_task_runner_->PostTask([id = koid_, width, height, insetTop, - insetRight, insetBottom, insetLeft, - focusable]() { - auto* view_holder = flutter::ViewHolder::FromId(id); - FML_DCHECK(view_holder); - - view_holder->SetProperties(width, height, insetTop, insetRight, insetBottom, - insetLeft, focusable); - }); -} - -} // namespace flutter diff --git a/lib/ui/compositing/scene_host.h b/lib/ui/compositing/scene_host.h deleted file mode 100644 index 5e76a0a18ce3b..0000000000000 --- a/lib/ui/compositing/scene_host.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_ -#define FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_ - -#include -#include - -#include - -#include "dart-pkg/zircon/sdk_ext/handle.h" -#include "flutter/fml/memory/ref_counted.h" -#include "flutter/fml/memory/weak_ptr.h" -#include "flutter/fml/task_runner.h" -#include "flutter/lib/ui/dart_wrapper.h" -#include "third_party/tonic/dart_library_natives.h" -#include "third_party/tonic/dart_persistent_value.h" - -namespace flutter { - -class SceneHost : public RefCountedDartWrappable { - DEFINE_WRAPPERTYPEINFO(); - FML_FRIEND_MAKE_REF_COUNTED(SceneHost); - - public: - static void RegisterNatives(tonic::DartLibraryNatives* natives); - static fml::RefPtr Create( - fml::RefPtr viewHolderToken, - Dart_Handle viewConnectedCallback, - Dart_Handle viewDisconnectedCallback, - Dart_Handle viewStateChangedCallback); - static void OnViewConnected(scenic::ResourceId id); - static void OnViewDisconnected(scenic::ResourceId id); - static void OnViewStateChanged(scenic::ResourceId id, bool state); - - ~SceneHost() override; - - zx_koid_t id() const { return koid_; } - - // These are visible to Dart. - void dispose(); - void setProperties(double width, - double height, - double insetTop, - double insetRight, - double insetBottom, - double insetLeft, - bool focusable); - - private: - SceneHost(fml::RefPtr viewHolderToken, - Dart_Handle viewConnectedCallback, - Dart_Handle viewDisconnectedCallback, - Dart_Handle viewStateChangedCallback); - - fml::RefPtr raster_task_runner_; - tonic::DartPersistentValue view_connected_callback_; - tonic::DartPersistentValue view_disconnected_callback_; - tonic::DartPersistentValue view_state_changed_callback_; - std::string isolate_service_id_; - scenic::ResourceId resource_id_ = 0; - zx_koid_t koid_ = ZX_KOID_INVALID; - - fml::WeakPtrFactory weak_factory_; - - FML_DISALLOW_COPY_AND_ASSIGN(SceneHost); -}; - -} // namespace flutter - -#endif // FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_ diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc index 7fca5720b6377..d2958c838420c 100644 --- a/lib/ui/dart_ui.cc +++ b/lib/ui/dart_ui.cc @@ -34,10 +34,6 @@ #include "third_party/tonic/converter/dart_converter.h" #include "third_party/tonic/logging/dart_error.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "flutter/lib/ui/compositing/scene_host.h" // nogncheck -#endif - using tonic::ToDart; namespace flutter { @@ -86,9 +82,6 @@ void DartUI::InitForGlobal() { SemanticsUpdateBuilder::RegisterNatives(g_natives); Vertices::RegisterNatives(g_natives); PlatformConfiguration::RegisterNatives(g_natives); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - SceneHost::RegisterNatives(g_natives); -#endif } } diff --git a/lib/web_ui/lib/src/engine/canvaskit/layer_scene_builder.dart b/lib/web_ui/lib/src/engine/canvaskit/layer_scene_builder.dart index 6fb752d3115da..c5f4e70ac6e80 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/layer_scene_builder.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/layer_scene_builder.dart @@ -35,17 +35,6 @@ class LayerSceneBuilder implements ui.SceneBuilder { final RootLayer rootLayer; late ContainerLayer currentLayer; - @override - void addChildScene({ - ui.Offset offset = ui.Offset.zero, - double width = 0.0, - double height = 0.0, - ui.SceneHost? sceneHost, - bool hitTestable = true, - }) { - throw UnimplementedError(); - } - @override void addPerformanceOverlay(int enabledOptions, ui.Rect bounds) { // We don't plan to implement this on the web. diff --git a/lib/web_ui/lib/src/engine/html/scene_builder.dart b/lib/web_ui/lib/src/engine/html/scene_builder.dart index 067e294c84596..533eab4cc8085 100644 --- a/lib/web_ui/lib/src/engine/html/scene_builder.dart +++ b/lib/web_ui/lib/src/engine/html/scene_builder.dart @@ -436,30 +436,6 @@ class SurfaceSceneBuilder implements ui.SceneBuilder { _addSurface(PersistedPlatformView(viewId, dx, dy, width, height)); } - /// (Fuchsia-only) Adds a scene rendered by another application to the scene - /// for this application. - @override - void addChildScene({ - ui.Offset offset = ui.Offset.zero, - double width = 0.0, - double height = 0.0, - ui.SceneHost? sceneHost, - bool hitTestable = true, - }) { - _addChildScene(offset.dx, offset.dy, width, height, sceneHost, hitTestable); - } - - void _addChildScene( - double dx, - double dy, - double width, - double height, - ui.SceneHost? sceneHost, - bool hitTestable, - ) { - throw UnimplementedError(); - } - /// Sets a threshold after which additional debugging information should be /// recorded. /// diff --git a/lib/web_ui/lib/src/ui/compositing.dart b/lib/web_ui/lib/src/ui/compositing.dart index 576ed8313cfce..de1e6cdbee255 100644 --- a/lib/web_ui/lib/src/ui/compositing.dart +++ b/lib/web_ui/lib/src/ui/compositing.dart @@ -119,13 +119,6 @@ abstract class SceneBuilder { double width = 0.0, double height = 0.0, }); - void addChildScene({ - Offset offset = Offset.zero, - double width = 0.0, - double height = 0.0, - required SceneHost sceneHost, - bool hitTestable = true, - }); void setRasterizerTracingThreshold(int frameInterval); void setCheckerboardRasterCacheImages(bool checkerboard); void setCheckerboardOffscreenLayers(bool checkerboard); @@ -144,24 +137,3 @@ abstract class SceneBuilder { class EngineLayer { void dispose() {} } - -class SceneHost { - SceneHost( - dynamic viewHolderToken, - void Function() viewConnectedCallback, - void Function() viewDisconnectedCallback, - void Function(bool) viewStateChangedCallback, - ); - void dispose() {} - void setProperties( - double width, - double height, - double insetTop, - double insetRight, - double insetBottom, - double insetLeft, - bool focusable, - ) { - throw UnimplementedError(); - } -} diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index ca48a4801319a..794095d308f2e 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -22,18 +22,6 @@ #include "third_party/skia/include/core/SkSurfaceCharacterization.h" #include "third_party/skia/include/utils/SkBase64.h" -// When screenshotting we want to ensure we call the base method for -// CompositorContext::AcquireFrame instead of the platform-specific method. -// Specifically, Fuchsia's CompositorContext handles the rendering surface -// itself which means that we will still continue to render to the onscreen -// surface if we don't call the base method. -// TODO(arbreng: fxb/55805) -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#define ACQUIRE_FRAME flutter::CompositorContext::AcquireFrame -#else -#define ACQUIRE_FRAME AcquireFrame -#endif - namespace flutter { // The rasterizer will tell Skia to purge cached resources that have not been @@ -49,19 +37,6 @@ Rasterizer::Rasterizer(Delegate& delegate) FML_DCHECK(compositor_context_); } -#if defined(LEGACY_FUCHSIA_EMBEDDER) -// TODO(arbreng: fxb/55805) -Rasterizer::Rasterizer( - Delegate& delegate, - std::unique_ptr compositor_context) - : delegate_(delegate), - compositor_context_(std::move(compositor_context)), - user_override_resource_cache_bytes_(false), - weak_factory_(this) { - FML_DCHECK(compositor_context_); -} -#endif - Rasterizer::~Rasterizer() = default; fml::TaskRunnerAffineWeakPtr Rasterizer::GetWeakPtr() const { @@ -564,7 +539,7 @@ static sk_sp ScreenshotLayerTreeAsPicture( // TODO(amirh): figure out how to take a screenshot with embedded UIView. // https://github.com/flutter/flutter/issues/23435 - auto frame = compositor_context.ACQUIRE_FRAME( + auto frame = compositor_context.AcquireFrame( nullptr, recorder.getRecordingCanvas(), nullptr, root_surface_transformation, false, true, nullptr); frame->Raster(*tree, true); @@ -631,9 +606,9 @@ sk_sp Rasterizer::ScreenshotLayerTreeAsImage( return nullptr; } - auto frame = compositor_context.ACQUIRE_FRAME( - surface_context, canvas, nullptr, root_surface_transformation, false, - true, nullptr); + auto frame = compositor_context.AcquireFrame(surface_context, canvas, nullptr, + root_surface_transformation, + false, true, nullptr); canvas->clear(SK_ColorTRANSPARENT); frame->Raster(*tree, true); canvas->flush(); diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index c922a7f8befd6..b34e10b0b0d74 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -102,21 +102,6 @@ class Rasterizer final : public SnapshotDelegate { /// Rasterizer(Delegate& delegate); -#if defined(LEGACY_FUCHSIA_EMBEDDER) - //---------------------------------------------------------------------------- - /// @brief Creates a new instance of a rasterizer. Rasterizers may only - /// be created on the raster task runner. Rasterizers are - /// currently only created by the shell (which also sets itself up - /// as the rasterizer delegate). - /// - /// @param[in] delegate The rasterizer delegate. - /// @param[in] compositor_context The compositor context used to hold all - /// the GPU state used by the rasterizer. - /// - Rasterizer(Delegate& delegate, - std::unique_ptr compositor_context); -#endif - //---------------------------------------------------------------------------- /// @brief Destroys the rasterizer. This must happen on the raster task /// runner. All GPU resources are collected before this call diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index 0812d59a71ebd..706e7141b39e3 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -94,12 +94,6 @@ template("runner_sources") { "vulkan_surface_producer.cc", "vulkan_surface_producer.h", ] - if (flutter_enable_legacy_fuchsia_embedder) { - sources += [ - "compositor_context.cc", - "compositor_context.h", - ] - } public_configs = runner_configs diff --git a/shell/platform/fuchsia/flutter/compositor_context.cc b/shell/platform/fuchsia/flutter/compositor_context.cc deleted file mode 100644 index 6f6bc8d5572bc..0000000000000 --- a/shell/platform/fuchsia/flutter/compositor_context.cc +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "compositor_context.h" - -#include -#include - -#include "flutter/flow/layers/layer_tree.h" -#include "third_party/skia/include/gpu/GrDirectContext.h" - -namespace flutter_runner { - -class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { - public: - ScopedFrame(CompositorContext& context, - GrDirectContext* gr_context, - SkCanvas* canvas, - flutter::ExternalViewEmbedder* view_embedder, - const SkMatrix& root_surface_transformation, - bool instrumentation_enabled, - bool surface_supports_readback, - fml::RefPtr raster_thread_merger, - DefaultSessionConnection& session_connection, - VulkanSurfaceProducer& surface_producer, - std::shared_ptr scene_update_context) - : flutter::CompositorContext::ScopedFrame(context, - surface_producer.gr_context(), - canvas, - view_embedder, - root_surface_transformation, - instrumentation_enabled, - surface_supports_readback, - raster_thread_merger), - session_connection_(session_connection), - surface_producer_(surface_producer), - scene_update_context_(scene_update_context) {} - - private: - DefaultSessionConnection& session_connection_; - VulkanSurfaceProducer& surface_producer_; - std::shared_ptr scene_update_context_; - - flutter::RasterStatus Raster(flutter::LayerTree& layer_tree, - bool ignore_raster_cache) override { - std::vector frame_paint_tasks; - std::vector> frame_surfaces; - - { - // Preroll the Flutter layer tree. This allows Flutter to perform - // pre-paint optimizations. - TRACE_EVENT0("flutter", "Preroll"); - layer_tree.Preroll(*this, ignore_raster_cache); - } - - { - // Traverse the Flutter layer tree so that the necessary session ops to - // represent the frame are enqueued in the underlying session. - TRACE_EVENT0("flutter", "UpdateScene"); - layer_tree.UpdateScene(scene_update_context_); - } - - { - // 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(); - - const SkISize& frame_size = layer_tree.frame_size(); - for (auto& task : frame_paint_tasks) { - // Clamp the logical size to the logical frame size in order to avoid - // huge surfaces. - const SkISize logical_size = SkISize::Make( - std::clamp(task.scale_x * task.paint_bounds.width(), 0.f, - static_cast(frame_size.width())), - std::clamp(task.scale_y * task.paint_bounds.height(), 0.f, - static_cast(frame_size.height()))); - - SkISize physical_size = SkISize::Make( - layer_tree.device_pixel_ratio() * logical_size.width(), - layer_tree.device_pixel_ratio() * logical_size.height()); - if (physical_size.width() == 0 || physical_size.height() == 0) { - frame_surfaces.emplace_back(nullptr); - continue; - } - - std::unique_ptr surface = - surface_producer_.ProduceSurface(physical_size); - if (!surface) { - FML_LOG(ERROR) - << "Could not acquire a surface from the surface producer " - "of size: " - << physical_size.width() << "x" << physical_size.height(); - } else { - task.material.SetTexture(surface->GetImageId()); - } - - frame_surfaces.emplace_back(std::move(surface)); - } - - session_connection_.Present(); - } - - { - // Execute paint tasks in parallel with Scenic's side of the Present, then - // signal fences. - TRACE_EVENT0("flutter", "ExecutePaintTasks"); - size_t surface_index = 0; - for (auto& task : frame_paint_tasks) { - std::unique_ptr& task_surface = - frame_surfaces[surface_index++]; - if (!task_surface) { - continue; - } - - SkCanvas* canvas = task_surface->GetSkiaSurface()->getCanvas(); - flutter::Layer::PaintContext paint_context = { - canvas, - canvas, - gr_context(), - nullptr, - context().raster_time(), - context().ui_time(), - context().texture_registry(), - &context().raster_cache(), - false, - layer_tree.device_pixel_ratio()}; - canvas->restoreToCount(1); - canvas->save(); - canvas->clear(task.background_color); - canvas->scale(layer_tree.device_pixel_ratio() * task.scale_x, - layer_tree.device_pixel_ratio() * task.scale_y); - canvas->translate(-task.paint_bounds.left(), -task.paint_bounds.top()); - for (flutter::Layer* layer : task.layers) { - layer->Paint(paint_context); - } - } - - // Tell the surface producer that a present has occurred so it can perform - // book-keeping on buffer caches. - surface_producer_.OnSurfacesPresented(std::move(frame_surfaces)); - } - - return flutter::RasterStatus::kSuccess; - } - - FML_DISALLOW_COPY_AND_ASSIGN(ScopedFrame); -}; - -CompositorContext::CompositorContext( - DefaultSessionConnection& session_connection, - VulkanSurfaceProducer& surface_producer, - std::shared_ptr scene_update_context) - : session_connection_(session_connection), - surface_producer_(surface_producer), - scene_update_context_(scene_update_context) {} - -CompositorContext::~CompositorContext() = default; - -std::unique_ptr -CompositorContext::AcquireFrame( - GrDirectContext* gr_context, - SkCanvas* canvas, - flutter::ExternalViewEmbedder* view_embedder, - const SkMatrix& root_surface_transformation, - bool instrumentation_enabled, - bool surface_supports_readback, - fml::RefPtr raster_thread_merger) { - return std::make_unique( - *this, gr_context, canvas, view_embedder, root_surface_transformation, - instrumentation_enabled, surface_supports_readback, raster_thread_merger, - session_connection_, surface_producer_, scene_update_context_); -} - -} // namespace flutter_runner diff --git a/shell/platform/fuchsia/flutter/compositor_context.h b/shell/platform/fuchsia/flutter/compositor_context.h deleted file mode 100644 index 2fef78523396c..0000000000000 --- a/shell/platform/fuchsia/flutter/compositor_context.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_ -#define FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_ - -#include - -#include "flutter/flow/compositor_context.h" -#include "flutter/flow/embedded_views.h" -#include "flutter/flow/scene_update_context.h" -#include "flutter/fml/macros.h" - -#include "default_session_connection.h" -#include "vulkan_surface_producer.h" - -namespace flutter_runner { - -// Holds composition specific state and bindings specific to composition on -// Fuchsia. -class CompositorContext final : public flutter::CompositorContext { - public: - CompositorContext( - DefaultSessionConnection& session_connection, - VulkanSurfaceProducer& surface_producer, - std::shared_ptr scene_update_context); - - ~CompositorContext() override; - - private: - DefaultSessionConnection& session_connection_; - VulkanSurfaceProducer& surface_producer_; - std::shared_ptr scene_update_context_; - - // |flutter::CompositorContext| - std::unique_ptr AcquireFrame( - GrDirectContext* gr_context, - SkCanvas* canvas, - flutter::ExternalViewEmbedder* view_embedder, - const SkMatrix& root_surface_transformation, - bool instrumentation_enabled, - bool surface_supports_readback, - fml::RefPtr raster_thread_merger) override; - - FML_DISALLOW_COPY_AND_ASSIGN(CompositorContext); -}; - -} // namespace flutter_runner - -#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_ diff --git a/shell/platform/fuchsia/flutter/default_session_connection.h b/shell/platform/fuchsia/flutter/default_session_connection.h index c6bef21902955..a00f87bb3cdd4 100644 --- a/shell/platform/fuchsia/flutter/default_session_connection.h +++ b/shell/platform/fuchsia/flutter/default_session_connection.h @@ -10,7 +10,6 @@ #include #include -#include "flutter/flow/scene_update_context.h" #include "flutter/fml/closure.h" #include "flutter/fml/macros.h" @@ -40,7 +39,7 @@ static constexpr fml::TimeDelta kDefaultPresentationInterval = // The component residing on the raster thread that is responsible for // maintaining the Scenic session connection and presenting node updates. -class DefaultSessionConnection final : public flutter::SessionWrapper { +class DefaultSessionConnection final { public: static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, @@ -82,11 +81,11 @@ class DefaultSessionConnection final : public flutter::SessionWrapper { ~DefaultSessionConnection(); - // |SessionWrapper| - scenic::Session* get() override { return &session_wrapper_; } + scenic::Session* get() { return &session_wrapper_; } - // |SessionWrapper| - void Present() override; + // Call to request that the all enqueued Session ops since the last |Present| + // be sent to Scenic. + void Present(); // Used to implement VsyncWaiter functionality. void AwaitVsync(FireCallbackCallback callback); diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index f16142321133b..2a51a25da9055 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc @@ -28,10 +28,6 @@ #include "task_runner_adapter.h" #include "vsync_waiter.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "compositor_context.h" // nogncheck -#endif - namespace flutter_runner { namespace { @@ -73,12 +69,8 @@ Engine::Engine(Delegate& delegate, FlutterRunnerProductConfiguration product_config) : delegate_(delegate), thread_label_(std::move(thread_label)), -#if defined(LEGACY_FUCHSIA_EMBEDDER) - use_legacy_renderer_(product_config.use_legacy_renderer()), -#endif intercept_all_input_(product_config.get_intercept_all_input()), weak_factory_(this) { - // Get the task runners from the managed threads. The current thread will be // used as the "platform" thread. const flutter::TaskRunners task_runners( @@ -150,22 +142,10 @@ Engine::Engine(Delegate& delegate, std::move(session_error_callback), [](auto) {}, max_frames_in_flight, vsync_offset); 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_.get()), - intercept_all_input_); - } else -#endif - { - external_view_embedder_ = - std::make_shared( - thread_label_, std::move(view_token), - std::move(view_ref_pair), *session_connection_.get(), - surface_producer_.value(), intercept_all_input_); - } + external_view_embedder_ = std::make_shared( + thread_label_, std::move(view_token), std::move(view_ref_pair), + *session_connection_.get(), surface_producer_.value(), + intercept_all_input_); view_embedder_latch.Signal(); })); view_embedder_latch.Wait(); @@ -362,29 +342,10 @@ Engine::Engine(Delegate& delegate, }); // Setup the callback that will instantiate the rasterizer. - flutter::Shell::CreateCallback on_create_rasterizer; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - on_create_rasterizer = [this](flutter::Shell& shell) { - if (use_legacy_renderer_) { - FML_DCHECK(session_connection_); - FML_DCHECK(surface_producer_); - FML_DCHECK(legacy_external_view_embedder_); - - auto compositor_context = - std::make_unique( - *(session_connection_.get()), surface_producer_.value(), - legacy_external_view_embedder_); - return std::make_unique( - shell, std::move(compositor_context)); - } else { - return std::make_unique(shell); - } - }; -#else - on_create_rasterizer = [this](flutter::Shell& shell) { - return std::make_unique(shell); - }; -#endif + flutter::Shell::CreateCallback on_create_rasterizer = + [](flutter::Shell& shell) { + return std::make_unique(shell); + }; settings.root_isolate_create_callback = std::bind(&Engine::OnMainIsolateStart, this); @@ -567,16 +528,8 @@ void Engine::DebugWireframeSettingsChanged(bool enabled) { FML_CHECK(shell_); shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask([this, enabled]() { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - if (use_legacy_renderer_) { - FML_CHECK(legacy_external_view_embedder_); - legacy_external_view_embedder_->EnableWireframe(enabled); - } else -#endif - { - FML_CHECK(external_view_embedder_); - external_view_embedder_->EnableWireframe(enabled); - } + FML_CHECK(external_view_embedder_); + external_view_embedder_->EnableWireframe(enabled); }); } @@ -591,21 +544,11 @@ void Engine::CreateView(int64_t view_id, [this, view_id, hit_testable, focusable, on_view_created = std::move(on_view_created), on_view_bound = std::move(on_view_bound)]() { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - if (use_legacy_renderer_) { - FML_CHECK(legacy_external_view_embedder_); - legacy_external_view_embedder_->CreateView( - view_id, std::move(on_view_created), std::move(on_view_bound), - hit_testable, focusable); - } else -#endif - { - FML_CHECK(external_view_embedder_); - external_view_embedder_->CreateView( - view_id, std::move(on_view_created), std::move(on_view_bound)); - external_view_embedder_->SetViewProperties( - view_id, SkRect::MakeEmpty(), hit_testable, focusable); - } + FML_CHECK(external_view_embedder_); + external_view_embedder_->CreateView(view_id, std::move(on_view_created), + std::move(on_view_bound)); + external_view_embedder_->SetViewProperties(view_id, SkRect::MakeEmpty(), + hit_testable, focusable); }); } @@ -617,18 +560,9 @@ void Engine::UpdateView(int64_t view_id, shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask( [this, view_id, occlusion_hint, hit_testable, focusable]() { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - if (use_legacy_renderer_) { - FML_CHECK(legacy_external_view_embedder_); - legacy_external_view_embedder_->UpdateView(view_id, occlusion_hint, - hit_testable, focusable); - } else -#endif - { - FML_CHECK(external_view_embedder_); - external_view_embedder_->SetViewProperties(view_id, occlusion_hint, - hit_testable, focusable); - } + FML_CHECK(external_view_embedder_); + external_view_embedder_->SetViewProperties(view_id, occlusion_hint, + hit_testable, focusable); }); } @@ -637,18 +571,9 @@ void Engine::DestroyView(int64_t view_id, ViewIdCallback on_view_unbound) { shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask( [this, view_id, on_view_unbound = std::move(on_view_unbound)]() { -#if defined(LEGACY_FUCHSIA_EMBEDDER) - if (use_legacy_renderer_) { - FML_CHECK(legacy_external_view_embedder_); - legacy_external_view_embedder_->DestroyView( - view_id, std::move(on_view_unbound)); - } else -#endif - { - FML_CHECK(external_view_embedder_); - external_view_embedder_->DestroyView(view_id, - std::move(on_view_unbound)); - } + FML_CHECK(external_view_embedder_); + external_view_embedder_->DestroyView(view_id, + std::move(on_view_unbound)); }); } @@ -659,22 +584,9 @@ std::unique_ptr Engine::CreateSurface() { std::shared_ptr Engine::GetExternalViewEmbedder() { - std::shared_ptr 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_; - } else -#endif - { - FML_CHECK(external_view_embedder_); - external_view_embedder = external_view_embedder_; - } - FML_CHECK(external_view_embedder); + FML_CHECK(external_view_embedder_); - return external_view_embedder; + return external_view_embedder_; } #if !defined(DART_PRODUCT) diff --git a/shell/platform/fuchsia/flutter/engine.h b/shell/platform/fuchsia/flutter/engine.h index 3e2b991940db0..2c86a9e390f9a 100644 --- a/shell/platform/fuchsia/flutter/engine.h +++ b/shell/platform/fuchsia/flutter/engine.h @@ -30,10 +30,6 @@ #include "thread.h" #include "vulkan_surface_producer.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "flutter/flow/scene_update_context.h" // nogncheck -#endif - namespace flutter_runner { namespace testing { @@ -78,9 +74,6 @@ class Engine final { std::shared_ptr session_connection_; std::optional surface_producer_; std::shared_ptr external_view_embedder_; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - std::shared_ptr legacy_external_view_embedder_; -#endif std::unique_ptr isolate_configurator_; std::unique_ptr shell_; @@ -90,9 +83,6 @@ class Engine final { zx::event vsync_event_; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - bool use_legacy_renderer_ = true; -#endif bool intercept_all_input_ = false; fml::WeakPtrFactory weak_factory_; diff --git a/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.cc b/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.cc index dfc50c1c5c9c9..e4af767231702 100644 --- a/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.cc +++ b/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.cc @@ -48,13 +48,6 @@ FlutterRunnerProductConfiguration::FlutterRunnerProductConfiguration( if (val.IsBool()) enable_shader_warmup_dart_hooks_ = val.GetBool(); } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - if (document.HasMember("use_legacy_renderer")) { - auto& val = document["use_legacy_renderer"]; - if (val.IsBool()) - use_legacy_renderer_ = val.GetBool(); - } -#endif } } // namespace flutter_runner diff --git a/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.h b/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.h index e5cee47fb7c9c..eb0178d8a7faf 100644 --- a/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.h +++ b/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.h @@ -21,19 +21,13 @@ class FlutterRunnerProductConfiguration { bool enable_shader_warmup_dart_hooks() { return enable_shader_warmup_dart_hooks_; } -#if defined(LEGACY_FUCHSIA_EMBEDDER) - bool use_legacy_renderer() { return use_legacy_renderer_; } -#endif private: fml::TimeDelta vsync_offset_ = fml::TimeDelta::Zero(); uint64_t max_frames_in_flight_ = 3; bool intercept_all_input_ = false; - bool enable_shader_warmup_ = true; + bool enable_shader_warmup_ = false; bool enable_shader_warmup_dart_hooks_ = true; -#if defined(LEGACY_FUCHSIA_EMBEDDER) - bool use_legacy_renderer_ = true; -#endif }; } // namespace flutter_runner diff --git a/shell/platform/fuchsia/flutter/platform_view.cc b/shell/platform/fuchsia/flutter/platform_view.cc index b2260088ae043..fa59b0609eb22 100644 --- a/shell/platform/fuchsia/flutter/platform_view.cc +++ b/shell/platform/fuchsia/flutter/platform_view.cc @@ -26,10 +26,6 @@ #include "runtime/dart/utils/inlines.h" #include "vsync_waiter.h" -#if defined(LEGACY_FUCHSIA_EMBEDDER) -#include "flutter/lib/ui/compositing/scene_host.h" -#endif - namespace flutter_runner { static constexpr char kFlutterPlatformChannel[] = "flutter/platform"; @@ -301,41 +297,18 @@ void PlatformView::OnScenicEvent( break; } case fuchsia::ui::gfx::Event::Tag::kViewConnected: -#if defined(LEGACY_FUCHSIA_EMBEDDER) - task_runners_.GetUITaskRunner()->PostTask( - [view_holder_id = - event.gfx().view_connected().view_holder_id]() { - flutter::SceneHost::OnViewConnected(view_holder_id); - }); -#endif // LEGACY_FUCHSIA_EMBEDDER if (!OnChildViewConnected( event.gfx().view_connected().view_holder_id)) { deferred_view_events.push_back(std::move(event.gfx())); } break; case fuchsia::ui::gfx::Event::Tag::kViewDisconnected: -#if defined(LEGACY_FUCHSIA_EMBEDDER) - task_runners_.GetUITaskRunner()->PostTask( - [view_holder_id = - event.gfx().view_disconnected().view_holder_id]() { - flutter::SceneHost::OnViewDisconnected(view_holder_id); - }); -#endif // LEGACY_FUCHSIA_EMBEDDER if (!OnChildViewDisconnected( event.gfx().view_disconnected().view_holder_id)) { deferred_view_events.push_back(std::move(event.gfx())); } break; case fuchsia::ui::gfx::Event::Tag::kViewStateChanged: -#if defined(LEGACY_FUCHSIA_EMBEDDER) - task_runners_.GetUITaskRunner()->PostTask( - [view_holder_id = - event.gfx().view_state_changed().view_holder_id, - state = - event.gfx().view_state_changed().state.is_rendering]() { - flutter::SceneHost::OnViewStateChanged(view_holder_id, state); - }); -#endif // LEGACY_FUCHSIA_EMBEDDER if (!OnChildViewStateChanged( event.gfx().view_state_changed().view_holder_id, event.gfx().view_state_changed().state.is_rendering)) { diff --git a/tools/gn b/tools/gn index 695e93dfe7db8..31a5a89586e8b 100755 --- a/tools/gn +++ b/tools/gn @@ -162,7 +162,6 @@ def to_gn_args(args): gn_args['use_ios_simulator'] = args.simulator elif args.target_os == 'fuchsia': gn_args['target_os'] = 'fuchsia' - gn_args['flutter_enable_legacy_fuchsia_embedder'] = args.fuchsia_legacy elif args.target_os == 'winuwp': gn_args['target_os'] = 'winuwp' elif args.target_os is not None: @@ -373,8 +372,6 @@ def parse_args(args): parser.add_argument('--simulator', action='store_true', default=False) parser.add_argument('--linux', dest='target_os', action='store_const', const='linux') parser.add_argument('--fuchsia', dest='target_os', action='store_const', const='fuchsia') - parser.add_argument('--fuchsia-legacy', default=True, action='store_true') - parser.add_argument('--no-fuchsia-legacy', dest='fuchsia_legacy', action='store_false') parser.add_argument('--winuwp', dest='target_os', action='store_const', const='winuwp') parser.add_argument('--linux-cpu', type=str, choices=['x64', 'x86', 'arm64', 'arm'])