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_); |
| 137 GLSurfaceFactory::SetCurrentFBO(framebuffer_binding_ext_); |
135 | 138 |
136 if (!g_gl_max_texture_units) { | 139 if (!g_gl_max_texture_units) { |
137 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &g_gl_max_texture_units); | 140 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &g_gl_max_texture_units); |
138 DCHECK_GT(g_gl_max_texture_units, 0); | 141 DCHECK_GT(g_gl_max_texture_units, 0); |
139 } | 142 } |
140 | 143 |
141 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); | 144 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); |
142 | 145 |
143 texture_bindings_.resize(g_gl_max_texture_units); | 146 texture_bindings_.resize(g_gl_max_texture_units); |
144 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { | 147 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { |
145 glActiveTexture(GL_TEXTURE0 + ii); | 148 glActiveTexture(GL_TEXTURE0 + ii); |
146 TextureBindings& bindings = texture_bindings_[ii]; | 149 TextureBindings& bindings = texture_bindings_[ii]; |
147 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bindings.texture_2d); | 150 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bindings.texture_2d); |
148 glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bindings.texture_cube_map); | 151 glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bindings.texture_cube_map); |
149 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, | 152 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, |
150 &bindings.texture_external_oes); | 153 &bindings.texture_external_oes); |
151 } | 154 } |
152 } | 155 } |
153 | 156 |
154 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() { | 157 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() { |
155 TRACE_EVENT0("android_webview", "AppGLStateRestore"); | 158 TRACE_EVENT0("android_webview", "AppGLStateRestore"); |
156 MakeAppContextCurrent(); | 159 MakeAppContextCurrent(); |
157 | 160 |
| 161 GLSurfaceFactory::SetCurrentFBO(0); |
| 162 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_binding_ext_); |
158 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); | 163 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); |
159 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); | 164 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); |
160 | 165 |
161 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { | 166 for (int ii = 0; ii < g_gl_max_texture_units; ++ii) { |
162 glActiveTexture(GL_TEXTURE0 + ii); | 167 glActiveTexture(GL_TEXTURE0 + ii); |
163 TextureBindings& bindings = texture_bindings_[ii]; | 168 TextureBindings& bindings = texture_bindings_[ii]; |
164 glBindTexture(GL_TEXTURE_2D, bindings.texture_2d); | 169 glBindTexture(GL_TEXTURE_2D, bindings.texture_2d); |
165 glBindTexture(GL_TEXTURE_CUBE_MAP, bindings.texture_cube_map); | 170 glBindTexture(GL_TEXTURE_CUBE_MAP, bindings.texture_cube_map); |
166 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bindings.texture_external_oes); | 171 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bindings.texture_external_oes); |
167 } | 172 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 229 |
225 glScissor( | 230 glScissor( |
226 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); | 231 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); |
227 } | 232 } |
228 | 233 |
229 GLEnableDisable(GL_STENCIL_TEST, stencil_test_); | 234 GLEnableDisable(GL_STENCIL_TEST, stencil_test_); |
230 glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); | 235 glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_); |
231 } | 236 } |
232 | 237 |
233 } // namespace android_webview | 238 } // namespace android_webview |
OLD | NEW |