| Flutter Windows Embedder |

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

`#include <flutter_windows_texture_registrar.h>`

## Public Member Functions
| FlutterWindowsTextureRegistrar (FlutterWindowsEngine *engine, const GlProcs &gl_procs)
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)

## Static Public Member Functions
static void | ResolveGlFunctions (GlProcs &gl_procs)

## Detailed Description

Definition at line 23 of file flutter_windows_texture_registrar.h.

## Constructor & Destructor Documentation

## ◆ FlutterWindowsTextureRegistrar()

flutter::FlutterWindowsTextureRegistrar::FlutterWindowsTextureRegistrar | ( | FlutterWindowsEngine * | engine,
|  | const GlProcs & | gl_procs
| ) |  |
| explicit

Definition at line 21 of file flutter_windows_texture_registrar.cc.

24 : engine_(engine), gl_procs_(gl_procs) {}

## Member Function Documentation

## ◆ MarkTextureFrameAvailable()

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

Definition at line 104 of file flutter_windows_texture_registrar.cc.

105 {
106 engine_->task_runner()->RunNowOrPostTask([engine = engine_, texture_id]() {
107 engine->MarkExternalTextureFrameAvailable(texture_id);
108 });
109 return true;
110 }

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 112 of file flutter_windows_texture_registrar.cc.

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

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_procs_.valid) {
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_procs_));
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_->surface_manager(),
57 gl_procs_));
58 }
59 }
60
61 FML_LOG(ERROR) << "Attempted to register texture of unsupport type.";
62 return kInvalidTexture;
63 }

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

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

## ◆ ResolveGlFunctions()

void flutter::FlutterWindowsTextureRegistrar::ResolveGlFunctions | ( | GlProcs & | gl_procs | ) |
| static

Definition at line 129 of file flutter_windows_texture_registrar.cc.

129 {
130 procs.glGenTextures =
131 reinterpret_cast<glGenTexturesProc>(eglGetProcAddress("glGenTextures"));
132 procs.glDeleteTextures = reinterpret_cast<glDeleteTexturesProc>(
133 eglGetProcAddress("glDeleteTextures"));
134 procs.glBindTexture =
135 reinterpret_cast<glBindTextureProc>(eglGetProcAddress("glBindTexture"));
136 procs.glTexParameteri = reinterpret_cast<glTexParameteriProc>(
137 eglGetProcAddress("glTexParameteri"));
138 procs.glTexImage2D =
139 reinterpret_cast<glTexImage2DProc>(eglGetProcAddress("glTexImage2D"));
140
141 procs.valid = procs.glGenTextures && procs.glDeleteTextures &&
142 procs.glBindTexture && procs.glTexParameteri &&
143 procs.glTexImage2D;
144 }

References flutter::GlProcs::glBindTexture, flutter::GlProcs::glDeleteTextures, flutter::GlProcs::glGenTextures, flutter::GlProcs::glTexImage2D, flutter::GlProcs::glTexParameteri, and flutter::GlProcs::valid.

## ◆ UnregisterTexture()

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

Definition at line 80 of file flutter_windows_texture_registrar.cc.

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

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

flutter::TaskRunner::RunNowOrPostTask
void RunNowOrPostTask(TaskClosure task)
Definition: task_runner.h:51
kFlutterDesktopGpuSurfaceTexture
@ kFlutterDesktopGpuSurfaceTexture
Definition: flutter_texture_registrar.h:28
flutter::FlutterWindowsEngine::task_runner
TaskRunner * task_runner()
Definition: flutter_windows_engine.h:134
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:47
flutter::GlProcs::valid
bool valid
Definition: external_texture.h:36
flutter::glDeleteTexturesProc
void(* glDeleteTexturesProc)(GLsizei n, const GLuint *textures)
Definition: external_texture.h:16
FlutterDesktopPixelBufferTextureConfig::user_data
void * user_data
Definition: flutter_texture_registrar.h:134
flutter::glTexImage2DProc
void(* glTexImage2DProc)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *data)
Definition: external_texture.h:19
kFlutterDesktopGpuSurfaceTypeNone
@ kFlutterDesktopGpuSurfaceTypeNone
Definition: flutter_texture_registrar.h:34
type
enum flutter::testing::@66::KeyboardChange::Type type
FlutterDesktopPixelBufferTextureConfig::callback
FlutterDesktopPixelBufferTextureCallback callback
Definition: flutter_texture_registrar.h:132
flutter::ExternalTexture::PopulateTexture
virtual bool PopulateTexture(size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)=0
flutter::glGenTexturesProc
void(* glGenTexturesProc)(GLsizei n, GLuint *textures)
Definition: external_texture.h:15
FlutterDesktopTextureInfo::type
FlutterDesktopTextureType type
Definition: flutter_texture_registrar.h:152
flutter::glTexParameteriProc
void(* glTexParameteriProc)(GLenum target, GLenum pname, GLint param)
Definition: external_texture.h:18
FlutterDesktopTextureInfo::pixel_buffer_config
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config
Definition: flutter_texture_registrar.h:154
kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
Definition: flutter_texture_registrar.h:40
FlutterDesktopTextureInfo::gpu_surface_config
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
Definition: flutter_texture_registrar.h:155
kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
@ kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
Definition: flutter_texture_registrar.h:38
flutter::glBindTextureProc
void(* glBindTextureProc)(GLenum target, GLuint texture)
Definition: external_texture.h:17
flutter::FlutterWindowsEngine::surface_manager
AngleSurfaceManager * surface_manager()
Definition: flutter_windows_engine.h:142
FlutterDesktopGpuSurfaceTextureConfig
Definition: flutter_texture_registrar.h:138
flutter::FlutterWindowsEngine::PostRasterThreadTask
virtual bool PostRasterThreadTask(fml::closure callback)
Definition: flutter_windows_engine.cc:682
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
flutter::ExternalTexture
Definition: external_texture.h:40
kFlutterDesktopPixelBufferTexture
@ kFlutterDesktopPixelBufferTexture
Definition: flutter_texture_registrar.h:26
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:46