Flutter Engine
The Flutter Engine
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
18namespace flutter {
19
20class FlutterWindowsEngine;
21
22// An object managing the registration of an external texture.
23// Thread safety: All member methods are thread safe.
25 public:
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.
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,
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_
bool PopulateTexture(int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *texture)
int64_t RegisterTexture(const FlutterDesktopTextureInfo *texture_info)
FlutterWindowsTextureRegistrar(FlutterWindowsEngine *engine, std::shared_ptr< egl::ProcTable > gl)
void UnregisterTexture(int64_t texture_id, fml::closure callback=nullptr)
FlutterEngine engine
Definition: main.cc:68
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
FlTexture * texture
std::function< void()> closure
Definition: closure.h:14
gl
Definition: malisc.py:41
int32_t height
int32_t width
int64_t texture_id