Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1e8c3c1

Browse files
committed
fuchsia: Remove dead code / break dependencies
The fuchsia code around metrics and sizing was just sending this information through a side-channel, when the engine already had the information available. So, delete all of it to make future CLs simpler. Additionally, the SceneUpdateContext has many unneccesary dependencies re: metrics and PaintTasks. Break those to make future CLs simpler. Tested: Ran all unittests and ran workstation on Fuchsia BUG: 53062, 53063
1 parent 9353692 commit 1e8c3c1

File tree

91 files changed

+892
-1721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+892
-1721
lines changed

flow/compositor_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ RasterStatus CompositorContext::ScopedFrame::Raster(
8787
if (canvas()) {
8888
if (needs_save_layer) {
8989
FML_LOG(INFO) << "Using SaveLayer to protect non-readback surface";
90-
SkRect bounds = SkRect::Make(layer_tree.frame_size());
90+
SkRect bounds = SkRect::MakeSize(layer_tree.frame_size());
9191
SkPaint paint;
9292
paint.setBlendMode(SkBlendMode::kSrc);
9393
canvas()->saveLayer(&bounds, &paint);

flow/layers/backdrop_filter_layer.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace flutter {
99
BackdropFilterLayer::BackdropFilterLayer(sk_sp<SkImageFilter> filter)
1010
: filter_(std::move(filter)) {}
1111

12+
BackdropFilterLayer::~BackdropFilterLayer() = default;
13+
1214
void BackdropFilterLayer::Preroll(PrerollContext* context,
1315
const SkMatrix& matrix) {
1416
Layer::AutoPrerollSaveLayerState save =
@@ -23,7 +25,7 @@ void BackdropFilterLayer::Paint(PaintContext& context) const {
2325
Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
2426
context,
2527
SkCanvas::SaveLayerRec{&paint_bounds(), nullptr, filter_.get(), 0});
26-
PaintChildren(context);
28+
ContainerLayer::Paint(context);
2729
}
2830

2931
} // namespace flutter

flow/layers/backdrop_filter_layer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
#define FLUTTER_FLOW_LAYERS_BACKDROP_FILTER_LAYER_H_
77

88
#include "flutter/flow/layers/container_layer.h"
9-
109
#include "third_party/skia/include/core/SkImageFilter.h"
1110

1211
namespace flutter {
1312

1413
class BackdropFilterLayer : public ContainerLayer {
1514
public:
1615
BackdropFilterLayer(sk_sp<SkImageFilter> filter);
16+
~BackdropFilterLayer() override;
1717

1818
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
19-
2019
void Paint(PaintContext& context) const override;
2120

2221
private:

flow/layers/backdrop_filter_layer_unittests.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ TEST_F(BackdropFilterLayerTest, PaintingEmptyLayerDies) {
2323
layer->Preroll(preroll_context(), SkMatrix());
2424
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
2525
EXPECT_FALSE(layer->needs_painting());
26-
EXPECT_FALSE(layer->needs_system_composite());
2726

2827
EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
2928
"needs_painting\\(\\)");
@@ -206,7 +205,7 @@ TEST_F(BackdropFilterLayerTest, Readback) {
206205

207206
// BDF with no filter blocks child with readback
208207
auto mock_layer =
209-
std::make_shared<MockLayer>(SkPath(), SkPaint(), false, false, true);
208+
std::make_shared<MockLayer>(SkPath(), SkPaint(), false, true);
210209
layer2->Add(mock_layer);
211210
preroll_context()->surface_needs_readback = false;
212211
layer2->Preroll(preroll_context(), initial_transform);

flow/layers/child_scene_layer.cc

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,36 @@
44

55
#include "flutter/flow/layers/child_scene_layer.h"
66

7-
#include "flutter/flow/view_holder.h"
8-
97
namespace flutter {
108

11-
ChildSceneLayer::ChildSceneLayer(zx_koid_t layer_id,
12-
const SkPoint& offset,
9+
ChildSceneLayer::ChildSceneLayer(const SkPoint& offset,
1310
const SkSize& size,
11+
zx_koid_t layer_id,
1412
bool hit_testable)
15-
: layer_id_(layer_id),
16-
offset_(offset),
13+
: offset_(offset),
1714
size_(size),
15+
layer_id_(layer_id),
1816
hit_testable_(hit_testable) {}
1917

18+
ChildSceneLayer::~ChildSceneLayer() = default;
19+
2020
void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
2121
TRACE_EVENT0("flutter", "ChildSceneLayer::Preroll");
22-
set_needs_system_composite(true);
2322

23+
context->has_platform_view = true;
24+
context->platform_view_exists_below = true;
2425
CheckForChildLayerBelow(context);
2526

26-
context->child_scene_layer_exists_below = true;
27-
2827
// An alpha "hole punch" is required if the frame behind us is not opaque.
29-
if (!context->is_opaque) {
30-
set_paint_bounds(
31-
SkRect::MakeXYWH(offset_.fX, offset_.fY, size_.fWidth, size_.fHeight));
28+
for (auto i = context->mutators_stack.Bottom();
29+
i != context->mutators_stack.Top(); ++i) {
30+
const auto& mutator = *i;
31+
if (mutator->GetType() == MutatorType::opacity &&
32+
mutator->GetAlpha() < 255) {
33+
set_paint_bounds(SkRect::MakeXYWH(offset_.fX, offset_.fY, size_.fWidth,
34+
size_.fHeight));
35+
break;
36+
}
3237
}
3338
}
3439

@@ -50,14 +55,7 @@ void ChildSceneLayer::UpdateScene(SceneUpdateContext& context) {
5055
TRACE_EVENT0("flutter", "ChildSceneLayer::UpdateScene");
5156
FML_DCHECK(needs_system_composite());
5257

53-
Layer::UpdateScene(context);
54-
55-
auto* view_holder = ViewHolder::FromId(layer_id_);
56-
FML_DCHECK(view_holder);
57-
58-
view_holder->UpdateScene(context, offset_, size_,
59-
SkScalarRoundToInt(context.alphaf() * 255),
60-
hit_testable_);
58+
context.UpdateScene(layer_id_, offset_, size_, hit_testable_);
6159
}
6260

6361
} // namespace flutter

flow/layers/child_scene_layer.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,29 @@
55
#ifndef FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_
66
#define FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_
77

8+
#include "flutter/flow/layers/layer.h"
89
#include "third_party/skia/include/core/SkMatrix.h"
910
#include "third_party/skia/include/core/SkPoint.h"
1011
#include "third_party/skia/include/core/SkSize.h"
1112

12-
#include "flutter/flow/layers/layer.h"
13-
#include "flutter/flow/scene_update_context.h"
14-
1513
namespace flutter {
1614

17-
// Layer that represents an embedded child.
1815
class ChildSceneLayer : public Layer {
1916
public:
20-
ChildSceneLayer(zx_koid_t layer_id,
21-
const SkPoint& offset,
17+
ChildSceneLayer(const SkPoint& offset,
2218
const SkSize& size,
19+
zx_koid_t layer_id,
2320
bool hit_testable);
24-
~ChildSceneLayer() override = default;
21+
~ChildSceneLayer() override;
2522

2623
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
27-
2824
void Paint(PaintContext& context) const override;
29-
3025
void UpdateScene(SceneUpdateContext& context) override;
3126

3227
private:
33-
zx_koid_t layer_id_ = ZX_KOID_INVALID;
3428
SkPoint offset_;
3529
SkSize size_;
30+
zx_koid_t layer_id_ = ZX_KOID_INVALID;
3631
bool hit_testable_ = true;
3732

3833
FML_DISALLOW_COPY_AND_ASSIGN(ChildSceneLayer);

flow/layers/clip_path_layer.cc

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44

55
#include "flutter/flow/layers/clip_path_layer.h"
66

7-
#if defined(LEGACY_FUCHSIA_EMBEDDER)
8-
9-
#include "lib/ui/scenic/cpp/commands.h"
10-
11-
#endif
12-
137
namespace flutter {
148

159
ClipPathLayer::ClipPathLayer(const SkPath& clip_path, Clip clip_behavior)
1610
: clip_path_(clip_path), clip_behavior_(clip_behavior) {
1711
FML_DCHECK(clip_behavior != Clip::none);
1812
}
1913

14+
ClipPathLayer::~ClipPathLayer() = default;
15+
2016
void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
2117
TRACE_EVENT0("flutter", "ClipPathLayer::Preroll");
2218

@@ -29,30 +25,16 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
2925
Layer::AutoPrerollSaveLayerState save =
3026
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
3127
context->mutators_stack.PushClipPath(clip_path_);
32-
SkRect child_paint_bounds = SkRect::MakeEmpty();
33-
PrerollChildren(context, matrix, &child_paint_bounds);
28+
ContainerLayer::Preroll(context, matrix);
3429

35-
if (child_paint_bounds.intersect(clip_path_bounds)) {
36-
set_paint_bounds(child_paint_bounds);
30+
if (clip_path_bounds.intersect(paint_bounds())) {
31+
set_paint_bounds(clip_path_bounds);
3732
}
3833
context->mutators_stack.Pop();
3934
}
4035
context->cull_rect = previous_cull_rect;
4136
}
4237

43-
#if defined(LEGACY_FUCHSIA_EMBEDDER)
44-
45-
void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
46-
TRACE_EVENT0("flutter", "ClipPathLayer::UpdateScene");
47-
FML_DCHECK(needs_system_composite());
48-
49-
// TODO(liyuqian): respect clip_behavior_
50-
SceneUpdateContext::Clip clip(context, clip_path_.getBounds());
51-
UpdateSceneChildren(context);
52-
}
53-
54-
#endif
55-
5638
void ClipPathLayer::Paint(PaintContext& context) const {
5739
TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
5840
FML_DCHECK(needs_painting());
@@ -69,10 +51,23 @@ void ClipPathLayer::Paint(PaintContext& context) const {
6951
if (UsesSaveLayer()) {
7052
context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
7153
}
72-
PaintChildren(context);
54+
ContainerLayer::Paint(context);
7355
if (UsesSaveLayer()) {
7456
context.internal_nodes_canvas->restore();
7557
}
7658
}
7759

60+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
61+
62+
void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
63+
TRACE_EVENT0("flutter", "ClipPathLayer::UpdateScene");
64+
FML_DCHECK(needs_system_composite());
65+
66+
// TODO(liyuqian): respect clip_behavior_
67+
SceneUpdateContext::Clip clip(context, clip_path_.getBounds());
68+
ContainerLayer::UpdateScene(context);
69+
}
70+
71+
#endif
72+
7873
} // namespace flutter

flow/layers/clip_path_layer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
#define FLUTTER_FLOW_LAYERS_CLIP_PATH_LAYER_H_
77

88
#include "flutter/flow/layers/container_layer.h"
9+
#include "third_party/skia/include/core/SkPath.h"
910

1011
namespace flutter {
1112

1213
class ClipPathLayer : public ContainerLayer {
1314
public:
1415
ClipPathLayer(const SkPath& clip_path, Clip clip_behavior = Clip::antiAlias);
16+
~ClipPathLayer() override;
1517

1618
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
17-
1819
void Paint(PaintContext& context) const override;
1920

2021
bool UsesSaveLayer() const {

flow/layers/clip_path_layer_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ TEST_F(ClipPathLayerTest, Readback) {
218218
const Clip save_layer = Clip::antiAliasWithSaveLayer;
219219

220220
std::shared_ptr<MockLayer> nochild;
221-
auto reader = std::make_shared<MockLayer>(path, paint, false, false, true);
221+
auto reader = std::make_shared<MockLayer>(path, paint, false, true);
222222
auto nonreader = std::make_shared<MockLayer>(path, paint);
223223

224224
// No children, no prior readback -> no readback after

flow/layers/clip_rect_layer.cc

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ClipRectLayer::ClipRectLayer(const SkRect& clip_rect, Clip clip_behavior)
1111
FML_DCHECK(clip_behavior != Clip::none);
1212
}
1313

14+
ClipRectLayer::~ClipRectLayer() = default;
15+
1416
void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
1517
TRACE_EVENT0("flutter", "ClipRectLayer::Preroll");
1618

@@ -22,30 +24,17 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
2224
Layer::AutoPrerollSaveLayerState save =
2325
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
2426
context->mutators_stack.PushClipRect(clip_rect_);
25-
SkRect child_paint_bounds = SkRect::MakeEmpty();
26-
PrerollChildren(context, matrix, &child_paint_bounds);
27+
ContainerLayer::Preroll(context, matrix);
2728

28-
if (child_paint_bounds.intersect(clip_rect_)) {
29-
set_paint_bounds(child_paint_bounds);
29+
SkRect new_paint_bounds;
30+
if (new_paint_bounds.intersect(paint_bounds(), clip_rect_)) {
31+
set_paint_bounds(new_paint_bounds);
3032
}
3133
context->mutators_stack.Pop();
3234
}
3335
context->cull_rect = previous_cull_rect;
3436
}
3537

36-
#if defined(LEGACY_FUCHSIA_EMBEDDER)
37-
38-
void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
39-
TRACE_EVENT0("flutter", "ClipRectLayer::UpdateScene");
40-
FML_DCHECK(needs_system_composite());
41-
42-
// TODO(liyuqian): respect clip_behavior_
43-
SceneUpdateContext::Clip clip(context, clip_rect_);
44-
UpdateSceneChildren(context);
45-
}
46-
47-
#endif
48-
4938
void ClipRectLayer::Paint(PaintContext& context) const {
5039
TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
5140
FML_DCHECK(needs_painting());
@@ -62,10 +51,23 @@ void ClipRectLayer::Paint(PaintContext& context) const {
6251
if (UsesSaveLayer()) {
6352
context.internal_nodes_canvas->saveLayer(clip_rect_, nullptr);
6453
}
65-
PaintChildren(context);
54+
ContainerLayer::Paint(context);
6655
if (UsesSaveLayer()) {
6756
context.internal_nodes_canvas->restore();
6857
}
6958
}
7059

60+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
61+
62+
void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
63+
TRACE_EVENT0("flutter", "ClipRectLayer::UpdateScene");
64+
FML_DCHECK(needs_system_composite());
65+
66+
// TODO(liyuqian): respect clip_behavior_
67+
SceneUpdateContext::Clip clip(context, clip_rect_);
68+
ContainerLayer::UpdateScene(context);
69+
}
70+
71+
#endif
72+
7173
} // namespace flutter

flow/layers/clip_rect_layer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88
#include "flutter/flow/layers/container_layer.h"
99

10+
#include "third_party/skia/include/core/SkRect.h"
11+
1012
namespace flutter {
1113

1214
class ClipRectLayer : public ContainerLayer {
1315
public:
1416
ClipRectLayer(const SkRect& clip_rect, Clip clip_behavior);
17+
~ClipRectLayer() override;
1518

1619
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
1720
void Paint(PaintContext& context) const override;

flow/layers/clip_rect_layer_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ TEST_F(ClipRectLayerTest, Readback) {
215215
const Clip save_layer = Clip::antiAliasWithSaveLayer;
216216

217217
std::shared_ptr<MockLayer> nochild;
218-
auto reader = std::make_shared<MockLayer>(path, paint, false, false, true);
218+
auto reader = std::make_shared<MockLayer>(path, paint, false, true);
219219
auto nonreader = std::make_shared<MockLayer>(path, paint);
220220

221221
// No children, no prior readback -> no readback after

0 commit comments

Comments
 (0)