From c444157614bc161382cb7f9d1ba950e1dc299cd0 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 23 Jun 2015 14:17:02 -0700 Subject: [PATCH] Port sky_shell to Linux for testing This CL makes it possible to build sky_shell on Linux. It doesn't do much, but it doesn't crash on startup. The goal is to evetually be able to test sky_shell on the bots and to be able to run the test_sky on Mac. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1202323002. --- engine/src/flutter/BUILD.gn | 4 ++ engine/src/flutter/shell/BUILD.gn | 13 +++++ engine/src/flutter/shell/gpu/rasterizer.h | 2 +- engine/src/flutter/shell/linux/main.cc | 49 +++++++++++++++++++ .../linux/platform_service_provider_linux.cc | 22 +++++++++ .../shell/linux/platform_view_linux.cc | 15 ++++++ engine/src/flutter/shell/platform_view.cc | 6 +++ engine/src/flutter/shell/platform_view.h | 3 ++ engine/src/flutter/shell/service_provider.cc | 20 ++++++++ engine/src/flutter/shell/service_provider.h | 4 +- engine/src/flutter/shell/ui/engine.cc | 6 +++ engine/src/flutter/shell/ui/engine.h | 3 ++ engine/src/flutter/shell/ui/internals.h | 2 +- 13 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 engine/src/flutter/shell/linux/main.cc create mode 100644 engine/src/flutter/shell/linux/platform_service_provider_linux.cc create mode 100644 engine/src/flutter/shell/linux/platform_view_linux.cc create mode 100644 engine/src/flutter/shell/service_provider.cc diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index f1fcc7a77a..05c39d444e 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -46,4 +46,8 @@ group("sky_apk") { "//sky/services/intents", ] } + + if (is_linux) { + deps += [ "//sky/shell" ] + } } diff --git a/engine/src/flutter/shell/BUILD.gn b/engine/src/flutter/shell/BUILD.gn index 0299d77428..b28c8f8bdf 100644 --- a/engine/src/flutter/shell/BUILD.gn +++ b/engine/src/flutter/shell/BUILD.gn @@ -37,6 +37,7 @@ source_set("common") { "gpu_delegate.h", "platform_view.cc", "platform_view.h", + "service_provider.cc", "service_provider.h", "shell.cc", "shell.h", @@ -169,6 +170,18 @@ if (is_android) { ":sky_resources", ] } +} else if (is_linux) { + executable("shell") { + output_name = "sky_shell" + + sources = [ + "linux/main.cc", + "linux/platform_service_provider_linux.cc", + "linux/platform_view_linux.cc", + ] + + deps = common_deps + [ ":common" ] + } } else { assert(false, "Unsupported platform") } diff --git a/engine/src/flutter/shell/gpu/rasterizer.h b/engine/src/flutter/shell/gpu/rasterizer.h index 8478914379..a0aec6e6e4 100644 --- a/engine/src/flutter/shell/gpu/rasterizer.h +++ b/engine/src/flutter/shell/gpu/rasterizer.h @@ -28,7 +28,7 @@ class GaneshSurface; class Rasterizer : public GPUDelegate { public: explicit Rasterizer(); - ~Rasterizer(); + ~Rasterizer() override; base::WeakPtr GetWeakPtr(); diff --git a/engine/src/flutter/shell/linux/main.cc b/engine/src/flutter/shell/linux/main.cc new file mode 100644 index 0000000000..a6b021bd7b --- /dev/null +++ b/engine/src/flutter/shell/linux/main.cc @@ -0,0 +1,49 @@ +// Copyright 2015 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 "base/at_exit.h" +#include "base/basictypes.h" +#include "base/bind.h" +#include "base/command_line.h" +#include "base/i18n/icu_util.h" +#include "base/logging.h" +#include "base/message_loop/message_loop.h" +#include "sky/shell/platform_view.h" +#include "sky/shell/service_provider.h" +#include "sky/shell/shell.h" +#include "sky/shell/shell_view.h" + +namespace sky { +namespace shell { + +void Init() { + Shell::Init(make_scoped_ptr(new ServiceProviderContext( + base::MessageLoop::current()->task_runner()))); + + // TODO(abarth): Currently we leak the ShellView. + ShellView* shell_view = new ShellView(Shell::Shared()); + + ViewportObserverPtr viewport_observer; + shell_view->view()->ConnectToViewportObserver(GetProxy(&viewport_observer)); + + // TODO(abarth): At this point we should load some content into the view. + // viewport_observer->LoadURL("https://domokit.github.io/home.dart"); +} + +} // namespace shell +} // namespace sky + +int main(int argc, const char* argv[]) { + base::AtExitManager exit_manager; + base::CommandLine::Init(argc, argv); + + base::MessageLoop message_loop; + + base::i18n::InitializeICU(); + + message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); + message_loop.Run(); + + return 0; +} diff --git a/engine/src/flutter/shell/linux/platform_service_provider_linux.cc b/engine/src/flutter/shell/linux/platform_service_provider_linux.cc new file mode 100644 index 0000000000..e0199163d6 --- /dev/null +++ b/engine/src/flutter/shell/linux/platform_service_provider_linux.cc @@ -0,0 +1,22 @@ +// Copyright 2015 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 "base/bind.h" +#include "base/trace_event/trace_event.h" +#include "mojo/public/cpp/bindings/interface_request.h" +#include "sky/shell/service_provider.h" + +namespace sky { +namespace shell { + +mojo::ServiceProviderPtr CreateServiceProvider( + ServiceProviderContext* context) { + mojo::MessagePipe pipe; + // TODO(abarth): Wire pipe.handle1 up to something. + return mojo::MakeProxy( + mojo::InterfacePtrInfo(pipe.handle0.Pass(), 0u)); +} + +} // namespace shell +} // namespace sky diff --git a/engine/src/flutter/shell/linux/platform_view_linux.cc b/engine/src/flutter/shell/linux/platform_view_linux.cc new file mode 100644 index 0000000000..73fee52ab7 --- /dev/null +++ b/engine/src/flutter/shell/linux/platform_view_linux.cc @@ -0,0 +1,15 @@ +// Copyright 2015 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 "sky/shell/platform_view.h" + +namespace sky { +namespace shell { + +PlatformView* PlatformView::Create(const Config& config) { + return new PlatformView(config); +} + +} // namespace shell +} // namespace sky diff --git a/engine/src/flutter/shell/platform_view.cc b/engine/src/flutter/shell/platform_view.cc index 4050aed310..0a6431dc5e 100644 --- a/engine/src/flutter/shell/platform_view.cc +++ b/engine/src/flutter/shell/platform_view.cc @@ -11,6 +11,12 @@ namespace sky { namespace shell { +PlatformView::Config::Config() { +} + +PlatformView::Config::~Config() { +} + PlatformView::PlatformView(const PlatformView::Config& config) : config_(config), window_(0) { } diff --git a/engine/src/flutter/shell/platform_view.h b/engine/src/flutter/shell/platform_view.h index 4fb3618cc5..b09980edf9 100644 --- a/engine/src/flutter/shell/platform_view.h +++ b/engine/src/flutter/shell/platform_view.h @@ -15,6 +15,9 @@ namespace shell { class PlatformView { public: struct Config { + Config(); + ~Config(); + base::WeakPtr ui_delegate; scoped_refptr ui_task_runner; }; diff --git a/engine/src/flutter/shell/service_provider.cc b/engine/src/flutter/shell/service_provider.cc new file mode 100644 index 0000000000..3b2b9ad187 --- /dev/null +++ b/engine/src/flutter/shell/service_provider.cc @@ -0,0 +1,20 @@ +// Copyright 2015 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 "sky/shell/service_provider.h" + +#include "base/single_thread_task_runner.h" + +namespace sky { +namespace shell { + +ServiceProviderContext::ServiceProviderContext( + scoped_refptr runner) + : platform_task_runner(runner.Pass()) {} + +ServiceProviderContext::~ServiceProviderContext() { +} + +} // namespace shell +} // namespace sky diff --git a/engine/src/flutter/shell/service_provider.h b/engine/src/flutter/shell/service_provider.h index f7c3818086..cff6b6cb85 100644 --- a/engine/src/flutter/shell/service_provider.h +++ b/engine/src/flutter/shell/service_provider.h @@ -18,8 +18,8 @@ namespace shell { class ServiceProviderContext { public: - ServiceProviderContext(scoped_refptr runner) - : platform_task_runner(runner.Pass()) {} + ServiceProviderContext(scoped_refptr runner); + ~ServiceProviderContext(); scoped_refptr platform_task_runner; }; diff --git a/engine/src/flutter/shell/ui/engine.cc b/engine/src/flutter/shell/ui/engine.cc index edb0ad5227..726f1d3c6e 100644 --- a/engine/src/flutter/shell/ui/engine.cc +++ b/engine/src/flutter/shell/ui/engine.cc @@ -37,6 +37,12 @@ PlatformImpl* g_platform_impl = nullptr; } +Engine::Config::Config() { +} + +Engine::Config::~Config() { +} + Engine::Engine(const Config& config) : config_(config), animator_(new Animator(config, this)), diff --git a/engine/src/flutter/shell/ui/engine.h b/engine/src/flutter/shell/ui/engine.h index d23b8eb809..f11960590e 100644 --- a/engine/src/flutter/shell/ui/engine.h +++ b/engine/src/flutter/shell/ui/engine.h @@ -39,6 +39,9 @@ class Engine : public UIDelegate, public blink::SkyViewClient { public: struct Config { + Config(); + ~Config(); + ServiceProviderContext* service_provider_context; base::WeakPtr gpu_delegate; diff --git a/engine/src/flutter/shell/ui/internals.h b/engine/src/flutter/shell/ui/internals.h index 7077e3e28b..0244f62353 100644 --- a/engine/src/flutter/shell/ui/internals.h +++ b/engine/src/flutter/shell/ui/internals.h @@ -23,7 +23,7 @@ class Internals : public base::SupportsUserData::Data, public mojo::InterfaceFactory { public: - virtual ~Internals(); + ~Internals() override; static void Create(Dart_Isolate isolate, mojo::ServiceProviderPtr platform_service_provider);