| 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/external_texture.h"
16
17 namespace flutter {
18
19 class FlutterWindowsEngine;
20
21 // An object managing the registration of an external texture.
22 // Thread safety: All member methods are thread safe.
23 class FlutterWindowsTextureRegistrar {
24 public:
25 explicit FlutterWindowsTextureRegistrar(FlutterWindowsEngine* engine,
26 const GlProcs& gl_procs);
27
28 // Registers a texture described by the given |texture_info| object.
29 // Returns the non-zero, positive texture id or -1 on error.
30 int64_t RegisterTexture(const FlutterDesktopTextureInfo* texture_info);
31
32 // Attempts to unregister the texture identified by |texture_id|.
33 void UnregisterTexture(int64_t texture_id, fml::closure callback = nullptr);
34
35 // Notifies the engine about a new frame being available.
36 // Returns true on success.
37 bool MarkTextureFrameAvailable(int64_t texture_id);
38
39 // Attempts to populate the given |texture| by copying the
40 // contents of the texture identified by |texture_id|.
41 // Returns true on success.
42 bool PopulateTexture(int64_t texture_id,
43 size_t width,
44 size_t height,
45 FlutterOpenGLTexture* texture);
46
47 // Populates the OpenGL function pointers in |gl_procs|.
48 static void ResolveGlFunctions(GlProcs& gl_procs);
49
50 private:
51 FlutterWindowsEngine* engine_ = nullptr;
52 const GlProcs& gl_procs_;
53
54 // All registered textures, keyed by their IDs.
55 std::unordered_map<int64_t, std::unique_ptr<flutter::ExternalTexture>>
56 textures_;
57 std::mutex map_mutex_;
58
59 int64_t EmplaceTexture(std::unique_ptr<ExternalTexture> texture);
60
61 FML_DISALLOW_COPY_AND_ASSIGN(FlutterWindowsTextureRegistrar);
62 };
63
64 }; // namespace flutter
65
66 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_TEXTURE_REGISTRAR_H_
flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable
bool MarkTextureFrameAvailable(int64_t texture_id)
Definition: flutter_windows_texture_registrar.cc:104
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:78
flutter::FlutterWindowsTextureRegistrar::PopulateTexture
bool PopulateTexture(int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *texture)
Definition: flutter_windows_texture_registrar.cc:112
flutter::FlutterWindowsTextureRegistrar
Definition: flutter_windows_texture_registrar.h:23
external_texture.h
FlutterDesktopTextureInfo
Definition: flutter_texture_registrar.h:151
flutter
Definition: accessibility_bridge_windows.cc:11
flutter_texture_registrar.h
flutter::GlProcs
Definition: external_texture.h:30
flutter::FlutterWindowsTextureRegistrar::ResolveGlFunctions
static void ResolveGlFunctions(GlProcs &gl_procs)
Definition: flutter_windows_texture_registrar.cc:129
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
flutter::FlutterWindowsTextureRegistrar::FlutterWindowsTextureRegistrar
FlutterWindowsTextureRegistrar(FlutterWindowsEngine *engine, const GlProcs &gl_procs)
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:80
flutter::FlutterWindowsTextureRegistrar::RegisterTexture
int64_t RegisterTexture(const FlutterDesktopTextureInfo *texture_info)
Definition: flutter_windows_texture_registrar.cc:26
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:46