|
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>
|
|
18 | 20 | #include "fuchsia_intl.h"
|
19 | 21 | #include "platform_view.h"
|
20 | 22 | #include "runtime/dart/utils/files.h"
|
21 |
| -#include "task_runner_adapter.h" |
22 | 23 | #include "third_party/skia/include/ports/SkFontMgr_fuchsia.h"
|
23 |
| -#include "thread.h" |
24 | 24 |
|
25 | 25 | namespace flutter_runner {
|
26 | 26 |
|
@@ -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;
|
@@ -167,12 +165,14 @@ Engine::Engine(Delegate& delegate,
|
167 | 165 |
|
168 | 166 | // Get the task runners from the managed threads. The current thread will be
|
169 | 167 | // used as the "platform" thread.
|
| 168 | + fml::MessageLoop::EnsureInitializedForCurrentThread(); |
| 169 | + |
170 | 170 | const flutter::TaskRunners task_runners(
|
171 |
| - thread_label_, // Dart thread labels |
172 |
| - CreateFMLTaskRunner(async_get_default_dispatcher()), // platform |
173 |
| - CreateFMLTaskRunner(threads_[0]->dispatcher()), // gpu |
174 |
| - CreateFMLTaskRunner(threads_[1]->dispatcher()), // ui |
175 |
| - CreateFMLTaskRunner(threads_[2]->dispatcher()) // io |
| 171 | + thread_label_, // Dart thread labels |
| 172 | + fml::MessageLoop::GetCurrent().GetTaskRunner(), // platform |
| 173 | + thread_host_.gpu_thread->GetTaskRunner(), // gpu |
| 174 | + thread_host_.ui_thread->GetTaskRunner(), // ui |
| 175 | + thread_host_.io_thread->GetTaskRunner() // io |
176 | 176 | );
|
177 | 177 |
|
178 | 178 | // Setup the callback that will instantiate the rasterizer.
|
@@ -353,12 +353,6 @@ Engine::Engine(Delegate& delegate,
|
353 | 353 |
|
354 | 354 | Engine::~Engine() {
|
355 | 355 | shell_.reset();
|
356 |
| - for (const auto& thread : threads_) { |
357 |
| - thread->Quit(); |
358 |
| - } |
359 |
| - for (const auto& thread : threads_) { |
360 |
| - thread->Join(); |
361 |
| - } |
362 | 356 | }
|
363 | 357 |
|
364 | 358 | std::pair<bool, uint32_t> Engine::GetEngineReturnCode() const {
|
|
0 commit comments