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; ...@@ -62,11 +62,7 @@ using ui::GetLastEGLErrorString;
namespace gl { namespace gl {
GLContextEGL::GLContextEGL(GLShareGroup* share_group) GLContextEGL::GLContextEGL(GLShareGroup* share_group)
: GLContextReal(share_group), : GLContextReal(share_group) {}
context_(EGL_NO_CONTEXT),
display_(EGL_NO_DISPLAY),
config_(nullptr),
unbind_fbo_on_makecurrent_(false) {}
bool GLContextEGL::Initialize(GLSurface* compatible_surface, bool GLContextEGL::Initialize(GLSurface* compatible_surface,
const GLContextAttribs& attribs) { const GLContextAttribs& attribs) {
...@@ -278,6 +274,8 @@ void GLContextEGL::ReleaseYUVToRGBConverters() { ...@@ -278,6 +274,8 @@ void GLContextEGL::ReleaseYUVToRGBConverters() {
bool GLContextEGL::MakeCurrent(GLSurface* surface) { bool GLContextEGL::MakeCurrent(GLSurface* surface) {
DCHECK(context_); DCHECK(context_);
if (lost_)
return false;
if (IsCurrent(surface)) if (IsCurrent(surface))
return true; return true;
...@@ -326,14 +324,20 @@ void GLContextEGL::ReleaseCurrent(GLSurface* surface) { ...@@ -326,14 +324,20 @@ void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
glBindFramebufferEXT(GL_FRAMEBUFFER, 0); glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
SetCurrent(nullptr); SetCurrent(nullptr);
eglMakeCurrent(display_, if (!eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
EGL_NO_SURFACE, DVLOG(1) << "eglMakeCurrent failed to release current with error "
EGL_NO_CONTEXT); << GetLastEGLErrorString();
lost_ = true;
}
DCHECK(!IsCurrent(nullptr));
} }
bool GLContextEGL::IsCurrent(GLSurface* surface) { bool GLContextEGL::IsCurrent(GLSurface* surface) {
DCHECK(context_); DCHECK(context_);
if (lost_)
return false;
bool native_context_is_current = context_ == eglGetCurrentContext(); bool native_context_is_current = context_ == eglGetCurrentContext();
......
...@@ -45,10 +45,11 @@ class GL_EXPORT GLContextEGL : public GLContextReal { ...@@ -45,10 +45,11 @@ class GL_EXPORT GLContextEGL : public GLContextReal {
void Destroy(); void Destroy();
void ReleaseYUVToRGBConverters(); void ReleaseYUVToRGBConverters();
EGLContext context_; EGLContext context_ = nullptr;
EGLDisplay display_; EGLDisplay display_ = nullptr;
EGLConfig config_; EGLConfig config_ = nullptr;
bool unbind_fbo_on_makecurrent_; bool unbind_fbo_on_makecurrent_ = false;
bool lost_ = false;
std::map<gfx::ColorSpace, std::unique_ptr<YUVToRGBConverter>> std::map<gfx::ColorSpace, std::unique_ptr<YUVToRGBConverter>>
yuv_to_rgb_converters_; 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