| 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 "android_webview/browser/gl_surface_factory.h" |
| 7 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 8 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 9 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
| 10 #include "ui/gl/gl_surface_stub.h" | 11 #include "ui/gl/gl_surface_stub.h" |
| 11 | 12 |
| 12 namespace android_webview { | 13 namespace android_webview { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // "App" context is a bit of a stretch. Basically we use this context while | 17 // "App" context is a bit of a stretch. Basically we use this context while |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 glGetBooleanv(GL_DITHER, &enable_dither_); | 126 glGetBooleanv(GL_DITHER, &enable_dither_); |
| 126 glGetBooleanv(GL_POLYGON_OFFSET_FILL, &enable_polygon_offset_fill_); | 127 glGetBooleanv(GL_POLYGON_OFFSET_FILL, &enable_polygon_offset_fill_); |
| 127 glGetBooleanv(GL_SAMPLE_ALPHA_TO_COVERAGE, &enable_sample_alpha_to_coverage_); | 128 glGetBooleanv(GL_SAMPLE_ALPHA_TO_COVERAGE, &enable_sample_alpha_to_coverage_); |
| 128 glGetBooleanv(GL_SAMPLE_COVERAGE, &enable_sample_coverage_); | 129 glGetBooleanv(GL_SAMPLE_COVERAGE, &enable_sample_coverage_); |
| 129 | 130 |
| 130 glGetBooleanv(GL_STENCIL_TEST, &stencil_test_); | 131 glGetBooleanv(GL_STENCIL_TEST, &stencil_test_); |
| 131 glGetIntegerv(GL_STENCIL_FUNC, &stencil_func_); | 132 glGetIntegerv(GL_STENCIL_FUNC, &stencil_func_); |
| 132 glGetIntegerv(GL_STENCIL_VALUE_MASK, &stencil_mask_); | 133 glGetIntegerv(GL_STENCIL_VALUE_MASK, &stencil_mask_); |
| 133 glGetIntegerv(GL_STENCIL_REF, &stencil_ref_); | 134 glGetIntegerv(GL_STENCIL_REF, &stencil_ref_); |
| 134 | 135 |
| 136 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &framebuffer_binding_ext_); |
| 135 | 137 |
| 136 if (!g_gl_max_texture_units) { | 138 if (!g_gl_max_texture_units) { |
| 137 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &g_gl_max_texture_units); | 139 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &g_gl_max_texture_units); |
| 138 DCHECK_GT(g_gl_max_texture_units, 0); | 140 DCHECK_GT(g_gl_max_texture_units, 0); |
| 139 } | 141 } |
| 140 | 142 |
| 141 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); | 143 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); |
| 142 | 144 |
| 143 texture_bindings_.resize(g_gl_max_texture_units); | 145 texture_bindings_.resize(g_gl_max_texture_units); |
| 144 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { | 146 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { |
| 145 glActiveTexture(GL_TEXTURE0 + ii); | 147 glActiveTexture(GL_TEXTURE0 + ii); |
| 146 TextureBindings& bindings = texture_bindings_[ii]; | 148 TextureBindings& bindings = texture_bindings_[ii]; |
| 147 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bindings.texture_2d); | 149 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bindings.texture_2d); |
| 148 glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bindings.texture_cube_map); | 150 glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bindings.texture_cube_map); |
| 149 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, | 151 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, |
| 150 &bindings.texture_external_oes); | 152 &bindings.texture_external_oes); |
| 151 } | 153 } |
| 152 } | 154 } |
| 153 | 155 |
| 154 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() { | 156 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() { |
| 155 TRACE_EVENT0("android_webview", "AppGLStateRestore"); | 157 TRACE_EVENT0("android_webview", "AppGLStateRestore"); |
| 156 MakeAppContextCurrent(); | 158 MakeAppContextCurrent(); |
| 157 | 159 |
| 160 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_); |
| 158 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); | 161 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); |
| 159 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); | 162 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); |
| 160 | 163 |
| 161 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { | 164 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { |
| 162 glActiveTexture(GL_TEXTURE0 + ii); | 165 glActiveTexture(GL_TEXTURE0 + ii); |
| 163 TextureBindings& bindings = texture_bindings_[ii]; | 166 TextureBindings& bindings = texture_bindings_[ii]; |
| 164 glBindTexture(GL_TEXTURE_2D, bindings.texture_2d); | 167 glBindTexture(GL_TEXTURE_2D, bindings.texture_2d); |
| 165 glBindTexture(GL_TEXTURE_CUBE_MAP, bindings.texture_cube_map); | 168 glBindTexture(GL_TEXTURE_CUBE_MAP, bindings.texture_cube_map); |
| 166 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bindings.texture_external_oes); | 169 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bindings.texture_external_oes); |
| 167 } | 170 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 227 |
| 225 glScissor( | 228 glScissor( |
| 226 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); | 229 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); |
| 227 } | 230 } |
| 228 | 231 |
| 229 GLEnableDisable(GL_STENCIL_TEST, stencil_test_); | 232 GLEnableDisable(GL_STENCIL_TEST, stencil_test_); |
| 230 glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); | 233 glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); |
| 231 } | 234 } |
| 232 | 235 |
| 233 } // namespace android_webview | 236 } // namespace android_webview |
| OLD | NEW |