Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1933)

Unified Diff: android_webview/browser/scoped_app_gl_state_restore.cc

Issue 288003002: aw: Avoid leaking GL error across android and chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clear stack Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/scoped_app_gl_state_restore.cc
diff --git a/android_webview/browser/scoped_app_gl_state_restore.cc b/android_webview/browser/scoped_app_gl_state_restore.cc
index 71a5711a26f7967fdbef4830738e810a673b98c3..399b36aaf06a83a0e0aa92d1410735fbee18d172 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698