| Flutter Windows Embedder |

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
flutter::egl::Manager Class Reference

`#include <manager.h>`

## Public Member Functions
virtual | ~Manager ()
bool | IsValid () const
virtual std::unique_ptr< WindowSurface > | CreateWindowSurface (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 Context * | render_context () const
virtual Context * | resource_context () const

## Static Public Member Functions
static std::unique_ptr< Manager > | Create (GpuPreference gpu_preference)
static std::optional< LUID > | GetLowPowerGpuLuid ()

## Protected Member Functions
| Manager (GpuPreference gpu_preference)

## Detailed Description

Definition at line 39 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 | ( | GpuPreference | gpu_preference | ) |
| explicit protected

Definition at line 26 of file manager.cc.

26 {
27 ++instance_count_;
28
29 if (!InitializeDisplay(gpu_preference)) {
30 return;
31 }
32
33 if (!InitializeConfig()) {
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 | ( | GpuPreference | gpu_preference | ) |
| static

Definition at line 17 of file manager.cc.

17 {
18 std::unique_ptr<Manager> manager;
19 manager.reset(new Manager(gpu_preference));
20 if (!manager->IsValid()) {
21 return nullptr;
22 }
23 return std::move(manager);
24 }
flutter::egl::Manager::Manager
Manager(GpuPreference gpu_preference)
Definition: manager.cc:26

References Manager().

## ◆ CreateSurfaceFromHandle()

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

Definition at line 310 of file manager.cc.

312 {
313 return ::eglCreatePbufferFromClientBuffer(display_, handle_type, handle,
314 config_, attributes);
315 }

## ◆ CreateWindowSurface()

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

Definition at line 276 of file manager.cc.

278 {
279 if (!hwnd || !is_valid_) {
280 return nullptr;
281 }
282
283 // Disable ANGLE's automatic surface resizing and provide an explicit size.
284 // The surface will need to be destroyed and re-created if the HWND is
285 // resized.
286 const EGLint surface_attributes[] = {EGL_FIXED_SIZE_ANGLE,
287 EGL_TRUE,
288 EGL_WIDTH,
289 static_cast<EGLint>(width),
290 EGL_HEIGHT,
291 static_cast<EGLint>(height),
292 EGL_NONE};
293
294 auto const surface = ::eglCreateWindowSurface(
295 display_, config_, static_cast<EGLNativeWindowType>(hwnd),
296 surface_attributes);
297 if (surface == EGL_NO_SURFACE) {
298 LogEGLError("Surface creation failed.");
299 return nullptr;
300 }
301
302 return std::make_unique<WindowSurface>(display_, render_context_->GetHandle(),
303 surface, width, height);
304 }
flutter::egl::LogEGLError
void LogEGLError(std::string_view message)
Log the last EGL error with an error message.
Definition: egl.cc:55

References flutter::egl::LogEGLError().

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

## ◆ egl_display()

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

Definition at line 71 of file manager.h.

71 { return display_; };

## ◆ GetDevice()

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

Definition at line 317 of file manager.cc.

317 {
318 if (!resolved_device_) {
319 if (!InitializeDevice()) {
320 return false;
321 }
322 }
323
324 resolved_device_.CopyTo(device);
325 return (resolved_device_ != nullptr);
326 }

## ◆ GetLowPowerGpuLuid()

std::optional< LUID > flutter::egl::Manager::GetLowPowerGpuLuid | ( |  | ) |
| static

Definition at line 336 of file manager.cc.

336 {
337 Microsoft::WRL::ComPtr<IDXGIFactory1> factory1 = nullptr;
338 Microsoft::WRL::ComPtr<IDXGIFactory6> factory6 = nullptr;
339 Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter = nullptr;
340 HRESULT hr = ::CreateDXGIFactory1(IID_PPV_ARGS(&factory1));
341 if (FAILED(hr)) {
342 return std::nullopt;
343 }
344 hr = factory1->QueryInterface(IID_PPV_ARGS(&factory6));
345 if (FAILED(hr)) {
346 // No support for IDXGIFactory6, so we will not use the selected GPU.
347 // We will follow with the default ANGLE selection.
348 return std::nullopt;
349 }
350 hr = factory6->EnumAdapterByGpuPreference(
351 0, DXGI_GPU_PREFERENCE_MINIMUM_POWER, IID_PPV_ARGS(&adapter));
352 if (FAILED(hr) || adapter == nullptr) {
353 return std::nullopt;
354 }
355 // Get the LUID of the adapter.
356 DXGI_ADAPTER_DESC desc;
357 hr = adapter->GetDesc(&desc);
358 if (FAILED(hr)) {
359 return std::nullopt;
360 }
361 return std::make_optional(desc.AdapterLuid);
362 }

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

## ◆ HasContextCurrent()

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

Definition at line 306 of file manager.cc.

306 {
307 return ::eglGetCurrentContext() != EGL_NO_CONTEXT;
308 }

## ◆ IsValid()

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

Definition at line 272 of file manager.cc.

272 {
273 return is_valid_;
274 }

## ◆ render_context()

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

Definition at line 328 of file manager.cc.

328 {
329 return render_context_.get();
330 }

## ◆ resource_context()

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

Definition at line 332 of file manager.cc.

332 {
333 return resource_context_.get();
334 }

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

- shell/platform/windows/egl/manager.h
- shell/platform/windows/egl/manager.cc