未验证 提交 a1bbea77 编写于 作者: A Amir Hardon 提交者: GitHub

Add a no-op platform view layer. (#6505)

This will be used for embedding UIViews on iOS.

Landing a no-op layer as a first incremental step to keep PRs small.
上级 2bb3afad
......@@ -556,8 +556,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../flutter/flutter_kernel_transformers/lib/track_widget_constructor_locations.dart + ../../../LICENSE
ORIGIN: ../../../flutter/flow/layers/platform_view_layer.cc + ../../../LICENSE
TYPE: LicenseType.bsd
FILE: ../../../flutter/flow/layers/platform_view_layer.cc
FILE: ../../../flutter/flow/layers/platform_view_layer.h
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
......
......@@ -34,6 +34,8 @@ source_set("flow") {
"layers/physical_shape_layer.h",
"layers/picture_layer.cc",
"layers/picture_layer.h",
"layers/platform_view_layer.cc",
"layers/platform_view_layer.h",
"layers/shader_mask_layer.cc",
"layers/shader_mask_layer.h",
"layers/texture_layer.cc",
......
// Copyright 2018 The Chromium 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/platform_view_layer.h"
namespace flow {
PlatformViewLayer::PlatformViewLayer() = default;
PlatformViewLayer::~PlatformViewLayer() = default;
void PlatformViewLayer::Preroll(PrerollContext* context,
const SkMatrix& matrix) {
set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
size_.height()));
}
void PlatformViewLayer::Paint(PaintContext& context) const {}
} // namespace flow
// Copyright 2018 The Chromium 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_PLATFORM_VIEW_LAYER_H_
#define FLUTTER_FLOW_LAYERS_PLATFORM_VIEW_LAYER_H_
#include "flutter/flow/layers/layer.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/GrTexture.h"
#include "third_party/skia/include/gpu/GrTypes.h"
namespace flow {
class PlatformViewLayer : public Layer {
public:
PlatformViewLayer();
~PlatformViewLayer() override;
void set_offset(const SkPoint& offset) { offset_ = offset; }
void set_size(const SkSize& size) { size_ = size; }
void set_view_id(int64_t view_id) { view_id_ = view_id; }
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext& context) const override;
private:
SkPoint offset_;
SkSize size_;
int64_t view_id_;
FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewLayer);
};
} // namespace flow
#endif // FLUTTER_FLOW_LAYERS_PLATFORM_VIEW_LAYER_H_
......@@ -268,6 +268,15 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
}
void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze) native 'SceneBuilder_addTexture';
/// Adds a platform view (e.g an iOS UIView) to the scene.
///
/// This is work in progress and is not currently supported on any platform.
void addPlatformView(int viewId, { Offset offset: Offset.zero, double width: 0.0, double height: 0.0}) {
assert(offset != null, 'Offset argument was null');
_addPlatformView(offset.dx, offset.dy, width, height, viewId);
}
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({
......
......@@ -19,6 +19,7 @@
#include "flutter/flow/layers/performance_overlay_layer.h"
#include "flutter/flow/layers/physical_shape_layer.h"
#include "flutter/flow/layers/picture_layer.h"
#include "flutter/flow/layers/platform_view_layer.h"
#include "flutter/flow/layers/shader_mask_layer.h"
#include "flutter/flow/layers/texture_layer.h"
#include "flutter/flow/layers/transform_layer.h"
......@@ -53,6 +54,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, SceneBuilder);
V(SceneBuilder, pushShaderMask) \
V(SceneBuilder, pushPhysicalShape) \
V(SceneBuilder, pop) \
V(SceneBuilder, addPlatformView) \
V(SceneBuilder, addRetained) \
V(SceneBuilder, addPicture) \
V(SceneBuilder, addTexture) \
......@@ -217,6 +219,21 @@ void SceneBuilder::addTexture(double dx,
current_layer_->Add(std::move(layer));
}
void SceneBuilder::addPlatformView(double dx,
double dy,
double width,
double height,
int64_t viewId) {
if (!current_layer_) {
return;
}
auto layer = std::make_unique<flow::PlatformViewLayer>();
layer->set_offset(SkPoint::Make(dx, dy));
layer->set_size(SkSize::Make(width, height));
layer->set_view_id(viewId);
current_layer_->Add(std::move(layer));
}
void SceneBuilder::addChildScene(double dx,
double dy,
double width,
......
......@@ -76,6 +76,12 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
int64_t textureId,
bool freeze);
void addPlatformView(double dx,
double dy,
double width,
double height,
int64_t viewId);
void addChildScene(double dx,
double dy,
double width,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册