88
99#include < utility>
1010
11- #include " android_environment_gl.h"
1211#include " flutter/fml/trace_event.h"
1312
1413namespace flutter {
@@ -106,14 +105,13 @@ static bool TeardownContext(EGLDisplay display, EGLContext context) {
106105 return true ;
107106}
108107
109- AndroidEGLSurface::AndroidEGLSurface (
110- EGLSurface surface,
111- fml::RefPtr<AndroidEnvironmentGL> environment,
112- EGLContext context)
113- : surface_(surface), environment_(environment), context_(context) {}
108+ AndroidEGLSurface::AndroidEGLSurface (EGLSurface surface,
109+ EGLDisplay display,
110+ EGLContext context)
111+ : surface_(surface), display_(display), context_(context) {}
114112
115113AndroidEGLSurface::~AndroidEGLSurface () {
116- auto result = eglDestroySurface (environment_-> Display () , surface_);
114+ auto result = eglDestroySurface (display_ , surface_);
117115 FML_DCHECK (result == EGL_TRUE);
118116}
119117
@@ -122,28 +120,25 @@ bool AndroidEGLSurface::IsValid() const {
122120}
123121
124122bool AndroidEGLSurface::MakeCurrent () const {
125- if (eglMakeCurrent (environment_->Display (), surface_, surface_, context_) !=
126- EGL_TRUE) {
123+ if (eglMakeCurrent (display_, surface_, surface_, context_) != EGL_TRUE) {
127124 FML_LOG (ERROR) << " Could not make the context current" ;
128125 LogLastEGLError ();
129126 return false ;
130127 }
131128 return true ;
132129}
133130
134- bool AndroidEGLSurface::SwapBuffers (fml::TimePoint target_time ) {
131+ bool AndroidEGLSurface::SwapBuffers () {
135132 TRACE_EVENT0 (" flutter" , " AndroidContextGL::SwapBuffers" );
136- environment_->SetPresentationTime (surface_, target_time);
137- return eglSwapBuffers (environment_->Display (), surface_);
133+ return eglSwapBuffers (display_, surface_);
138134}
139135
140136SkISize AndroidEGLSurface::GetSize () const {
141137 EGLint width = 0 ;
142138 EGLint height = 0 ;
143139
144- if (!eglQuerySurface (environment_->Display (), surface_, EGL_WIDTH, &width) ||
145- !eglQuerySurface (environment_->Display (), surface_, EGL_HEIGHT,
146- &height)) {
140+ if (!eglQuerySurface (display_, surface_, EGL_WIDTH, &width) ||
141+ !eglQuerySurface (display_, surface_, EGL_HEIGHT, &height)) {
147142 FML_LOG (ERROR) << " Unable to query EGL surface size" ;
148143 LogLastEGLError ();
149144 return SkISize::Make (0 , 0 );
@@ -234,24 +229,27 @@ std::unique_ptr<AndroidEGLSurface> AndroidContextGL::CreateOnscreenSurface(
234229 if (window->IsFakeWindow ()) {
235230 return CreatePbufferSurface ();
236231 } else {
232+ EGLDisplay display = environment_->Display ();
233+
237234 const EGLint attribs[] = {EGL_NONE};
238235
239236 EGLSurface surface = eglCreateWindowSurface (
240- environment_-> Display () , config_,
237+ display , config_,
241238 reinterpret_cast <EGLNativeWindowType>(window->handle ()), attribs);
242- return std::make_unique<AndroidEGLSurface>(surface, environment_ , context_);
239+ return std::make_unique<AndroidEGLSurface>(surface, display , context_);
243240 }
244241}
245242
246243std::unique_ptr<AndroidEGLSurface> AndroidContextGL::CreateOffscreenSurface ()
247244 const {
248245 // We only ever create pbuffer surfaces for background resource loading
249246 // contexts. We never bind the pbuffer to anything.
247+ EGLDisplay display = environment_->Display ();
248+
250249 const EGLint attribs[] = {EGL_WIDTH, 1 , EGL_HEIGHT, 1 , EGL_NONE};
251250
252- EGLSurface surface =
253- eglCreatePbufferSurface (environment_->Display (), config_, attribs);
254- return std::make_unique<AndroidEGLSurface>(surface, environment_,
251+ EGLSurface surface = eglCreatePbufferSurface (display, config_, attribs);
252+ return std::make_unique<AndroidEGLSurface>(surface, display,
255253 resource_context_);
256254}
257255
@@ -262,7 +260,7 @@ std::unique_ptr<AndroidEGLSurface> AndroidContextGL::CreatePbufferSurface()
262260 const EGLint attribs[] = {EGL_WIDTH, 1 , EGL_HEIGHT, 1 , EGL_NONE};
263261
264262 EGLSurface surface = eglCreatePbufferSurface (display, config_, attribs);
265- return std::make_unique<AndroidEGLSurface>(surface, environment_ , context_);
263+ return std::make_unique<AndroidEGLSurface>(surface, display , context_);
266264}
267265
268266fml::RefPtr<AndroidEnvironmentGL> AndroidContextGL::Environment () const {
0 commit comments