diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-26 00:06:53 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-26 00:06:53 +0000 |
commit | f52258168c3c83ce3702f6355fcf4d1b5edebcde (patch) | |
tree | de9ace0d4c2f209cb5fe18bdce6b52e2e0abcf72 /ui/gl | |
parent | b97059d17d2548af7fcd8ca034658726008d9860 (diff) | |
download | chromium_src-f52258168c3c83ce3702f6355fcf4d1b5edebcde.zip chromium_src-f52258168c3c83ce3702f6355fcf4d1b5edebcde.tar.gz chromium_src-f52258168c3c83ce3702f6355fcf4d1b5edebcde.tar.bz2 |
Fix bug where no context would be made current on failure to create pbuffer surface.
It might fail because, e.g., the requested size is zero.
I think this might have made some of the GL issued by the renderer go to /dev/null and might explain the random black tiles bug.
Review URL: https://chromiumcodereview.appspot.com/11896084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178946 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl')
-rw-r--r-- | ui/gl/gl_surface_egl.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc index 7dc8bf4..7d216c1 100644 --- a/ui/gl/gl_surface_egl.cc +++ b/ui/gl/gl_surface_egl.cc @@ -441,9 +441,10 @@ PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) } bool PbufferGLSurfaceEGL::Initialize() { - DCHECK(!surface_); + EGLSurface old_surface = surface_; - if (!GetDisplay()) { + EGLDisplay display = GetDisplay(); + if (!display) { LOG(ERROR) << "Trying to create surface with invalid display."; return false; } @@ -454,22 +455,29 @@ bool PbufferGLSurfaceEGL::Initialize() { return false; } + // Allocate the new pbuffer surface before freeing the old one to ensure + // they have different addresses. If they have the same address then a + // future call to MakeCurrent might early out because it appears the current + // context and surface have not changed. const EGLint pbuffer_attribs[] = { EGL_WIDTH, size_.width(), EGL_HEIGHT, size_.height(), EGL_NONE }; - surface_ = eglCreatePbufferSurface(GetDisplay(), - GetConfig(), - pbuffer_attribs); - if (!surface_) { + EGLSurface new_surface = eglCreatePbufferSurface(display, + GetConfig(), + pbuffer_attribs); + if (!new_surface) { LOG(ERROR) << "eglCreatePbufferSurface failed with error " << GetLastEGLErrorString(); - Destroy(); return false; } + if (old_surface) + eglDestroySurface(display, old_surface); + + surface_ = new_surface; return true; } @@ -506,10 +514,6 @@ bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { GLContext* current_context = GLContext::GetCurrent(); bool was_current = current_context && current_context->IsCurrent(this); - if (was_current) - current_context->ReleaseCurrent(this); - - Destroy(); size_ = size; |