| Flutter Windows Embedder |

flutter_windows_texture_registrar.h
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
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_TEXTURE_REGISTRAR_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_TEXTURE_REGISTRAR_H_
7
8 #include <memory>
9 #include <mutex>
10 #include <unordered_map>
11
12 #include "flutter/fml/closure.h"
13 #include "flutter/fml/macros.h"
14 #include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
15 #include "flutter/shell/platform/windows/egl/proc_table.h"
16 #include "flutter/shell/platform/windows/external_texture.h"
17
18 namespace flutter {
19
20 class FlutterWindowsEngine;
21
22 // An object managing the registration of an external texture.
23 // Thread safety: All member methods are thread safe.
24 class FlutterWindowsTextureRegistrar {
25 public:
26 explicit FlutterWindowsTextureRegistrar(FlutterWindowsEngine* engine,
27 std::shared_ptr<egl::ProcTable> gl);
28
29 // Registers a texture described by the given |texture_info| object.
30 // Returns the non-zero, positive texture id or -1 on error.
31 int64_t RegisterTexture(const FlutterDesktopTextureInfo* texture_info);
32
33 // Attempts to unregister the texture identified by |texture_id|.
34 void UnregisterTexture(int64_t texture_id, fml::closure callback = nullptr);
35
36 // Notifies the engine about a new frame being available.
37 // Returns true on success.
38 bool MarkTextureFrameAvailable(int64_t texture_id);
39
40 // Attempts to populate the given |texture| by copying the
41 // contents of the texture identified by |texture_id|.
42 // Returns true on success.
43 bool PopulateTexture(int64_t texture_id,
44 size_t width,
45 size_t height,
46 FlutterOpenGLTexture* texture);
47
48 private:
49 FlutterWindowsEngine* engine_ = nullptr;
50 std::shared_ptr<egl::ProcTable> gl_;
51
52 // All registered textures, keyed by their IDs.
53 std::unordered_map<int64_t, std::unique_ptr<flutter::ExternalTexture>>
54 textures_;
55 std::mutex map_mutex_;
56
57 int64_t EmplaceTexture(std::unique_ptr<ExternalTexture> texture);
58
59 FML_DISALLOW_COPY_AND_ASSIGN(FlutterWindowsTextureRegistrar);
60 };
61
62 }; // namespace flutter
63
64 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_TEXTURE_REGISTRAR_H_
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:92
flutter::FlutterWindowsTextureRegistrar
Definition: flutter_windows_texture_registrar.h:24
flutter::FlutterWindowsTextureRegistrar::PopulateTexture
bool PopulateTexture(int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *texture)
Definition: flutter_windows_texture_registrar.cc:111
flutter::FlutterWindowsTextureRegistrar::RegisterTexture
int64_t RegisterTexture(const FlutterDesktopTextureInfo *texture_info)
Definition: flutter_windows_texture_registrar.cc:26
flutter::FlutterWindowsTextureRegistrar::FlutterWindowsTextureRegistrar
FlutterWindowsTextureRegistrar(FlutterWindowsEngine *engine, std::shared_ptr< egl::ProcTable > gl)
Definition: flutter_windows_texture_registrar.cc:21
flutter::FlutterWindowsTextureRegistrar::UnregisterTexture
void UnregisterTexture(int64_t texture_id, fml::closure callback=nullptr)
Definition: flutter_windows_texture_registrar.cc:79
flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable
bool MarkTextureFrameAvailable(int64_t texture_id)
Definition: flutter_windows_texture_registrar.cc:103
texture_id
uint32_t texture_id
Definition: compositor_opengl.cc:20
external_texture.h
flutter_texture_registrar.h
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
flutter
Definition: accessibility_bridge_windows.cc:11
proc_table.h
FlutterDesktopTextureInfo
Definition: flutter_texture_registrar.h:151