| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::FlutterWindowsTextureRegistrar Class Reference

`#include <flutter_windows_texture_registrar.h>`

## Public Member Functions
| FlutterWindowsTextureRegistrar (FlutterWindowsEngine *engine, std::shared_ptr< egl::ProcTable > gl)
int64_t | RegisterTexture (const FlutterDesktopTextureInfo *texture_info)
void | UnregisterTexture (int64_t texture_id, fml::closure callback=nullptr)
bool | MarkTextureFrameAvailable (int64_t texture_id)
bool | PopulateTexture (int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *texture)

## Detailed Description

Definition at line 24 of file flutter_windows_texture_registrar.h.

## Constructor & Destructor Documentation

## ◆ FlutterWindowsTextureRegistrar()

flutter::FlutterWindowsTextureRegistrar::FlutterWindowsTextureRegistrar | ( | FlutterWindowsEngine * | engine,
|  | std::shared_ptr< egl::ProcTable > | gl
| ) |  |
| explicit

Definition at line 21 of file flutter_windows_texture_registrar.cc.

24 : engine_(engine), gl_(std::move(gl)) {}

## Member Function Documentation

## ◆ MarkTextureFrameAvailable()

bool flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable | ( | int64_t | texture_id | ) |

Definition at line 103 of file flutter_windows_texture_registrar.cc.

104 {
105 engine_->task_runner()->RunNowOrPostTask([engine = engine_, texture_id]() {
106 engine->MarkExternalTextureFrameAvailable(texture_id);
107 });
108 return true;
109 }
flutter::FlutterWindowsEngine::task_runner
TaskRunner * task_runner()
Definition: flutter_windows_engine.h:170
flutter::TaskRunner::RunNowOrPostTask
void RunNowOrPostTask(TaskClosure task)
Definition: task_runner.h:55
texture_id
uint32_t texture_id
Definition: compositor_opengl.cc:20

References flutter::TaskRunner::RunNowOrPostTask(), flutter::FlutterWindowsEngine::task_runner(), and texture_id.

Referenced by FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(), and flutter::testing::TEST().

## ◆ PopulateTexture()

bool flutter::FlutterWindowsTextureRegistrar::PopulateTexture | ( | int64_t | texture_id,
|  | size_t | width,
|  | size_t | height,
|  | FlutterOpenGLTexture * | texture
| ) |  |

Definition at line 111 of file flutter_windows_texture_registrar.cc.

115 {
116 flutter::ExternalTexture* texture;
117 {
118 std::lock_guard<std::mutex> lock(map_mutex_);
119 auto it = textures_.find(texture_id);
120 if (it == textures_.end()) {
121 return false;
122 }
123 texture = it->second.get();
124 }
125 return texture->PopulateTexture(width, height, opengl_texture);
126 }
flutter::ExternalTexture
Definition: external_texture.h:16
flutter::ExternalTexture::PopulateTexture
virtual bool PopulateTexture(size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)=0

References flutter::ExternalTexture::PopulateTexture(), and texture_id.

Referenced by flutter::testing::TEST().

## ◆ RegisterTexture()

int64_t flutter::FlutterWindowsTextureRegistrar::RegisterTexture | ( | const FlutterDesktopTextureInfo * | texture_info | ) |

Definition at line 26 of file flutter_windows_texture_registrar.cc.

