Flutter Windows Embedder
flutter::egl::Manager Class Reference

#include <manager.h>

Public Member Functions

virtual ~Manager ()
 
bool IsValid () const
 
virtual std::unique_ptr< WindowSurfaceCreateWindowSurface (HWND hwnd, size_t width, size_t height)
 
bool HasContextCurrent ()
 
EGLSurface CreateSurfaceFromHandle (EGLenum handle_type, EGLClientBuffer handle, const EGLint *attributes) const
 
EGLDisplay egl_display () const
 
bool GetDevice (ID3D11Device **device)
 
virtual Contextrender_context () const
 
virtual Contextresource_context () const
 

Static Public Member Functions

static std::unique_ptr< ManagerCreate (bool enable_impeller)
 

Protected Member Functions

 Manager (bool enable_impeller)
 

Detailed Description

Definition at line 31 of file manager.h.

Constructor & Destructor Documentation

◆ ~Manager()

flutter::egl::Manager::~Manager ( )
virtual

Definition at line 44 of file manager.cc.

44  {
45  CleanUp();
46  --instance_count_;
47 }

◆ Manager()

flutter::egl::Manager::Manager ( bool  enable_impeller)
explicitprotected

Definition at line 26 of file manager.cc.

26  {
27  ++instance_count_;
28 
29  if (!InitializeDisplay()) {
30  return;
31  }
32 
33  if (!InitializeConfig(enable_impeller)) {
34  return;
35  }
36 
37  if (!InitializeContexts()) {
38  return;
39  }
40 
41  is_valid_ = true;
42 }

Referenced by Create().

Member Function Documentation

◆ Create()

std::unique_ptr< Manager > flutter::egl::Manager::Create ( bool  enable_impeller)
static

Definition at line 17 of file manager.cc.

17  {
18  std::unique_ptr<Manager> manager;
19  manager.reset(new Manager(enable_impeller));
20  if (!manager->IsValid()) {
21  return nullptr;
22  }
23  return std::move(manager);
24 }

References Manager().

◆ CreateSurfaceFromHandle()

EGLSurface flutter::egl::Manager::CreateSurfaceFromHandle ( EGLenum  handle_type,
EGLClientBuffer  handle,
const EGLint *  attributes 
) const

Definition at line 300 of file manager.cc.

302  {
303  return ::eglCreatePbufferFromClientBuffer(display_, handle_type, handle,
304  config_, attributes);
305 }

◆ CreateWindowSurface()

std::unique_ptr< WindowSurface > flutter::egl::Manager::CreateWindowSurface ( HWND  hwnd,
size_t  width,
size_t  height 
)
virtual

Definition at line 266 of file manager.cc.

268  {
269  if (!hwnd || !is_valid_) {
270  return nullptr;
271  }
272 
273  // Disable ANGLE's automatic surface resizing and provide an explicit size.
274  // The surface will need to be destroyed and re-created if the HWND is
275  // resized.
276  const EGLint surface_attributes[] = {EGL_FIXED_SIZE_ANGLE,
277  EGL_TRUE,
278  EGL_WIDTH,
279  static_cast<EGLint>(width),
280  EGL_HEIGHT,
281  static_cast<EGLint>(height),
282  EGL_NONE};
283 
284  auto const surface = ::eglCreateWindowSurface(
285  display_, config_, static_cast<EGLNativeWindowType>(hwnd),
286  surface_attributes);
287  if (surface == EGL_NO_SURFACE) {
288  LogEGLError("Surface creation failed.");
289  return nullptr;
290  }
291 
292  return std::make_unique<WindowSurface>(display_, render_context_->GetHandle(),
293  surface, width, height);
294 }

References flutter::egl::LogEGLError().

Referenced by flutter::FlutterWindowsView::CreateRenderSurface().

◆ egl_display()

EGLDisplay flutter::egl::Manager::egl_display ( ) const
inline

Definition at line 63 of file manager.h.

63 { return display_; };

◆ GetDevice()

bool flutter::egl::Manager::GetDevice ( ID3D11Device **  device)

Definition at line 307 of file manager.cc.

307  {
308  if (!resolved_device_) {
309  if (!InitializeDevice()) {
310  return false;
311  }
312  }
313 
314  resolved_device_.CopyTo(device);
315  return (resolved_device_ != nullptr);
316 }

◆ HasContextCurrent()

bool flutter::egl::Manager::HasContextCurrent ( )

Definition at line 296 of file manager.cc.

296  {
297  return ::eglGetCurrentContext() != EGL_NO_CONTEXT;
298 }

◆ IsValid()

bool flutter::egl::Manager::IsValid ( ) const

Definition at line 262 of file manager.cc.

262  {
263  return is_valid_;
264 }

◆ render_context()

Context * flutter::egl::Manager::render_context ( ) const
virtual

Definition at line 318 of file manager.cc.

318  {
319  return render_context_.get();
320 }

◆ resource_context()

Context * flutter::egl::Manager::resource_context ( ) const
virtual

Definition at line 322 of file manager.cc.

322  {
323  return resource_context_.get();
324 }

The documentation for this class was generated from the following files:
flutter::egl::LogEGLError
void LogEGLError(std::string_view message)
Log the last EGL error with an error message.
Definition: egl.cc:55
flutter::egl::Manager::Manager
Manager(bool enable_impeller)
Definition: manager.cc:26