sky/shell should link with sky/engine
This CL causes sky/shell to create a blink::WebView to show that sky/shell links with sky/engine. In the process, I've made it easier to be a trivial embedder of sky/engine by removing the requirement to implement blink::ServiceProvider. This CL also causes sky/shell to link with mojo/edk/system to resolve link errors with Mojo fabric (e.g., MojoClose, MojoWriteMessage, etc). To make this work properly, we'll need to initialize the EDK in a future CL. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/873923003
This commit is contained in:
@@ -29,6 +29,10 @@ shared_library("sky_shell") {
|
||||
"gpu/ganesh_surface.h",
|
||||
"gpu/rasterizer.cc",
|
||||
"gpu/rasterizer.h",
|
||||
"ui/engine.cc",
|
||||
"ui/engine.h",
|
||||
"ui/platform_impl.cc",
|
||||
"ui/platform_impl.h",
|
||||
"library_loader.cc",
|
||||
"shell.cc",
|
||||
"shell.h",
|
||||
@@ -38,12 +42,13 @@ shared_library("sky_shell") {
|
||||
"sky_view.h",
|
||||
]
|
||||
|
||||
configs += [ "//third_party/khronos:khronos_headers" ]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//base:i18n",
|
||||
"//build/config/sanitizers:deps",
|
||||
"//mojo/edk/system",
|
||||
"//skia",
|
||||
"//sky/engine",
|
||||
"//ui/gfx/geometry",
|
||||
"//ui/gl",
|
||||
":jni_headers",
|
||||
|
||||
@@ -24,6 +24,13 @@ void Shell::Init() {
|
||||
gpu_thread_->Start();
|
||||
rasterizer_.reset(new Rasterizer());
|
||||
|
||||
ui_thread_.reset(new base::Thread("ui_thread"));
|
||||
ui_thread_->Start();
|
||||
engine_.reset(new Engine());
|
||||
|
||||
ui_thread_->message_loop()->PostTask(
|
||||
FROM_HERE, base::Bind(&Engine::Init, engine_->GetWeakPtr()));
|
||||
|
||||
view_.reset(new SkyView(this));
|
||||
view_->Init();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "sky/shell/gpu/rasterizer.h"
|
||||
#include "sky/shell/sky_view.h"
|
||||
#include "sky/shell/ui/engine.h"
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
@@ -33,9 +34,11 @@ class Shell : public SkyView::Delegate {
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner_;
|
||||
scoped_ptr<base::Thread> gpu_thread_;
|
||||
scoped_ptr<base::Thread> ui_thread_;
|
||||
|
||||
scoped_ptr<SkyView> view_;
|
||||
scoped_ptr<Rasterizer> rasterizer_;
|
||||
scoped_ptr<Engine> engine_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Shell);
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "base/at_exit.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
@@ -63,6 +64,7 @@ static void Init(JNIEnv* env,
|
||||
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
|
||||
base::MessageLoopForUI::current()->Start();
|
||||
|
||||
base::i18n::InitializeICU();
|
||||
gfx::GLSurface::InitializeOneOff();
|
||||
|
||||
g_shell.Get().reset(new Shell(g_java_message_loop.Get()->task_runner()));
|
||||
|
||||
36
engine/src/flutter/shell/ui/engine.cc
Normal file
36
engine/src/flutter/shell/ui/engine.cc
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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/ui/engine.h"
|
||||
|
||||
#include "sky/engine/public/web/Sky.h"
|
||||
#include "sky/engine/public/web/WebLocalFrame.h"
|
||||
#include "sky/engine/public/web/WebView.h"
|
||||
#include "sky/shell/ui/platform_impl.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
Engine::Engine() : web_view_(nullptr), weak_factory_(this) {
|
||||
}
|
||||
|
||||
Engine::~Engine() {
|
||||
if (web_view_)
|
||||
web_view_->close();
|
||||
}
|
||||
|
||||
base::WeakPtr<Engine> Engine::GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
void Engine::Init() {
|
||||
platform_impl_.reset(new PlatformImpl);
|
||||
blink::initialize(platform_impl_.get());
|
||||
|
||||
web_view_ = blink::WebView::create(this);
|
||||
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
40
engine/src/flutter/shell/ui/engine.h
Normal file
40
engine/src/flutter/shell/ui/engine.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_SHELL_UI_ENGINE_H_
|
||||
#define SKY_SHELL_UI_ENGINE_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "sky/engine/public/web/WebFrameClient.h"
|
||||
#include "sky/engine/public/web/WebViewClient.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
class PlatformImpl;
|
||||
|
||||
class Engine : public blink::WebFrameClient,
|
||||
public blink::WebViewClient {
|
||||
public:
|
||||
Engine();
|
||||
~Engine() override;
|
||||
|
||||
base::WeakPtr<Engine> GetWeakPtr();
|
||||
|
||||
void Init();
|
||||
|
||||
private:
|
||||
scoped_ptr<PlatformImpl> platform_impl_;
|
||||
blink::WebView* web_view_;
|
||||
|
||||
base::WeakPtrFactory<Engine> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Engine);
|
||||
};
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_UI_ENGINE_H_
|
||||
26
engine/src/flutter/shell/ui/platform_impl.cc
Normal file
26
engine/src/flutter/shell/ui/platform_impl.cc
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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/ui/platform_impl.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
PlatformImpl::PlatformImpl()
|
||||
: main_thread_task_runner_(base::MessageLoop::current()->task_runner()) {
|
||||
}
|
||||
|
||||
PlatformImpl::~PlatformImpl() {
|
||||
}
|
||||
|
||||
blink::WebString PlatformImpl::defaultLocale() {
|
||||
return blink::WebString::fromUTF8("en-US");
|
||||
}
|
||||
|
||||
base::SingleThreadTaskRunner* PlatformImpl::mainThreadTaskRunner() {
|
||||
return main_thread_task_runner_.get();
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
32
engine/src/flutter/shell/ui/platform_impl.h
Normal file
32
engine/src/flutter/shell/ui/platform_impl.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_SHELL_UI_PLATFORM_IMPL_H_
|
||||
#define SKY_SHELL_UI_PLATFORM_IMPL_H_
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "sky/engine/public/platform/Platform.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
class PlatformImpl : public blink::Platform {
|
||||
public:
|
||||
PlatformImpl();
|
||||
~PlatformImpl() override;
|
||||
|
||||
// blink::Platform:
|
||||
blink::WebString defaultLocale() override;
|
||||
base::SingleThreadTaskRunner* mainThreadTaskRunner() override;
|
||||
|
||||
private:
|
||||
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
|
||||
};
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_UI_PLATFORM_IMPL_H_
|
||||
Reference in New Issue
Block a user