mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This does some long-overdue refactoring of the spaghetti code that grew in the GLFW embedding to begin providing a clearer separation between the engine and the window. It is now possible to register plugins, and run the runloop, on a headless engine, which makes headless mode much more usable. This is useful in some automated testing environments. There is more refactoring that should be done in the future, but this is a good incremental point to stop as the PR is already large, and it provides useful new functionality as-is.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
// Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_GLFW_HEADLESS_EVENT_LOOP_H_
|
|
#define FLUTTER_SHELL_PLATFORM_GLFW_HEADLESS_EVENT_LOOP_H_
|
|
|
|
#include <condition_variable>
|
|
|
|
#include "flutter/shell/platform/glfw/event_loop.h"
|
|
|
|
namespace flutter {
|
|
|
|
// An event loop implementation that only handles Flutter Engine task
|
|
// scheduling.
|
|
class HeadlessEventLoop : public EventLoop {
|
|
public:
|
|
using TaskExpiredCallback = std::function<void(const FlutterTask*)>;
|
|
HeadlessEventLoop(std::thread::id main_thread_id,
|
|
const TaskExpiredCallback& on_task_expired);
|
|
|
|
~HeadlessEventLoop();
|
|
|
|
// Disallow copy.
|
|
HeadlessEventLoop(const HeadlessEventLoop&) = delete;
|
|
HeadlessEventLoop& operator=(const HeadlessEventLoop&) = delete;
|
|
|
|
private:
|
|
// |EventLoop|
|
|
void WaitUntil(const TaskTimePoint& time) override;
|
|
|
|
// |EventLoop|
|
|
void Wake() override;
|
|
|
|
std::condition_variable task_queue_condition_;
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_GLFW_HEADLESS_EVENT_LOOP_H_
|