19constexpr char kEmulatorRendererPrefix[] =
20 "Android Emulator OpenGL ES Translator";
24 const std::shared_ptr<AndroidContextGLSkia>& android_context)
25 : android_context_(android_context),
26 native_window_(nullptr),
27 onscreen_surface_(nullptr),
28 offscreen_surface_(nullptr) {
30 offscreen_surface_ = android_context_->CreateOffscreenSurface();
31 if (!offscreen_surface_->IsValid()) {
32 offscreen_surface_ =
nullptr;
42 android_context_->ClearCurrent();
43 onscreen_surface_ =
nullptr;
47 return offscreen_surface_ && android_context_->IsValid();
51 GrDirectContext* gr_context) {
53 return std::make_unique<GPUSurfaceGLSkia>(sk_ref_sp(gr_context),
this,
56 sk_sp<GrDirectContext> main_skia_context =
57 android_context_->GetMainSkiaContext();
58 if (!main_skia_context) {
60 android_context_->SetMainSkiaContext(main_skia_context);
62 return std::make_unique<GPUSurfaceGLSkia>(main_skia_context,
this,
true);
71 if (
size == onscreen_surface_->GetSize()) {
75 android_context_->ClearCurrent();
79 onscreen_surface_ =
nullptr;
80 onscreen_surface_ = android_context_->CreateOnscreenSurface(native_window_);
81 if (!onscreen_surface_->IsValid()) {
82 FML_LOG(ERROR) <<
"Unable to create EGL window surface on resize.";
85 onscreen_surface_->MakeCurrent();
91 auto status = offscreen_surface_->MakeCurrent();
97 EGLBoolean result = eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE,
98 EGL_NO_SURFACE, EGL_NO_CONTEXT);
99 return result == EGL_TRUE;
104 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade) {
110 onscreen_surface_ =
nullptr;
112 onscreen_surface_ = android_context_->CreateOnscreenSurface(
window);
113 if (!onscreen_surface_->IsValid()) {
122 auto status = onscreen_surface_->MakeCurrent();
123 auto default_context_result = std::make_unique<GLContextDefaultResult>(
125 return std::move(default_context_result);
130 return android_context_->ClearCurrent();
151 const std::optional<DlIRect>& region) {
153 onscreen_surface_->SetDamageRegion(region);
162 return onscreen_surface_->SwapBuffers(present_info.
frame_damage);
170 .existing_damage = onscreen_surface_->InitialDamage(),
184 const char* gl_renderer =
185 reinterpret_cast<const char*
>(glGetString(GL_RENDERER));
186 if (gl_renderer && strncmp(gl_renderer, kEmulatorRendererPrefix,
187 strlen(kEmulatorRendererPrefix)) == 0) {
188 EGLContext new_context = android_context_->CreateNewContext();
189 if (new_context != EGL_NO_CONTEXT) {
190 EGLContext old_context = eglGetCurrentContext();
191 EGLDisplay display = eglGetCurrentDisplay();
192 EGLSurface draw_surface = eglGetCurrentSurface(EGL_DRAW);
193 EGLSurface read_surface = eglGetCurrentSurface(EGL_READ);
194 [[maybe_unused]] EGLBoolean result =
195 eglMakeCurrent(display, draw_surface, read_surface, new_context);
197 result = eglMakeCurrent(display, draw_surface, read_surface, old_context);
199 result = eglDestroyContext(display, new_context);
208 if (!onscreen_surface_ || !onscreen_surface_->IsValid()) {
209 onscreen_surface_ = android_context_->CreatePbufferSurface();
211 sk_sp<GrDirectContext> main_skia_context =
212 android_context_->GetMainSkiaContext();
213 if (!main_skia_context) {
215 android_context_->SetMainSkiaContext(main_skia_context);
218 return std::make_unique<GPUSurfaceGLSkia>(main_skia_context,
this,
true);
bool OnScreenSurfaceResize(const DlISize &size) override
bool GLContextPresent(const GLPresentInfo &present_info) override
std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context) override
bool ResourceContextMakeCurrent() override
virtual std::unique_ptr< Surface > CreateSnapshotSurface() override
bool GLContextClearCurrent() override
sk_sp< const GrGLInterface > GetGLInterface() const override
bool ResourceContextClearCurrent() override
AndroidSurfaceGLSkia(const std::shared_ptr< AndroidContextGLSkia > &android_context)
void TeardownOnScreenContext() override
void GLContextSetDamageRegion(const std::optional< DlIRect > ®ion) override
bool IsValid() const override
std::unique_ptr< GLContextResult > GLContextMakeCurrent() override
SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override
bool SetNativeWindow(fml::RefPtr< AndroidNativeWindow > window, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade) override
GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override
~AndroidSurfaceGLSkia() override
virtual sk_sp< const GrGLInterface > GetGLInterface() const
static sk_sp< GrDirectContext > MakeGLContext(GPUSurfaceGLDelegate *delegate)
#define FML_LOG(severity)
#define FML_DCHECK(condition)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
@ kFailure
Failed to make the egl context for the surface current.
std::optional< fml::TimePoint > presentation_time
const std::optional< DlIRect > & frame_damage
bool supports_partial_repaint
std::optional< DlIRect > existing_damage
int horizontal_clip_alignment
int vertical_clip_alignment