Flutter Engine
flutter::AndroidEGLSurface Class Reference

#include <android_context_gl.h>

Public Member Functions

 AndroidEGLSurface (EGLSurface surface, EGLDisplay display, EGLContext context)
 
 ~AndroidEGLSurface ()
 
bool IsValid () const
 
bool MakeCurrent ()
 Binds the EGLContext context to the current rendering thread and to the draw and read surface. More...
 
bool SwapBuffers ()
 This only applies to on-screen surfaces such as those created by AndroidContextGL::CreateOnscreenSurface. More...
 
SkISize GetSize () const
 

Detailed Description

Holds an EGLSurface reference.

This can be used in conjuction to unique_ptr to provide better guarantees about the lifespan of the EGLSurface object.

Definition at line 26 of file android_context_gl.h.

Constructor & Destructor Documentation

◆ AndroidEGLSurface()

flutter::AndroidEGLSurface::AndroidEGLSurface ( EGLSurface  surface,
EGLDisplay  display,
EGLContext  context 
)

Definition at line 108 of file android_context_gl.cc.

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

◆ ~AndroidEGLSurface()

flutter::AndroidEGLSurface::~AndroidEGLSurface ( )

Definition at line 113 of file android_context_gl.cc.

References FML_DCHECK.

113  {
114  auto result = eglDestroySurface(display_, surface_);
115  FML_DCHECK(result == EGL_TRUE);
116 }
#define FML_DCHECK(condition)
Definition: logging.h:86

Member Function Documentation

◆ GetSize()

SkISize flutter::AndroidEGLSurface::GetSize ( ) const
Returns
The size of an EGLSurface.

Definition at line 136 of file android_context_gl.cc.

References FML_LOG, height, flutter::LogLastEGLError(), and width.

136  {
137  EGLint width = 0;
138  EGLint height = 0;
139 
140  if (!eglQuerySurface(display_, surface_, EGL_WIDTH, &width) ||
141  !eglQuerySurface(display_, surface_, EGL_HEIGHT, &height)) {
142  FML_LOG(ERROR) << "Unable to query EGL surface size";
143  LogLastEGLError();
144  return SkISize::Make(0, 0);
145  }
146  return SkISize::Make(width, height);
147 }
static void LogLastEGLError()
#define FML_LOG(severity)
Definition: logging.h:65
int32_t height
int32_t width

◆ IsValid()

bool flutter::AndroidEGLSurface::IsValid ( ) const
Returns
Whether the current EGLSurface reference is valid. That is, if the surface doesn't point to EGL_NO_SURFACE.

Definition at line 118 of file android_context_gl.cc.

118  {
119  return surface_ != EGL_NO_SURFACE;
120 }

◆ MakeCurrent()

bool flutter::AndroidEGLSurface::MakeCurrent ( )

Binds the EGLContext context to the current rendering thread and to the draw and read surface.

Returns
Whether the surface was made current.

Definition at line 122 of file android_context_gl.cc.

References eglMakeCurrent(), FML_LOG, and flutter::LogLastEGLError().

122  {
123  if (eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
124  FML_LOG(ERROR) << "Could not make the context current";
125  LogLastEGLError();
126  return false;
127  }
128  return true;
129 }
static void LogLastEGLError()
#define FML_LOG(severity)
Definition: logging.h:65
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306

◆ SwapBuffers()

bool flutter::AndroidEGLSurface::SwapBuffers ( )

This only applies to on-screen surfaces such as those created by AndroidContextGL::CreateOnscreenSurface.

Returns
Whether the EGL surface color buffer was swapped.

Definition at line 131 of file android_context_gl.cc.

References eglSwapBuffers(), and TRACE_EVENT0.

131  {
132  TRACE_EVENT0("flutter", "AndroidContextGL::SwapBuffers");
133  return eglSwapBuffers(display_, surface_);
134 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
Definition: mock_egl.cc:316

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