27 {
28 if (!gl_) {
29 return kInvalidTexture;
30 }
31
32 if (texture_info->type == kFlutterDesktopPixelBufferTexture) {
33 if (!texture_info->pixel_buffer_config.callback) {
34 FML_LOG(ERROR) << "Invalid pixel buffer texture callback.";
35 return kInvalidTexture;
36 }
37
38 return EmplaceTexture(std::make_unique<flutter::ExternalTexturePixelBuffer>(
39 texture_info->pixel_buffer_config.callback,
40 texture_info->pixel_buffer_config.user_data, gl_));
41 } else if (texture_info->type == kFlutterDesktopGpuSurfaceTexture) {
42 const FlutterDesktopGpuSurfaceTextureConfig* gpu_surface_config =
43 &texture_info->gpu_surface_config;
44 auto surface_type = SAFE_ACCESS(gpu_surface_config, type,
45 kFlutterDesktopGpuSurfaceTypeNone);
46 if (surface_type == kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle ||
47 surface_type == kFlutterDesktopGpuSurfaceTypeD3d11Texture2D) {
48 auto callback = SAFE_ACCESS(gpu_surface_config, callback, nullptr);
49 if (!callback) {
50 FML_LOG(ERROR) << "Invalid GPU surface descriptor callback.";
51 return kInvalidTexture;
52 }
53
54 auto user_data = SAFE_ACCESS(gpu_surface_config, user_data, nullptr);
55 return EmplaceTexture(std::make_unique<flutter::ExternalTextureD3d>(
56 surface_type, callback, user_data, engine_->egl_manager(), gl_));
57 }
58 }
59
60 FML_LOG(ERROR) << "Attempted to register texture of unsupport type.";
61 return kInvalidTexture;
62 }
flutter::FlutterWindowsEngine::egl_manager
egl::Manager * egl_manager() const
Definition: flutter_windows_engine.h:180
kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
@ kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
Definition: flutter_texture_registrar.h:38
kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
Definition: flutter_texture_registrar.h:40
kFlutterDesktopGpuSurfaceTypeNone
@ kFlutterDesktopGpuSurfaceTypeNone
Definition: flutter_texture_registrar.h:34
kFlutterDesktopGpuSurfaceTexture
@ kFlutterDesktopGpuSurfaceTexture
Definition: flutter_texture_registrar.h:28
kFlutterDesktopPixelBufferTexture
@ kFlutterDesktopPixelBufferTexture
Definition: flutter_texture_registrar.h:26
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:53
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
type
enum flutter::testing::@93::KeyboardChange::Type type
FlutterDesktopGpuSurfaceTextureConfig
Definition: flutter_texture_registrar.h:138
FlutterDesktopPixelBufferTextureConfig::user_data
void * user_data
Definition: flutter_texture_registrar.h:134
FlutterDesktopPixelBufferTextureConfig::callback
FlutterDesktopPixelBufferTextureCallback callback
Definition: flutter_texture_registrar.h:132
FlutterDesktopTextureInfo::gpu_surface_config
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
Definition: flutter_texture_registrar.h:155
FlutterDesktopTextureInfo::type
FlutterDesktopTextureType type
Definition: flutter_texture_registrar.h:152
FlutterDesktopTextureInfo::pixel_buffer_config
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config
Definition: flutter_texture_registrar.h:154

References FlutterDesktopPixelBufferTextureConfig::callback, callback, flutter::FlutterWindowsEngine::egl_manager(), FlutterDesktopTextureInfo::gpu_surface_config, kFlutterDesktopGpuSurfaceTexture, kFlutterDesktopGpuSurfaceTypeD3d11Texture2D, kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle, kFlutterDesktopGpuSurfaceTypeNone, kFlutterDesktopPixelBufferTexture, FlutterDesktopTextureInfo::pixel_buffer_config, FlutterDesktopTextureInfo::type, type, FlutterDesktopPixelBufferTextureConfig::user_data, and user_data.

Referenced by FlutterDesktopTextureRegistrarRegisterExternalTexture(), and flutter::testing::TEST().

## ◆ UnregisterTexture()

void flutter::FlutterWindowsTextureRegistrar::UnregisterTexture | ( | int64_t | texture_id,
|  | fml::closure | callback = `nullptr`
| ) |  |

Definition at line 79 of file flutter_windows_texture_registrar.cc.

80 {
81 engine_->task_runner()->RunNowOrPostTask([engine = engine_, texture_id]() {
82 engine->UnregisterExternalTexture(texture_id);
83 });
84
85 bool posted = engine_->PostRasterThreadTask([this, texture_id, callback]() {
86 {
87 std::lock_guard<std::mutex> lock(map_mutex_);
88 auto it = textures_.find(texture_id);
89 if (it != textures_.end()) {
90 textures_.erase(it);
91 }
92 }
93 if (callback) {
94 callback();
95 }
96 });
97
98 if (!posted && callback) {
99 callback();
100 }
101 }
flutter::FlutterWindowsEngine::PostRasterThreadTask
virtual bool PostRasterThreadTask(fml::closure callback) const
Definition: flutter_windows_engine.cc:950

References callback, flutter::FlutterWindowsEngine::PostRasterThreadTask(), flutter::TaskRunner::RunNowOrPostTask(), flutter::FlutterWindowsEngine::task_runner(), and texture_id.

Referenced by flutter::testing::TEST().

The documentation for this class was generated from the following files:

- shell/platform/windows/flutter_windows_texture_registrar.h
- shell/platform/windows/flutter_windows_texture_registrar.cc