Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::AndroidEGLSurface Class Reference

#include <android_egl_surface.h>

Public Member Functions

 AndroidEGLSurface (EGLSurface surface, EGLDisplay display, EGLContext context)
 
 ~AndroidEGLSurface ()
 
bool IsValid () const
 
AndroidEGLSurfaceMakeCurrentStatus MakeCurrent () const
 Binds the EGLContext context to the current rendering thread and to the draw and read surface. More...
 
bool SupportsPartialRepaint () const
 
std::optional< SkIRectInitialDamage ()
 This is the minimal area that needs to be repainted to get correct result. More...
 
void SetDamageRegion (const std::optional< SkIRect > &buffer_damage)
 Sets the damage region for current surface. Corresponds to. More...
 
bool SetPresentationTime (const fml::TimePoint &presentation_time)
 Sets the presentation time for the current surface. This. More...
 
bool SwapBuffers (const std::optional< SkIRect > &surface_damage)
 This only applies to on-screen surfaces such as those created by AndroidContextGL::CreateOnscreenSurface. More...
 
SkISize GetSize () const
 

Detailed Description

Definition at line 41 of file android_egl_surface.h.

Constructor & Destructor Documentation

◆ AndroidEGLSurface()

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

Definition at line 84 of file android_egl_surface.cc.

87 : surface_(surface),
88 display_(display),
89 context_(context),
90 damage_(std::make_unique<AndroidEGLSurfaceDamage>()) {
91 damage_->init(display_, context);
92}
VkSurfaceKHR surface
Definition: main.cc:49

◆ ~AndroidEGLSurface()

flutter::AndroidEGLSurface::~AndroidEGLSurface ( )

Definition at line 94 of file android_egl_surface.cc.

94 {
95 [[maybe_unused]] auto result = eglDestroySurface(display_, surface_);
96 FML_DCHECK(result == EGL_TRUE);
97}
GAsyncResult * result
#define FML_DCHECK(condition)
Definition: logging.h:103

Member Function Documentation

◆ GetSize()

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

Definition at line 168 of file android_egl_surface.cc.

168 {
169 EGLint width = 0;
170 EGLint height = 0;
171
172 if (!eglQuerySurface(display_, surface_, EGL_WIDTH, &width) ||
173 !eglQuerySurface(display_, surface_, EGL_HEIGHT, &height)) {
174 FML_LOG(ERROR) << "Unable to query EGL surface size";
176 return SkISize::Make(0, 0);
177 }
178 return SkISize::Make(width, height);
179}
#define FML_LOG(severity)
Definition: logging.h:82
void LogLastEGLError()
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
#define ERROR(message)
Definition: elf_loader.cc:260

◆ InitialDamage()

std::optional< SkIRect > flutter::AndroidEGLSurface::InitialDamage ( )

This is the minimal area that needs to be repainted to get correct result.

With double or triple buffering this buffer content may lag behind current front buffer and the rect accounts for accumulated damage.

Returns
The area of current surface where it is behind front buffer.

Definition at line 164 of file android_egl_surface.cc.

164 {
165 return damage_->InitialDamage(display_, surface_);
166}

◆ 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 99 of file android_egl_surface.cc.

99 {
100 return surface_ != EGL_NO_SURFACE;
101}

◆ MakeCurrent()

AndroidEGLSurfaceMakeCurrentStatus flutter::AndroidEGLSurface::MakeCurrent ( ) const

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 127 of file android_egl_surface.cc.

127 {
128 if (IsContextCurrent()) {
130 }
131 if (eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
132 FML_LOG(ERROR) << "Could not make the context current";
135 }
137}
@ kFailure
Failed to make the egl context for the surface current.
@ kSuccessMadeCurrent
Success, the egl context for the surface made current.
@ kSuccessAlreadyCurrent
Success, the egl context for the surface was already current.

◆ SetDamageRegion()

void flutter::AndroidEGLSurface::SetDamageRegion ( const std::optional< SkIRect > &  buffer_damage)

Sets the damage region for current surface. Corresponds to.

Definition at line 139 of file android_egl_surface.cc.

140 {
141 damage_->SetDamageRegion(display_, surface_, buffer_damage);
142}

◆ SetPresentationTime()

bool flutter::AndroidEGLSurface::SetPresentationTime ( const fml::TimePoint presentation_time)

Sets the presentation time for the current surface. This.

Definition at line 144 of file android_egl_surface.cc.

145 {
146 if (presentation_time_proc_) {
147 const auto time_ns = presentation_time.ToEpochDelta().ToNanoseconds();
148 return presentation_time_proc_(display_, surface_, time_ns);
149 } else {
150 return false;
151 }
152}
constexpr int64_t ToNanoseconds() const
Definition: time_delta.h:61
TimeDelta ToEpochDelta() const
Definition: time_point.h:52

◆ SupportsPartialRepaint()

bool flutter::AndroidEGLSurface::SupportsPartialRepaint ( ) const
Returns
Whether target surface supports partial repaint.

Definition at line 160 of file android_egl_surface.cc.

160 {
161 return damage_->SupportsPartialRepaint();
162}

◆ SwapBuffers()

bool flutter::AndroidEGLSurface::SwapBuffers ( const std::optional< SkIRect > &  surface_damage)

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 154 of file android_egl_surface.cc.

155 {
156 TRACE_EVENT0("flutter", "AndroidContextGL::SwapBuffers");
157 return damage_->SwapBuffersWithDamage(display_, surface_, surface_damage);
158}
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

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