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.
This commit is contained in:
Adam Barth
2015-06-23 14:17:02 -07:00
parent 4d6115bed3
commit c444157614
13 changed files with 145 additions and 4 deletions

View File

@@ -46,4 +46,8 @@ group("sky_apk") {
"//sky/services/intents",
]
}
if (is_linux) {
deps += [ "//sky/shell" ]
}
}

View File

@@ -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")
}

View File

@@ -28,7 +28,7 @@ class GaneshSurface;
class Rasterizer : public GPUDelegate {
public:
explicit Rasterizer();
~Rasterizer();
~Rasterizer() override;
base::WeakPtr<Rasterizer> GetWeakPtr();

View File

@@ -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;
}

View File

@@ -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<mojo::ServiceProvider>(pipe.handle0.Pass(), 0u));
}
} // namespace shell
} // namespace sky

View File

@@ -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

View File

@@ -11,6 +11,12 @@
namespace sky {
namespace shell {
PlatformView::Config::Config() {
}
PlatformView::Config::~Config() {
}
PlatformView::PlatformView(const PlatformView::Config& config)
: config_(config), window_(0) {
}

View File

@@ -15,6 +15,9 @@ namespace shell {
class PlatformView {
public:
struct Config {
Config();
~Config();
base::WeakPtr<UIDelegate> ui_delegate;
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner;
};

View File

@@ -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<base::SingleThreadTaskRunner> runner)
: platform_task_runner(runner.Pass()) {}
ServiceProviderContext::~ServiceProviderContext() {
}
} // namespace shell
} // namespace sky

View File

@@ -18,8 +18,8 @@ namespace shell {
class ServiceProviderContext {
public:
ServiceProviderContext(scoped_refptr<base::SingleThreadTaskRunner> runner)
: platform_task_runner(runner.Pass()) {}
ServiceProviderContext(scoped_refptr<base::SingleThreadTaskRunner> runner);
~ServiceProviderContext();
scoped_refptr<base::SingleThreadTaskRunner> platform_task_runner;
};

View File

@@ -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)),

View File

@@ -39,6 +39,9 @@ class Engine : public UIDelegate,
public blink::SkyViewClient {
public:
struct Config {
Config();
~Config();
ServiceProviderContext* service_provider_context;
base::WeakPtr<GPUDelegate> gpu_delegate;

View File

@@ -23,7 +23,7 @@ class Internals
: public base::SupportsUserData::Data,
public mojo::InterfaceFactory<mojo::asset_bundle::AssetUnpacker> {
public:
virtual ~Internals();
~Internals() override;
static void Create(Dart_Isolate isolate,
mojo::ServiceProviderPtr platform_service_provider);