This commit is contained in:
Dan Field 2019-12-20 15:55:02 -08:00 committed by GitHub
parent 7c5abdaa50
commit 159a0bc76f
10 changed files with 35 additions and 44 deletions

View File

@ -11,6 +11,7 @@
#include <lib/async/default.h>
#include <lib/fdio/directory.h>
#include <lib/fdio/namespace.h>
#include <lib/ui/scenic/cpp/view_ref_pair.h>
#include <lib/ui/scenic/cpp/view_token_pair.h>
#include <lib/vfs/cpp/composed_service_dir.h>
#include <lib/vfs/cpp/remote_dir.h>
@ -604,17 +605,6 @@ void Application::CreateView(
return;
}
// TODO(MI4-2490): remove once ViewRefControl and ViewRef come as a parameters
// to CreateView
fuchsia::ui::views::ViewRefControl view_ref_control;
fuchsia::ui::views::ViewRef view_ref;
zx_status_t status = zx::eventpair::create(
/*flags*/ 0u, &view_ref_control.reference, &view_ref.reference);
FML_DCHECK(status == ZX_OK);
status = view_ref.reference.replace(ZX_RIGHTS_BASIC, &view_ref.reference);
FML_DCHECK(status == ZX_OK);
shell_holders_.emplace(std::make_unique<Engine>(
*this, // delegate
debug_label_, // thread label
@ -623,8 +613,7 @@ void Application::CreateView(
settings_, // settings
std::move(isolate_snapshot_), // isolate snapshot
scenic::ToViewToken(std::move(view_token)), // view token
std::move(view_ref_control), // view ref control
std::move(view_ref), // view ref
scenic::ViewRefPair::New(), // view ref pair
std::move(fdio_ns_), // FDIO namespace
std::move(directory_request_) // outgoing request
));

View File

@ -63,12 +63,14 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
CompositorContext::CompositorContext(
std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
scenic::ViewRefPair view_ref_pair,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle)
: debug_label_(std::move(debug_label)),
session_connection_(debug_label_,
std::move(view_token),
std::move(view_ref_pair),
std::move(session),
session_error_callback,
vsync_event_handle) {}

View File

@ -8,6 +8,7 @@
#include <fuchsia/ui/scenic/cpp/fidl.h>
#include <fuchsia/ui/views/cpp/fidl.h>
#include <lib/fit/function.h>
#include <lib/ui/scenic/cpp/view_ref_pair.h>
#include "flutter/flow/compositor_context.h"
#include "flutter/flow/embedded_views.h"
@ -22,6 +23,7 @@ class CompositorContext final : public flutter::CompositorContext {
public:
CompositorContext(std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
scenic::ViewRefPair view_ref_pair,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle);
@ -36,6 +38,7 @@ class CompositorContext final : public flutter::CompositorContext {
private:
const std::string debug_label_;
scenic::ViewRefPair view_ref_pair_;
SessionConnection session_connection_;
// |flutter::CompositorContext|

View File

@ -55,8 +55,7 @@ Engine::Engine(Delegate& delegate,
flutter::Settings settings,
fml::RefPtr<const flutter::DartSnapshot> isolate_snapshot,
fuchsia::ui::views::ViewToken view_token,
fuchsia::ui::views::ViewRefControl view_ref_control,
fuchsia::ui::views::ViewRef view_ref,
scenic::ViewRefPair view_ref_pair,
UniqueFDIONS fdio_ns,
fidl::InterfaceRequest<fuchsia::io::Directory> directory_request)
: delegate_(delegate),
@ -114,12 +113,14 @@ Engine::Engine(Delegate& delegate,
});
};
fuchsia::ui::views::ViewRef view_ref;
view_ref_pair.view_ref.Clone(&view_ref);
// Setup the callback that will instantiate the platform view.
flutter::Shell::CreateCallback<flutter::PlatformView>
on_create_platform_view = fml::MakeCopyable(
[debug_label = thread_label_,
view_ref_control = std::move(view_ref_control),
view_ref = std::move(view_ref), runner_services,
[debug_label = thread_label_, view_ref = std::move(view_ref),
runner_services,
parent_environment_service_provider =
std::move(parent_environment_service_provider),
session_listener_request = std::move(session_listener_request),
@ -133,11 +134,10 @@ Engine::Engine(Delegate& delegate,
std::move(on_enable_wireframe_callback),
vsync_handle = vsync_event_.get()](flutter::Shell& shell) mutable {
return std::make_unique<flutter_runner::PlatformView>(
shell, // delegate
debug_label, // debug label
std::move(view_ref_control), // view control ref
std::move(view_ref), // view ref
shell.GetTaskRunners(), // task runners
shell, // delegate
debug_label, // debug label
std::move(view_ref), // view ref
shell.GetTaskRunners(), // task runners
std::move(runner_services),
std::move(parent_environment_service_provider), // services
std::move(session_listener_request), // session listener
@ -177,11 +177,12 @@ Engine::Engine(Delegate& delegate,
// Setup the callback that will instantiate the rasterizer.
flutter::Shell::CreateCallback<flutter::Rasterizer> on_create_rasterizer =
fml::MakeCopyable([thread_label = thread_label_, //
view_token = std::move(view_token), //
session = std::move(session), //
on_session_error_callback, //
vsync_event = vsync_event_.get() //
fml::MakeCopyable([thread_label = thread_label_, //
view_token = std::move(view_token), //
view_ref_pair = std::move(view_ref_pair), //
session = std::move(session), //
on_session_error_callback, //
vsync_event = vsync_event_.get() //
](flutter::Shell& shell) mutable {
std::unique_ptr<flutter_runner::CompositorContext> compositor_context;
{
@ -190,7 +191,8 @@ Engine::Engine(Delegate& delegate,
std::make_unique<flutter_runner::CompositorContext>(
thread_label, // debug label
std::move(view_token), // scenic view we attach our tree to
std::move(session), // scenic session
std::move(view_ref_pair), // scenic view ref/view ref control
std::move(session), // scenic session
on_session_error_callback, // session did encounter error
vsync_event // vsync event handle
);

View File

@ -11,6 +11,7 @@
#include <fuchsia/ui/views/cpp/fidl.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/sys/cpp/service_directory.h>
#include <lib/ui/scenic/cpp/view_ref_pair.h>
#include <lib/zx/event.h>
#include "flutter/fml/macros.h"
@ -36,8 +37,7 @@ class Engine final {
flutter::Settings settings,
fml::RefPtr<const flutter::DartSnapshot> isolate_snapshot,
fuchsia::ui::views::ViewToken view_token,
fuchsia::ui::views::ViewRefControl view_ref_control,
fuchsia::ui::views::ViewRef view_ref,
scenic::ViewRefPair view_ref_pair,
UniqueFDIONS fdio_ns,
fidl::InterfaceRequest<fuchsia::io::Directory> directory_request);
~Engine();

View File

@ -80,7 +80,6 @@ void SetInterfaceErrorHandler(fidl::Binding<T>& binding, std::string name) {
PlatformView::PlatformView(
flutter::PlatformView::Delegate& delegate,
std::string debug_label,
fuchsia::ui::views::ViewRefControl view_ref_control,
fuchsia::ui::views::ViewRef view_ref,
flutter::TaskRunners task_runners,
std::shared_ptr<sys::ServiceDirectory> runner_services,
@ -95,7 +94,6 @@ PlatformView::PlatformView(
zx_handle_t vsync_event_handle)
: flutter::PlatformView(delegate, std::move(task_runners)),
debug_label_(std::move(debug_label)),
view_ref_control_(std::move(view_ref_control)),
view_ref_(std::move(view_ref)),
session_listener_binding_(this, std::move(session_listener_request)),
session_listener_error_callback_(

View File

@ -42,7 +42,6 @@ class PlatformView final : public flutter::PlatformView,
public:
PlatformView(flutter::PlatformView::Delegate& delegate,
std::string debug_label,
fuchsia::ui::views::ViewRefControl view_ref_control,
fuchsia::ui::views::ViewRef view_ref,
flutter::TaskRunners task_runners,
std::shared_ptr<sys::ServiceDirectory> runner_services,
@ -77,7 +76,6 @@ class PlatformView final : public flutter::PlatformView,
const std::string debug_label_;
// TODO(MI4-2490): remove once ViewRefControl is passed to Scenic and kept
// alive there
const fuchsia::ui::views::ViewRefControl view_ref_control_;
const fuchsia::ui::views::ViewRef view_ref_;
std::unique_ptr<AccessibilityBridge> accessibility_bridge_;

View File

@ -92,9 +92,6 @@ TEST_F(PlatformViewTests, ChangesAccessibilitySettings) {
auto view_ref = fuchsia::ui::views::ViewRef({
.reference = std::move(a),
});
auto view_ref_control = fuchsia::ui::views::ViewRefControl({
.reference = std::move(b),
});
flutter::TaskRunners task_runners =
flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
@ -104,7 +101,6 @@ TEST_F(PlatformViewTests, ChangesAccessibilitySettings) {
auto platform_view = flutter_runner::PlatformView(
delegate, // delegate
"test_platform_view", // label
std::move(view_ref_control), // view_ref_control
std::move(view_ref), // view_ref
std::move(task_runners), // task_runners
services_provider.service_directory(), // runner_services
@ -143,9 +139,6 @@ TEST_F(PlatformViewTests, EnableWireframeTest) {
auto view_ref = fuchsia::ui::views::ViewRef({
.reference = std::move(a),
});
auto view_ref_control = fuchsia::ui::views::ViewRefControl({
.reference = std::move(b),
});
flutter::TaskRunners task_runners =
flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
@ -160,7 +153,6 @@ TEST_F(PlatformViewTests, EnableWireframeTest) {
auto platform_view = flutter_runner::PlatformView(
delegate, // delegate
"test_platform_view", // label
std::move(view_ref_control), // view_ref_control
std::move(view_ref), // view_refs
std::move(task_runners), // task_runners
services_provider.service_directory(), // runner_services

View File

@ -15,12 +15,17 @@ namespace flutter_runner {
SessionConnection::SessionConnection(
std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
scenic::ViewRefPair view_ref_pair,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle)
: debug_label_(std::move(debug_label)),
session_wrapper_(session.Bind(), nullptr),
root_view_(&session_wrapper_, std::move(view_token.value), debug_label),
root_view_(&session_wrapper_,
std::move(view_token),
std::move(view_ref_pair.control_ref),
std::move(view_ref_pair.view_ref),
debug_label),
root_node_(&session_wrapper_),
surface_producer_(
std::make_unique<VulkanSurfaceProducer>(&session_wrapper_)),

View File

@ -13,6 +13,7 @@
#include <lib/fit/function.h>
#include <lib/ui/scenic/cpp/resources.h>
#include <lib/ui/scenic/cpp/session.h>
#include <lib/ui/scenic/cpp/view_ref_pair.h>
#include "flutter/flow/compositor_context.h"
#include "flutter/flow/scene_update_context.h"
@ -29,6 +30,7 @@ class SessionConnection final {
public:
SessionConnection(std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
scenic::ViewRefPair view_ref_pair,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle);