| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/shell/shell_view.h" | 5 #include "sky/shell/shell_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "sky/shell/gpu/rasterizer.h" | 9 #include "sky/shell/gpu/rasterizer.h" |
| 10 #include "sky/shell/platform_view.h" | 10 #include "sky/shell/platform_view.h" |
| 11 #include "sky/shell/shell.h" | 11 #include "sky/shell/shell.h" |
| 12 #include "sky/shell/ui/engine.h" | 12 #include "sky/shell/ui/engine.h" |
| 13 | 13 |
| 14 namespace sky { | 14 namespace sky { |
| 15 namespace shell { | 15 namespace shell { |
| 16 namespace { |
| 17 |
| 18 template<typename T> |
| 19 void Drop(scoped_ptr<T> ptr) { } |
| 20 |
| 21 } // namespace |
| 16 | 22 |
| 17 ShellView::ShellView(Shell& shell) | 23 ShellView::ShellView(Shell& shell) |
| 18 : shell_(shell) { | 24 : shell_(shell) { |
| 19 rasterizer_.reset(new Rasterizer()); | 25 rasterizer_.reset(new Rasterizer()); |
| 20 CreateEngine(); | 26 CreateEngine(); |
| 21 CreatePlatformView(); | 27 CreatePlatformView(); |
| 22 } | 28 } |
| 23 | 29 |
| 24 ShellView::~ShellView() { | 30 ShellView::~ShellView() { |
| 31 shell_.gpu_task_runner()->PostTask(FROM_HERE, |
| 32 base::Bind(&Drop<Rasterizer>, base::Passed(&rasterizer_))); |
| 33 shell_.ui_task_runner()->PostTask(FROM_HERE, |
| 34 base::Bind(&Drop<Engine>, base::Passed(&engine_))); |
| 25 } | 35 } |
| 26 | 36 |
| 27 void ShellView::CreateEngine() { | 37 void ShellView::CreateEngine() { |
| 28 Engine::Config config; | 38 Engine::Config config; |
| 29 config.service_provider_context = shell_.service_provider_context(); | 39 config.service_provider_context = shell_.service_provider_context(); |
| 30 config.gpu_task_runner = shell_.gpu_task_runner(); | 40 config.gpu_task_runner = shell_.gpu_task_runner(); |
| 31 config.gpu_delegate = rasterizer_->GetWeakPtr(); | 41 config.gpu_delegate = rasterizer_->GetWeakPtr(); |
| 32 engine_.reset(new Engine(config)); | 42 engine_.reset(new Engine(config)); |
| 33 } | 43 } |
| 34 | 44 |
| 35 void ShellView::CreatePlatformView() { | 45 void ShellView::CreatePlatformView() { |
| 36 PlatformView::Config config; | 46 PlatformView::Config config; |
| 37 config.ui_task_runner = shell_.ui_task_runner(); | 47 config.ui_task_runner = shell_.ui_task_runner(); |
| 38 config.ui_delegate = engine_->GetWeakPtr(); | 48 config.ui_delegate = engine_->GetWeakPtr(); |
| 39 view_.reset(PlatformView::Create(config)); | 49 view_.reset(PlatformView::Create(config)); |
| 40 } | 50 } |
| 41 | 51 |
| 42 } // namespace shell | 52 } // namespace shell |
| 43 } // namespace sky | 53 } // namespace sky |
| OLD | NEW |