5#include "flutter/shell/platform/windows/external_texture_d3d.h"
7#include "flutter/fml/logging.h"
8#include "flutter/shell/platform/embedder/embedder_struct_macros.h"
17 std::shared_ptr<egl::ProcTable>
gl)
21 egl_manager_(egl_manager),
27 if (gl_texture_ != 0) {
28 gl_->DeleteTextures(1, &gl_texture_);
38 if (!CreateOrUpdateTexture(descriptor)) {
43 opengl_texture->
target = GL_TEXTURE_2D;
44 opengl_texture->
name = gl_texture_;
45 opengl_texture->
format = GL_RGBA8_OES;
54void ExternalTextureD3d::ReleaseImage() {
55 if (egl_surface_ != EGL_NO_SURFACE) {
56 eglReleaseTexImage(egl_manager_->
egl_display(), egl_surface_,
58 eglDestroySurface(egl_manager_->
egl_display(), egl_surface_);
59 egl_surface_ = EGL_NO_SURFACE;
63bool ExternalTextureD3d::CreateOrUpdateTexture(
65 if (descriptor ==
nullptr ||
66 SAFE_ACCESS(descriptor, handle,
nullptr) ==
nullptr) {
71 if (gl_texture_ == 0) {
72 gl_->GenTextures(1, &gl_texture_);
74 gl_->BindTexture(GL_TEXTURE_2D, gl_texture_);
75 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
76 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
77 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
78 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
80 gl_->BindTexture(GL_TEXTURE_2D, gl_texture_);
83 auto handle =
SAFE_ACCESS(descriptor, handle,
nullptr);
84 if (handle != last_surface_handle_) {
87 EGLint attributes[] = {
100 ? EGL_D3D_TEXTURE_ANGLE
101 : EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE,
104 if (egl_surface_ == EGL_NO_SURFACE ||
105 eglBindTexImage(egl_manager_->
egl_display(), egl_surface_,
106 EGL_BACK_BUFFER) == EGL_FALSE) {
109 last_surface_handle_ = handle;
112 auto release_callback =
SAFE_ACCESS(descriptor, release_callback,
nullptr);
113 if (release_callback) {
114 release_callback(
SAFE_ACCESS(descriptor, release_context,
nullptr));
116 return egl_surface_ != EGL_NO_SURFACE;
virtual ~ExternalTextureD3d()
bool PopulateTexture(size_t width, size_t height, FlutterOpenGLTexture *opengl_texture) override
ExternalTextureD3d(FlutterDesktopGpuSurfaceType type, const FlutterDesktopGpuSurfaceTextureCallback texture_callback, void *user_data, const egl::Manager *egl_manager, std::shared_ptr< egl::ProcTable > gl)
EGLSurface CreateSurfaceFromHandle(EGLenum handle_type, EGLClientBuffer handle, const EGLint *attributes) const
EGLDisplay egl_display() const
#define SAFE_ACCESS(pointer, member, default_value)
const FlutterDesktopGpuSurfaceDescriptor *(* FlutterDesktopGpuSurfaceTextureCallback)(size_t width, size_t height, void *user_data)
FlutterDesktopGpuSurfaceType
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
#define FML_LOG(severity)
uint32_t name
The name of the texture.
VoidCallback destruction_callback
void * user_data
User data to be returned on the invocation of the destruction callback.
size_t height
Height of the texture.
uint32_t format
The texture format (example GL_RGBA8).
FlutterDesktopPixelBufferTextureCallback texture_callback