Port Flutter to Mozart. (flutter/engine#3094)
Example: $ mojo:launcher mojo:spinning_square
This commit is contained in:
@@ -10,8 +10,6 @@ source_set("flow") {
|
||||
"instrumentation.h",
|
||||
"layers/backdrop_filter_layer.cc",
|
||||
"layers/backdrop_filter_layer.h",
|
||||
"layers/child_scene_layer.cc",
|
||||
"layers/child_scene_layer.h",
|
||||
"layers/clip_path_layer.cc",
|
||||
"layers/clip_path_layer.h",
|
||||
"layers/clip_rect_layer.cc",
|
||||
@@ -48,13 +46,17 @@ source_set("flow") {
|
||||
"//flutter/skia",
|
||||
"//flutter/synchronization",
|
||||
"//lib/ftl",
|
||||
"//mojo/services/gfx/composition/interfaces",
|
||||
]
|
||||
|
||||
if (is_fuchsia) {
|
||||
sources += [
|
||||
"layers/child_scene_layer.cc",
|
||||
"layers/child_scene_layer.h",
|
||||
"texture_image_none.cc",
|
||||
]
|
||||
deps += [
|
||||
"//apps/mozart/services/composition/interfaces",
|
||||
]
|
||||
} else {
|
||||
sources += [
|
||||
"gl_connection.cc",
|
||||
|
||||
@@ -50,18 +50,19 @@ void ChildSceneLayer::Paint(PaintContext& context) {
|
||||
TRACE_EVENT0("flutter", "ChildSceneLayer::Paint");
|
||||
}
|
||||
|
||||
void ChildSceneLayer::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container) {
|
||||
void ChildSceneLayer::UpdateScene(mozart::SceneUpdate* update,
|
||||
mozart::Node* container) {
|
||||
uint32_t id = next_id++;
|
||||
|
||||
auto child_resource = mojo::gfx::composition::Resource::New();
|
||||
child_resource->set_scene(mojo::gfx::composition::SceneResource::New());
|
||||
child_resource->get_scene()->scene_token = scene_token_.Clone();
|
||||
auto child_resource = mozart::Resource::New();
|
||||
child_resource->set_scene(mozart::SceneResource::New());
|
||||
child_resource->get_scene()->scene_token = mozart::SceneToken::New();
|
||||
child_resource->get_scene()->scene_token->value = scene_token_;
|
||||
update->resources.insert(id, child_resource.Pass());
|
||||
|
||||
auto child_node = mojo::gfx::composition::Node::New();
|
||||
child_node->op = mojo::gfx::composition::NodeOp::New();
|
||||
child_node->op->set_scene(mojo::gfx::composition::SceneNodeOp::New());
|
||||
auto child_node = mozart::Node::New();
|
||||
child_node->op = mozart::NodeOp::New();
|
||||
child_node->op->set_scene(mozart::SceneNodeOp::New());
|
||||
child_node->op->get_scene()->scene_resource_id = id;
|
||||
child_node->content_clip = mojo::RectF::New();
|
||||
child_node->content_clip->width = physical_size_.width();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_
|
||||
|
||||
#include "flutter/flow/layers/layer.h"
|
||||
#include "mojo/services/gfx/composition/interfaces/scenes.mojom.h"
|
||||
#include "apps/mozart/services/composition/interfaces/scenes.mojom.h"
|
||||
|
||||
namespace flow {
|
||||
|
||||
@@ -25,20 +25,18 @@ class ChildSceneLayer : public Layer {
|
||||
physical_size_ = physical_size;
|
||||
}
|
||||
|
||||
void set_scene_token(mojo::gfx::composition::SceneTokenPtr scene_token) {
|
||||
scene_token_ = scene_token.Pass();
|
||||
}
|
||||
void set_scene_token(uint32_t scene_token) { scene_token_ = scene_token; }
|
||||
|
||||
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
|
||||
void Paint(PaintContext& context) override;
|
||||
void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container) override;
|
||||
void UpdateScene(mozart::SceneUpdate* update,
|
||||
mozart::Node* container) override;
|
||||
|
||||
private:
|
||||
SkPoint offset_;
|
||||
float device_pixel_ratio_;
|
||||
SkISize physical_size_;
|
||||
mojo::gfx::composition::SceneTokenPtr scene_token_;
|
||||
uint32_t scene_token_;
|
||||
SkMatrix transform_;
|
||||
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(ChildSceneLayer);
|
||||
|
||||
@@ -39,10 +39,12 @@ void ContainerLayer::PaintChildren(PaintContext& context) const {
|
||||
layer->Paint(context);
|
||||
}
|
||||
|
||||
void ContainerLayer::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container) {
|
||||
#if defined(OS_FUCHSIA)
|
||||
void ContainerLayer::UpdateScene(mozart::SceneUpdate* update,
|
||||
mozart::Node* container) {
|
||||
for (auto& layer : layers_)
|
||||
layer->UpdateScene(update, container);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace flow
|
||||
|
||||
@@ -22,8 +22,10 @@ class ContainerLayer : public Layer {
|
||||
|
||||
void PaintChildren(PaintContext& context) const;
|
||||
|
||||
void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container) override;
|
||||
#if defined(OS_FUCHSIA)
|
||||
void UpdateScene(mozart::SceneUpdate* update,
|
||||
mozart::Node* container) override;
|
||||
#endif
|
||||
|
||||
const std::vector<std::unique_ptr<Layer>>& layers() const { return layers_; }
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ Layer::~Layer() {}
|
||||
|
||||
void Layer::Preroll(PrerollContext* context, const SkMatrix& matrix) {}
|
||||
|
||||
void Layer::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container) {}
|
||||
#if defined(OS_FUCHSIA)
|
||||
void Layer::UpdateScene(mozart::SceneUpdate* update, mozart::Node* container) {}
|
||||
#endif
|
||||
|
||||
} // namespace flow
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "flutter/flow/instrumentation.h"
|
||||
#include "flutter/flow/raster_cache.h"
|
||||
#include "flutter/glue/trace_event.h"
|
||||
#include "lib/ftl/build_config.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/ftl/macros.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
@@ -23,14 +24,12 @@
|
||||
#include "third_party/skia/include/core/SkRRect.h"
|
||||
#include "third_party/skia/include/core/SkXfermode.h"
|
||||
|
||||
namespace mojo {
|
||||
namespace gfx {
|
||||
namespace composition {
|
||||
#if defined(OS_FUCHSIA)
|
||||
namespace mozart {
|
||||
class SceneUpdate;
|
||||
class Node;
|
||||
} // composition
|
||||
} // namespace gfx
|
||||
} // namespace mojo
|
||||
} // namespace mozart
|
||||
#endif
|
||||
|
||||
namespace flow {
|
||||
|
||||
@@ -55,8 +54,11 @@ class Layer {
|
||||
};
|
||||
|
||||
virtual void Paint(PaintContext& context) = 0;
|
||||
virtual void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container);
|
||||
|
||||
#if defined(OS_FUCHSIA)
|
||||
virtual void UpdateScene(mozart::SceneUpdate* update,
|
||||
mozart::Node* container);
|
||||
#endif
|
||||
|
||||
ContainerLayer* parent() const { return parent_; }
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
namespace flow {
|
||||
|
||||
LayerTree::LayerTree() : scene_version_(0), rasterizer_tracing_threshold_(0) {}
|
||||
LayerTree::LayerTree()
|
||||
: frame_size_{}, scene_version_(0), rasterizer_tracing_threshold_(0) {}
|
||||
|
||||
LayerTree::~LayerTree() {}
|
||||
|
||||
@@ -32,10 +33,12 @@ void LayerTree::Raster(CompositorContext::ScopedFrame& frame,
|
||||
}
|
||||
}
|
||||
|
||||
void LayerTree::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container) {
|
||||
#if defined(OS_FUCHSIA)
|
||||
void LayerTree::UpdateScene(mozart::SceneUpdate* update,
|
||||
mozart::Node* container) {
|
||||
TRACE_EVENT0("flutter", "LayerTree::UpdateScene");
|
||||
root_layer_->UpdateScene(update, container);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace flow
|
||||
|
||||
@@ -26,11 +26,12 @@ class LayerTree {
|
||||
void Raster(CompositorContext::ScopedFrame& frame,
|
||||
bool ignore_raster_cache = false);
|
||||
|
||||
#if defined(OS_FUCHSIA)
|
||||
// TODO(abarth): Integrate scene updates with the rasterization pass so that
|
||||
// we can draw on top of child scenes (and so that we can apply clips and
|
||||
// blending operations to child scene).
|
||||
void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
|
||||
mojo::gfx::composition::Node* container);
|
||||
void UpdateScene(mozart::SceneUpdate* update, mozart::Node* container);
|
||||
#endif
|
||||
|
||||
Layer* root_layer() const { return root_layer_.get(); }
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "flutter/lib/ui/compositing/scene_builder.h"
|
||||
|
||||
#include "flutter/flow/layers/backdrop_filter_layer.h"
|
||||
#include "flutter/flow/layers/child_scene_layer.h"
|
||||
#include "flutter/flow/layers/clip_path_layer.h"
|
||||
#include "flutter/flow/layers/clip_rect_layer.h"
|
||||
#include "flutter/flow/layers/clip_rrect_layer.h"
|
||||
@@ -18,12 +17,17 @@
|
||||
#include "flutter/flow/layers/transform_layer.h"
|
||||
#include "flutter/lib/ui/painting/matrix.h"
|
||||
#include "flutter/lib/ui/painting/shader.h"
|
||||
#include "lib/ftl/build_config.h"
|
||||
#include "lib/tonic/dart_args.h"
|
||||
#include "lib/tonic/dart_binding_macros.h"
|
||||
#include "lib/tonic/converter/dart_converter.h"
|
||||
#include "lib/tonic/dart_library_natives.h"
|
||||
#include "third_party/skia/include/core/SkColorFilter.h"
|
||||
|
||||
#if defined(OS_FUCHSIA)
|
||||
#include "flutter/flow/layers/child_scene_layer.h"
|
||||
#endif
|
||||
|
||||
namespace blink {
|
||||
|
||||
static void SceneBuilder_constructor(Dart_NativeArguments args) {
|
||||
@@ -197,17 +201,16 @@ void SceneBuilder::addChildScene(double dx,
|
||||
int physicalWidth,
|
||||
int physicalHeight,
|
||||
uint32_t sceneToken) {
|
||||
#if defined(OS_FUCHSIA)
|
||||
if (!m_currentLayer)
|
||||
return;
|
||||
std::unique_ptr<flow::ChildSceneLayer> layer(new flow::ChildSceneLayer());
|
||||
layer->set_offset(SkPoint::Make(dx, dy));
|
||||
layer->set_device_pixel_ratio(devicePixelRatio);
|
||||
layer->set_physical_size(SkISize::Make(physicalWidth, physicalHeight));
|
||||
mojo::gfx::composition::SceneTokenPtr token =
|
||||
mojo::gfx::composition::SceneToken::New();
|
||||
token->value = sceneToken;
|
||||
layer->set_scene_token(token.Pass());
|
||||
layer->set_scene_token(sceneToken);
|
||||
m_currentLayer->Add(std::move(layer));
|
||||
#endif
|
||||
}
|
||||
|
||||
void SceneBuilder::addPerformanceOverlay(uint64_t enabledOptions,
|
||||
|
||||
@@ -49,13 +49,6 @@ void DartTakeShell(Dart_NativeArguments args) {
|
||||
Dart_SetIntegerReturnValue(args, handle);
|
||||
}
|
||||
|
||||
void DartTakeView(Dart_NativeArguments args) {
|
||||
int handle = MOJO_HANDLE_INVALID;
|
||||
if (MojoServices* services = GetMojoServices())
|
||||
handle = services->TakeView();
|
||||
Dart_SetIntegerReturnValue(args, handle);
|
||||
}
|
||||
|
||||
void DartTakeViewServices(Dart_NativeArguments args) {
|
||||
int handle = MOJO_HANDLE_INVALID;
|
||||
if (MojoServices* services = GetMojoServices())
|
||||
@@ -71,7 +64,6 @@ void MojoServices::RegisterNatives(tonic::DartLibraryNatives* natives) {
|
||||
{"MojoServices_takeIncomingServices", DartTakeIncomingServices, 0, true},
|
||||
{"MojoServices_takeOutgoingServices", DartTakeOutgoingServices, 0, true},
|
||||
{"MojoServices_takeShell", DartTakeShell, 0, true},
|
||||
{"MojoServices_takeView", DartTakeView, 0, true},
|
||||
{"MojoServices_takeViewServices", DartTakeViewServices, 0, true},
|
||||
});
|
||||
}
|
||||
@@ -122,12 +114,6 @@ int MojoServices::TakeShell() {
|
||||
return MOJO_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
int MojoServices::TakeView() {
|
||||
if (services_)
|
||||
return services_->view.PassHandle().release().value();
|
||||
return MOJO_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
int MojoServices::TakeViewServices() {
|
||||
if (services_)
|
||||
return services_->view_services.PassHandle().release().value();
|
||||
|
||||
@@ -16,6 +16,5 @@ class MojoServices {
|
||||
static int takeIncomingServices() native "MojoServices_takeIncomingServices";
|
||||
static int takeOutgoingServices() native "MojoServices_takeOutgoingServices";
|
||||
static int takeShell() native "MojoServices_takeShell";
|
||||
static int takeView() native "MojoServices_takeView";
|
||||
static int takeViewServices() native "MojoServices_takeViewServices";
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/// Copyright 2016 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.
|
||||
|
||||
import 'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart';
|
||||
export 'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart';
|
||||
@@ -1,6 +0,0 @@
|
||||
/// Copyright 2016 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.
|
||||
|
||||
import 'package:mojo_services/mojo/ui/view_containers.mojom.dart';
|
||||
export 'package:mojo_services/mojo/ui/view_containers.mojom.dart';
|
||||
@@ -1,6 +0,0 @@
|
||||
/// Copyright 2016 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.
|
||||
|
||||
import 'package:mojo_services/mojo/ui/view_properties.mojom.dart';
|
||||
export 'package:mojo_services/mojo/ui/view_properties.mojom.dart';
|
||||
@@ -1,6 +0,0 @@
|
||||
/// Copyright 2016 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.
|
||||
|
||||
import 'package:mojo_services/mojo/ui/view_provider.mojom.dart';
|
||||
export 'package:mojo_services/mojo/ui/view_provider.mojom.dart';
|
||||
@@ -1,6 +0,0 @@
|
||||
/// Copyright 2016 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.
|
||||
|
||||
import 'package:mojo_services/mojo/ui/view_token.mojom.dart';
|
||||
export 'package:mojo_services/mojo/ui/view_token.mojom.dart';
|
||||
@@ -1,6 +0,0 @@
|
||||
/// Copyright 2016 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.
|
||||
|
||||
import 'package:mojo_services/mojo/ui/views.mojom.dart';
|
||||
export 'package:mojo_services/mojo/ui/views.mojom.dart';
|
||||
Reference in New Issue
Block a user