Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/browser/scoped_app_gl_state_restore.h" | 5 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(ScopedAppGLStateRestoreImpl); | 142 DISALLOW_COPY_AND_ASSIGN(ScopedAppGLStateRestoreImpl); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl( | 145 ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl( |
| 146 ScopedAppGLStateRestore::CallMode mode) | 146 ScopedAppGLStateRestore::CallMode mode) |
| 147 : mode_(mode) { | 147 : mode_(mode) { |
| 148 TRACE_EVENT0("android_webview", "AppGLStateSave"); | 148 TRACE_EVENT0("android_webview", "AppGLStateSave"); |
| 149 MakeAppContextCurrent(); | 149 MakeAppContextCurrent(); |
| 150 | 150 |
| 151 // Ignore incoming GL errors. | |
| 152 GLenum error = glGetError(); | |
| 153 DLOG_IF(WARNING, error != static_cast<GLenum>(GL_NO_ERROR)) | |
| 154 << "Incoming GLError " << error; | |
|
no sievers
2014/05/15 20:49:24
Since it's an error stack you need to loop over it
| |
| 155 | |
| 151 if (!g_globals_initialized) { | 156 if (!g_globals_initialized) { |
| 152 g_globals_initialized = true; | 157 g_globals_initialized = true; |
| 153 | 158 |
| 154 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &g_gl_max_texture_units); | 159 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &g_gl_max_texture_units); |
| 155 DCHECK_GT(g_gl_max_texture_units, 0); | 160 DCHECK_GT(g_gl_max_texture_units, 0); |
| 156 | 161 |
| 157 std::string extensions( | 162 std::string extensions( |
| 158 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); | 163 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); |
| 159 g_supports_oes_vertex_array_object = | 164 g_supports_oes_vertex_array_object = |
| 160 extensions.find("GL_OES_vertex_array_object") != std::string::npos; | 165 extensions.find("GL_OES_vertex_array_object") != std::string::npos; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 glGetVertexAttribPointerv( | 249 glGetVertexAttribPointerv( |
| 245 i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &vertex_attrib_[i].pointer); | 250 i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &vertex_attrib_[i].pointer); |
| 246 glGetVertexAttribPointerv( | 251 glGetVertexAttribPointerv( |
| 247 i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &vertex_attrib_[i].pointer); | 252 i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &vertex_attrib_[i].pointer); |
| 248 glGetVertexAttribiv(i, | 253 glGetVertexAttribiv(i, |
| 249 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, | 254 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, |
| 250 &vertex_attrib_[i].vertex_attrib_array_buffer_binding); | 255 &vertex_attrib_[i].vertex_attrib_array_buffer_binding); |
| 251 glGetVertexAttribfv( | 256 glGetVertexAttribfv( |
| 252 i, GL_CURRENT_VERTEX_ATTRIB, vertex_attrib_[i].current_vertex_attrib); | 257 i, GL_CURRENT_VERTEX_ATTRIB, vertex_attrib_[i].current_vertex_attrib); |
| 253 } | 258 } |
| 259 DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR)); | |
| 254 } | 260 } |
| 255 | 261 |
| 256 ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() { | 262 ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() { |
| 257 TRACE_EVENT0("android_webview", "AppGLStateRestore"); | 263 TRACE_EVENT0("android_webview", "AppGLStateRestore"); |
| 258 MakeAppContextCurrent(); | 264 MakeAppContextCurrent(); |
| 259 | 265 |
| 266 DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR)); | |
| 267 | |
| 260 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_); | 268 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_); |
| 261 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); | 269 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); |
| 262 | 270 |
| 263 if (g_supports_oes_vertex_array_object) | 271 if (g_supports_oes_vertex_array_object) |
| 264 glBindVertexArrayOES(0); | 272 glBindVertexArrayOES(0); |
| 265 | 273 |
| 266 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib_); ++i) { | 274 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib_); ++i) { |
| 267 glBindBuffer(GL_ARRAY_BUFFER, | 275 glBindBuffer(GL_ARRAY_BUFFER, |
| 268 vertex_attrib_[i].vertex_attrib_array_buffer_binding); | 276 vertex_attrib_[i].vertex_attrib_array_buffer_binding); |
| 269 glVertexAttribPointer(i, | 277 glVertexAttribPointer(i, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 | 348 |
| 341 GLEnableDisable(GL_SCISSOR_TEST, scissor_test_); | 349 GLEnableDisable(GL_SCISSOR_TEST, scissor_test_); |
| 342 | 350 |
| 343 glScissor( | 351 glScissor( |
| 344 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); | 352 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); |
| 345 break; | 353 break; |
| 346 } | 354 } |
| 347 | 355 |
| 348 GLEnableDisable(GL_STENCIL_TEST, stencil_test_); | 356 GLEnableDisable(GL_STENCIL_TEST, stencil_test_); |
| 349 glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); | 357 glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); |
| 358 | |
| 359 // Do not leak GLError out of chromium. | |
| 360 GLenum error = glGetError(); | |
| 361 DLOG_IF(WARNING, error != static_cast<GLenum>(GL_NO_ERROR)) | |
| 362 << "Chromium produced GLError " << error; | |
| 350 } | 363 } |
| 351 | 364 |
| 352 } // namespace internal | 365 } // namespace internal |
| 353 | 366 |
| 354 ScopedAppGLStateRestore::ScopedAppGLStateRestore(CallMode mode) | 367 ScopedAppGLStateRestore::ScopedAppGLStateRestore(CallMode mode) |
| 355 : impl_(new internal::ScopedAppGLStateRestoreImpl(mode)) { | 368 : impl_(new internal::ScopedAppGLStateRestoreImpl(mode)) { |
| 356 } | 369 } |
| 357 | 370 |
| 358 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() {} | 371 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() {} |
| 359 | 372 |
| 360 bool ScopedAppGLStateRestore::stencil_enabled() const { | 373 bool ScopedAppGLStateRestore::stencil_enabled() const { |
| 361 return impl_->stencil_enabled(); | 374 return impl_->stencil_enabled(); |
| 362 } | 375 } |
| 363 int ScopedAppGLStateRestore::framebuffer_binding_ext() const { | 376 int ScopedAppGLStateRestore::framebuffer_binding_ext() const { |
| 364 return impl_->framebuffer_binding_ext(); | 377 return impl_->framebuffer_binding_ext(); |
| 365 } | 378 } |
| 366 | 379 |
| 367 } // namespace android_webview | 380 } // namespace android_webview |
| OLD | NEW |