Flutter Engine
 
Loading...
Searching...
No Matches
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.
 
bool SupportsPartialRepaint () const
 
std::optional< DlIRectInitialDamage ()
 This is the minimal area that needs to be repainted to get correct result.
 
void SetDamageRegion (const std::optional< DlIRect > &buffer_damage)
 Sets the damage region for current surface. Corresponds to.
 
bool SetPresentationTime (const fml::TimePoint &presentation_time)
 Sets the presentation time for the current surface. This.
 
bool SwapBuffers (const std::optional< DlIRect > &surface_damage)
 This only applies to on-screen surfaces such as those created by AndroidContextGL::CreateOnscreenSurface.
 
DlISize 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 86 of file android_egl_surface.cc.

89 : surface_(surface),
90 display_(display),
91 context_(context),
92 damage_(std::make_unique<AndroidEGLSurfaceDamage>()) {
93 damage_->init(display_, context);
94}

References surface.

◆ ~AndroidEGLSurface()

flutter::AndroidEGLSurface::~AndroidEGLSurface ( )

Definition at line 96 of file android_egl_surface.cc.

96 {
97 [[maybe_unused]] auto result = eglDestroySurface(display_, surface_);
98 FML_DCHECK(result == EGL_TRUE);
99}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK.

Member Function Documentation

◆ GetSize()

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

Definition at line 170 of file android_egl_surface.cc.

170 {
171 EGLint width = 0;
172 EGLint height = 0;
173
174 if (!eglQuerySurface(display_, surface_, EGL_WIDTH, &width) ||
175 !eglQuerySurface(display_, surface_, EGL_HEIGHT, &height)) {
176 FML_LOG(ERROR) << "Unable to query EGL surface size";
178 return DlISize();
179 }
180 return DlISize(width, height);
181}
#define FML_LOG(severity)
Definition logging.h:101
void LogLastEGLError()
impeller::ISize32 DlISize
int32_t height
int32_t width

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

◆ InitialDamage()

std::optional< DlIRect > 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 166 of file android_egl_surface.cc.

166 {
167 return damage_->InitialDamage(display_, surface_);
168}

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

101 {
102 return surface_ != EGL_NO_SURFACE;
103}

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

129 {
130 if (IsContextCurrent()) {
132 }
133 if (eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
134 FML_LOG(ERROR) << "Could not make the context current";
137 }
139}
@ 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.

References FML_LOG, flutter::kFailure, flutter::kSuccessAlreadyCurrent, flutter::kSuccessMadeCurrent, and flutter::LogLastEGLError().

◆ SetDamageRegion()

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

Sets the damage region for current surface. Corresponds to.

Definition at line 141 of file android_egl_surface.cc.

142 {
143 damage_->SetDamageRegion(display_, surface_, buffer_damage);
144}

◆ SetPresentationTime()

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

Sets the presentation time for the current surface. This.

Definition at line 146 of file android_egl_surface.cc.

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

References fml::TimePoint::ToEpochDelta(), and fml::TimeDelta::ToNanoseconds().

◆ SupportsPartialRepaint()

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

Definition at line 162 of file android_egl_surface.cc.

162 {
163 return damage_->SupportsPartialRepaint();
164}

◆ SwapBuffers()

bool flutter::AndroidEGLSurface::SwapBuffers ( const std::optional< DlIRect > &  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 156 of file android_egl_surface.cc.

157 {
158 TRACE_EVENT0("flutter", "AndroidContextGL::SwapBuffers");
159 return damage_->SwapBuffersWithDamage(display_, surface_, surface_damage);
160}
#define TRACE_EVENT0(category_group, name)

References TRACE_EVENT0.


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