diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-16 00:16:25 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-16 00:16:25 +0000 |
commit | 8afc64910396ff88dcafd306b0a7aeb96000bf63 (patch) | |
tree | f6165fcd50dbe39bc215e1ffbc9bf72e1efa095e /android_webview | |
parent | 02022fc1935970dfc2690eb150cbb0ab304d54ed (diff) | |
download | chromium_src-8afc64910396ff88dcafd306b0a7aeb96000bf63.zip chromium_src-8afc64910396ff88dcafd306b0a7aeb96000bf63.tar.gz chromium_src-8afc64910396ff88dcafd306b0a7aeb96000bf63.tar.bz2 |
aw: Avoid leaking GL error across android and chromium
BUG=
Review URL: https://codereview.chromium.org/288003002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270871 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/browser/scoped_app_gl_state_restore.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/android_webview/browser/scoped_app_gl_state_restore.cc b/android_webview/browser/scoped_app_gl_state_restore.cc index 71a5711..399b36a 100644 --- a/android_webview/browser/scoped_app_gl_state_restore.cc +++ b/android_webview/browser/scoped_app_gl_state_restore.cc @@ -51,6 +51,17 @@ void GLEnableDisable(GLenum cap, bool enable) { glDisable(cap); } +bool ClearGLErrors(bool warn, const char* msg) { + bool no_error = true; + GLenum error; + while ((error = glGetError()) != GL_NO_ERROR) { + DLOG_IF(WARNING, warn) << error << " " << msg; + no_error = false; + } + + return no_error; +} + bool g_globals_initialized = false; GLint g_gl_max_texture_units = 0; bool g_supports_oes_vertex_array_object = false; @@ -148,6 +159,8 @@ ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl( TRACE_EVENT0("android_webview", "AppGLStateSave"); MakeAppContextCurrent(); + ClearGLErrors(true, "Incoming GLError"); + if (!g_globals_initialized) { g_globals_initialized = true; @@ -251,12 +264,15 @@ ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl( glGetVertexAttribfv( i, GL_CURRENT_VERTEX_ATTRIB, vertex_attrib_[i].current_vertex_attrib); } + DCHECK(ClearGLErrors(false, NULL)); } ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() { TRACE_EVENT0("android_webview", "AppGLStateRestore"); MakeAppContextCurrent(); + DCHECK(ClearGLErrors(false, NULL)); + glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); @@ -347,6 +363,9 @@ ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() { GLEnableDisable(GL_STENCIL_TEST, stencil_test_); glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); + + // Do not leak GLError out of chromium. + ClearGLErrors(true, "Chromium GLError"); } } // namespace internal |