Flutter Engine
flutter::AngleSurfaceManager Class Reference

#include <angle_surface_manager.h>

Public Member Functions

 AngleSurfaceManager ()
 
 ~AngleSurfaceManager ()
 
 AngleSurfaceManager (const AngleSurfaceManager &)=delete
 
AngleSurfaceManageroperator= (const AngleSurfaceManager &)=delete
 
bool CreateSurface (WindowsRenderTarget *render_target, EGLint width, EGLint height)
 
void ResizeSurface (WindowsRenderTarget *render_target, EGLint width, EGLint height)
 
void GetSurfaceDimensions (EGLint *width, EGLint *height)
 
void DestroySurface ()
 
bool MakeCurrent ()
 
bool ClearContext ()
 
bool MakeResourceCurrent ()
 
EGLBoolean SwapBuffers ()
 

Detailed Description

Definition at line 24 of file angle_surface_manager.h.

Constructor & Destructor Documentation

◆ AngleSurfaceManager() [1/2]

flutter::AngleSurfaceManager::AngleSurfaceManager ( )

Definition at line 11 of file angle_surface_manager.cc.

12  : egl_config_(nullptr),
13  egl_display_(EGL_NO_DISPLAY),
14  egl_context_(EGL_NO_CONTEXT) {
15  initialize_succeeded_ = Initialize();
16 }

◆ ~AngleSurfaceManager()

flutter::AngleSurfaceManager::~AngleSurfaceManager ( )

Definition at line 18 of file angle_surface_manager.cc.

References eglChooseConfig(), eglCreateContext(), eglGetProcAddress, and eglInitialize().

18  {
19  CleanUp();
20 }

◆ AngleSurfaceManager() [2/2]

flutter::AngleSurfaceManager::AngleSurfaceManager ( const AngleSurfaceManager )
delete

Member Function Documentation

◆ ClearContext()

bool flutter::AngleSurfaceManager::ClearContext ( )

Definition at line 244 of file angle_surface_manager.cc.

References eglMakeCurrent().

244  {
245  return (eglMakeCurrent(egl_display_, nullptr, nullptr, egl_context_) ==
246  EGL_TRUE);
247 }
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306

◆ CreateSurface()

bool flutter::AngleSurfaceManager::CreateSurface ( WindowsRenderTarget render_target,
EGLint  width,
EGLint  height 
)

Definition at line 172 of file angle_surface_manager.cc.

References eglCreateWindowSurface(), height, and width.

Referenced by ResizeSurface().

174  {
175  if (!render_target || !initialize_succeeded_) {
176  return false;
177  }
178 
179  EGLSurface surface = EGL_NO_SURFACE;
180 
181  // Disable Angle's automatic surface sizing logic and provide and exlicit
182  // size. AngleSurfaceManager is responsible for initiating Angle surface size
183  // changes to avoid race conditions with rendering when automatic mode is
184  // used.
185  const EGLint surfaceAttributes[] = {
186  EGL_FIXED_SIZE_ANGLE, EGL_TRUE, EGL_WIDTH, width,
187  EGL_HEIGHT, height, EGL_NONE};
188 
189  surface = eglCreateWindowSurface(
190  egl_display_, egl_config_,
191  static_cast<EGLNativeWindowType>(std::get<HWND>(*render_target)),
192  surfaceAttributes);
193  if (surface == EGL_NO_SURFACE) {
194  std::cerr << "Surface creation failed." << std::endl;
195  }
196 
197  render_surface_ = surface;
198  return true;
199 }
EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
Definition: mock_egl.cc:142
int32_t height
int32_t width

◆ DestroySurface()

void flutter::AngleSurfaceManager::DestroySurface ( )

Definition at line 232 of file angle_surface_manager.cc.

Referenced by ResizeSurface().

232  {
233  if (egl_display_ != EGL_NO_DISPLAY && render_surface_ != EGL_NO_SURFACE) {
234  eglDestroySurface(egl_display_, render_surface_);
235  }
236  render_surface_ = EGL_NO_SURFACE;
237 }

◆ GetSurfaceDimensions()

void flutter::AngleSurfaceManager::GetSurfaceDimensions ( EGLint *  width,
EGLint *  height 
)

Definition at line 221 of file angle_surface_manager.cc.

Referenced by ResizeSurface().

221  {
222  if (render_surface_ == EGL_NO_SURFACE || !initialize_succeeded_) {
223  width = 0;
224  height = 0;
225  return;
226  }
227 
228  eglQuerySurface(egl_display_, render_surface_, EGL_WIDTH, width);
229  eglQuerySurface(egl_display_, render_surface_, EGL_HEIGHT, height);
230 }
int32_t height
int32_t width

◆ MakeCurrent()

bool flutter::AngleSurfaceManager::MakeCurrent ( )

Definition at line 239 of file angle_surface_manager.cc.

References eglMakeCurrent().

239  {
240  return (eglMakeCurrent(egl_display_, render_surface_, render_surface_,
241  egl_context_) == EGL_TRUE);
242 }
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306

◆ MakeResourceCurrent()

bool flutter::AngleSurfaceManager::MakeResourceCurrent ( )

Definition at line 249 of file angle_surface_manager.cc.

References eglMakeCurrent().

249  {
250  return (eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE,
251  egl_resource_context_) == EGL_TRUE);
252 }
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306

◆ operator=()

AngleSurfaceManager& flutter::AngleSurfaceManager::operator= ( const AngleSurfaceManager )
delete

◆ ResizeSurface()

void flutter::AngleSurfaceManager::ResizeSurface ( WindowsRenderTarget render_target,
EGLint  width,
EGLint  height 
)

Definition at line 201 of file angle_surface_manager.cc.

References CreateSurface(), DestroySurface(), and GetSurfaceDimensions().

203  {
204  EGLint existing_width, existing_height;
205  GetSurfaceDimensions(&existing_width, &existing_height);
206  if (width != existing_width || height != existing_height) {
207  // Destroy existing surface with previous stale dimensions and create new
208  // surface at new size. Since the Windows compositor retains the front
209  // buffer until the new surface has been presented, no need to manually
210  // preserve the previous surface contents. This resize approach could be
211  // further optimized if Angle exposed a public entrypoint for
212  // SwapChain11::reset or SwapChain11::resize.
213  DestroySurface();
214  if (!CreateSurface(render_target, width, height)) {
215  std::cerr << "AngleSurfaceManager::ResizeSurface failed to create surface"
216  << std::endl;
217  }
218  }
219 }
void GetSurfaceDimensions(EGLint *width, EGLint *height)
int32_t height
int32_t width
bool CreateSurface(WindowsRenderTarget *render_target, EGLint width, EGLint height)

◆ SwapBuffers()

EGLBoolean flutter::AngleSurfaceManager::SwapBuffers ( )

Definition at line 254 of file angle_surface_manager.cc.

References eglSwapBuffers().

254  {
255  return (eglSwapBuffers(egl_display_, render_surface_));
256 }
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
Definition: mock_egl.cc:316

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