Commit c32e3445 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Track eglMakeCurrent failure in GLContextEGL::ReleaseCurrent

Under lost device conditions, eglMakeCurrent can fail, even when releasing
the context. As we otherwise assume that we have correct bindings when
GLContext::IsCurrent returns true, we need to track the lost state to
ensure that after ReleaseCurrent, IsCurrent will return false.

Bug: 928693
Change-Id: I5bbf2616f872532c03da1e1beeade5c94d920b92
Reviewed-on: https://chromium-review.googlesource.com/c/1457675Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Auto-Submit: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629879}
parent 5fdbf6eb
......@@ -62,11 +62,7 @@ using ui::GetLastEGLErrorString;
namespace gl {
GLContextEGL::GLContextEGL(GLShareGroup* share_group)
: GLContextReal(share_group),
context_(EGL_NO_CONTEXT),
display_(EGL_NO_DISPLAY),
config_(nullptr),
unbind_fbo_on_makecurrent_(false) {}
: GLContextReal(share_group) {}
bool GLContextEGL::Initialize(GLSurface* compatible_surface,
const GLContextAttribs& attribs) {
......@@ -278,8 +274,10 @@ void GLContextEGL::ReleaseYUVToRGBConverters() {
bool GLContextEGL::MakeCurrent(GLSurface* surface) {
DCHECK(context_);
if (lost_)
return false;
if (IsCurrent(surface))
return true;
return true;
ScopedReleaseCurrent release_current;
TRACE_EVENT2("gpu", "GLContextEGL::MakeCurrent",
......@@ -326,14 +324,20 @@ void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
SetCurrent(nullptr);
eglMakeCurrent(display_,
EGL_NO_SURFACE,
EGL_NO_SURFACE,
EGL_NO_CONTEXT);
if (!eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT)) {
DVLOG(1) << "eglMakeCurrent failed to release current with error "
<< GetLastEGLErrorString();
lost_ = true;
}
DCHECK(!IsCurrent(nullptr));
}
bool GLContextEGL::IsCurrent(GLSurface* surface) {
DCHECK(context_);
if (lost_)
return false;
bool native_context_is_current = context_ == eglGetCurrentContext();
......
......@@ -45,10 +45,11 @@ class GL_EXPORT GLContextEGL : public GLContextReal {
void Destroy();
void ReleaseYUVToRGBConverters();
EGLContext context_;
EGLDisplay display_;
EGLConfig config_;
bool unbind_fbo_on_makecurrent_;
EGLContext context_ = nullptr;
EGLDisplay display_ = nullptr;
EGLConfig config_ = nullptr;
bool unbind_fbo_on_makecurrent_ = false;
bool lost_ = false;
std::map<gfx::ColorSpace, std::unique_ptr<YUVToRGBConverter>>
yuv_to_rgb_converters_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment