mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
11f482978c
Previously, we weren't scheduling a visual update when our surface was created, so we'd just continue to show black until the author requested a new animation frame. After this CL, we schedule a visual update as soon as our surface is created. As part of this change, I've removed knowledge of the GPU delegate from PlatformView. Now, all the calls from PlatformView to the GPU system bounce through the UI delegate, which serializes the commands with other commands from the UI engine to the GPU rasterizer. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/974483004
85 lines
2.3 KiB
C++
85 lines
2.3 KiB
C++
// 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/shell.h"
|
|
|
|
#include "base/bind.h"
|
|
#include "base/single_thread_task_runner.h"
|
|
#include "mojo/common/message_pump_mojo.h"
|
|
#include "mojo/edk/embedder/embedder.h"
|
|
#include "mojo/edk/embedder/simple_platform_support.h"
|
|
#include "sky/shell/gpu/rasterizer.h"
|
|
#include "sky/shell/java_service_provider.h"
|
|
#include "sky/shell/platform_view.h"
|
|
#include "sky/shell/ui/engine.h"
|
|
|
|
namespace sky {
|
|
namespace shell {
|
|
namespace {
|
|
|
|
static Shell* g_shell = nullptr;
|
|
|
|
scoped_ptr<base::MessagePump> CreateMessagePumpMojo() {
|
|
return make_scoped_ptr(new mojo::common::MessagePumpMojo);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
Shell::Shell(scoped_refptr<base::SingleThreadTaskRunner> java_task_runner)
|
|
: java_task_runner_(java_task_runner) {
|
|
DCHECK(!g_shell);
|
|
mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
|
|
new mojo::embedder::SimplePlatformSupport()));
|
|
|
|
base::Thread::Options options;
|
|
options.message_pump_factory = base::Bind(&CreateMessagePumpMojo);
|
|
|
|
InitGPU(options);
|
|
InitUI(options);
|
|
InitView();
|
|
}
|
|
|
|
Shell::~Shell() {
|
|
}
|
|
|
|
void Shell::Init(scoped_refptr<base::SingleThreadTaskRunner> java_task_runner) {
|
|
g_shell = new Shell(java_task_runner);
|
|
}
|
|
|
|
Shell& Shell::Shared() {
|
|
DCHECK(g_shell);
|
|
return *g_shell;
|
|
}
|
|
|
|
void Shell::InitGPU(const base::Thread::Options& options) {
|
|
gpu_thread_.reset(new base::Thread("gpu_thread"));
|
|
gpu_thread_->StartWithOptions(options);
|
|
|
|
rasterizer_.reset(new Rasterizer());
|
|
}
|
|
|
|
void Shell::InitUI(const base::Thread::Options& options) {
|
|
ui_thread_.reset(new base::Thread("ui_thread"));
|
|
ui_thread_->StartWithOptions(options);
|
|
|
|
Engine::Config config;
|
|
config.java_task_runner = java_task_runner_;
|
|
config.gpu_task_runner = gpu_thread_->message_loop()->task_runner();
|
|
config.gpu_delegate = rasterizer_->GetWeakPtr();
|
|
engine_.reset(new Engine(config));
|
|
|
|
ui_thread_->message_loop()->PostTask(
|
|
FROM_HERE, base::Bind(&Engine::Init, engine_->GetWeakPtr()));
|
|
}
|
|
|
|
void Shell::InitView() {
|
|
PlatformView::Config config;
|
|
config.ui_task_runner = ui_thread_->message_loop()->task_runner();
|
|
config.ui_delegate = engine_->GetWeakPtr();
|
|
view_.reset(new PlatformView(config));
|
|
}
|
|
|
|
} // namespace shell
|
|
} // namespace sky
|