|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
| 5 | +#define FML_USED_ON_EMBEDDER |
| 6 | + |
5 | 7 | #include "engine.h" |
6 | 8 |
|
7 | 9 | #include <lib/async/cpp/task.h> |
|
19 | 21 | #include "fuchsia_intl.h" |
20 | 22 | #include "platform_view.h" |
21 | 23 | #include "runtime/dart/utils/files.h" |
22 | | -#include "task_runner_adapter.h" |
23 | 24 | #include "third_party/skia/include/ports/SkFontMgr_fuchsia.h" |
24 | | -#include "thread.h" |
25 | 25 |
|
26 | 26 | namespace flutter_runner { |
27 | 27 |
|
@@ -60,19 +60,17 @@ Engine::Engine(Delegate& delegate, |
60 | 60 | fidl::InterfaceRequest<fuchsia::io::Directory> directory_request) |
61 | 61 | : delegate_(delegate), |
62 | 62 | thread_label_(std::move(thread_label)), |
| 63 | + thread_host_(thread_label_ + ".", |
| 64 | + flutter::ThreadHost::Type::IO | |
| 65 | + flutter::ThreadHost::Type::UI | |
| 66 | + flutter::ThreadHost::Type::GPU), |
63 | 67 | settings_(std::move(settings)), |
64 | 68 | weak_factory_(this) { |
65 | 69 | if (zx::event::create(0, &vsync_event_) != ZX_OK) { |
66 | 70 | FML_DLOG(ERROR) << "Could not create the vsync event."; |
67 | 71 | return; |
68 | 72 | } |
69 | 73 |
|
70 | | - // Launch the threads that will be used to run the shell. These threads will |
71 | | - // be joined in the destructor. |
72 | | - for (auto& thread : threads_) { |
73 | | - thread.reset(new Thread()); |
74 | | - } |
75 | | - |
76 | 74 | // Set up the session connection. |
77 | 75 | auto scenic = svc->Connect<fuchsia::ui::scenic::Scenic>(); |
78 | 76 | fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session; |
@@ -172,12 +170,14 @@ Engine::Engine(Delegate& delegate, |
172 | 170 |
|
173 | 171 | // Get the task runners from the managed threads. The current thread will be |
174 | 172 | // used as the "platform" thread. |
| 173 | + fml::MessageLoop::EnsureInitializedForCurrentThread(); |
| 174 | + |
175 | 175 | const flutter::TaskRunners task_runners( |
176 | | - thread_label_, // Dart thread labels |
177 | | - CreateFMLTaskRunner(async_get_default_dispatcher()), // platform |
178 | | - CreateFMLTaskRunner(threads_[0]->dispatcher()), // gpu |
179 | | - CreateFMLTaskRunner(threads_[1]->dispatcher()), // ui |
180 | | - CreateFMLTaskRunner(threads_[2]->dispatcher()) // io |
| 176 | + thread_label_, // Dart thread labels |
| 177 | + fml::MessageLoop::GetCurrent().GetTaskRunner(), // platform |
| 178 | + thread_host_.gpu_thread->GetTaskRunner(), // gpu |
| 179 | + thread_host_.ui_thread->GetTaskRunner(), // ui |
| 180 | + thread_host_.io_thread->GetTaskRunner() // io |
181 | 181 | ); |
182 | 182 |
|
183 | 183 | // Setup the callback that will instantiate the rasterizer. |
@@ -359,12 +359,6 @@ Engine::Engine(Delegate& delegate, |
359 | 359 |
|
360 | 360 | Engine::~Engine() { |
361 | 361 | shell_.reset(); |
362 | | - for (const auto& thread : threads_) { |
363 | | - thread->Quit(); |
364 | | - } |
365 | | - for (const auto& thread : threads_) { |
366 | | - thread->Join(); |
367 | | - } |
368 | 362 | } |
369 | 363 |
|
370 | 364 | std::pair<bool, uint32_t> Engine::GetEngineReturnCode() const { |
|
0 commit comments