diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index d46098891bbe7..fa453415c1a63 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -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 diff --git a/flow/BUILD.gn b/flow/BUILD.gn index dd4a292dd9d66..c476b4c5bdf48 100644 --- a/flow/BUILD.gn +++ b/flow/BUILD.gn @@ -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", diff --git a/flow/layers/platform_view_layer.cc b/flow/layers/platform_view_layer.cc new file mode 100644 index 0000000000000..0a6a17244e0df --- /dev/null +++ b/flow/layers/platform_view_layer.cc @@ -0,0 +1,21 @@ +// 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 diff --git a/flow/layers/platform_view_layer.h b/flow/layers/platform_view_layer.h new file mode 100644 index 0000000000000..13b7f5d0f1dae --- /dev/null +++ b/flow/layers/platform_view_layer.h @@ -0,0 +1,39 @@ +// 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_ diff --git a/lib/ui/compositing.dart b/lib/ui/compositing.dart index f2e5fb049cd7e..8c3d9261d69e5 100644 --- a/lib/ui/compositing.dart +++ b/lib/ui/compositing.dart @@ -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({ diff --git a/lib/ui/compositing/scene_builder.cc b/lib/ui/compositing/scene_builder.cc index 98888d77ad1fd..76137c464969d 100644 --- a/lib/ui/compositing/scene_builder.cc +++ b/lib/ui/compositing/scene_builder.cc @@ -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(); + 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, diff --git a/lib/ui/compositing/scene_builder.h b/lib/ui/compositing/scene_builder.h index e8638e6aee3bf..8674d004ab5d8 100644 --- a/lib/ui/compositing/scene_builder.h +++ b/lib/ui/compositing/scene_builder.h @@ -76,6 +76,12 @@ class SceneBuilder : public RefCountedDartWrappable { 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,