Commit 8afc6491 authored by boliu@chromium.org's avatar boliu@chromium.org

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
parent 02022fc1
...@@ -51,6 +51,17 @@ void GLEnableDisable(GLenum cap, bool enable) { ...@@ -51,6 +51,17 @@ void GLEnableDisable(GLenum cap, bool enable) {
glDisable(cap); 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; bool g_globals_initialized = false;
GLint g_gl_max_texture_units = 0; GLint g_gl_max_texture_units = 0;
bool g_supports_oes_vertex_array_object = false; bool g_supports_oes_vertex_array_object = false;
...@@ -148,6 +159,8 @@ ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl( ...@@ -148,6 +159,8 @@ ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl(
TRACE_EVENT0("android_webview", "AppGLStateSave"); TRACE_EVENT0("android_webview", "AppGLStateSave");
MakeAppContextCurrent(); MakeAppContextCurrent();
ClearGLErrors(true, "Incoming GLError");
if (!g_globals_initialized) { if (!g_globals_initialized) {
g_globals_initialized = true; g_globals_initialized = true;
...@@ -251,12 +264,15 @@ ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl( ...@@ -251,12 +264,15 @@ ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl(
glGetVertexAttribfv( glGetVertexAttribfv(
i, GL_CURRENT_VERTEX_ATTRIB, vertex_attrib_[i].current_vertex_attrib); i, GL_CURRENT_VERTEX_ATTRIB, vertex_attrib_[i].current_vertex_attrib);
} }
DCHECK(ClearGLErrors(false, NULL));
} }
ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() { ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() {
TRACE_EVENT0("android_webview", "AppGLStateRestore"); TRACE_EVENT0("android_webview", "AppGLStateRestore");
MakeAppContextCurrent(); MakeAppContextCurrent();
DCHECK(ClearGLErrors(false, NULL));
glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_); glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_);
...@@ -347,6 +363,9 @@ ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() { ...@@ -347,6 +363,9 @@ ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() {
GLEnableDisable(GL_STENCIL_TEST, stencil_test_); GLEnableDisable(GL_STENCIL_TEST, stencil_test_);
glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_);
// Do not leak GLError out of chromium.
ClearGLErrors(true, "Chromium GLError");
} }
} // namespace internal } // namespace internal
......
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