Chromium Code Reviews| Index: gpu/command_buffer/service/context_state.cc |
| diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc |
| index 5aa24fbacd095e7c09ea022d30254b49588ba9fe..f600857e9100fad5b4258154725d899bdab45f32 100644 |
| --- a/gpu/command_buffer/service/context_state.cc |
| +++ b/gpu/command_buffer/service/context_state.cc |
| @@ -417,6 +417,34 @@ void ContextState::RestoreVertexAttribValues() const { |
| } |
| } |
| +void ContextState::RestoreVertexAttribArray(unsigned attrib_index) const { |
| + const VertexAttrib* attrib = |
| + vertex_attrib_manager->GetVertexAttrib(attrib_index); |
| + |
| + // Restore vertex array. |
| + Buffer* buffer = attrib->buffer(); |
| + GLuint buffer_service_id = buffer ? buffer->service_id() : 0; |
| + glBindBuffer(GL_ARRAY_BUFFER, buffer_service_id); |
| + const void* ptr = reinterpret_cast<const void*>(attrib->offset()); |
| + glVertexAttribPointer(attrib_index, attrib->size(), attrib->type(), |
| + attrib->normalized(), attrib->gl_stride(), ptr); |
| + |
| + // Restore attrib divisor if supported. |
| + if (feature_info_->feature_flags().angle_instanced_arrays) |
| + glVertexAttribDivisorANGLE(attrib_index, attrib->divisor()); |
| + |
| + // Never touch vertex attribute 0's state (in particular, never |
| + // disable it) when running on desktop GL with compatibility profile |
| + // because it will never be re-enabled. |
| + if (attrib_index != 0 || feature_info_->gl_version_info().BehavesLikeGLES()) { |
| + if (attrib->enabled()) { |
| + glEnableVertexAttribArray(attrib_index); |
| + } else { |
| + glDisableVertexAttribArray(attrib_index); |
| + } |
| + } |
| +} |
| + |
| void ContextState::RestoreVertexAttribArrays( |
| const scoped_refptr<VertexAttribManager> attrib_manager) const { |
| // This is expected to be called only for VAO with service_id 0, |
| @@ -430,37 +458,8 @@ void ContextState::RestoreVertexAttribArrays( |
| // Restore vertex attrib arrays. |
| for (size_t attrib_index = 0; attrib_index < attrib_manager->num_attribs(); |
| - ++attrib_index) { |
| - const VertexAttrib* attrib = attrib_manager->GetVertexAttrib(attrib_index); |
| - |
| - // Restore vertex array. |
| - Buffer* buffer = attrib->buffer(); |
| - GLuint buffer_service_id = buffer ? buffer->service_id() : 0; |
| - glBindBuffer(GL_ARRAY_BUFFER, buffer_service_id); |
| - const void* ptr = reinterpret_cast<const void*>(attrib->offset()); |
| - glVertexAttribPointer(attrib_index, |
| - attrib->size(), |
| - attrib->type(), |
| - attrib->normalized(), |
| - attrib->gl_stride(), |
| - ptr); |
| - |
| - // Restore attrib divisor if supported. |
| - if (feature_info_->feature_flags().angle_instanced_arrays) |
| - glVertexAttribDivisorANGLE(attrib_index, attrib->divisor()); |
| - |
| - // Never touch vertex attribute 0's state (in particular, never |
| - // disable it) when running on desktop GL with compatibility profile |
| - // because it will never be re-enabled. |
| - if (attrib_index != 0 || |
| - feature_info_->gl_version_info().BehavesLikeGLES()) { |
| - if (attrib->enabled()) { |
| - glEnableVertexAttribArray(attrib_index); |
| - } else { |
| - glDisableVertexAttribArray(attrib_index); |
| - } |
| - } |
| - } |
| + ++attrib_index) |
| + RestoreVertexAttribArray(attrib_index); |
|
piman
2017/03/22 21:28:26
This needs to pass in |attrib_manager|. RestoreVer
Chandan
2017/03/23 09:19:39
Have removed these changes in context_state.cc in
|
| } |
| void ContextState::RestoreVertexAttribs() const { |