Flutter Engine
The Flutter Engine
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)) {}
FlutterEngine engine
Definition: main.cc:68
gl
Definition: malisc.py:41

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}
void RunNowOrPostTask(TaskClosure task)
Definition: task_runner.h:51
int64_t texture_id

◆ 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 {
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}
FlTexture * texture
int32_t height
int32_t width

◆ 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,
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}
GLenum type
#define SAFE_ACCESS(pointer, member, default_value)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
@ kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTypeNone
@ kFlutterDesktopGpuSurfaceTexture
@ kFlutterDesktopPixelBufferTexture
#define FML_LOG(severity)
Definition: logging.h:82
FlutterDesktopPixelBufferTextureCallback callback
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
FlutterDesktopTextureType type
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config
void * user_data
#define ERROR(message)
Definition: elf_loader.cc:260

◆ 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}
virtual bool PostRasterThreadTask(fml::closure callback) const

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