flutter_flutter/shell/platform/glfw/platform_handler.h
stuartmorgan 716dbf00c8
Refactor GLFW embedding to support headless mode (#18205)
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.
2020-05-07 17:10:11 -07:00

39 lines
1.3 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_PLATFORM_HANDLER_H_
#define FLUTTER_SHELL_PLATFORM_GLFW_PLATFORM_HANDLER_H_
#include <GLFW/glfw3.h>
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h"
#include "flutter/shell/platform/glfw/public/flutter_glfw.h"
#include "rapidjson/document.h"
namespace flutter {
// Handler for internal system channels.
class PlatformHandler {
public:
explicit PlatformHandler(flutter::BinaryMessenger* messenger,
GLFWwindow* window);
private:
// Called when a method is called on |channel_|;
void HandleMethodCall(
const flutter::MethodCall<rapidjson::Document>& method_call,
std::unique_ptr<flutter::MethodResult<rapidjson::Document>> result);
// The MethodChannel used for communication with the Flutter engine.
std::unique_ptr<flutter::MethodChannel<rapidjson::Document>> channel_;
// A reference to the GLFW window, if any. Null in headless mode.
GLFWwindow* window_;
};
} // namespace flutter
#endif // FLUTTER_SHELL_PLATFORM_GLFW_PLATFORM_HANDLER_H_