5#include "flutter/shell/platform/android/android_egl_surface.h"
8#include <sys/system_properties.h>
13#include "flutter/fml/trace_event.h"
18 struct EGLNameErrorPair {
23#define _EGL_ERROR_DESC(a) \
26 const EGLNameErrorPair pairs[] = {
46 const auto count =
sizeof(pairs) /
sizeof(EGLNameErrorPair);
48 EGLint last_error = eglGetError();
51 if (last_error == pairs[
i].
code) {
52 FML_LOG(
ERROR) <<
"EGL Error: " << pairs[
i].name <<
" (" << pairs[
i].code
63 void init(EGLDisplay display, EGLContext context) {}
67 const std::optional<SkIRect>&
region) {}
79 const std::optional<SkIRect>& damage) {
80 return eglSwapBuffers(display,
surface);
91 damage_->init(display_, context);
95 [[maybe_unused]]
auto result = eglDestroySurface(display_, surface_);
100 return surface_ != EGL_NO_SURFACE;
103bool AndroidEGLSurface::IsContextCurrent()
const {
104 EGLContext current_egl_context = eglGetCurrentContext();
105 if (context_ != current_egl_context) {
109 EGLDisplay current_egl_display = eglGetCurrentDisplay();
110 if (display_ != current_egl_display) {
114 EGLSurface draw_surface = eglGetCurrentSurface(EGL_DRAW);
115 if (draw_surface != surface_) {
119 EGLSurface read_surface = eglGetCurrentSurface(EGL_READ);
120 if (read_surface != surface_) {
128 if (IsContextCurrent()) {
131 if (eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
140 const std::optional<SkIRect>& buffer_damage) {
141 damage_->SetDamageRegion(display_, surface_, buffer_damage);
146 if (presentation_time_proc_) {
148 return presentation_time_proc_(display_, surface_, time_ns);
155 const std::optional<SkIRect>& surface_damage) {
156 TRACE_EVENT0(
"flutter",
"AndroidContextGL::SwapBuffers");
157 return damage_->SwapBuffersWithDamage(display_, surface_, surface_damage);
161 return damage_->SupportsPartialRepaint();
165 return damage_->InitialDamage(display_, surface_);
172 if (!eglQuerySurface(display_, surface_, EGL_WIDTH, &
width) ||
173 !eglQuerySurface(display_, surface_, EGL_HEIGHT, &
height)) {
#define _EGL_ERROR_DESC(a)
bool SupportsPartialRepaint() const
std::optional< SkIRect > InitialDamage(EGLDisplay display, EGLSurface surface)
void SetDamageRegion(EGLDisplay display, EGLSurface surface, const std::optional< SkIRect > ®ion)
bool SwapBuffersWithDamage(EGLDisplay display, EGLSurface surface, const std::optional< SkIRect > &damage)
void init(EGLDisplay display, EGLContext context)
std::optional< SkIRect > InitialDamage()
This is the minimal area that needs to be repainted to get correct result.
bool SwapBuffers(const std::optional< SkIRect > &surface_damage)
This only applies to on-screen surfaces such as those created by AndroidContextGL::CreateOnscreenSurf...
void SetDamageRegion(const std::optional< SkIRect > &buffer_damage)
Sets the damage region for current surface. Corresponds to.
bool SupportsPartialRepaint() const
AndroidEGLSurface(EGLSurface surface, EGLDisplay display, EGLContext context)
bool SetPresentationTime(const fml::TimePoint &presentation_time)
Sets the presentation time for the current surface. This.
AndroidEGLSurfaceMakeCurrentStatus MakeCurrent() const
Binds the EGLContext context to the current rendering thread and to the draw and read surface.
constexpr int64_t ToNanoseconds() const
TimeDelta ToEpochDelta() const
#define FML_LOG(severity)
#define FML_DCHECK(condition)
ClipOpAndAA opAA SkRegion region
DEF_SWITCHES_START aot vmservice shared library name
AndroidEGLSurfaceMakeCurrentStatus
Result of calling MakeCurrent on AndroidEGLSurface.
@ 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.
static constexpr SkISize Make(int32_t w, int32_t h)
#define TRACE_EVENT0(category_group, name)