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

#include <surface.h>

Inheritance diagram for flutter::egl::Surface:
flutter::egl::WindowSurface

Public Member Functions

 Surface (EGLDisplay display, EGLContext context, EGLSurface surface)
 
virtual ~Surface ()
 
virtual bool Destroy ()
 
virtual bool IsValid () const
 
virtual bool IsCurrent () const
 
virtual bool MakeCurrent () const
 
virtual bool SwapBuffers () const
 
virtual const EGLSurface & GetHandle () const
 

Protected Member Functions

 FML_DISALLOW_COPY_AND_ASSIGN (Surface)
 

Protected Attributes

bool is_valid_ = true
 
EGLDisplay display_ = EGL_NO_DISPLAY
 
EGLContext context_ = EGL_NO_CONTEXT
 
EGLSurface surface_ = EGL_NO_SURFACE
 

Detailed Description

Definition at line 18 of file surface.h.

Constructor & Destructor Documentation

◆ Surface()

flutter::egl::Surface::Surface ( EGLDisplay  display,
EGLContext  context,
EGLSurface  surface 
)

Definition at line 12 of file surface.cc.

13  : display_(display), context_(context), surface_(surface) {}

◆ ~Surface()

flutter::egl::Surface::~Surface ( )
virtual

Definition at line 15 of file surface.cc.

15  {
16  Destroy();
17 }

References Destroy().

Member Function Documentation

◆ Destroy()

bool flutter::egl::Surface::Destroy ( )
virtual

Definition at line 23 of file surface.cc.

23  {
24  if (surface_ != EGL_NO_SURFACE) {
25  // Ensure the surface is not current before destroying it.
26  if (::eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE,
27  EGL_NO_CONTEXT) != EGL_TRUE) {
29  return false;
30  }
31 
32  if (::eglDestroySurface(display_, surface_) != EGL_TRUE) {
34  return false;
35  }
36  }
37 
38  is_valid_ = false;
39  surface_ = EGL_NO_SURFACE;
40  return true;
41 }

References display_, is_valid_, surface_, and WINDOWS_LOG_EGL_ERROR.

Referenced by ~Surface().

◆ FML_DISALLOW_COPY_AND_ASSIGN()

flutter::egl::Surface::FML_DISALLOW_COPY_AND_ASSIGN ( Surface  )
protected

◆ GetHandle()

const EGLSurface & flutter::egl::Surface::GetHandle ( ) const
virtual

Definition at line 68 of file surface.cc.

68  {
69  return surface_;
70 }

References surface_.

◆ IsCurrent()

bool flutter::egl::Surface::IsCurrent ( ) const
virtual

Definition at line 43 of file surface.cc.

43  {
44  return display_ == ::eglGetCurrentDisplay() &&
45  surface_ == ::eglGetCurrentSurface(EGL_DRAW) &&
46  surface_ == ::eglGetCurrentSurface(EGL_READ) &&
47  context_ == ::eglGetCurrentContext();
48 }

References context_, display_, and surface_.

Referenced by flutter::egl::WindowSurface::SetVSyncEnabled().

◆ IsValid()

bool flutter::egl::Surface::IsValid ( ) const
virtual

Definition at line 19 of file surface.cc.

19  {
20  return is_valid_;
21 }

References is_valid_.

Referenced by flutter::CompositorOpenGL::Present().

◆ MakeCurrent()

bool flutter::egl::Surface::MakeCurrent ( ) const
virtual

Definition at line 50 of file surface.cc.

50  {
51  if (::eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
53  return false;
54  }
55 
56  return true;
57 }

References context_, display_, surface_, and WINDOWS_LOG_EGL_ERROR.

Referenced by flutter::CompositorOpenGL::Present().

◆ SwapBuffers()

bool flutter::egl::Surface::SwapBuffers ( ) const
virtual

Definition at line 59 of file surface.cc.

59  {
60  if (::eglSwapBuffers(display_, surface_) != EGL_TRUE) {
62  return false;
63  }
64 
65  return true;
66 }

References display_, surface_, and WINDOWS_LOG_EGL_ERROR.

Referenced by flutter::CompositorOpenGL::Present().

Member Data Documentation

◆ context_

EGLContext flutter::egl::Surface::context_ = EGL_NO_CONTEXT
protected

Definition at line 51 of file surface.h.

Referenced by IsCurrent(), and MakeCurrent().

◆ display_

EGLDisplay flutter::egl::Surface::display_ = EGL_NO_DISPLAY
protected

◆ is_valid_

bool flutter::egl::Surface::is_valid_ = true
protected

Definition at line 48 of file surface.h.

Referenced by Destroy(), and IsValid().

◆ surface_

EGLSurface flutter::egl::Surface::surface_ = EGL_NO_SURFACE
protected

Definition at line 52 of file surface.h.

Referenced by Destroy(), GetHandle(), IsCurrent(), MakeCurrent(), and SwapBuffers().


The documentation for this class was generated from the following files:
flutter::egl::Surface::is_valid_
bool is_valid_
Definition: surface.h:48
WINDOWS_LOG_EGL_ERROR
#define WINDOWS_LOG_EGL_ERROR
Definition: egl.h:19
flutter::egl::Surface::Destroy
virtual bool Destroy()
Definition: surface.cc:23
flutter::egl::Surface::display_
EGLDisplay display_
Definition: surface.h:50
flutter::egl::Surface::surface_
EGLSurface surface_
Definition: surface.h:52
flutter::egl::Surface::context_
EGLContext context_
Definition: surface.h:51