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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "ui/gl/gl_context.h" | 8 #include "ui/gl/gl_context.h" |
| 9 #include "ui/gl/gl_surface_stub.h" | 9 #include "ui/gl/gl_surface_stub.h" |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 glGetVertexAttribiv( | 82 glGetVertexAttribiv( |
| 83 i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &vertex_attrib_[i].normalized); | 83 i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &vertex_attrib_[i].normalized); |
| 84 glGetVertexAttribiv( | 84 glGetVertexAttribiv( |
| 85 i, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &vertex_attrib_[i].stride); | 85 i, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &vertex_attrib_[i].stride); |
| 86 glGetVertexAttribPointerv( | 86 glGetVertexAttribPointerv( |
| 87 i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &vertex_attrib_[i].pointer); | 87 i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &vertex_attrib_[i].pointer); |
| 88 } | 88 } |
| 89 | 89 |
| 90 glGetBooleanv(GL_DEPTH_TEST, &depth_test_); | 90 glGetBooleanv(GL_DEPTH_TEST, &depth_test_); |
| 91 glGetBooleanv(GL_CULL_FACE, &cull_face_); | 91 glGetBooleanv(GL_CULL_FACE, &cull_face_); |
| 92 glGetIntegerv(GL_CULL_FACE_MODE, &cull_face_mode_); | |
| 92 glGetBooleanv(GL_COLOR_WRITEMASK, color_mask_); | 93 glGetBooleanv(GL_COLOR_WRITEMASK, color_mask_); |
| 93 glGetBooleanv(GL_BLEND, &blend_enabled_); | |
| 94 glGetIntegerv(GL_BLEND_SRC_RGB, &blend_src_rgb_); | |
| 95 glGetIntegerv(GL_BLEND_SRC_ALPHA, &blend_src_alpha_); | |
| 96 glGetIntegerv(GL_BLEND_DST_RGB, &blend_dest_rgb_); | |
| 97 glGetIntegerv(GL_BLEND_DST_ALPHA, &blend_dest_alpha_); | |
| 98 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); | |
| 99 glGetIntegerv(GL_VIEWPORT, viewport_); | |
| 100 glGetBooleanv(GL_SCISSOR_TEST, &scissor_test_); | |
| 101 glGetIntegerv(GL_SCISSOR_BOX, scissor_box_); | |
| 102 glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_); | 94 glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_); |
| 95 glGetFloatv(GL_COLOR_CLEAR_VALUE, color_clear_); | |
| 96 glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depth_clear_); | |
| 97 glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencil_clear_value_); | |
| 98 glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencil_clear_value_); | |
|
joth
2013/07/23 05:52:57
you got this one twice.
boliu
2013/07/23 20:41:24
Done.
| |
| 99 glGetIntegerv(GL_DEPTH_FUNC, &depth_func_); | |
| 100 glGetBooleanv(GL_DEPTH_WRITEMASK, &depth_mask_); | |
| 101 glGetFloatv(GL_DEPTH_RANGE, depth_rage_); | |
| 102 glGetIntegerv(GL_FRONT_FACE, &front_face_); | |
| 103 glGetIntegerv(GL_GENERATE_MIPMAP_HINT, &hint_generate_mipmap_); | |
| 104 glGetFloatv(GL_LINE_WIDTH, &line_width_); | |
| 105 glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &polygon_offset_factor_); | |
| 106 glGetFloatv(GL_POLYGON_OFFSET_UNITS, &polygon_offset_units_); | |
| 107 glGetFloatv(GL_SAMPLE_COVERAGE_VALUE, &sample_coverage_value_); | |
| 108 glGetBooleanv(GL_SAMPLE_COVERAGE_INVERT, &sample_coverage_invert_); | |
| 109 glGetIntegerv(GL_STENCIL_FUNC, &stencil_front_func_); | |
| 110 glGetIntegerv(GL_STENCIL_REF, &stencil_front_ref_); | |
| 111 glGetIntegerv(GL_STENCIL_VALUE_MASK, &stencil_front_mask_); | |
| 112 glGetIntegerv(GL_STENCIL_BACK_FUNC, &stencil_back_func_); | |
| 113 glGetIntegerv(GL_STENCIL_BACK_REF, &stencil_back_ref_); | |
| 114 glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &stencil_back_mask_); | |
| 115 glGetIntegerv(GL_STENCIL_WRITEMASK, &stencil_front_writemask_); | |
| 116 glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, &stencil_back_writemask_); | |
| 117 glGetIntegerv(GL_STENCIL_FAIL, &stencil_front_fail_op_); | |
| 118 glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &stencil_front_z_fail_op_); | |
| 119 glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &stencil_front_z_pass_op_); | |
| 120 glGetIntegerv(GL_STENCIL_BACK_FAIL, &stencil_back_fail_op_); | |
| 121 glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, &stencil_back_z_fail_op_); | |
| 122 glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, &stencil_back_z_pass_op_); | |
|
joth
2013/07/23 05:52:57
Lets chat this through with aelias. Stencil should
boliu
2013/07/23 20:41:24
Let's just not restore stencil here for now then.
| |
| 123 | |
| 124 glGetBooleanv(GL_DITHER, &enable_dither_); | |
| 125 glGetBooleanv(GL_POLYGON_OFFSET_FILL, &enable_polygon_offset_fill_); | |
| 126 glGetBooleanv(GL_SAMPLE_ALPHA_TO_COVERAGE, &enable_sample_alpha_to_coverage_); | |
| 127 glGetBooleanv(GL_SAMPLE_COVERAGE, &enable_sample_coverage_); | |
| 128 glGetBooleanv(GL_STENCIL_TEST, &enable_stencil_test_); | |
| 103 } | 129 } |
| 104 | 130 |
| 105 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() { | 131 ScopedAppGLStateRestore::~ScopedAppGLStateRestore() { |
| 106 MakeAppContextCurrent(); | 132 MakeAppContextCurrent(); |
| 107 | 133 |
| 108 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); | 134 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); |
| 109 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); | 135 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); |
| 110 | 136 |
| 111 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_external_oes_binding_); | 137 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_external_oes_binding_); |
| 112 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); | 138 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 131 glEnable(GL_DEPTH_TEST); | 157 glEnable(GL_DEPTH_TEST); |
| 132 } else { | 158 } else { |
| 133 glDisable(GL_DEPTH_TEST); | 159 glDisable(GL_DEPTH_TEST); |
| 134 } | 160 } |
| 135 | 161 |
| 136 if (cull_face_) { | 162 if (cull_face_) { |
| 137 glEnable(GL_CULL_FACE); | 163 glEnable(GL_CULL_FACE); |
| 138 } else { | 164 } else { |
| 139 glDisable(GL_CULL_FACE); | 165 glDisable(GL_CULL_FACE); |
| 140 } | 166 } |
| 167 glCullFace(cull_face_mode_); | |
| 141 | 168 |
| 142 glColorMask(color_mask_[0], color_mask_[1], color_mask_[2], color_mask_[3]); | 169 glColorMask(color_mask_[0], color_mask_[1], color_mask_[2], color_mask_[3]); |
| 143 | 170 |
| 144 if (blend_enabled_) { | 171 glUseProgram(current_program_); |
| 145 glEnable(GL_BLEND); | |
| 146 } else { | |
| 147 glDisable(GL_BLEND); | |
| 148 } | |
| 149 | 172 |
| 150 glBlendFuncSeparate( | 173 glClearColor( |
| 151 blend_src_rgb_, blend_dest_rgb_, blend_src_alpha_, blend_dest_alpha_); | 174 color_clear_[0], color_clear_[1], color_clear_[2], color_clear_[3]); |
| 152 glActiveTexture(active_texture_); | 175 glClearDepth(depth_clear_); |
| 176 glClearStencil(stencil_clear_value_); | |
| 177 glDepthFunc(depth_func_); | |
| 178 glDepthMask(depth_mask_); | |
| 179 glDepthRange(depth_rage_[0], depth_rage_[1]); | |
| 180 glFrontFace(front_face_); | |
| 181 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap_); | |
| 182 // TODO(boliu): GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES ?? | |
| 183 glLineWidth(line_width_); | |
| 184 glPolygonOffset(polygon_offset_factor_, polygon_offset_units_); | |
| 185 glSampleCoverage(sample_coverage_value_, sample_coverage_invert_); | |
| 186 glStencilFuncSeparate( | |
| 187 GL_FRONT, stencil_front_func_, stencil_front_ref_, stencil_front_mask_); | |
| 188 glStencilFuncSeparate( | |
| 189 GL_BACK, stencil_back_func_, stencil_back_ref_, stencil_back_mask_); | |
| 190 glStencilMaskSeparate(GL_FRONT, stencil_front_writemask_); | |
| 191 glStencilMaskSeparate(GL_BACK, stencil_back_writemask_); | |
| 192 glStencilOpSeparate(GL_FRONT, | |
| 193 stencil_front_fail_op_, | |
| 194 stencil_front_z_fail_op_, | |
| 195 stencil_front_z_pass_op_); | |
| 196 glStencilOpSeparate(GL_BACK, | |
| 197 stencil_back_fail_op_, | |
| 198 stencil_back_z_fail_op_, | |
| 199 stencil_back_z_pass_op_); | |
| 153 | 200 |
| 154 glViewport(viewport_[0], viewport_[1], viewport_[2], viewport_[3]); | 201 if (enable_dither_) |
| 202 glEnable(GL_DITHER); | |
| 203 else | |
| 204 glDisable(GL_DITHER); | |
| 155 | 205 |
| 156 if (scissor_test_) { | 206 if (enable_polygon_offset_fill_) |
| 157 glEnable(GL_SCISSOR_TEST); | 207 glEnable(GL_POLYGON_OFFSET_FILL); |
| 158 } else { | 208 else |
| 159 glDisable(GL_SCISSOR_TEST); | 209 glDisable(GL_POLYGON_OFFSET_FILL); |
| 160 } | |
| 161 | 210 |
| 162 glScissor( | 211 if (enable_sample_alpha_to_coverage_) |
| 163 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); | 212 glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); |
| 213 else | |
| 214 glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); | |
| 164 | 215 |
| 165 glUseProgram(current_program_); | 216 if (enable_sample_coverage_) |
| 217 glEnable(GL_SAMPLE_COVERAGE); | |
| 218 else | |
| 219 glDisable(GL_SAMPLE_COVERAGE); | |
| 220 | |
| 221 if (enable_stencil_test_) | |
| 222 glEnable(GL_STENCIL_TEST); | |
| 223 else | |
| 224 glDisable(GL_STENCIL_TEST); | |
| 166 } | 225 } |
| 167 | 226 |
| 168 } // namespace android_webview | 227 } // namespace android_webview |
| OLD | NEW |