Skip to content

Commit 74662ab

Browse files
authored
Revert "Share engine layers with the framework" (flutter#6412)
Reverts flutter/engine#6406 We need to fix the SkiaGPUObject issue of the raster cache SkImage before merging this PR.
1 parent 2de87a8 commit 74662ab

File tree

14 files changed

+33
-137
lines changed

14 files changed

+33
-137
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ TYPE: LicenseType.bsd
475475
FILE: ../../../flutter/flutter_kernel_transformers/lib/track_widget_constructor_locations.dart
476476
FILE: ../../../flutter/fml/paths_unittests.cc
477477
FILE: ../../../flutter/lib/ui/isolate_name_server.dart
478-
FILE: ../../../flutter/lib/ui/painting/engine_layer.cc
479-
FILE: ../../../flutter/lib/ui/painting/engine_layer.h
480478
FILE: ../../../flutter/lib/ui/painting/image_encoding.cc
481479
FILE: ../../../flutter/lib/ui/painting/image_encoding.h
482480
FILE: ../../../flutter/lib/ui/plugins.dart

flow/layers/container_layer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ContainerLayer::ContainerLayer() {}
1010

1111
ContainerLayer::~ContainerLayer() = default;
1212

13-
void ContainerLayer::Add(std::shared_ptr<Layer> layer) {
13+
void ContainerLayer::Add(std::unique_ptr<Layer> layer) {
1414
layer->set_parent(this);
1515
layers_.push_back(std::move(layer));
1616
}

flow/layers/container_layer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class ContainerLayer : public Layer {
1515
ContainerLayer();
1616
~ContainerLayer() override;
1717

18-
void Add(std::shared_ptr<Layer> layer);
18+
void Add(std::unique_ptr<Layer> layer);
1919

2020
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
2121

2222
#if defined(OS_FUCHSIA)
2323
void UpdateScene(SceneUpdateContext& context) override;
2424
#endif // defined(OS_FUCHSIA)
2525

26-
const std::vector<std::shared_ptr<Layer>>& layers() const { return layers_; }
26+
const std::vector<std::unique_ptr<Layer>>& layers() const { return layers_; }
2727

2828
protected:
2929
void PrerollChildren(PrerollContext* context,
@@ -36,7 +36,7 @@ class ContainerLayer : public Layer {
3636
#endif // defined(OS_FUCHSIA)
3737

3838
private:
39-
std::vector<std::shared_ptr<Layer>> layers_;
39+
std::vector<std::unique_ptr<Layer>> layers_;
4040

4141
FML_DISALLOW_COPY_AND_ASSIGN(ContainerLayer);
4242
};

flow/layers/layer_tree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LayerTree {
3838

3939
Layer* root_layer() const { return root_layer_.get(); }
4040

41-
void set_root_layer(std::shared_ptr<Layer> root_layer) {
41+
void set_root_layer(std::unique_ptr<Layer> root_layer) {
4242
root_layer_ = std::move(root_layer);
4343
}
4444

@@ -73,7 +73,7 @@ class LayerTree {
7373

7474
private:
7575
SkISize frame_size_; // Physical pixels.
76-
std::shared_ptr<Layer> root_layer_;
76+
std::unique_ptr<Layer> root_layer_;
7777
fml::TimeDelta construction_time_;
7878
uint32_t rasterizer_tracing_threshold_;
7979
bool checkerboard_raster_cache_images_;

lib/ui/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ source_set("ui") {
2323
"painting/canvas.h",
2424
"painting/codec.cc",
2525
"painting/codec.h",
26-
"painting/engine_layer.h",
27-
"painting/engine_layer.cc",
2826
"painting/frame_info.cc",
2927
"painting/frame_info.h",
3028
"painting/gradient.cc",

lib/ui/compositing.dart

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
6969
/// This is equivalent to [pushTransform] with a matrix with only translation.
7070
///
7171
/// See [pop] for details about the operation stack.
72-
EngineLayer pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset';
72+
void pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset';
7373

7474
/// Pushes a rectangular clip operation onto the operation stack.
7575
///
@@ -177,10 +177,10 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
177177
///
178178
/// See [pop] for details about the operation stack, and [Clip] for different clip modes.
179179
// ignore: deprecated_member_use
180-
EngineLayer pushPhysicalShape({ Path path, double elevation, Color color, Color shadowColor, Clip clipBehavior = defaultClipBehavior}) {
181-
return _pushPhysicalShape(path, elevation, color.value, shadowColor?.value ?? 0xFF000000, clipBehavior.index);
180+
void pushPhysicalShape({ Path path, double elevation, Color color, Color shadowColor, Clip clipBehavior = defaultClipBehavior}) {
181+
_pushPhysicalShape(path, elevation, color.value, shadowColor?.value ?? 0xFF000000, clipBehavior.index);
182182
}
183-
EngineLayer _pushPhysicalShape(Path path, double elevation, int color, int shadowColor, int clipBehavior) native
183+
void _pushPhysicalShape(Path path, double elevation, int color, int shadowColor, int clipBehavior) native
184184
'SceneBuilder_pushPhysicalShape';
185185

186186
/// Ends the effect of the most recently pushed operation.
@@ -191,14 +191,6 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
191191
/// stack.
192192
void pop() native 'SceneBuilder_pop';
193193

194-
/// Add a retained engine layer subtree from previous frames.
195-
///
196-
/// All the engine layers that are in the subtree of the retained layer will
197-
/// be automatically appended to the current engine layer tree. Therefore,
198-
/// once this is called, there's no need to call [addToScene] for its children
199-
/// layers.
200-
EngineLayer addRetained(EngineLayer retainedLayer) native 'SceneBuilder_addRetained';
201-
202194
/// Adds an object to the scene that displays performance statistics.
203195
///
204196
/// Useful during development to assess the performance of the application.

lib/ui/compositing/scene.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Scene);
2626

2727
DART_BIND_ALL(Scene, FOR_EACH_BINDING)
2828

29-
fml::RefPtr<Scene> Scene::create(std::shared_ptr<flow::Layer> rootLayer,
29+
fml::RefPtr<Scene> Scene::create(std::unique_ptr<flow::Layer> rootLayer,
3030
uint32_t rasterizerTracingThreshold,
3131
bool checkerboardRasterCacheImages,
3232
bool checkerboardOffscreenLayers) {
@@ -35,7 +35,7 @@ fml::RefPtr<Scene> Scene::create(std::shared_ptr<flow::Layer> rootLayer,
3535
checkerboardRasterCacheImages, checkerboardOffscreenLayers);
3636
}
3737

38-
Scene::Scene(std::shared_ptr<flow::Layer> rootLayer,
38+
Scene::Scene(std::unique_ptr<flow::Layer> rootLayer,
3939
uint32_t rasterizerTracingThreshold,
4040
bool checkerboardRasterCacheImages,
4141
bool checkerboardOffscreenLayers)

lib/ui/compositing/scene.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Scene : public RefCountedDartWrappable<Scene> {
2424

2525
public:
2626
~Scene() override;
27-
static fml::RefPtr<Scene> create(std::shared_ptr<flow::Layer> rootLayer,
27+
static fml::RefPtr<Scene> create(std::unique_ptr<flow::Layer> rootLayer,
2828
uint32_t rasterizerTracingThreshold,
2929
bool checkerboardRasterCacheImages,
3030
bool checkerboardOffscreenLayers);
@@ -40,7 +40,7 @@ class Scene : public RefCountedDartWrappable<Scene> {
4040
static void RegisterNatives(tonic::DartLibraryNatives* natives);
4141

4242
private:
43-
explicit Scene(std::shared_ptr<flow::Layer> rootLayer,
43+
explicit Scene(std::unique_ptr<flow::Layer> rootLayer,
4444
uint32_t rasterizerTracingThreshold,
4545
bool checkerboardRasterCacheImages,
4646
bool checkerboardOffscreenLayers);

lib/ui/compositing/scene_builder.cc

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, SceneBuilder);
5353
V(SceneBuilder, pushShaderMask) \
5454
V(SceneBuilder, pushPhysicalShape) \
5555
V(SceneBuilder, pop) \
56-
V(SceneBuilder, addRetained) \
5756
V(SceneBuilder, addPicture) \
5857
V(SceneBuilder, addTexture) \
5958
V(SceneBuilder, addChildScene) \
@@ -81,12 +80,11 @@ void SceneBuilder::pushTransform(const tonic::Float64List& matrix4) {
8180
PushLayer(std::move(layer));
8281
}
8382

84-
fml::RefPtr<EngineLayer> SceneBuilder::pushOffset(double dx, double dy) {
83+
void SceneBuilder::pushOffset(double dx, double dy) {
8584
SkMatrix sk_matrix = SkMatrix::MakeTrans(dx, dy);
86-
auto layer = std::make_shared<flow::TransformLayer>();
85+
auto layer = std::make_unique<flow::TransformLayer>();
8786
layer->set_transform(sk_matrix);
88-
PushLayer(layer);
89-
return EngineLayer::MakeRetained(layer);
87+
PushLayer(std::move(layer));
9088
}
9189

9290
void SceneBuilder::pushClipRect(double left,
@@ -150,29 +148,21 @@ void SceneBuilder::pushShaderMask(Shader* shader,
150148
PushLayer(std::move(layer));
151149
}
152150

153-
fml::RefPtr<EngineLayer> SceneBuilder::pushPhysicalShape(const CanvasPath* path,
154-
double elevation,
155-
int color,
156-
int shadow_color,
157-
int clipBehavior) {
151+
void SceneBuilder::pushPhysicalShape(const CanvasPath* path,
152+
double elevation,
153+
int color,
154+
int shadow_color,
155+
int clipBehavior) {
158156
const SkPath& sk_path = path->path();
159157
flow::Clip clip_behavior = static_cast<flow::Clip>(clipBehavior);
160-
auto layer = std::make_shared<flow::PhysicalShapeLayer>(clip_behavior);
158+
auto layer = std::make_unique<flow::PhysicalShapeLayer>(clip_behavior);
161159
layer->set_path(sk_path);
162160
layer->set_elevation(elevation);
163161
layer->set_color(static_cast<SkColor>(color));
164162
layer->set_shadow_color(static_cast<SkColor>(shadow_color));
165163
layer->set_device_pixel_ratio(
166164
UIDartState::Current()->window()->viewport_metrics().device_pixel_ratio);
167-
PushLayer(layer);
168-
return EngineLayer::MakeRetained(layer);
169-
}
170-
171-
void SceneBuilder::addRetained(fml::RefPtr<EngineLayer> retainedLayer) {
172-
if (!current_layer_) {
173-
return;
174-
}
175-
current_layer_->Add(retainedLayer->Layer());
165+
PushLayer(std::move(layer));
176166
}
177167

178168
void SceneBuilder::pop() {
@@ -270,7 +260,7 @@ fml::RefPtr<Scene> SceneBuilder::build() {
270260
return scene;
271261
}
272262

273-
void SceneBuilder::PushLayer(std::shared_ptr<flow::ContainerLayer> layer) {
263+
void SceneBuilder::PushLayer(std::unique_ptr<flow::ContainerLayer> layer) {
274264
FML_DCHECK(layer);
275265

276266
if (!root_layer_) {

lib/ui/compositing/scene_builder.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "flutter/lib/ui/compositing/scene.h"
1313
#include "flutter/lib/ui/compositing/scene_host.h"
1414
#include "flutter/lib/ui/dart_wrapper.h"
15-
#include "flutter/lib/ui/painting/engine_layer.h"
1615
#include "flutter/lib/ui/painting/image_filter.h"
1716
#include "flutter/lib/ui/painting/path.h"
1817
#include "flutter/lib/ui/painting/picture.h"
@@ -34,7 +33,7 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
3433
~SceneBuilder() override;
3534

3635
void pushTransform(const tonic::Float64List& matrix4);
37-
fml::RefPtr<EngineLayer> pushOffset(double dx, double dy);
36+
void pushOffset(double dx, double dy);
3837
void pushClipRect(double left,
3938
double right,
4039
double top,
@@ -51,13 +50,11 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
5150
double maskRectTop,
5251
double maskRectBottom,
5352
int blendMode);
54-
fml::RefPtr<EngineLayer> pushPhysicalShape(const CanvasPath* path,
55-
double elevation,
56-
int color,
57-
int shadowColor,
58-
int clipBehavior);
59-
60-
void addRetained(fml::RefPtr<EngineLayer> retainedLayer);
53+
void pushPhysicalShape(const CanvasPath* path,
54+
double elevation,
55+
int color,
56+
int shadowColor,
57+
int clipBehavior);
6158

6259
void pop();
6360

@@ -95,14 +92,14 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
9592
private:
9693
SceneBuilder();
9794

98-
std::shared_ptr<flow::ContainerLayer> root_layer_;
95+
std::unique_ptr<flow::ContainerLayer> root_layer_;
9996
flow::ContainerLayer* current_layer_ = nullptr;
10097

10198
int rasterizer_tracing_threshold_ = 0;
10299
bool checkerboard_raster_cache_images_ = false;
103100
bool checkerboard_offscreen_layers_ = false;
104101

105-
void PushLayer(std::shared_ptr<flow::ContainerLayer> layer);
102+
void PushLayer(std::unique_ptr<flow::ContainerLayer> layer);
106103

107104
FML_DISALLOW_COPY_AND_ASSIGN(SceneBuilder);
108105
};

0 commit comments

Comments
 (0)