Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
plugin_registrar.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <iostream>
8#include <map>
9
14
15namespace flutter {
16
17// ===== PluginRegistrar =====
18
20 : registrar_(registrar) {
21 auto core_messenger = FlutterDesktopPluginRegistrarGetMessenger(registrar_);
22 messenger_ = std::make_unique<BinaryMessengerImpl>(core_messenger);
23
26 texture_registrar_ =
27 std::make_unique<TextureRegistrarImpl>(texture_registrar);
28}
29
31 // This must always be the first call.
33
34 // Explicitly cleared to facilitate testing of destruction order.
35 messenger_.reset();
36}
37
38void PluginRegistrar::AddPlugin(std::unique_ptr<Plugin> plugin) {
39 plugins_.insert(std::move(plugin));
40}
41
43 plugins_.clear();
44}
45
46// ===== PluginRegistrarManager =====
47
48// static
51 return instance;
52}
53
54PluginRegistrarManager::PluginRegistrarManager() = default;
55
56// static
57void PluginRegistrarManager::OnRegistrarDestroyed(
59 GetInstance()->registrars()->erase(registrar);
60}
61
62} // namespace flutter
static PluginRegistrarManager * GetInstance()
void AddPlugin(std::unique_ptr< Plugin > plugin)
TextureRegistrar * texture_registrar()
PluginRegistrar(FlutterDesktopPluginRegistrarRef core_registrar)
VkInstance instance
Definition: main.cc:48
FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar(FlutterDesktopPluginRegistrarRef registrar)
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar)