Skip to content

Commit

Permalink
Revert "Share engine layers with the framework" (flutter#6412)
Browse files Browse the repository at this point in the history
Reverts flutter#6406

We need to fix the SkiaGPUObject issue of the raster cache SkImage before merging this PR.
  • Loading branch information
liyuqian authored Oct 2, 2018
1 parent 2de87a8 commit 74662ab
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 137 deletions.
2 changes: 0 additions & 2 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ TYPE: LicenseType.bsd
FILE: ../../../flutter/flutter_kernel_transformers/lib/track_widget_constructor_locations.dart
FILE: ../../../flutter/fml/paths_unittests.cc
FILE: ../../../flutter/lib/ui/isolate_name_server.dart
FILE: ../../../flutter/lib/ui/painting/engine_layer.cc
FILE: ../../../flutter/lib/ui/painting/engine_layer.h
FILE: ../../../flutter/lib/ui/painting/image_encoding.cc
FILE: ../../../flutter/lib/ui/painting/image_encoding.h
FILE: ../../../flutter/lib/ui/plugins.dart
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/container_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ContainerLayer::ContainerLayer() {}

ContainerLayer::~ContainerLayer() = default;

void ContainerLayer::Add(std::shared_ptr<Layer> layer) {
void ContainerLayer::Add(std::unique_ptr<Layer> layer) {
layer->set_parent(this);
layers_.push_back(std::move(layer));
}
Expand Down
6 changes: 3 additions & 3 deletions flow/layers/container_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class ContainerLayer : public Layer {
ContainerLayer();
~ContainerLayer() override;

void Add(std::shared_ptr<Layer> layer);
void Add(std::unique_ptr<Layer> layer);

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

#if defined(OS_FUCHSIA)
void UpdateScene(SceneUpdateContext& context) override;
#endif // defined(OS_FUCHSIA)

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

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

private:
std::vector<std::shared_ptr<Layer>> layers_;
std::vector<std::unique_ptr<Layer>> layers_;

FML_DISALLOW_COPY_AND_ASSIGN(ContainerLayer);
};
Expand Down
4 changes: 2 additions & 2 deletions flow/layers/layer_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LayerTree {

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

void set_root_layer(std::shared_ptr<Layer> root_layer) {
void set_root_layer(std::unique_ptr<Layer> root_layer) {
root_layer_ = std::move(root_layer);
}

Expand Down Expand Up @@ -73,7 +73,7 @@ class LayerTree {

private:
SkISize frame_size_; // Physical pixels.
std::shared_ptr<Layer> root_layer_;
std::unique_ptr<Layer> root_layer_;
fml::TimeDelta construction_time_;
uint32_t rasterizer_tracing_threshold_;
bool checkerboard_raster_cache_images_;
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ source_set("ui") {
"painting/canvas.h",
"painting/codec.cc",
"painting/codec.h",
"painting/engine_layer.h",
"painting/engine_layer.cc",
"painting/frame_info.cc",
"painting/frame_info.h",
"painting/gradient.cc",
Expand Down
16 changes: 4 additions & 12 deletions lib/ui/compositing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
/// This is equivalent to [pushTransform] with a matrix with only translation.
///
/// See [pop] for details about the operation stack.
EngineLayer pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset';
void pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset';

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

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

/// Add a retained engine layer subtree from previous frames.
///
/// All the engine layers that are in the subtree of the retained layer will
/// be automatically appended to the current engine layer tree. Therefore,
/// once this is called, there's no need to call [addToScene] for its children
/// layers.
EngineLayer addRetained(EngineLayer retainedLayer) native 'SceneBuilder_addRetained';

/// Adds an object to the scene that displays performance statistics.
///
/// Useful during development to assess the performance of the application.
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/compositing/scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Scene);

DART_BIND_ALL(Scene, FOR_EACH_BINDING)

fml::RefPtr<Scene> Scene::create(std::shared_ptr<flow::Layer> rootLayer,
fml::RefPtr<Scene> Scene::create(std::unique_ptr<flow::Layer> rootLayer,
uint32_t rasterizerTracingThreshold,
bool checkerboardRasterCacheImages,
bool checkerboardOffscreenLayers) {
Expand All @@ -35,7 +35,7 @@ fml::RefPtr<Scene> Scene::create(std::shared_ptr<flow::Layer> rootLayer,
checkerboardRasterCacheImages, checkerboardOffscreenLayers);
}

Scene::Scene(std::shared_ptr<flow::Layer> rootLayer,
Scene::Scene(std::unique_ptr<flow::Layer> rootLayer,
uint32_t rasterizerTracingThreshold,
bool checkerboardRasterCacheImages,
bool checkerboardOffscreenLayers)
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/compositing/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Scene : public RefCountedDartWrappable<Scene> {

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

private:
explicit Scene(std::shared_ptr<flow::Layer> rootLayer,
explicit Scene(std::unique_ptr<flow::Layer> rootLayer,
uint32_t rasterizerTracingThreshold,
bool checkerboardRasterCacheImages,
bool checkerboardOffscreenLayers);
Expand Down
32 changes: 11 additions & 21 deletions lib/ui/compositing/scene_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, SceneBuilder);
V(SceneBuilder, pushShaderMask) \
V(SceneBuilder, pushPhysicalShape) \
V(SceneBuilder, pop) \
V(SceneBuilder, addRetained) \
V(SceneBuilder, addPicture) \
V(SceneBuilder, addTexture) \
V(SceneBuilder, addChildScene) \
Expand Down Expand Up @@ -81,12 +80,11 @@ void SceneBuilder::pushTransform(const tonic::Float64List& matrix4) {
PushLayer(std::move(layer));
}

fml::RefPtr<EngineLayer> SceneBuilder::pushOffset(double dx, double dy) {
void SceneBuilder::pushOffset(double dx, double dy) {
SkMatrix sk_matrix = SkMatrix::MakeTrans(dx, dy);
auto layer = std::make_shared<flow::TransformLayer>();
auto layer = std::make_unique<flow::TransformLayer>();
layer->set_transform(sk_matrix);
PushLayer(layer);
return EngineLayer::MakeRetained(layer);
PushLayer(std::move(layer));
}

void SceneBuilder::pushClipRect(double left,
Expand Down Expand Up @@ -150,29 +148,21 @@ void SceneBuilder::pushShaderMask(Shader* shader,
PushLayer(std::move(layer));
}

fml::RefPtr<EngineLayer> SceneBuilder::pushPhysicalShape(const CanvasPath* path,
double elevation,
int color,
int shadow_color,
int clipBehavior) {
void SceneBuilder::pushPhysicalShape(const CanvasPath* path,
double elevation,
int color,
int shadow_color,
int clipBehavior) {
const SkPath& sk_path = path->path();
flow::Clip clip_behavior = static_cast<flow::Clip>(clipBehavior);
auto layer = std::make_shared<flow::PhysicalShapeLayer>(clip_behavior);
auto layer = std::make_unique<flow::PhysicalShapeLayer>(clip_behavior);
layer->set_path(sk_path);
layer->set_elevation(elevation);
layer->set_color(static_cast<SkColor>(color));
layer->set_shadow_color(static_cast<SkColor>(shadow_color));
layer->set_device_pixel_ratio(
UIDartState::Current()->window()->viewport_metrics().device_pixel_ratio);
PushLayer(layer);
return EngineLayer::MakeRetained(layer);
}

void SceneBuilder::addRetained(fml::RefPtr<EngineLayer> retainedLayer) {
if (!current_layer_) {
return;
}
current_layer_->Add(retainedLayer->Layer());
PushLayer(std::move(layer));
}

void SceneBuilder::pop() {
Expand Down Expand Up @@ -270,7 +260,7 @@ fml::RefPtr<Scene> SceneBuilder::build() {
return scene;
}

void SceneBuilder::PushLayer(std::shared_ptr<flow::ContainerLayer> layer) {
void SceneBuilder::PushLayer(std::unique_ptr<flow::ContainerLayer> layer) {
FML_DCHECK(layer);

if (!root_layer_) {
Expand Down
19 changes: 8 additions & 11 deletions lib/ui/compositing/scene_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "flutter/lib/ui/compositing/scene.h"
#include "flutter/lib/ui/compositing/scene_host.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "flutter/lib/ui/painting/engine_layer.h"
#include "flutter/lib/ui/painting/image_filter.h"
#include "flutter/lib/ui/painting/path.h"
#include "flutter/lib/ui/painting/picture.h"
Expand All @@ -34,7 +33,7 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
~SceneBuilder() override;

void pushTransform(const tonic::Float64List& matrix4);
fml::RefPtr<EngineLayer> pushOffset(double dx, double dy);
void pushOffset(double dx, double dy);
void pushClipRect(double left,
double right,
double top,
Expand All @@ -51,13 +50,11 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
double maskRectTop,
double maskRectBottom,
int blendMode);
fml::RefPtr<EngineLayer> pushPhysicalShape(const CanvasPath* path,
double elevation,
int color,
int shadowColor,
int clipBehavior);

void addRetained(fml::RefPtr<EngineLayer> retainedLayer);
void pushPhysicalShape(const CanvasPath* path,
double elevation,
int color,
int shadowColor,
int clipBehavior);

void pop();

Expand Down Expand Up @@ -95,14 +92,14 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
private:
SceneBuilder();

std::shared_ptr<flow::ContainerLayer> root_layer_;
std::unique_ptr<flow::ContainerLayer> root_layer_;
flow::ContainerLayer* current_layer_ = nullptr;

int rasterizer_tracing_threshold_ = 0;
bool checkerboard_raster_cache_images_ = false;
bool checkerboard_offscreen_layers_ = false;

void PushLayer(std::shared_ptr<flow::ContainerLayer> layer);
void PushLayer(std::unique_ptr<flow::ContainerLayer> layer);

FML_DISALLOW_COPY_AND_ASSIGN(SceneBuilder);
};
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/dart_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "flutter/lib/ui/isolate_name_server/isolate_name_server_natives.h"
#include "flutter/lib/ui/painting/canvas.h"
#include "flutter/lib/ui/painting/codec.h"
#include "flutter/lib/ui/painting/engine_layer.h"
#include "flutter/lib/ui/painting/frame_info.h"
#include "flutter/lib/ui/painting/gradient.h"
#include "flutter/lib/ui/painting/image.h"
Expand Down Expand Up @@ -59,7 +58,6 @@ void DartUI::InitForGlobal() {
CanvasPathMeasure::RegisterNatives(g_natives);
Codec::RegisterNatives(g_natives);
DartRuntimeHooks::RegisterNatives(g_natives);
EngineLayer::RegisterNatives(g_natives);
FrameInfo::RegisterNatives(g_natives);
ImageFilter::RegisterNatives(g_natives);
ImageShader::RegisterNatives(g_natives);
Expand Down
7 changes: 0 additions & 7 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1742,13 +1742,6 @@ enum PathOperation {
reverseDifference,
}

/// A handle for the framework to hold and retain an engine layer across frames.
class EngineLayer extends NativeFieldWrapperClass2 {
/// This class is created by the engine, and should not be instantiated
/// or extended directly.
EngineLayer._();
}

/// A complex, one-dimensional subset of a plane.
///
/// A path consists of a number of subpaths, and a _current point_.
Expand Down
26 changes: 0 additions & 26 deletions lib/ui/painting/engine_layer.cc

This file was deleted.

44 changes: 0 additions & 44 deletions lib/ui/painting/engine_layer.h

This file was deleted.

0 comments on commit 74662ab

Please sign in to comment.